@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
@@ -1,100 +1,13 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Storybook Tests SegmentedControl ObjectSegments 1`] = `
4
- .c0 {
5
- display: -webkit-inline-box;
6
- display: -webkit-inline-flex;
7
- display: -ms-inline-flexbox;
8
- display: inline-flex;
9
- -webkit-align-items: center;
10
- -webkit-box-align: center;
11
- -ms-flex-align: center;
12
- align-items: center;
13
- background-color: var(--charcoal-surface3);
14
- border-radius: 16px;
15
- }
16
-
17
- .c1 {
18
- position: relative;
19
- display: -webkit-box;
20
- display: -webkit-flex;
21
- display: -ms-flexbox;
22
- display: flex;
23
- -webkit-align-items: center;
24
- -webkit-box-align: center;
25
- -ms-flex-align: center;
26
- align-items: center;
27
- cursor: pointer;
28
- height: 32px;
29
- padding-right: 16px;
30
- padding-left: 16px;
31
- border-radius: 16px;
32
- color: var(--charcoal-text2);
33
- }
34
-
35
- .c1:disabled,
36
- .c1[aria-disabled]:not([aria-disabled='false']) {
37
- cursor: default;
38
- opacity: 0.32;
39
- }
40
-
41
- .c2 {
42
- position: absolute;
43
- height: 0px;
44
- width: 0px;
45
- padding: 0;
46
- margin: 0;
47
- -webkit-appearance: none;
48
- -moz-appearance: none;
49
- appearance: none;
50
- box-sizing: border-box;
51
- overflow: hidden;
52
- white-space: nowrap;
53
- opacity: 0;
54
- }
55
-
56
- .c3 {
57
- background: transparent;
58
- display: -webkit-box;
59
- display: -webkit-flex;
60
- display: -ms-flexbox;
61
- display: flex;
62
- -webkit-align-items: center;
63
- -webkit-box-align: center;
64
- -ms-flex-align: center;
65
- align-items: center;
66
- height: 22px;
67
- }
68
-
69
- .c4 {
70
- font-size: 14px;
71
- line-height: 22px;
72
- display: flow-root;
73
- }
74
-
75
- .c4::before {
76
- display: block;
77
- width: 0;
78
- height: 0;
79
- content: '';
80
- margin-top: -4px;
81
- }
82
-
83
- .c4::after {
84
- display: block;
85
- width: 0;
86
- height: 0;
87
- content: '';
88
- margin-bottom: -4px;
89
- }
90
-
91
4
  <div
92
5
  data-dark={false}
93
6
  >
94
7
  <div
95
8
  aria-label="test"
96
9
  aria-orientation="vertical"
97
- className="c0"
10
+ className="charcoal-segmented-control"
98
11
  id="test-id"
99
12
  onBlur={[Function]}
100
13
  onFocus={[Function]}
@@ -103,12 +16,12 @@ exports[`Storybook Tests SegmentedControl ObjectSegments 1`] = `
103
16
  >
104
17
  <label
105
18
  aria-disabled={false}
106
- checked={false}
107
- className="c1"
19
+ className="charcoal-segmented-control-radio__label"
20
+ data-checked={false}
108
21
  >
109
22
  <input
110
23
  checked={false}
111
- className="c2"
24
+ className="charcoal-segmented-control-radio__input"
112
25
  disabled={false}
113
26
  name="test-id"
114
27
  onChange={[Function]}
@@ -130,24 +43,16 @@ exports[`Storybook Tests SegmentedControl ObjectSegments 1`] = `
130
43
  type="radio"
131
44
  value="option1"
132
45
  />
133
- <div
134
- className="c3"
135
- >
136
- <div
137
- className="c4"
138
- >
139
- 選択肢1
140
- </div>
141
- </div>
46
+ 選択肢1
142
47
  </label>
143
48
  <label
144
49
  aria-disabled={false}
145
- checked={false}
146
- className="c1"
50
+ className="charcoal-segmented-control-radio__label"
51
+ data-checked={false}
147
52
  >
148
53
  <input
149
54
  checked={false}
150
- className="c2"
55
+ className="charcoal-segmented-control-radio__input"
151
56
  disabled={false}
152
57
  name="test-id"
153
58
  onChange={[Function]}
@@ -169,24 +74,16 @@ exports[`Storybook Tests SegmentedControl ObjectSegments 1`] = `
169
74
  type="radio"
170
75
  value="option2"
171
76
  />
172
- <div
173
- className="c3"
174
- >
175
- <div
176
- className="c4"
177
- >
178
- 選択肢2
179
- </div>
180
- </div>
77
+ 選択肢2
181
78
  </label>
182
79
  <label
183
80
  aria-disabled={false}
184
- checked={false}
185
- className="c1"
81
+ className="charcoal-segmented-control-radio__label"
82
+ data-checked={false}
186
83
  >
187
84
  <input
188
85
  checked={false}
189
- className="c2"
86
+ className="charcoal-segmented-control-radio__input"
190
87
  disabled={false}
191
88
  name="test-id"
192
89
  onChange={[Function]}
@@ -208,24 +105,16 @@ exports[`Storybook Tests SegmentedControl ObjectSegments 1`] = `
208
105
  type="radio"
209
106
  value="option3"
210
107
  />
211
- <div
212
- className="c3"
213
- >
214
- <div
215
- className="c4"
216
- >
217
- 選択肢3
218
- </div>
219
- </div>
108
+ 選択肢3
220
109
  </label>
221
110
  <label
222
111
  aria-disabled={true}
223
- checked={false}
224
- className="c1"
112
+ className="charcoal-segmented-control-radio__label"
113
+ data-checked={false}
225
114
  >
226
115
  <input
227
116
  checked={false}
228
- className="c2"
117
+ className="charcoal-segmented-control-radio__input"
229
118
  disabled={true}
230
119
  name="test-id"
231
120
  onChange={[Function]}
@@ -245,115 +134,20 @@ exports[`Storybook Tests SegmentedControl ObjectSegments 1`] = `
245
134
  type="radio"
246
135
  value="option4"
247
136
  />
248
- <div
249
- className="c3"
250
- >
251
- <div
252
- className="c4"
253
- >
254
- 選択肢4
255
- </div>
256
- </div>
137
+ 選択肢4
257
138
  </label>
258
139
  </div>
259
140
  </div>
260
141
  `;
261
142
 
262
143
  exports[`Storybook Tests SegmentedControl StringSegments 1`] = `
263
- .c0 {
264
- display: -webkit-inline-box;
265
- display: -webkit-inline-flex;
266
- display: -ms-inline-flexbox;
267
- display: inline-flex;
268
- -webkit-align-items: center;
269
- -webkit-box-align: center;
270
- -ms-flex-align: center;
271
- align-items: center;
272
- background-color: var(--charcoal-surface3);
273
- border-radius: 16px;
274
- }
275
-
276
- .c1 {
277
- position: relative;
278
- display: -webkit-box;
279
- display: -webkit-flex;
280
- display: -ms-flexbox;
281
- display: flex;
282
- -webkit-align-items: center;
283
- -webkit-box-align: center;
284
- -ms-flex-align: center;
285
- align-items: center;
286
- cursor: pointer;
287
- height: 32px;
288
- padding-right: 16px;
289
- padding-left: 16px;
290
- border-radius: 16px;
291
- color: var(--charcoal-text2);
292
- }
293
-
294
- .c1:disabled,
295
- .c1[aria-disabled]:not([aria-disabled='false']) {
296
- cursor: default;
297
- opacity: 0.32;
298
- }
299
-
300
- .c2 {
301
- position: absolute;
302
- height: 0px;
303
- width: 0px;
304
- padding: 0;
305
- margin: 0;
306
- -webkit-appearance: none;
307
- -moz-appearance: none;
308
- appearance: none;
309
- box-sizing: border-box;
310
- overflow: hidden;
311
- white-space: nowrap;
312
- opacity: 0;
313
- }
314
-
315
- .c3 {
316
- background: transparent;
317
- display: -webkit-box;
318
- display: -webkit-flex;
319
- display: -ms-flexbox;
320
- display: flex;
321
- -webkit-align-items: center;
322
- -webkit-box-align: center;
323
- -ms-flex-align: center;
324
- align-items: center;
325
- height: 22px;
326
- }
327
-
328
- .c4 {
329
- font-size: 14px;
330
- line-height: 22px;
331
- display: flow-root;
332
- }
333
-
334
- .c4::before {
335
- display: block;
336
- width: 0;
337
- height: 0;
338
- content: '';
339
- margin-top: -4px;
340
- }
341
-
342
- .c4::after {
343
- display: block;
344
- width: 0;
345
- height: 0;
346
- content: '';
347
- margin-bottom: -4px;
348
- }
349
-
350
144
  <div
351
145
  data-dark={false}
352
146
  >
353
147
  <div
354
148
  aria-label="test"
355
149
  aria-orientation="vertical"
356
- className="c0"
150
+ className="charcoal-segmented-control"
357
151
  id="test-id"
358
152
  onBlur={[Function]}
359
153
  onFocus={[Function]}
@@ -362,12 +156,12 @@ exports[`Storybook Tests SegmentedControl StringSegments 1`] = `
362
156
  >
363
157
  <label
364
158
  aria-disabled={false}
365
- checked={false}
366
- className="c1"
159
+ className="charcoal-segmented-control-radio__label"
160
+ data-checked={false}
367
161
  >
368
162
  <input
369
163
  checked={false}
370
- className="c2"
164
+ className="charcoal-segmented-control-radio__input"
371
165
  disabled={false}
372
166
  name="test-id"
373
167
  onChange={[Function]}
@@ -389,24 +183,16 @@ exports[`Storybook Tests SegmentedControl StringSegments 1`] = `
389
183
  type="radio"
390
184
  value="option1"
391
185
  />
392
- <div
393
- className="c3"
394
- >
395
- <div
396
- className="c4"
397
- >
398
- option1
399
- </div>
400
- </div>
186
+ option1
401
187
  </label>
402
188
  <label
403
189
  aria-disabled={false}
404
- checked={false}
405
- className="c1"
190
+ className="charcoal-segmented-control-radio__label"
191
+ data-checked={false}
406
192
  >
407
193
  <input
408
194
  checked={false}
409
- className="c2"
195
+ className="charcoal-segmented-control-radio__input"
410
196
  disabled={false}
411
197
  name="test-id"
412
198
  onChange={[Function]}
@@ -428,24 +214,16 @@ exports[`Storybook Tests SegmentedControl StringSegments 1`] = `
428
214
  type="radio"
429
215
  value="option2"
430
216
  />
431
- <div
432
- className="c3"
433
- >
434
- <div
435
- className="c4"
436
- >
437
- option2
438
- </div>
439
- </div>
217
+ option2
440
218
  </label>
441
219
  <label
442
220
  aria-disabled={false}
443
- checked={false}
444
- className="c1"
221
+ className="charcoal-segmented-control-radio__label"
222
+ data-checked={false}
445
223
  >
446
224
  <input
447
225
  checked={false}
448
- className="c2"
226
+ className="charcoal-segmented-control-radio__input"
449
227
  disabled={false}
450
228
  name="test-id"
451
229
  onChange={[Function]}
@@ -467,15 +245,7 @@ exports[`Storybook Tests SegmentedControl StringSegments 1`] = `
467
245
  type="radio"
468
246
  value="option3"
469
247
  />
470
- <div
471
- className="c3"
472
- >
473
- <div
474
- className="c4"
475
- >
476
- option3
477
- </div>
478
- </div>
248
+ option3
479
249
  </label>
480
250
  </div>
481
251
  </div>
@@ -0,0 +1,50 @@
1
+ .charcoal-segmented-control {
2
+ display: inline-flex;
3
+ align-items: center;
4
+
5
+ background-color: var(--charcoal-surface3);
6
+ border-radius: 16px;
7
+ }
8
+
9
+ .charcoal-segmented-control-radio__label {
10
+ position: relative;
11
+ display: flex;
12
+ align-items: center;
13
+ cursor: pointer;
14
+ height: 32px;
15
+
16
+ padding-right: 16px;
17
+ padding-left: 16px;
18
+ border-radius: 16px;
19
+ color: var(--charcoal-text2);
20
+
21
+ font-size: 14px;
22
+ line-height: 22px;
23
+ }
24
+
25
+ .charcoal-segmented-control-radio__label[aria-disabled]:not(
26
+ [aria-disabled='false']
27
+ ) {
28
+ cursor: default;
29
+ opacity: 0.32;
30
+ }
31
+
32
+ .charcoal-segmented-control-radio__label[data-checked='true'] {
33
+ background-color: var(--charcoal-brand);
34
+ color: var(--charcoal-text5);
35
+ }
36
+
37
+ .charcoal-segmented-control-radio__input {
38
+ position: absolute;
39
+
40
+ height: 0px;
41
+ width: 0px;
42
+ padding: 0;
43
+ margin: 0;
44
+
45
+ appearance: none;
46
+ box-sizing: border-box;
47
+ overflow: hidden;
48
+ white-space: nowrap;
49
+ opacity: 0;
50
+ }
@@ -7,9 +7,10 @@ import {
7
7
  useRadio,
8
8
  useRadioGroup,
9
9
  } from '@react-aria/radio'
10
- import styled, { css } from 'styled-components'
11
-
12
10
  import { RadioProvider, useRadioContext } from './RadioGroupContext'
11
+ import { useClassNames } from '../../_lib/useClassNames'
12
+
13
+ import './index.css'
13
14
 
14
15
  type SegmentedControlItem = {
15
16
  label: React.ReactNode
@@ -35,6 +36,11 @@ export type SegmentedControlProps = {
35
36
 
36
37
  const SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(
37
38
  function SegmentedControlInner(props, ref) {
39
+ const className = useClassNames(
40
+ 'charcoal-segmented-control',
41
+ props.className
42
+ )
43
+
38
44
  const ariaRadioGroupProps = useMemo<AriaRadioGroupProps>(
39
45
  () => ({
40
46
  ...props,
@@ -54,11 +60,7 @@ const SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(
54
60
  }, [props.data])
55
61
 
56
62
  return (
57
- <SegmentedControlRoot
58
- ref={ref}
59
- {...radioGroupProps}
60
- className={props.className}
61
- >
63
+ <div ref={ref} {...radioGroupProps} className={className}>
62
64
  <RadioProvider value={state}>
63
65
  {segmentedControlItems.map((item) => (
64
66
  <Segmented
@@ -70,7 +72,7 @@ const SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(
70
72
  </Segmented>
71
73
  ))}
72
74
  </RadioProvider>
73
- </SegmentedControlRoot>
75
+ </div>
74
76
  )
75
77
  }
76
78
  )
@@ -102,88 +104,17 @@ const Segmented = (props: RadioProps) => {
102
104
  )
103
105
 
104
106
  return (
105
- <SegmentedRoot
107
+ <label
108
+ className="charcoal-segmented-control-radio__label"
106
109
  aria-disabled={isDisabled || state.isReadOnly}
107
- checked={isSelected}
110
+ data-checked={isSelected}
108
111
  >
109
- <SegmentedInput {...inputProps} ref={ref} />
110
- <RadioLabel>
111
- <SegmentedLabelInner>{props.children}</SegmentedLabelInner>
112
- </RadioLabel>
113
- </SegmentedRoot>
112
+ <input
113
+ className="charcoal-segmented-control-radio__input"
114
+ {...inputProps}
115
+ ref={ref}
116
+ />
117
+ {props.children}
118
+ </label>
114
119
  )
115
120
  }
116
-
117
- const SegmentedControlRoot = styled.div`
118
- display: inline-flex;
119
- align-items: center;
120
-
121
- background-color: var(--charcoal-surface3);
122
- border-radius: 16px;
123
- `
124
-
125
- const SegmentedRoot = styled.label<{ checked?: boolean }>`
126
- position: relative;
127
- display: flex;
128
- align-items: center;
129
- cursor: pointer;
130
- height: 32px;
131
-
132
- padding-right: 16px;
133
- padding-left: 16px;
134
- border-radius: 16px;
135
- &:disabled,
136
- &[aria-disabled]:not([aria-disabled='false']) {
137
- cursor: default;
138
- opacity: 0.32;
139
- }
140
- color: var(--charcoal-text2);
141
-
142
- ${({ checked = false }) =>
143
- checked &&
144
- css`
145
- background-color: var(--charcoal-brand);
146
- color: var(--charcoal-text5);
147
- `}
148
- `
149
- const SegmentedInput = styled.input`
150
- position: absolute;
151
-
152
- height: 0px;
153
- width: 0px;
154
- padding: 0;
155
- margin: 0;
156
-
157
- appearance: none;
158
- box-sizing: border-box;
159
- overflow: hidden;
160
- white-space: nowrap;
161
- opacity: 0;
162
- `
163
-
164
- const RadioLabel = styled.div`
165
- background: transparent;
166
- display: flex;
167
- align-items: center;
168
- height: 22px;
169
- `
170
- const SegmentedLabelInner = styled.div`
171
- font-size: 14px;
172
- line-height: 22px;
173
- display: flow-root;
174
-
175
- &::before {
176
- display: block;
177
- width: 0;
178
- height: 0;
179
- content: '';
180
- margin-top: -4px;
181
- }
182
- &::after {
183
- display: block;
184
- width: 0;
185
- height: 0;
186
- content: '';
187
- margin-bottom: -4px;
188
- }
189
- `
@@ -0,0 +1,82 @@
1
+ .charcoal-switch-input {
2
+ cursor: pointer;
3
+ appearance: none;
4
+ display: inline-flex;
5
+ position: relative;
6
+ box-sizing: border-box;
7
+ width: 28px;
8
+ border: 2px solid transparent;
9
+
10
+ transition-property: background-color, box-shadow;
11
+ transition-duration: 0.2s;
12
+
13
+ outline: none;
14
+ border-radius: 16px;
15
+ height: 16px;
16
+ margin: 0;
17
+ background-color: var(--charcoal-text4);
18
+ }
19
+
20
+ .charcoal-switch-input:disabled,
21
+ .charcoal-switch-input[readonly] {
22
+ opacity: 0.32;
23
+ cursor: default;
24
+ }
25
+
26
+ .charcoal-switch-input::after {
27
+ content: '';
28
+ position: absolute;
29
+ display: block;
30
+ top: 0;
31
+ left: 0;
32
+ width: 12px;
33
+ height: 12px;
34
+ transform: translateX(0);
35
+ transition: transform 0.2s;
36
+ border-radius: 1024px;
37
+ background-color: var(--charcoal-text5);
38
+ }
39
+
40
+ .charcoal-switch-input:checked::after {
41
+ transform: translateX(12px);
42
+ transition: transform 0.2s;
43
+ }
44
+
45
+ .charcoal-switch-input:checked {
46
+ background-color: var(--charcoal-brand);
47
+ }
48
+
49
+ .charcoal-switch-input:not(:disabled):hover {
50
+ background-color: var(--charcoal-text4-hover);
51
+ }
52
+
53
+ .charcoal-switch-input:not(:disabled):active {
54
+ background-color: var(--charcoal-text4-press);
55
+ }
56
+
57
+ .charcoal-switch-input:not(:disabled):focus {
58
+ outline: none;
59
+ box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
60
+ }
61
+ .charcoal-switch-input:not(:disabled):focus-visible {
62
+ box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
63
+ }
64
+ .charcoal-switch-input:not(:disabled):focus:not(:focus-visible) {
65
+ box-shadow: none;
66
+ }
67
+
68
+ .charcoal-switch-input:not(:disabled)::after:hover {
69
+ background-color: var(--charcoal-text5-hover);
70
+ }
71
+
72
+ .charcoal-switch-input:not(:disabled)::after:active {
73
+ background-color: var(--charcoal-text5-press);
74
+ }
75
+
76
+ .charcoal-switch-input:not(:disabled):checked:hover {
77
+ background-color: var(--charcoal-brand-hover);
78
+ }
79
+
80
+ .charcoal-switch-input:not(:disabled):checked:active {
81
+ background-color: var(--charcoal-brand-press);
82
+ }