Skip to content

Commit

Permalink
Extract submit button
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens committed Dec 3, 2024
1 parent 8c54ab9 commit 0345c21
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
6 changes: 2 additions & 4 deletions libs/form-renderer/src/FormRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Button } from '@amsterdam/design-system-react'
import type {
FormCheckboxComponentOutput,
FormRadioComponentOutput,
FormSelectComponentOutput,
FormTextAreaComponentOutput,
FormTextFieldInputComponentOutput,
} from '@meldingen/api-client'
import { SubmitButton } from '@meldingen/ui'
import type { FormEvent } from 'react'

import { Checkbox, Radio, Select, TextArea, TextInput } from './components'
Expand Down Expand Up @@ -42,8 +42,6 @@ type Props = {
export const FormRenderer = ({ formData, onSubmit }: Props) => (
<form className="ams-gap--md" onSubmit={onSubmit}>
{formData.map((component) => getComponent(component))}
<Button type="submit" style={{ width: 'fit-content' }}>
Volgende vraag
</Button>
<SubmitButton>Volgende vraag</SubmitButton>
</form>
)
3 changes: 3 additions & 0 deletions libs/ui/src/SubmitButton/SubmitButton.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.button {
width: fit-content;
}
10 changes: 10 additions & 0 deletions libs/ui/src/SubmitButton/SubmitButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { ButtonProps } from '@amsterdam/design-system-react'
import { Button } from '@amsterdam/design-system-react'

import styles from './SubmitButton.module.css'

export const SubmitButton = ({ children, ...restProps }: ButtonProps) => (
<Button {...restProps} className={styles.button} type="submit">
{children}
</Button>
)
3 changes: 3 additions & 0 deletions libs/ui/src/SubmitButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use client'

export { SubmitButton } from './SubmitButton'
1 change: 1 addition & 0 deletions libs/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './Footer'
export * from './Grid'
export * from './Header'
export * from './Screen'
export * from './SubmitButton'

0 comments on commit 0345c21

Please sign in to comment.