Created
January 14, 2022 16:08
-
-
Save vinzcelavi/5458e7a0b18f98c4d16d6fb2e22dca4c to your computer and use it in GitHub Desktop.
Story with useState
This file contains hidden or 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
import React, { createElement, useState } from 'react'; | |
import { storiesOf } from '@storybook/react'; | |
import Checkbox from './Checkbox'; | |
import Grid from '../Grid/Grid'; | |
import { StoryWrapper, Wrap } from '../Mixins'; | |
storiesOf('Forms/Checkbox', module).add('Default', () => | |
createElement(() => { | |
const [isChecked, setIsChecked] = useState([0, 0, 0, 0]); | |
return ( | |
<StoryWrapper> | |
<Wrap> | |
<h2>Checkbox</h2> | |
<Grid smCol="2" mdCol="2"> | |
<Checkbox | |
name="checkbox01" | |
label="Checkbox 01" | |
onChange={() => setIsChecked([1, 0, 0, 0])} | |
checked={isChecked[0]} | |
/> | |
<Checkbox | |
name="checkbox02" | |
label="Checkbox 02" | |
onChange={() => setIsChecked([0, 1, 0, 0])} | |
checked={isChecked[1]} | |
/> | |
<Checkbox | |
name="checkbox03" | |
label="Checkbox 03" | |
onChange={() => setIsChecked([0, 0, 1, 0])} | |
checked={isChecked[2]} | |
/> | |
<Checkbox | |
name="checkbox04" | |
label="Checkbox 04" | |
onChange={() => setIsChecked([0, 0, 0, 1])} | |
checked={isChecked[3]} | |
/> | |
</Grid> | |
</Wrap> | |
</StoryWrapper> | |
); | |
}), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment