6
6
*/
7
7
8
8
import React from 'react' ;
9
- import { storiesOf } from '@storybook/react' ;
10
9
import { action } from '@storybook/addon-actions' ;
11
10
import { withKnobs , boolean , text } from '@storybook/addon-knobs' ;
12
11
import Checkbox from '../Checkbox' ;
@@ -25,76 +24,83 @@ const props = () => ({
25
24
onChange : action ( 'onChange' ) ,
26
25
} ) ;
27
26
28
- storiesOf ( 'Checkbox' , module )
29
- . addParameters ( {
27
+ export default {
28
+ title : 'Checkbox' ,
29
+ decorators : [ withKnobs ] ,
30
+
31
+ parameters : {
30
32
component : Checkbox ,
33
+
31
34
subcomponents : {
32
35
CheckboxSkeleton,
33
36
} ,
34
- } )
35
- . addDecorator ( withKnobs )
36
- . add (
37
- 'checked' ,
38
- ( ) => {
39
- const checkboxProps = props ( ) ;
40
- return (
41
- < fieldset className = { `${ prefix } --fieldset` } >
42
- < legend className = { `${ prefix } --label` } > Checkbox heading</ legend >
43
- < Checkbox defaultChecked { ...checkboxProps } id = "checkbox-label-1" />
44
- < Checkbox defaultChecked { ...checkboxProps } id = "checkbox-label-2" />
45
- </ fieldset >
46
- ) ;
47
- } ,
48
- {
49
- info : {
50
- text : `
51
- Checkboxes are used when there is a list of options and the user may select multiple options, including all or none.
52
- The example below shows how the Checkbox component can be used as an uncontrolled component that is initially checked
53
- by setting the defaultChecked property to true. To use the component in a controlled way, you should set the
54
- checked property instead.
55
- ` ,
56
- } ,
57
- }
58
- )
59
- . add (
60
- 'unchecked' ,
61
- ( ) => {
62
- const checkboxProps = props ( ) ;
63
- return (
64
- < fieldset className = { `${ prefix } --fieldset` } >
65
- < legend className = { `${ prefix } --label` } > Checkbox heading</ legend >
66
- < Checkbox { ...checkboxProps } id = "checkbox-label-1" />
67
- < Checkbox { ...checkboxProps } id = "checkbox-label-2" />
68
- </ fieldset >
69
- ) ;
70
- } ,
71
- {
72
- info : {
73
- text : `
74
- Checkboxes are used when there is a list of options and the user may select multiple options, including all or none.
75
- The example below shows how the Checkbox component can be used as an uncontrolled component that is initially
76
- unchecked. To use the component in a controlled way, you should set the checked property instead.
77
- ` ,
78
- } ,
79
- }
80
- )
81
- . add (
82
- 'skeleton' ,
83
- ( ) => (
84
- < div
85
- aria-label = "loading checkbox"
86
- aria-live = "assertive"
87
- role = "status"
88
- tabIndex = "0" // eslint-disable-line jsx-a11y/no-noninteractive-tabindex
89
- >
90
- < CheckboxSkeleton />
91
- </ div >
92
- ) ,
93
- {
94
- info : {
95
- text : `
96
- Placeholder skeleton state to use when content is loading.
97
- ` ,
98
- } ,
99
- }
37
+ } ,
38
+ } ;
39
+
40
+ export const Checked = ( ) => {
41
+ const checkboxProps = props ( ) ;
42
+ return (
43
+ < fieldset className = { `${ prefix } --fieldset` } >
44
+ < legend className = { `${ prefix } --label` } > Checkbox heading</ legend >
45
+ < Checkbox defaultChecked { ...checkboxProps } id = "checkbox-label-1" />
46
+ < Checkbox defaultChecked { ...checkboxProps } id = "checkbox-label-2" />
47
+ </ fieldset >
48
+ ) ;
49
+ } ;
50
+
51
+ Checked . storyName = 'checked' ;
52
+
53
+ Checked . parameters = {
54
+ info : {
55
+ text : `
56
+ Checkboxes are used when there is a list of options and the user may select multiple options, including all or none.
57
+ The example below shows how the Checkbox component can be used as an uncontrolled component that is initially checked
58
+ by setting the defaultChecked property to true. To use the component in a controlled way, you should set the
59
+ checked property instead.
60
+ ` ,
61
+ } ,
62
+ } ;
63
+
64
+ export const Unchecked = ( ) => {
65
+ const checkboxProps = props ( ) ;
66
+ return (
67
+ < fieldset className = { `${ prefix } --fieldset` } >
68
+ < legend className = { `${ prefix } --label` } > Checkbox heading</ legend >
69
+ < Checkbox { ...checkboxProps } id = "checkbox-label-1" />
70
+ < Checkbox { ...checkboxProps } id = "checkbox-label-2" />
71
+ </ fieldset >
100
72
) ;
73
+ } ;
74
+
75
+ Unchecked . storyName = 'unchecked' ;
76
+
77
+ Unchecked . parameters = {
78
+ info : {
79
+ text : `
80
+ Checkboxes are used when there is a list of options and the user may select multiple options, including all or none.
81
+ The example below shows how the Checkbox component can be used as an uncontrolled component that is initially
82
+ unchecked. To use the component in a controlled way, you should set the checked property instead.
83
+ ` ,
84
+ } ,
85
+ } ;
86
+
87
+ export const Skeleton = ( ) => (
88
+ < div
89
+ aria-label = "loading checkbox"
90
+ aria-live = "assertive"
91
+ role = "status"
92
+ tabIndex = "0" // eslint-disable-line jsx-a11y/no-noninteractive-tabindex
93
+ >
94
+ < CheckboxSkeleton />
95
+ </ div >
96
+ ) ;
97
+
98
+ Skeleton . storyName = 'skeleton' ;
99
+
100
+ Skeleton . parameters = {
101
+ info : {
102
+ text : `
103
+ Placeholder skeleton state to use when content is loading.
104
+ ` ,
105
+ } ,
106
+ } ;
0 commit comments