diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-30 19:27:21 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-31 23:15:07 +0200 |
| commit | 782cc0a31a866519fb7c3e18a523b347d3e40238 (patch) | |
| tree | 34fb984e8dc356cd013e5e0d6f203a8c8907b9fe /src/components/organisms/toolbar/main-nav.tsx | |
| parent | 519b1439dce3f25dd38cd0d0f82fecd10f28dcc8 (diff) | |
chore: replace Checkbox component with a BooleanField component
Checkbox and radio buttons are working the same way so I decided to
group them in a same component.
Diffstat (limited to 'src/components/organisms/toolbar/main-nav.tsx')
| -rw-r--r-- | src/components/organisms/toolbar/main-nav.tsx | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/components/organisms/toolbar/main-nav.tsx b/src/components/organisms/toolbar/main-nav.tsx index d205112..5dd32f7 100644 --- a/src/components/organisms/toolbar/main-nav.tsx +++ b/src/components/organisms/toolbar/main-nav.tsx @@ -1,4 +1,6 @@ -import Checkbox, { type CheckboxProps } from '@components/atoms/forms/checkbox'; +import BooleanField, { + type BooleanFieldProps, +} from '@components/atoms/forms/boolean-field'; import Label from '@components/atoms/forms/label'; import Hamburger from '@components/atoms/icons/hamburger'; import Nav, { @@ -18,7 +20,7 @@ export type MainNavProps = { /** * The button state. */ - isActive: CheckboxProps['value']; + isActive: BooleanFieldProps['checked']; /** * The main nav items. */ @@ -26,7 +28,7 @@ export type MainNavProps = { /** * A callback function to handle button state. */ - setIsActive: CheckboxProps['setValue']; + setIsActive: BooleanFieldProps['onChange']; }; /** @@ -53,12 +55,14 @@ const MainNav: ForwardRefRenderFunction<HTMLDivElement, MainNavProps> = ( return ( <div className={`${sharedStyles.item} ${mainNavStyles.item}`} ref={ref}> - <Checkbox + <BooleanField + checked={isActive} + className={`${sharedStyles.checkbox} ${mainNavStyles.checkbox}`} id="main-nav-button" name="main-nav-button" - value={isActive} - setValue={setIsActive} - className={`${sharedStyles.checkbox} ${mainNavStyles.checkbox}`} + onChange={setIsActive} + type="checkbox" + value="open" /> <Label htmlFor="main-nav-button" |
