-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DS-88 - Layer Panel + Adding READMEs
- Loading branch information
1 parent
16fe163
commit fcfd470
Showing
7 changed files
with
145 additions
and
43 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
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
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,99 @@ | ||
# Checkbox | ||
|
||
[Storybook Ref](https://wri.github.io/wri-design-systems/?path=/docs/controls-checkbox--docs) | ||
|
||
## Import | ||
|
||
```js | ||
import { Checkbox } from 'wri-design-systems' | ||
``` | ||
|
||
## Usage | ||
|
||
```html | ||
<Checkbox | ||
label='Checkbox' | ||
name='Checkbox' | ||
value='1' | ||
/> | ||
``` | ||
|
||
## Props | ||
|
||
```js | ||
type CheckboxProps = Omit< | ||
ChakraCheckboxProps, | ||
| 'size' | ||
| 'variant' | ||
| 'colorScheme' | ||
| 'icon' | ||
| 'iconColor' | ||
| 'iconSize' | ||
| 'spacing' | ||
> & { | ||
label?: string | ||
name: string | ||
value: string | ||
defaultChecked?: boolean | ||
isChecked?: boolean | ||
isDisabled?: boolean | ||
isIndeterminate?: boolean | ||
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void | ||
} | ||
``` | ||
|
||
## Default Checked | ||
|
||
```html | ||
<Checkbox | ||
label='Checkbox' | ||
name='Checkbox' | ||
value='1' | ||
defaultChecked | ||
/> | ||
``` | ||
|
||
## Disabled | ||
|
||
```html | ||
<Checkbox | ||
label='Checkbox' | ||
name='Checkbox' | ||
value='1' | ||
isDisabled | ||
/> | ||
``` | ||
|
||
## Invalid | ||
|
||
```html | ||
<Checkbox | ||
label='Checkbox' | ||
name='Checkbox' | ||
value='1' | ||
isInvalid | ||
/> | ||
``` | ||
|
||
## Indeterminate | ||
|
||
You will need to add some logic to validate all checked status and set or not an indeterminate state to the parent Checkbox | ||
|
||
```js | ||
const [checkedItems, setCheckedItems] = React.useState([false, false]) | ||
|
||
const allChecked = checkedItems.every(Boolean) | ||
const isIndeterminate = checkedItems.some(Boolean) && !allChecked | ||
|
||
.... | ||
``` | ||
|
||
```html | ||
<Checkbox | ||
label='Checkbox' | ||
name='Checkbox' | ||
value='1' | ||
isChecked={allChecked} | ||
isIndeterminate={isIndeterminate} | ||
/> | ||
``` |
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
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
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
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