@charcoal-ui/react 4.0.0-beta.4 → 4.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/_lib/useClassNames.d.ts +2 -2
  2. package/dist/_lib/useClassNames.d.ts.map +1 -1
  3. package/dist/components/Checkbox/CheckboxInput/index.d.ts +11 -0
  4. package/dist/components/Checkbox/CheckboxInput/index.d.ts.map +1 -0
  5. package/dist/components/Checkbox/CheckboxWithLabel.d.ts +9 -0
  6. package/dist/components/Checkbox/CheckboxWithLabel.d.ts.map +1 -0
  7. package/dist/components/Checkbox/index.d.ts +9 -7
  8. package/dist/components/Checkbox/index.d.ts.map +1 -1
  9. package/dist/components/Clickable/index.d.ts +10 -13
  10. package/dist/components/Clickable/index.d.ts.map +1 -1
  11. package/dist/components/DropdownSelector/index.d.ts.map +1 -1
  12. package/dist/components/FieldLabel/index.d.ts +1 -0
  13. package/dist/components/FieldLabel/index.d.ts.map +1 -1
  14. package/dist/components/IconButton/index.d.ts +7 -5
  15. package/dist/components/IconButton/index.d.ts.map +1 -1
  16. package/dist/components/LoadingSpinner/index.d.ts +1 -0
  17. package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
  18. package/dist/components/Modal/Dialog/index.d.ts +6 -24
  19. package/dist/components/Modal/Dialog/index.d.ts.map +1 -1
  20. package/dist/components/Modal/ModalPlumbing.d.ts +10 -3
  21. package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
  22. package/dist/components/Modal/index.d.ts +1 -1
  23. package/dist/components/Modal/index.d.ts.map +1 -1
  24. package/dist/components/Radio/index.d.ts +3 -5
  25. package/dist/components/Radio/index.d.ts.map +1 -1
  26. package/dist/components/SegmentedControl/index.d.ts +1 -0
  27. package/dist/components/SegmentedControl/index.d.ts.map +1 -1
  28. package/dist/components/Switch/SwitchInput/index.d.ts +9 -0
  29. package/dist/components/Switch/SwitchInput/index.d.ts.map +1 -0
  30. package/dist/components/Switch/SwitchWithLabel.d.ts +9 -0
  31. package/dist/components/Switch/SwitchWithLabel.d.ts.map +1 -0
  32. package/dist/components/Switch/index.d.ts +4 -15
  33. package/dist/components/Switch/index.d.ts.map +1 -1
  34. package/dist/components/TagItem/index.d.ts +14 -15
  35. package/dist/components/TagItem/index.d.ts.map +1 -1
  36. package/dist/components/TextArea/index.d.ts +28 -18
  37. package/dist/components/TextArea/index.d.ts.map +1 -1
  38. package/dist/components/TextField/index.d.ts +32 -19
  39. package/dist/components/TextField/index.d.ts.map +1 -1
  40. package/dist/index.cjs.js +390 -776
  41. package/dist/index.cjs.js.map +1 -1
  42. package/dist/index.css +732 -28
  43. package/dist/index.css.map +1 -1
  44. package/dist/index.d.ts +1 -2
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.esm.js +415 -799
  47. package/dist/index.esm.js.map +1 -1
  48. package/dist/styled.d.ts +4 -4
  49. package/package.json +11 -10
  50. package/src/_lib/useClassNames.ts +3 -9
  51. package/src/components/Checkbox/CheckboxInput/__snapshots__/index.story.storyshot +77 -0
  52. package/src/components/Checkbox/CheckboxInput/index.css +111 -0
  53. package/src/components/{CheckboxInput → Checkbox/CheckboxInput}/index.story.tsx +16 -0
  54. package/src/components/Checkbox/CheckboxInput/index.tsx +47 -0
  55. package/src/components/Checkbox/CheckboxWithLabel.tsx +24 -0
  56. package/src/components/Checkbox/__snapshots__/index.story.storyshot +53 -134
  57. package/src/components/Checkbox/index.css +2 -2
  58. package/src/components/Checkbox/index.story.tsx +16 -11
  59. package/src/components/Checkbox/index.tsx +23 -15
  60. package/src/components/Clickable/__snapshots__/index.story.storyshot +2 -78
  61. package/src/components/Clickable/index.css +41 -0
  62. package/src/components/Clickable/index.story.tsx +1 -1
  63. package/src/components/Clickable/index.tsx +25 -85
  64. package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +10 -135
  65. package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +308 -1014
  66. package/src/components/DropdownSelector/index.tsx +9 -38
  67. package/src/components/FieldLabel/index.css +35 -0
  68. package/src/components/FieldLabel/index.tsx +15 -105
  69. package/src/components/IconButton/__snapshots__/index.story.storyshot +12 -288
  70. package/src/components/IconButton/index.css +118 -0
  71. package/src/components/IconButton/index.story.tsx +2 -2
  72. package/src/components/IconButton/index.tsx +41 -118
  73. package/src/components/LoadingSpinner/__snapshots__/LoadingSpinnerIcon.story.storyshot +2 -17
  74. package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +40 -128
  75. package/src/components/LoadingSpinner/index.css +42 -0
  76. package/src/components/LoadingSpinner/index.tsx +26 -52
  77. package/src/components/Modal/Dialog/index.css +44 -0
  78. package/src/components/Modal/Dialog/index.tsx +13 -57
  79. package/src/components/Modal/ModalPlumbing.css +40 -0
  80. package/src/components/Modal/ModalPlumbing.tsx +22 -61
  81. package/src/components/Modal/__snapshots__/index.story.storyshot +459 -1881
  82. package/src/components/Modal/index.css +36 -0
  83. package/src/components/Modal/index.tsx +26 -73
  84. package/src/components/Radio/__snapshots__/index.story.storyshot +50 -775
  85. package/src/components/Radio/index.css +97 -0
  86. package/src/components/Radio/index.story.tsx +1 -10
  87. package/src/components/Radio/index.test.tsx +0 -1
  88. package/src/components/Radio/index.tsx +50 -161
  89. package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +30 -260
  90. package/src/components/SegmentedControl/index.css +50 -0
  91. package/src/components/SegmentedControl/index.tsx +20 -89
  92. package/src/components/Switch/SwitchInput/index.css +82 -0
  93. package/src/components/Switch/SwitchInput/index.tsx +40 -0
  94. package/src/components/Switch/SwitchWithLabel.tsx +24 -0
  95. package/src/components/Switch/__snapshots__/index.story.storyshot +29 -532
  96. package/src/components/Switch/index.css +23 -0
  97. package/src/components/Switch/index.story.tsx +5 -0
  98. package/src/components/Switch/index.tsx +43 -140
  99. package/src/components/TagItem/__snapshots__/index.story.storyshot +153 -1130
  100. package/src/components/TagItem/index.css +140 -0
  101. package/src/components/TagItem/index.story.tsx +1 -1
  102. package/src/components/TagItem/index.tsx +76 -220
  103. package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +203 -1357
  104. package/src/components/TextArea/index.tsx +68 -91
  105. package/src/components/TextField/__snapshots__/TextField.story.storyshot +274 -1614
  106. package/src/components/TextField/index.tsx +77 -105
  107. package/src/index.ts +0 -7
  108. package/src/type.d.ts +6 -0
  109. package/dist/components/CheckboxInput/index.d.ts +0 -9
  110. package/dist/components/CheckboxInput/index.d.ts.map +0 -1
  111. package/dist/components/MultiSelect/context.d.ts +0 -14
  112. package/dist/components/MultiSelect/context.d.ts.map +0 -1
  113. package/dist/components/MultiSelect/index.d.ts +0 -36
  114. package/dist/components/MultiSelect/index.d.ts.map +0 -1
  115. package/src/components/CheckboxInput/__snapshots__/index.story.storyshot +0 -109
  116. package/src/components/CheckboxInput/index.css +0 -77
  117. package/src/components/CheckboxInput/index.tsx +0 -53
  118. package/src/components/MultiSelect/__snapshots__/index.story.storyshot +0 -1054
  119. package/src/components/MultiSelect/context.ts +0 -23
  120. package/src/components/MultiSelect/index.story.tsx +0 -112
  121. package/src/components/MultiSelect/index.test.tsx +0 -263
  122. package/src/components/MultiSelect/index.tsx +0 -282
@@ -0,0 +1,40 @@
1
+ import './index.css'
2
+
3
+ import { forwardRef, useCallback } from 'react'
4
+ import { useClassNames } from '../../../_lib/useClassNames'
5
+
6
+ export type CharcoalSwitchProps = {
7
+ onChange?: (checked: boolean) => void
8
+ }
9
+
10
+ type InputProps = React.HTMLProps<HTMLInputElement>
11
+
12
+ export type SwitchInputProps = CharcoalSwitchProps &
13
+ Omit<InputProps, keyof CharcoalSwitchProps | 'ref'>
14
+
15
+ const SwitchInput = forwardRef<
16
+ HTMLInputElement,
17
+ Omit<SwitchInputProps, 'children'>
18
+ >(function SwitchInput({ onChange, className, ...props }, ref) {
19
+ const handleChange = useCallback(
20
+ (e: React.ChangeEvent<HTMLInputElement>) => {
21
+ const el = e.currentTarget
22
+ onChange?.(el.checked)
23
+ },
24
+ [onChange]
25
+ )
26
+ props.children
27
+
28
+ const classNames = useClassNames('charcoal-switch-input', className)
29
+ return (
30
+ <input
31
+ ref={ref}
32
+ className={classNames}
33
+ type="checkbox"
34
+ onChange={handleChange}
35
+ {...props}
36
+ />
37
+ )
38
+ })
39
+
40
+ export default SwitchInput
@@ -0,0 +1,24 @@
1
+ import * as React from 'react'
2
+ import { useClassNames } from '../../_lib/useClassNames'
3
+
4
+ export const SwitchWithLabel = React.memo(function SwitchWithLabel({
5
+ children,
6
+ className,
7
+ disabled,
8
+ id,
9
+ input,
10
+ }: {
11
+ children: React.ReactNode
12
+ className?: string
13
+ disabled?: boolean
14
+ id?: string
15
+ input: React.ReactNode
16
+ }) {
17
+ const classNames = useClassNames('charcoal-switch__label', className)
18
+ return (
19
+ <label htmlFor={id} className={classNames} aria-disabled={disabled}>
20
+ {input}
21
+ <div className="charcoal-switch__label_div">{children}</div>
22
+ </label>
23
+ )
24
+ })
@@ -1,440 +1,64 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Storybook Tests Switch Checked 1`] = `
4
- .c0 {
5
- display: inline-grid;
6
- grid-template-columns: auto 1fr;
7
- -webkit-align-items: center;
8
- -webkit-box-align: center;
9
- -ms-flex-align: center;
10
- align-items: center;
11
- cursor: pointer;
12
- outline: 0;
13
- }
14
-
15
- .c0:disabled,
16
- .c0[aria-disabled]:not([aria-disabled='false']) {
17
- opacity: 0.32;
18
- cursor: default;
19
- }
20
-
21
- .c1 {
22
- -webkit-appearance: none;
23
- -moz-appearance: none;
24
- appearance: none;
25
- display: -webkit-inline-box;
26
- display: -webkit-inline-flex;
27
- display: -ms-inline-flexbox;
28
- display: inline-flex;
29
- position: relative;
30
- box-sizing: border-box;
31
- width: 28px;
32
- border: 2px solid transparent;
33
- -webkit-transition-property: background-color,box-shadow;
34
- transition-property: background-color,box-shadow;
35
- -webkit-transition-duration: 0.2s;
36
- transition-duration: 0.2s;
37
- cursor: inherit;
38
- outline: none;
39
- border-radius: 16px;
40
- height: 16px;
41
- margin: 0;
42
- background-color: var(--charcoal-text4);
43
- }
44
-
45
- .c1:hover {
46
- background-color: var(--charcoal-text4-hover);
47
- }
48
-
49
- .c1:active {
50
- background-color: var(--charcoal-text4-press);
51
- }
52
-
53
- .c1:focus {
54
- outline: none;
55
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
56
- }
57
-
58
- .c1:focus:not(:focus-visible) {
59
- box-shadow: none;
60
- }
61
-
62
- .c1:focus-visible {
63
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
64
- }
65
-
66
- .c1::after {
67
- content: '';
68
- position: absolute;
69
- display: block;
70
- top: 0;
71
- left: 0;
72
- width: 12px;
73
- height: 12px;
74
- -webkit-transform: translateX(0);
75
- -ms-transform: translateX(0);
76
- transform: translateX(0);
77
- -webkit-transition: -webkit-transform 0.2s;
78
- -webkit-transition: transform 0.2s;
79
- transition: transform 0.2s;
80
- border-radius: 1024px;
81
- background-color: var(--charcoal-text5);
82
- }
83
-
84
- .c1::after:hover {
85
- background-color: var(--charcoal-text5-hover);
86
- }
87
-
88
- .c1::after:active {
89
- background-color: var(--charcoal-text5-press);
90
- }
91
-
92
- .c1:checked {
93
- background-color: var(--charcoal-brand);
94
- }
95
-
96
- .c1:checked:hover {
97
- background-color: var(--charcoal-brand-hover);
98
- }
99
-
100
- .c1:checked:active {
101
- background-color: var(--charcoal-brand-press);
102
- }
103
-
104
- .c1:checked::after {
105
- -webkit-transform: translateX(12px);
106
- -ms-transform: translateX(12px);
107
- transform: translateX(12px);
108
- -webkit-transition: -webkit-transform 0.2s;
109
- -webkit-transition: transform 0.2s;
110
- transition: transform 0.2s;
111
- }
112
-
113
4
  <div
114
5
  data-dark={false}
115
6
  >
116
7
  <div>
117
- <label
118
- className="c0"
119
- >
120
- <input
121
- aria-label="checked"
122
- checked={true}
123
- className="c1"
124
- disabled={false}
125
- name="name"
126
- onChange={[Function]}
127
- onClick={[Function]}
128
- onDragStart={[Function]}
129
- onKeyDown={[Function]}
130
- onKeyUp={[Function]}
131
- onMouseDown={[Function]}
132
- onMouseEnter={[Function]}
133
- onMouseLeave={[Function]}
134
- onMouseUp={[Function]}
135
- onTouchCancel={[Function]}
136
- onTouchEnd={[Function]}
137
- onTouchMove={[Function]}
138
- onTouchStart={[Function]}
139
- role="switch"
140
- type="checkbox"
141
- />
142
- </label>
8
+ <input
9
+ checked={true}
10
+ className="charcoal-switch-input"
11
+ id="test-id"
12
+ label="checked"
13
+ name="name"
14
+ onChange={[Function]}
15
+ role="switch"
16
+ type="checkbox"
17
+ />
143
18
  </div>
144
19
  </div>
145
20
  `;
146
21
 
147
22
  exports[`Storybook Tests Switch Default 1`] = `
148
- .c0 {
149
- display: inline-grid;
150
- grid-template-columns: auto 1fr;
151
- -webkit-align-items: center;
152
- -webkit-box-align: center;
153
- -ms-flex-align: center;
154
- align-items: center;
155
- cursor: pointer;
156
- outline: 0;
157
- }
158
-
159
- .c0:disabled,
160
- .c0[aria-disabled]:not([aria-disabled='false']) {
161
- opacity: 0.32;
162
- cursor: default;
163
- }
164
-
165
- .c1 {
166
- -webkit-appearance: none;
167
- -moz-appearance: none;
168
- appearance: none;
169
- display: -webkit-inline-box;
170
- display: -webkit-inline-flex;
171
- display: -ms-inline-flexbox;
172
- display: inline-flex;
173
- position: relative;
174
- box-sizing: border-box;
175
- width: 28px;
176
- border: 2px solid transparent;
177
- -webkit-transition-property: background-color,box-shadow;
178
- transition-property: background-color,box-shadow;
179
- -webkit-transition-duration: 0.2s;
180
- transition-duration: 0.2s;
181
- cursor: inherit;
182
- outline: none;
183
- border-radius: 16px;
184
- height: 16px;
185
- margin: 0;
186
- background-color: var(--charcoal-text4);
187
- }
188
-
189
- .c1:hover {
190
- background-color: var(--charcoal-text4-hover);
191
- }
192
-
193
- .c1:active {
194
- background-color: var(--charcoal-text4-press);
195
- }
196
-
197
- .c1:focus {
198
- outline: none;
199
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
200
- }
201
-
202
- .c1:focus:not(:focus-visible) {
203
- box-shadow: none;
204
- }
205
-
206
- .c1:focus-visible {
207
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
208
- }
209
-
210
- .c1::after {
211
- content: '';
212
- position: absolute;
213
- display: block;
214
- top: 0;
215
- left: 0;
216
- width: 12px;
217
- height: 12px;
218
- -webkit-transform: translateX(0);
219
- -ms-transform: translateX(0);
220
- transform: translateX(0);
221
- -webkit-transition: -webkit-transform 0.2s;
222
- -webkit-transition: transform 0.2s;
223
- transition: transform 0.2s;
224
- border-radius: 1024px;
225
- background-color: var(--charcoal-text5);
226
- }
227
-
228
- .c1::after:hover {
229
- background-color: var(--charcoal-text5-hover);
230
- }
231
-
232
- .c1::after:active {
233
- background-color: var(--charcoal-text5-press);
234
- }
235
-
236
- .c1:checked {
237
- background-color: var(--charcoal-brand);
238
- }
239
-
240
- .c1:checked:hover {
241
- background-color: var(--charcoal-brand-hover);
242
- }
243
-
244
- .c1:checked:active {
245
- background-color: var(--charcoal-brand-press);
246
- }
247
-
248
- .c1:checked::after {
249
- -webkit-transform: translateX(12px);
250
- -ms-transform: translateX(12px);
251
- transform: translateX(12px);
252
- -webkit-transition: -webkit-transform 0.2s;
253
- -webkit-transition: transform 0.2s;
254
- transition: transform 0.2s;
255
- }
256
-
257
23
  <div
258
24
  data-dark={false}
259
25
  >
260
26
  <div>
261
- <label
262
- className="c0"
263
- >
264
- <input
265
- checked={false}
266
- className="c1"
267
- disabled={false}
268
- name="name"
269
- onChange={[Function]}
270
- onClick={[Function]}
271
- onDragStart={[Function]}
272
- onKeyDown={[Function]}
273
- onKeyUp={[Function]}
274
- onMouseDown={[Function]}
275
- onMouseEnter={[Function]}
276
- onMouseLeave={[Function]}
277
- onMouseUp={[Function]}
278
- onTouchCancel={[Function]}
279
- onTouchEnd={[Function]}
280
- onTouchMove={[Function]}
281
- onTouchStart={[Function]}
282
- role="switch"
283
- type="checkbox"
284
- />
285
- </label>
27
+ <input
28
+ checked={false}
29
+ className="charcoal-switch-input"
30
+ id="test-id"
31
+ name="name"
32
+ onChange={[Function]}
33
+ role="switch"
34
+ type="checkbox"
35
+ />
286
36
  </div>
287
37
  </div>
288
38
  `;
289
39
 
290
40
  exports[`Storybook Tests Switch Disabled 1`] = `
291
- .c0 {
292
- display: inline-grid;
293
- grid-template-columns: auto 1fr;
294
- -webkit-align-items: center;
295
- -webkit-box-align: center;
296
- -ms-flex-align: center;
297
- align-items: center;
298
- cursor: pointer;
299
- outline: 0;
300
- }
301
-
302
- .c0:disabled,
303
- .c0[aria-disabled]:not([aria-disabled='false']) {
304
- opacity: 0.32;
305
- cursor: default;
306
- }
307
-
308
- .c2 {
309
- font-size: 14px;
310
- line-height: 22px;
311
- color: var(--charcoal-text2);
312
- margin-left: 4px;
313
- }
314
-
315
- .c1 {
316
- -webkit-appearance: none;
317
- -moz-appearance: none;
318
- appearance: none;
319
- display: -webkit-inline-box;
320
- display: -webkit-inline-flex;
321
- display: -ms-inline-flexbox;
322
- display: inline-flex;
323
- position: relative;
324
- box-sizing: border-box;
325
- width: 28px;
326
- border: 2px solid transparent;
327
- -webkit-transition-property: background-color,box-shadow;
328
- transition-property: background-color,box-shadow;
329
- -webkit-transition-duration: 0.2s;
330
- transition-duration: 0.2s;
331
- cursor: inherit;
332
- outline: none;
333
- border-radius: 16px;
334
- height: 16px;
335
- margin: 0;
336
- background-color: var(--charcoal-text4);
337
- }
338
-
339
- .c1:hover {
340
- background-color: var(--charcoal-text4-hover);
341
- }
342
-
343
- .c1:active {
344
- background-color: var(--charcoal-text4-press);
345
- }
346
-
347
- .c1:focus {
348
- outline: none;
349
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
350
- }
351
-
352
- .c1:focus:not(:focus-visible) {
353
- box-shadow: none;
354
- }
355
-
356
- .c1:focus-visible {
357
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
358
- }
359
-
360
- .c1::after {
361
- content: '';
362
- position: absolute;
363
- display: block;
364
- top: 0;
365
- left: 0;
366
- width: 12px;
367
- height: 12px;
368
- -webkit-transform: translateX(0);
369
- -ms-transform: translateX(0);
370
- transform: translateX(0);
371
- -webkit-transition: -webkit-transform 0.2s;
372
- -webkit-transition: transform 0.2s;
373
- transition: transform 0.2s;
374
- border-radius: 1024px;
375
- background-color: var(--charcoal-text5);
376
- }
377
-
378
- .c1::after:hover {
379
- background-color: var(--charcoal-text5-hover);
380
- }
381
-
382
- .c1::after:active {
383
- background-color: var(--charcoal-text5-press);
384
- }
385
-
386
- .c1:checked {
387
- background-color: var(--charcoal-brand);
388
- }
389
-
390
- .c1:checked:hover {
391
- background-color: var(--charcoal-brand-hover);
392
- }
393
-
394
- .c1:checked:active {
395
- background-color: var(--charcoal-brand-press);
396
- }
397
-
398
- .c1:checked::after {
399
- -webkit-transform: translateX(12px);
400
- -ms-transform: translateX(12px);
401
- transform: translateX(12px);
402
- -webkit-transition: -webkit-transform 0.2s;
403
- -webkit-transition: transform 0.2s;
404
- transition: transform 0.2s;
405
- }
406
-
407
41
  <div
408
42
  data-dark={false}
409
43
  >
410
44
  <div>
411
45
  <label
412
46
  aria-disabled={true}
413
- className="c0"
47
+ className="charcoal-switch__label"
48
+ htmlFor="test-id"
414
49
  >
415
50
  <input
416
51
  checked={false}
417
- className="c1"
52
+ className="charcoal-switch-input"
418
53
  disabled={true}
54
+ id="test-id"
419
55
  name="disabled"
420
56
  onChange={[Function]}
421
- onClick={[Function]}
422
- onDragStart={[Function]}
423
- onKeyDown={[Function]}
424
- onKeyUp={[Function]}
425
- onMouseDown={[Function]}
426
- onMouseEnter={[Function]}
427
- onMouseLeave={[Function]}
428
- onMouseUp={[Function]}
429
- onTouchCancel={[Function]}
430
- onTouchEnd={[Function]}
431
- onTouchMove={[Function]}
432
- onTouchStart={[Function]}
433
57
  role="switch"
434
58
  type="checkbox"
435
59
  />
436
60
  <div
437
- className="c2"
61
+ className="charcoal-switch__label_div"
438
62
  >
439
63
  Label
440
64
  </div>
@@ -444,152 +68,25 @@ exports[`Storybook Tests Switch Disabled 1`] = `
444
68
  `;
445
69
 
446
70
  exports[`Storybook Tests Switch Label 1`] = `
447
- .c0 {
448
- display: inline-grid;
449
- grid-template-columns: auto 1fr;
450
- -webkit-align-items: center;
451
- -webkit-box-align: center;
452
- -ms-flex-align: center;
453
- align-items: center;
454
- cursor: pointer;
455
- outline: 0;
456
- }
457
-
458
- .c0:disabled,
459
- .c0[aria-disabled]:not([aria-disabled='false']) {
460
- opacity: 0.32;
461
- cursor: default;
462
- }
463
-
464
- .c2 {
465
- font-size: 14px;
466
- line-height: 22px;
467
- color: var(--charcoal-text2);
468
- margin-left: 4px;
469
- }
470
-
471
- .c1 {
472
- -webkit-appearance: none;
473
- -moz-appearance: none;
474
- appearance: none;
475
- display: -webkit-inline-box;
476
- display: -webkit-inline-flex;
477
- display: -ms-inline-flexbox;
478
- display: inline-flex;
479
- position: relative;
480
- box-sizing: border-box;
481
- width: 28px;
482
- border: 2px solid transparent;
483
- -webkit-transition-property: background-color,box-shadow;
484
- transition-property: background-color,box-shadow;
485
- -webkit-transition-duration: 0.2s;
486
- transition-duration: 0.2s;
487
- cursor: inherit;
488
- outline: none;
489
- border-radius: 16px;
490
- height: 16px;
491
- margin: 0;
492
- background-color: var(--charcoal-text4);
493
- }
494
-
495
- .c1:hover {
496
- background-color: var(--charcoal-text4-hover);
497
- }
498
-
499
- .c1:active {
500
- background-color: var(--charcoal-text4-press);
501
- }
502
-
503
- .c1:focus {
504
- outline: none;
505
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
506
- }
507
-
508
- .c1:focus:not(:focus-visible) {
509
- box-shadow: none;
510
- }
511
-
512
- .c1:focus-visible {
513
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
514
- }
515
-
516
- .c1::after {
517
- content: '';
518
- position: absolute;
519
- display: block;
520
- top: 0;
521
- left: 0;
522
- width: 12px;
523
- height: 12px;
524
- -webkit-transform: translateX(0);
525
- -ms-transform: translateX(0);
526
- transform: translateX(0);
527
- -webkit-transition: -webkit-transform 0.2s;
528
- -webkit-transition: transform 0.2s;
529
- transition: transform 0.2s;
530
- border-radius: 1024px;
531
- background-color: var(--charcoal-text5);
532
- }
533
-
534
- .c1::after:hover {
535
- background-color: var(--charcoal-text5-hover);
536
- }
537
-
538
- .c1::after:active {
539
- background-color: var(--charcoal-text5-press);
540
- }
541
-
542
- .c1:checked {
543
- background-color: var(--charcoal-brand);
544
- }
545
-
546
- .c1:checked:hover {
547
- background-color: var(--charcoal-brand-hover);
548
- }
549
-
550
- .c1:checked:active {
551
- background-color: var(--charcoal-brand-press);
552
- }
553
-
554
- .c1:checked::after {
555
- -webkit-transform: translateX(12px);
556
- -ms-transform: translateX(12px);
557
- transform: translateX(12px);
558
- -webkit-transition: -webkit-transform 0.2s;
559
- -webkit-transition: transform 0.2s;
560
- transition: transform 0.2s;
561
- }
562
-
563
71
  <div
564
72
  data-dark={false}
565
73
  >
566
74
  <div>
567
75
  <label
568
- className="c0"
76
+ className="charcoal-switch__label"
77
+ htmlFor="test-id"
569
78
  >
570
79
  <input
571
80
  checked={false}
572
- className="c1"
573
- disabled={false}
81
+ className="charcoal-switch-input"
82
+ id="test-id"
574
83
  name="label"
575
84
  onChange={[Function]}
576
- onClick={[Function]}
577
- onDragStart={[Function]}
578
- onKeyDown={[Function]}
579
- onKeyUp={[Function]}
580
- onMouseDown={[Function]}
581
- onMouseEnter={[Function]}
582
- onMouseLeave={[Function]}
583
- onMouseUp={[Function]}
584
- onTouchCancel={[Function]}
585
- onTouchEnd={[Function]}
586
- onTouchMove={[Function]}
587
- onTouchStart={[Function]}
588
85
  role="switch"
589
86
  type="checkbox"
590
87
  />
591
88
  <div
592
- className="c2"
89
+ className="charcoal-switch__label_div"
593
90
  >
594
91
  Label
595
92
  </div>
@@ -0,0 +1,23 @@
1
+ .charcoal-switch__label {
2
+ display: inline-grid;
3
+ grid-template-columns: auto 1fr;
4
+ align-items: center;
5
+ cursor: pointer;
6
+ outline: 0;
7
+ gap: 4px;
8
+ }
9
+
10
+ .charcoal-switch__label[aria-disabled='true'] {
11
+ opacity: 0.32;
12
+ cursor: default;
13
+ }
14
+
15
+ .charcoal-switch__label[aria-disabled='true'] > input {
16
+ opacity: 1;
17
+ }
18
+
19
+ .charcoal-switch__label_div {
20
+ font-size: 14px;
21
+ line-height: 22px;
22
+ color: var(--charcoal-text2);
23
+ }
@@ -11,6 +11,11 @@ export default {
11
11
  } as Meta<typeof Switch>
12
12
 
13
13
  export const Default: StoryObj<typeof Switch> = {
14
+ argTypes: {
15
+ checked: { type: 'boolean' },
16
+ children: { type: 'string' },
17
+ disabled: { type: 'boolean' },
18
+ },
14
19
  render: function Render(args) {
15
20
  const [checked, setChecked] = useState(false)
16
21
  return (