-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathRadioButton.stories.tsx
More file actions
151 lines (140 loc) · 3.97 KB
/
RadioButton.stories.tsx
File metadata and controls
151 lines (140 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Libraries
import React, {RefObject, createRef} from 'react'
import marked from 'marked'
// Storybook
import {storiesOf} from '@storybook/react'
import {withKnobs, select, text} from '@storybook/addon-knobs'
import {mapEnumKeys} from '../../../Utils/storybook'
// Components
import {
RadioButton,
RadioButtonRef,
RadioButtonGroup,
RadioButtonGroupRef,
} from '../'
// Types
// Notes
import RadioButtonReadMe from './RadioButton.md'
import RadioButtonGroupReadMe from './RadioButtonGroup.md'
import {
InputToggleType,
ComponentSize,
ComponentOrientation,
} from '../../../Types'
const RadioButtonStories = storiesOf(
'Component|RadioButton',
module
).addDecorator(withKnobs)
RadioButtonStories.add(
'RadioButton',
() => {
const radioButtonRef: RefObject<RadioButtonRef> = createRef()
const logRef = (): void => {
/* eslint-disable */
console.log(radioButtonRef.current)
/* eslint-enable */
}
return (
<div className="story--example">
<RadioButton
value="test-1"
id="test-1"
type={InputToggleType.Radio}
toolTipText={text('titleText', 'Title Text')}
size={
ComponentSize[select('size', mapEnumKeys(ComponentSize), 'Small')]
}
ref={radioButtonRef}
labelText={text('labelText', 'Radio Button')}
/* eslint-disable */
onChange={value => console.log(value)}
/* eslint-disable */
></RadioButton>
<div className="story--test-buttons">
<button onClick={logRef}>Log Ref</button>
</div>
</div>
)
},
{
readme: {
content: marked(RadioButtonReadMe),
},
}
)
RadioButtonStories.add(
'RadioButtonGroup',
() => {
const radioButtonGroupRef: RefObject<RadioButtonGroupRef> = createRef()
const radioButtonRef1: RefObject<RadioButtonRef> = createRef()
const radioButtonRef2: RefObject<RadioButtonRef> = createRef()
const radioButtonRef3: RefObject<RadioButtonRef> = createRef()
const logRef = (): void => {
/* eslint-disable */
console.log(radioButtonGroupRef.current)
/* eslint-enable */
}
return (
<div className="story--example">
<RadioButtonGroup
ref={radioButtonGroupRef}
orientation={
ComponentOrientation[
select(
'orientation',
mapEnumKeys(ComponentOrientation),
'Horizontal'
)
]
}
name={'hello-1'}
/* eslint-disable */
onChange={value => console.log(value)}
/* eslint-disable */
>
<RadioButton
value="test-1"
id="test-1"
type={InputToggleType.Radio}
toolTipText={text('titleText', 'Title Text')}
size={
ComponentSize[select('size', mapEnumKeys(ComponentSize), 'Small')]
}
ref={radioButtonRef1}
labelText={'Hello 1'}
></RadioButton>
<RadioButton
value="test-2"
id="test-2"
type={InputToggleType.Radio}
toolTipText={text('titleText', 'Title Text')}
size={
ComponentSize[select('size', mapEnumKeys(ComponentSize), 'Small')]
}
ref={radioButtonRef2}
labelText={'Hello 2'}
></RadioButton>
<RadioButton
value="test-3"
id="test-3"
type={InputToggleType.Radio}
toolTipText={text('titleText', 'Title Text')}
size={
ComponentSize[select('size', mapEnumKeys(ComponentSize), 'Small')]
}
ref={radioButtonRef3}
labelText={'Hello 3'}
></RadioButton>
</RadioButtonGroup>
<div className="story--test-buttons">
<button onClick={logRef}>Log Ref</button>
</div>
</div>
)
},
{
readme: {
content: marked(RadioButtonGroupReadMe),
},
}
)