1- import React from 'react' ;
1+ import React , { useState } from 'react' ;
22import Radio from '.' ;
33
44import '../../styles/stories.scss' ;
@@ -13,65 +13,116 @@ const FormContainer = ({ children }) => {
1313 return < div style = { { width : '140px' } } > { children } </ div > ;
1414} ;
1515
16- export const BasicUsage = ( ) => (
17- < div className = 'storybook__container' >
18- < FormContainer >
19- < Radio />
20- </ FormContainer >
21- </ div >
22- ) ;
23-
24- export const RadioDisabled = ( ) => (
25- < div className = 'storybook__container' >
26- < FormContainer >
27- < Radio disabled />
28- </ FormContainer >
29- </ div >
30- ) ;
31-
32- export const LabelDisabled = ( ) => (
33- < div className = 'storybook__container' >
34- < FormContainer >
35- < Radio labelDisabled />
36- </ FormContainer >
37- </ div >
38- ) ;
39-
40- export const RadioColor = ( ) => (
41- < div className = 'storybook__container' >
42- < FormContainer >
43- < Radio checkedColor = 'rgb(7, 193, 96)' />
44- </ FormContainer >
45- </ div >
46- ) ;
47-
48- export const OnChange = ( ) => (
49- < div className = 'storybook__container' >
50- < FormContainer >
51- < Radio onChange = { ( v ) => alert ( v ) } />
52- </ FormContainer >
53- </ div >
54- ) ;
55- export const OnClick = ( ) => (
56- < div className = 'storybook__container' >
57- < FormContainer >
58- < Radio onClick = { ( ) => alert ( 'clicked' ) } />
59- </ FormContainer >
60- </ div >
61- ) ;
62-
63- export const RadioCell = ( ) => (
64- < >
65- < div className = 'storybook__container grey' >
66- < Cell radio = { { label : 'Radio Cell' } } />
16+ export const BasicUsage = ( ) => {
17+ const [ checked , setChecked ] = useState ( false ) ;
18+ return (
19+ < div className = 'storybook__container' >
20+ < FormContainer >
21+ < Radio checked = { checked } onClick = { ( ) => setChecked ( ! checked ) } />
22+ </ FormContainer >
6723 </ div >
68- </ >
69- ) ;
24+ ) ;
25+ } ;
26+
27+ export const RadioDisabled = ( ) => {
28+ const [ checked , setChecked ] = useState ( false ) ;
29+
30+ return (
31+ < div className = 'storybook__container' >
32+ < FormContainer >
33+ < Radio
34+ disabled
35+ checked = { checked }
36+ onClick = { ( ) => setChecked ( ! checked ) }
37+ />
38+ </ FormContainer >
39+ </ div >
40+ ) ;
41+ } ;
42+
43+ export const LabelDisabled = ( ) => {
44+ const [ checked , setChecked ] = useState ( false ) ;
7045
71- export const RadioCellRTL = ( ) => (
72- < >
73- < div className = 'storybook__container grey' >
74- < Cell radio = { { label : 'Radio Cell' , rtl : true } } />
46+ return (
47+ < div className = 'storybook__container' >
48+ < FormContainer >
49+ < Radio
50+ labelDisabled
51+ checked = { checked }
52+ onClick = { ( ) => setChecked ( ! checked ) }
53+ />
54+ </ FormContainer >
7555 </ div >
76- </ >
77- ) ;
56+ ) ;
57+ } ;
58+
59+ export const RadioColor = ( ) => {
60+ const [ checked , setChecked ] = useState ( false ) ;
61+
62+ return (
63+ < div className = 'storybook__container' >
64+ < FormContainer >
65+ < Radio
66+ checkedColor = 'rgb(7, 193, 96)'
67+ checked = { checked }
68+ onClick = { ( ) => setChecked ( ! checked ) }
69+ />
70+ </ FormContainer >
71+ </ div >
72+ ) ;
73+ } ;
74+
75+ export const OnClick = ( ) => {
76+ const [ checked , setChecked ] = useState ( false ) ;
77+
78+ return (
79+ < div className = 'storybook__container' >
80+ < FormContainer >
81+ < Radio
82+ checked = { checked }
83+ onClick = { ( ) => {
84+ setChecked ( ! checked ) ;
85+ alert ( checked ) ;
86+ } }
87+ />
88+ </ FormContainer >
89+ </ div >
90+ ) ;
91+ } ;
92+
93+ export const RadioCell = ( ) => {
94+ const [ checked , setChecked ] = useState ( false ) ;
95+
96+ return (
97+ < >
98+ < div className = 'storybook__container grey' >
99+ < Cell
100+ radio = { {
101+ label : 'Radio Cell' ,
102+ checked,
103+ onClick : ( ) => setChecked ( ! checked )
104+ } }
105+ />
106+ </ div >
107+ </ >
108+ ) ;
109+ } ;
110+
111+ export const RadioCellRTL = ( ) => {
112+ const [ checked , setChecked ] = useState ( false ) ;
113+
114+ return (
115+ < >
116+ < div className = 'storybook__container grey' >
117+ < Cell
118+ radio = { {
119+ label : 'Radio Cell' ,
120+ rtl : true ,
121+ checked,
122+ onClick : ( ) => setChecked ( ! checked )
123+ } }
124+ />
125+ </ div >
126+ </ >
127+ ) ;
128+ } ;
0 commit comments