Skip to content

Commit

Permalink
Merge pull request #358 from WestpacGEL/357-compacta-default-demo-is-…
Browse files Browse the repository at this point in the history
…missing-in-gel-next

357 compacta default demo is missing in gel next
  • Loading branch information
jaortiz authored Nov 23, 2023
2 parents 6eb8d26 + b9965e8 commit 1e17867
Showing 1 changed file with 45 additions and 30 deletions.
75 changes: 45 additions & 30 deletions apps/site/src/content/design-system/components/compacta/code.mdoc
Original file line number Diff line number Diff line change
@@ -1,52 +1,67 @@
## Collapsible sizes
### Default compacta example

```tsx
() => {
const [inputs, setInputs] = useState({});

const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
setInputs((prev: object) => ({ ...prev, [e.target.name]: e.target.value }));
const handleChange = e => {
setInputs(prev => ({ ...prev, [e.target.name]: e.target.value }));
};

return (
<Compacta>
{({ id, setPrimaryTitle, setSecondaryTitle, setTertiaryTitle }) => (
<Form>
<Form spacing="large">
<Form.Group>
<Form.Label htmlFor={`primary-${id}`}>Primary</Form.Label>
<Form.Hint>Primary title text</Form.Hint>
<Input
name={`primary-${id}`}
value={inputs[`primary-${id}` as keyof typeof inputs] || ''}
onChange={e => {
handleChange(e);
setPrimaryTitle(e.target.value);
}}
/>
<Field label="Primary" hintMessage="Select your card insitution">
<Select
name={`input-primary-${id}`}
value={inputs[`input-primary-${id}`] || ''}
onChange={e => {
handleChange(e);
setPrimaryTitle(e.target.value);
}}
width={30}
>
<option>Select</option>
<option>AMP Bank</option>
<option>ANZ - Australia and New Zealand Banking Group</option>
<option>Bank of Queensland</option>
<option>Bendigo Bank</option>
<option>CBA - Commonwealth Bank</option>
<option>Macquarie Bank</option>
<option>NAB - National Australian Bank</option>
<option>Westpac Bank</option>
</Select>
</Field>
</Form.Group>
<Form.Group>
<Form.Label htmlFor={`secondary-${id}`}>Secondary</Form.Label>
<Form.Hint>Secondary title text</Form.Hint>
<Input
name={`secondary-${id}`}
value={inputs[`secondary-${id}` as keyof typeof inputs] || ''}
onChange={e => {
handleChange(e);
setSecondaryTitle(e.target.value);
}}
/>
<Field label="Account number" hintMessage="Refer to a statement from the card’s financial institution">
<Input
name={`input-secondary-${id}`}
value={inputs[`input-secondary-${id}`] || ''}
onChange={e => {
handleChange(e);
setSecondaryTitle(e.target.value);
}}
width={30}
/>
</Field>
</Form.Group>
<Form.Group>
<Form.Label htmlFor={`tertiary-${id}`}>Tertiary</Form.Label>
<Form.Hint>Tertiary title text</Form.Hint>
<Input
name={`tertiary-${id}`}
value={inputs[`tertiary-${id}` as keyof typeof inputs] || ''}
<InputField
name={`input-tertiary-${id}`}
value={inputs[`input-tertiary-${id}`] || ''}
onChange={e => {
handleChange(e);
setTertiaryTitle(e.target.value);
}}
/>
width={20}
before="$"
label="Amount to transfer"
>
<Input />
</InputField>
</Form.Group>
</Form>
)}
Expand Down

0 comments on commit 1e17867

Please sign in to comment.