Skip to content

Commit a072744

Browse files
committed
feat(checkbox-toggle): add stories
1 parent f29dda1 commit a072744

File tree

4 files changed

+1739
-214
lines changed

4 files changed

+1739
-214
lines changed

stories/Checkbox.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { boolean } from '@storybook/addon-knobs/react';
44
import { storiesOf } from '@storybook/react';
55
import * as React from 'react';
66

7-
import { Checkbox } from '../Checkbox';
8-
import { boxKnobs } from './Box';
7+
import { Checkbox } from '../src/Checkbox';
98

109
export const checkboxKnobs = (tabName = 'Checkbox') => {
1110
return {
11+
checked: boolean('checked', false, tabName),
1212
disabled: boolean('disabled', false, tabName),
1313
};
1414
};
1515

16-
storiesOf('components/Checkbox', module)
16+
storiesOf('Checkbox', module)
1717
.addDecorator(withKnobs)
18-
.add('with defaults', () => <Checkbox {...checkboxKnobs()} {...boxKnobs()} onChange={action('onChange')} />);
18+
.add('with defaults', () => <Checkbox {...checkboxKnobs()} onChange={action('onChange')} />);

stories/Toggle.tsx

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,18 @@
1-
import { StateDecorator, Store } from '@sambego/storybook-state';
21
import { action } from '@storybook/addon-actions';
32
import { withKnobs } from '@storybook/addon-knobs';
43
import { boolean } from '@storybook/addon-knobs/react';
54
import { storiesOf } from '@storybook/react';
65
import * as React from 'react';
76

8-
import { Toggle } from '../Toggle';
9-
import { boxKnobs } from './Box';
10-
11-
const store = new Store({
12-
checked: false,
13-
});
7+
import { Toggle } from '../src/Toggle';
148

159
export const toggleKnobs = (tabName = 'Toggle') => {
1610
return {
11+
checked: boolean('checked', false, tabName),
1712
disabled: boolean('disabled', false, tabName),
1813
};
1914
};
2015

21-
storiesOf('components/Toggle', module)
16+
storiesOf('Toggle', module)
2217
.addDecorator(withKnobs)
23-
.addDecorator(StateDecorator(store))
24-
.add('with defaults', () => (
25-
<Toggle
26-
{...toggleKnobs()}
27-
{...boxKnobs()}
28-
checked={store.get('checked')}
29-
onChange={e => {
30-
action('onChange')(e);
31-
store.set({ checked: e.target.checked });
32-
}}
33-
/>
34-
));
18+
.add('with defaults', () => <Toggle {...toggleKnobs()} onChange={action('onChange')} />);

stories/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import './Box';
22
import './Button';
3+
import './Checkbox';
34
import './Flex';
45
import './Heading';
56
import './Icon';
@@ -9,3 +10,4 @@ import './KitchenSink';
910
import './List';
1011
import './Text';
1112
import './Textarea';
13+
import './Toggle';

0 commit comments

Comments
 (0)