Skip to content

Commit

Permalink
fix: placeholders, gas, scroll container
Browse files Browse the repository at this point in the history
  • Loading branch information
frdomovic committed Dec 11, 2024
1 parent 1ed040e commit 253d19c
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 73 deletions.
1 change: 1 addition & 0 deletions app/src/components/proposals/ChangeApprovalsNeededForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function ChangeApprovalsNeededForm({
type="number"
id="minApprovals"
name="minApprovals"
placeholder='2'
value={proposalForm.minApprovals}
onChange={handleInputChange}
min="1"
Expand Down
10 changes: 6 additions & 4 deletions app/src/components/proposals/CreateProposalPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ const ModalOverlay = styled.div`

const ModalContent = styled.div`
background-color: #1e1e1e;
padding: 2rem;
padding: 1rem;
border-radius: 8px;
width: 90%;
max-width: 500px;
color: white;
h2 {
padding-bottom: 0.5rem;
margin: 0;
}
`;

export const FormGroup = styled.div`
Expand Down Expand Up @@ -76,7 +81,6 @@ export interface ProposalData {
methodName: string;
arguments: { key: string; value: string }[];
deposit: string;
gas: string;
receiverId: string;
amount: string;
contextVariables: { key: string; value: string }[];
Expand All @@ -100,7 +104,6 @@ export default function CreateProposalPopup({
methodName: '',
arguments: [{ key: '', value: '' }],
deposit: '',
gas: '',
receiverId: '',
amount: '',
contextVariables: [{ key: '', value: '' }],
Expand Down Expand Up @@ -197,7 +200,6 @@ export default function CreateProposalPopup({
methodName: '',
arguments: [{ key: '', value: '' }],
deposit: '',
gas: '',
receiverId: '',
amount: '',
contextVariables: [{ key: '', value: '' }],
Expand Down
136 changes: 70 additions & 66 deletions app/src/components/proposals/CrossContractCallForm.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
import React from "react";
import { ButtonSm, FormGroup, ProposalData } from "./CreateProposalPopup";
import React from 'react';
import { ButtonSm, FormGroup, ProposalData } from './CreateProposalPopup';
import { styled } from 'styled-components';

const ScrollWrapper = styled.div`
max-height: 150px;
overflow-y: auto;
`;

interface CrossContractCallFormProps {
proposalForm: ProposalData;
handleInputChange: (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>) => void;
handleArgumentChange: (index: number, field: "key" | "value", value: string) => void;
removeArgument: (index: number) => void;
addArgument: () => void;
proposalForm: ProposalData;
handleInputChange: (
e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>,
) => void;
handleArgumentChange: (
index: number,
field: 'key' | 'value',
value: string,
) => void;
removeArgument: (index: number) => void;
addArgument: () => void;
}

export default function CrossContractCallForm({
proposalForm,
handleInputChange,
handleArgumentChange,
removeArgument,
addArgument
proposalForm,
handleInputChange,
handleArgumentChange,
removeArgument,
addArgument,
}: CrossContractCallFormProps) {
return (
<>
Expand All @@ -37,6 +49,7 @@ export default function CrossContractCallForm({
type="text"
id="contractId"
name="contractId"
placeholder="contract address"
value={proposalForm.contractId}
onChange={handleInputChange}
required
Expand All @@ -48,6 +61,7 @@ export default function CrossContractCallForm({
type="text"
id="methodName"
name="methodName"
placeholder="create_post"
value={proposalForm.methodName}
onChange={handleInputChange}
required
Expand All @@ -68,62 +82,52 @@ export default function CrossContractCallForm({
required
/>
</FormGroup>
{proposalForm.protocol === 'NEAR' && (
<FormGroup>
<label htmlFor="gas">Gas</label>
<input
type="text"
id="gas"
name="gas"
value={proposalForm.gas}
onChange={handleInputChange}
placeholder="30000000000000"
required
/>
</FormGroup>
)}
<FormGroup>
<label>Arguments</label>
{proposalForm.arguments.map((arg: {key: string, value: string}, index: number) => (
<div
key={index}
style={{
display: 'flex',
gap: '1rem',
alignItems: 'flex-end',
}}
>
<FormGroup>
<label>Key</label>
<input
type="text"
value={arg.key}
onChange={(e) =>
handleArgumentChange(index, 'key', e.target.value)
}
required
/>
</FormGroup>
<FormGroup>
<label>Value</label>
<input
type="text"
value={arg.value}
onChange={(e) =>
handleArgumentChange(index, 'value', e.target.value)
}
required
/>
</FormGroup>
<ButtonSm
type="button"
onClick={() => removeArgument(index)}
style={{ background: '#666', marginBottom: '1rem' }}
>
Remove
</ButtonSm>
</div>
))}
<ScrollWrapper>
{proposalForm.arguments.map(
(arg: { key: string; value: string }, index: number) => (
<div
key={index}
style={{
display: 'flex',
gap: '1rem',
alignItems: 'flex-end',
}}
>
<FormGroup>
<input
type="text"
placeholder="key"
value={arg.key}
onChange={(e) =>
handleArgumentChange(index, 'key', e.target.value)
}
required
/>
</FormGroup>
<FormGroup>
<input
type="text"
placeholder="value"
value={arg.value}
onChange={(e) =>
handleArgumentChange(index, 'value', e.target.value)
}
required
/>
</FormGroup>
<ButtonSm
type="button"
onClick={() => removeArgument(index)}
style={{ background: '#666', marginBottom: '1rem' }}
>
Remove
</ButtonSm>
</div>
),
)}
</ScrollWrapper>
<ButtonSm type="button" onClick={addArgument}>
Add Argument
</ButtonSm>
Expand Down
1 change: 1 addition & 0 deletions app/src/components/proposals/MaxActiveProposalsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function MaxActiveProposalsForm({
type="number"
id="maxActiveProposals"
name="maxActiveProposals"
placeholder='10'
value={proposalForm.maxActiveProposals}
onChange={handleInputChange}
min="1"
Expand Down
12 changes: 10 additions & 2 deletions app/src/components/proposals/SetContextVariableForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React from 'react';
import { ButtonSm, FormGroup, ProposalData } from './CreateProposalPopup';
import { styled } from 'styled-components';

const ScrollWrapper = styled.div`
max-height: 150px;
overflow-y: auto;
`

interface SetContextVariableFormProps {
proposalForm: ProposalData;
Expand All @@ -20,6 +26,7 @@ export default function SetContextVariableForm({
}: SetContextVariableFormProps) {
return (
<>
<ScrollWrapper>
{proposalForm.contextVariables.map((variable: { key: string; value: string }, index: number) => (
<div
key={index}
Expand All @@ -30,9 +37,9 @@ export default function SetContextVariableForm({
}}
>
<FormGroup>
<label>Key</label>
<input
type="text"
placeholder='key'
value={variable.key}
onChange={(e) =>
handleContextVariableChange(index, 'key', e.target.value)
Expand All @@ -41,9 +48,9 @@ export default function SetContextVariableForm({
/>
</FormGroup>
<FormGroup>
<label>Value</label>
<input
type="text"
placeholder='value'
value={variable.value}
onChange={(e) =>
handleContextVariableChange(index, 'value', e.target.value)
Expand All @@ -60,6 +67,7 @@ export default function SetContextVariableForm({
</ButtonSm>
</div>
))}
</ScrollWrapper>
<ButtonSm type="button" onClick={addContextVariable}>
Add Variable
</ButtonSm>
Expand Down
2 changes: 2 additions & 0 deletions app/src/components/proposals/TransferForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function TransferForm({
type="text"
id="receiverId"
name="receiverId"
placeholder='account address'
value={proposalForm.receiverId}
onChange={handleInputChange}
required
Expand All @@ -31,6 +32,7 @@ export default function TransferForm({
type="text"
id="amount"
name="amount"
placeholder='10'
value={proposalForm.amount}
onChange={handleInputChange}
required
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default function HomePage() {
deposit: formData.deposit || '0',
gas:
formData.protocol === 'NEAR'
? formData.gas || '30000000000000'
? '30000000000000'
: '0',
},
};
Expand Down

0 comments on commit 253d19c

Please sign in to comment.