@@ -5,59 +5,106 @@ import { DateInput, Form } from '../../src';
55
66const stories = storiesOf ( 'FormElementBehaviour: DateInput' , module ) ;
77
8- stories . add ( 'Standard' , ( ) => (
9- < div style = { { padding : 20 } } >
10- < h2 > Scenario: onChange and onInput handlers are bound without any other props</ h2 >
11- < h5 > Expected Behaviour</ h5 >
12- < ul className = "nhsuk-hint" >
13- < li > OnChange Handlers are fired using the generated IDs and Names</ li >
14- < li > The value is passed through</ li >
15- </ ul >
16- < h5 > Component</ h5 >
17- < Form >
18- < DateInput onChange = { e => console . log ( e . target . value ) } hint = "Test hint" label = "Test label" />
19- </ Form >
20- </ div >
21- ) ) ;
22-
23- stories . add ( 'Standard with Error' , ( ) => (
24- < div style = { { padding : 20 } } >
25- < h2 > Scenario: onChange and onInput handlers are bound without any other props</ h2 >
26- < h5 > Expected Behaviour</ h5 >
27- < ul className = "nhsuk-hint" >
28- < li > OnChange Handlers are fired using the generated IDs and Names</ li >
29- < li > The value is passed through</ li >
30- </ ul >
31- < h5 > Component</ h5 >
32- < Form error >
33- < DateInput onChange = { e => console . log ( e . target . value ) } error = "Test Error" hint = "Test hint" label = "Test label" />
34- </ Form >
35- < h5 > Component with specific field errors</ h5 >
36- < Form error >
37- < DateInput onChange = { e => console . log ( e . target . value ) } error = "Test Error" hint = "Test hint" label = "Test label" >
38- < DateInput . Day error = { false } />
39- < DateInput . Month />
40- < DateInput . Year />
41- </ DateInput >
42- </ Form >
43- </ div >
44- ) ) ;
45-
46- stories . add ( 'Pre-populated' , ( ) => {
47- const initialValue = { day : '20' , month : '09' , year : '1996' } ;
48- return (
8+ stories
9+ . add ( 'Standard' , ( ) => (
4910 < div style = { { padding : 20 } } >
11+ < h2 > Scenario: onChange and onInput handlers are bound without any other props</ h2 >
12+ < h5 > Expected Behaviour</ h5 >
13+ < ul className = "nhsuk-hint" >
14+ < li > OnChange Handlers are fired using the generated IDs and Names</ li >
15+ < li > The value is passed through</ li >
16+ </ ul >
5017 < h5 > Component</ h5 >
5118 < Form >
5219 < DateInput
20+ onChange = { e => console . log ( e . target . value ) }
21+ hint = "Test hint"
22+ label = "Test label"
23+ />
24+ </ Form >
25+ </ div >
26+ ) )
27+ . add ( 'Standard with Error' , ( ) => (
28+ < div style = { { padding : 20 } } >
29+ < h2 > Scenario: onChange and onInput handlers are bound without any other props</ h2 >
30+ < h5 > Expected Behaviour</ h5 >
31+ < ul className = "nhsuk-hint" >
32+ < li > OnChange Handlers are fired using the generated IDs and Names</ li >
33+ < li > The value is passed through</ li >
34+ </ ul >
35+ < h5 > Component</ h5 >
36+ < Form error >
37+ < DateInput
38+ onChange = { e => console . log ( e . target . value ) }
39+ error = "Test Error"
40+ hint = "Test hint"
41+ label = "Test label"
42+ />
43+ </ Form >
44+ < h5 > Component with specific field errors</ h5 >
45+ < Form error >
46+ < DateInput
47+ onChange = { e => console . log ( e . target . value ) }
48+ error = "Test Error"
5349 hint = "Test hint"
5450 label = "Test label"
5551 >
56- < DateInput . Day value = { initialValue . day } />
57- < DateInput . Month value = { initialValue . month } />
58- < DateInput . Year value = { initialValue . year } />
52+ < DateInput . Day error = { false } />
53+ < DateInput . Month />
54+ < DateInput . Year />
5955 </ DateInput >
6056 </ Form >
6157 </ div >
62- ) ;
63- } ) ;
58+ ) )
59+ . add ( 'Pre-populated (Individual Components)' , ( ) => {
60+ const defaultValue = { day : '20' , month : '09' , year : '1996' } ;
61+ return (
62+ < div style = { { padding : 20 } } >
63+ < h5 > Component</ h5 >
64+ < Form >
65+ < DateInput hint = "Test hint" label = "Test label" >
66+ < DateInput . Day defaultValue = { defaultValue . day } />
67+ < DateInput . Month defaultValue = { defaultValue . month } />
68+ < DateInput . Year defaultValue = { defaultValue . year } />
69+ </ DateInput >
70+ </ Form >
71+ </ div >
72+ ) ;
73+ } )
74+ . add ( 'Pre-populated (Wrapper)' , ( ) => {
75+ const defaultValue = { day : '20' , month : '09' , year : '1996' } ;
76+ return (
77+ < div style = { { padding : 20 } } >
78+ < h5 > Component</ h5 >
79+ < Form >
80+ < DateInput hint = "Test hint" label = "Test label" defaultValue = { defaultValue } />
81+ </ Form >
82+ </ div >
83+ ) ;
84+ } )
85+ . add ( 'Controlled Element (Individual Components)' , ( ) => {
86+ const value = { day : '20' , month : '09' , year : '1996' } ;
87+ return (
88+ < div style = { { padding : 20 } } >
89+ < h5 > Component</ h5 >
90+ < Form >
91+ < DateInput hint = "Test hint" label = "Test label" >
92+ < DateInput . Day value = { value . day } />
93+ < DateInput . Month value = { value . month } />
94+ < DateInput . Year value = { value . year } />
95+ </ DateInput >
96+ </ Form >
97+ </ div >
98+ ) ;
99+ } )
100+ . add ( 'Controlled Element (Wrapper)' , ( ) => {
101+ const value = { day : '20' , month : '09' , year : '1996' } ;
102+ return (
103+ < div style = { { padding : 20 } } >
104+ < h5 > Component</ h5 >
105+ < Form >
106+ < DateInput hint = "Test hint" label = "Test label" value = { value } />
107+ </ Form >
108+ </ div >
109+ ) ;
110+ } ) ;
0 commit comments