-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Checkbox Approach 2 -- validation status group
- Loading branch information
1 parent
9c01165
commit 60a7d0e
Showing
2 changed files
with
71 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/components/Checkbox/CheckboxValidationStatus.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* eslint-disable react/jsx-handler-names */ | ||
import { useArgs } from '@storybook/client-api'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import Checkbox from './Checkbox'; | ||
|
||
/** | ||
Use checkboxes when the user can select more than one option from a list. Make clear with helper text that this is the case. Use [radio buttons](https://cfpb.github.io/design-system/components/radio-buttons) when the user can choose only one option from a list. | ||
Source: https://cfpb.github.io/design-system/components/checkboxes | ||
*/ | ||
const meta: Meta<typeof Checkbox> = { | ||
title: 'Components (Verified)/Checkboxes/ValidationStatus', | ||
component: Checkbox, | ||
argTypes: { | ||
disabled: { control: 'boolean' }, | ||
isLarge: { control: 'boolean' } | ||
} | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
function CheckboxWrapper({ ...arguments_ }): JSX.Element { | ||
const [, updateArguments] = useArgs(); | ||
|
||
return ( | ||
<Checkbox | ||
{...arguments_} | ||
checked={arguments_.checked} | ||
onChange={(): void => { | ||
updateArguments({ | ||
checked: !arguments_.checked | ||
}); | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
export const Success: Story = { | ||
render: _arguments => CheckboxWrapper(_arguments), | ||
name: 'Success', | ||
args: { | ||
id: 'success', | ||
name: 'success', | ||
label: 'Success', | ||
status: 'success' | ||
} | ||
}; | ||
|
||
export const Warning: Story = { | ||
render: _arguments => CheckboxWrapper(_arguments), | ||
name: 'Warning', | ||
args: { | ||
id: 'warning', | ||
name: 'warning', | ||
label: 'Warning', | ||
status: 'warning' | ||
} | ||
}; | ||
|
||
export const Error: Story = { | ||
render: _arguments => CheckboxWrapper(_arguments), | ||
name: 'Error', | ||
args: { | ||
id: 'error', | ||
name: 'error', | ||
label: 'Error', | ||
status: 'error' | ||
} | ||
}; |