1- import { Stack } from '@scaleway/ui'
1+ import { Checkbox , Stack } from '@scaleway/ui'
22import { ComponentStory } from '@storybook/react'
3+ import { ChangeEvent , useState } from 'react'
34import {
45 CheckboxField ,
56 Form ,
@@ -10,45 +11,58 @@ import {
1011} from '../..'
1112import { emailRegex , mockErrors } from '../../../mocks/mockErrors'
1213
13- export const Playground : ComponentStory < typeof Form > = args => (
14- < Form { ...args } >
15- < Stack gap = { 2 } >
16- < TextBoxField
17- name = "name"
18- label = "Name"
19- placeholder = "John"
20- required
21- autoComplete = "given-name"
22- />
23- < TextBoxField
24- name = "email"
25- label = "Email"
26- type = "email"
27- placeholder = "john.smith@email.com"
28- required
29- regex = { [ emailRegex ] }
30- />
31- < RichSelectField
32- multiple
33- noTopLabel
34- name = "topics"
35- label = "Topics "
36- placeholder = "Select topics you're interested in"
37- options = { [
38- { label : 'React' , value : 'react' } ,
39- { label : 'Webdev' , value : 'web' } ,
40- { label : 'Cloud' , value : 'cloud' } ,
41- { label : 'Devops' , value : 'devops' } ,
42- ] }
43- />
44- < CheckboxField name = "receiveEmailUpdates" >
45- I'd like to receive news updates
46- </ CheckboxField >
47- < SubmitErrorAlert />
48- < Submit > Submit</ Submit >
49- </ Stack >
50- </ Form >
51- )
14+ export const Playground : ComponentStory < typeof Form > = args => {
15+ const [ state , setState ] = useState ( false )
16+
17+ return (
18+ < Form { ...args } >
19+ < Stack gap = { 2 } >
20+ < Checkbox
21+ checked = { state }
22+ onChange = { ( event : ChangeEvent < HTMLInputElement > ) =>
23+ setState ( event . target . checked )
24+ }
25+ >
26+ I'm disabling the field name to remove validation
27+ </ Checkbox >
28+ < TextBoxField
29+ name = "name"
30+ label = "Name"
31+ placeholder = "John"
32+ required
33+ autoComplete = "given-name"
34+ disabled = { state }
35+ />
36+ < TextBoxField
37+ name = "email"
38+ label = "Email"
39+ type = "email"
40+ placeholder = "john.smith@email.com"
41+ required
42+ regex = { [ emailRegex ] }
43+ />
44+ < RichSelectField
45+ multiple
46+ noTopLabel
47+ name = "topics"
48+ label = "Topics "
49+ placeholder = "Select topics you're interested in"
50+ options = { [
51+ { label : 'React' , value : 'react' } ,
52+ { label : 'Webdev' , value : 'web' } ,
53+ { label : 'Cloud' , value : 'cloud' } ,
54+ { label : 'Devops' , value : 'devops' } ,
55+ ] }
56+ />
57+ < CheckboxField name = "receiveEmailUpdates" >
58+ I'd like to receive news updates
59+ </ CheckboxField >
60+ < SubmitErrorAlert />
61+ < Submit > Submit</ Submit >
62+ </ Stack >
63+ </ Form >
64+ )
65+ }
5266
5367Playground . args = {
5468 errors : mockErrors ,
0 commit comments