@charcoal-ui/react 3.5.0 → 3.7.0
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.
- package/dist/_lib/compat.d.ts +1 -0
- package/dist/_lib/compat.d.ts.map +1 -1
- package/dist/components/Button/StyledButton.d.ts +12 -0
- package/dist/components/Button/StyledButton.d.ts.map +1 -0
- package/dist/components/Button/index.d.ts +2 -2
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/lib/variantToBackground.d.ts +3 -0
- package/dist/components/Button/lib/variantToBackground.d.ts.map +1 -0
- package/dist/components/Button/lib/variantToFont.d.ts +3 -0
- package/dist/components/Button/lib/variantToFont.d.ts.map +1 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.story.d.ts +6 -15
- package/dist/components/Checkbox/index.story.d.ts.map +1 -1
- package/dist/components/Clickable/index.story.d.ts +4 -6
- package/dist/components/Clickable/index.story.d.ts.map +1 -1
- package/dist/components/DropdownSelector/DropdownMenuItem.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.story.d.ts +1 -0
- package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
- package/dist/components/FieldLabel/index.d.ts.map +1 -1
- package/dist/components/Icon/index.story.d.ts +1 -1
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.story.d.ts +1 -0
- package/dist/components/Modal/index.story.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.story.d.ts +2 -0
- package/dist/components/MultiSelect/index.story.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.d.ts +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TextField/TextField.story.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/index.cjs.js +1026 -384
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +991 -349
- package/dist/index.esm.js.map +1 -1
- package/dist/styled.d.ts +4 -4
- package/package.json +18 -21
- package/src/_lib/compat.ts +8 -0
- package/src/components/Button/StyledButton.tsx +66 -0
- package/src/components/Button/__snapshots__/index.story.storyshot +312 -592
- package/src/components/Button/index.tsx +14 -70
- package/src/components/Button/lib/variantToBackground.tsx +19 -0
- package/src/components/Button/lib/variantToFont.tsx +19 -0
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +209 -40
- package/src/components/Checkbox/index.story.tsx +82 -64
- package/src/components/Checkbox/index.tsx +47 -17
- package/src/components/Clickable/__snapshots__/index.story.storyshot +4 -0
- package/src/components/Clickable/index.story.tsx +12 -9
- package/src/components/Clickable/index.tsx +1 -0
- package/src/components/DropdownSelector/DropdownMenuItem.tsx +6 -3
- package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +3 -10
- package/src/components/DropdownSelector/ListItem/index.tsx +6 -4
- package/src/components/DropdownSelector/MenuItemGroup/index.tsx +1 -1
- package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +4 -13
- package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +20 -37
- package/src/components/DropdownSelector/Popover/index.tsx +5 -8
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +227 -294
- package/src/components/DropdownSelector/index.story.tsx +33 -0
- package/src/components/DropdownSelector/index.tsx +63 -20
- package/src/components/FieldLabel/index.tsx +77 -12
- package/src/components/IconButton/__snapshots__/index.story.storyshot +30 -54
- package/src/components/IconButton/index.tsx +51 -26
- package/src/components/LoadingSpinner/index.tsx +3 -6
- package/src/components/Modal/Dialog/index.tsx +1 -1
- package/src/components/Modal/ModalPlumbing.tsx +26 -5
- package/src/components/Modal/__snapshots__/index.story.storyshot +2450 -108
- package/src/components/Modal/index.story.tsx +27 -0
- package/src/components/Modal/index.tsx +19 -4
- package/src/components/MultiSelect/__snapshots__/index.story.storyshot +528 -25
- package/src/components/MultiSelect/index.story.tsx +60 -0
- package/src/components/MultiSelect/index.tsx +82 -22
- package/src/components/Radio/__snapshots__/index.story.storyshot +32 -49
- package/src/components/Radio/index.tsx +71 -23
- package/src/components/SegmentedControl/RadioGroupContext.tsx +1 -1
- package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +9 -10
- package/src/components/SegmentedControl/index.tsx +36 -16
- package/src/components/Switch/__snapshots__/index.story.storyshot +6 -18
- package/src/components/Switch/index.tsx +10 -15
- package/src/components/TagItem/__snapshots__/index.story.storyshot +39 -158
- package/src/components/TagItem/index.tsx +84 -19
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +55 -91
- package/src/components/TextField/TextField.story.tsx +35 -18
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +92 -148
- package/src/components/TextField/index.tsx +0 -1
- package/dist/components/Checkbox/performance.test.d.ts +0 -4
- package/dist/components/Checkbox/performance.test.d.ts.map +0 -1
- package/dist/components/Checkbox/snapshot.test.d.ts +0 -2
- package/dist/components/Checkbox/snapshot.test.d.ts.map +0 -1
- package/src/components/Checkbox/__snapshots__/snapshot.test.tsx.snap +0 -763
- package/src/components/Checkbox/performance.test.tsx +0 -30
- package/src/components/Checkbox/snapshot.test.tsx +0 -66
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { forwardRef } from 'react'
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
2
|
+
import { ClickableElement, ClickableProps } from '../Clickable'
|
|
3
|
+
import { variantToFont } from './lib/variantToFont'
|
|
4
|
+
import { variantToBackground } from './lib/variantToBackground'
|
|
5
|
+
import { StyledButton } from './StyledButton'
|
|
6
6
|
|
|
7
|
-
type Variant =
|
|
8
|
-
|
|
7
|
+
export type Variant =
|
|
8
|
+
| 'Primary'
|
|
9
|
+
| 'Default'
|
|
10
|
+
| 'Overlay'
|
|
11
|
+
| 'Danger'
|
|
12
|
+
| 'Navigation'
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
$variant: Variant
|
|
12
|
-
$fullWidth: boolean
|
|
13
|
-
$size: Size
|
|
14
|
-
}
|
|
14
|
+
export type Size = 'S' | 'M'
|
|
15
15
|
|
|
16
16
|
export type ButtonProps = Partial<{
|
|
17
17
|
variant: Variant
|
|
@@ -35,7 +35,8 @@ const Button = forwardRef<ClickableElement, ButtonProps>(function Button(
|
|
|
35
35
|
<StyledButton
|
|
36
36
|
{...rest}
|
|
37
37
|
disabled={disabled}
|
|
38
|
-
$
|
|
38
|
+
$background={variantToBackground(variant)}
|
|
39
|
+
$color={variantToFont(variant)}
|
|
39
40
|
$size={size}
|
|
40
41
|
$fullWidth={fixed}
|
|
41
42
|
ref={ref}
|
|
@@ -44,62 +45,5 @@ const Button = forwardRef<ClickableElement, ButtonProps>(function Button(
|
|
|
44
45
|
</StyledButton>
|
|
45
46
|
)
|
|
46
47
|
})
|
|
47
|
-
export default Button
|
|
48
|
-
|
|
49
|
-
const StyledButton = styled(Clickable)<StyledProps>`
|
|
50
|
-
width: ${(p) => (p.$fullWidth ? 'stretch' : 'min-content')};
|
|
51
|
-
display: inline-grid;
|
|
52
|
-
align-items: center;
|
|
53
|
-
justify-content: center;
|
|
54
|
-
cursor: pointer;
|
|
55
|
-
user-select: none;
|
|
56
|
-
white-space: nowrap;
|
|
57
|
-
|
|
58
|
-
${(p) =>
|
|
59
|
-
theme((o) => [
|
|
60
|
-
o.font[variantToFont(p.$variant)].hover.press,
|
|
61
|
-
o.bg[variantToBackground(p.$variant)].hover.press,
|
|
62
|
-
o.typography(14).bold.preserveHalfLeading,
|
|
63
|
-
o.padding.horizontal(p.$size === 'M' ? 24 : 16),
|
|
64
|
-
o.disabled,
|
|
65
|
-
o.borderRadius('oval'),
|
|
66
|
-
o.outline.default.focus,
|
|
67
|
-
])}
|
|
68
48
|
|
|
69
|
-
|
|
70
|
-
height: ${(p) => (p.$size === 'M' ? 40 : 32)}px;
|
|
71
|
-
`
|
|
72
|
-
|
|
73
|
-
function variantToBackground(variant: Variant) {
|
|
74
|
-
switch (variant) {
|
|
75
|
-
case 'Overlay':
|
|
76
|
-
return 'surface4'
|
|
77
|
-
case 'Default':
|
|
78
|
-
return 'surface3'
|
|
79
|
-
case 'Primary':
|
|
80
|
-
return 'brand'
|
|
81
|
-
case 'Navigation':
|
|
82
|
-
return 'surface6'
|
|
83
|
-
case 'Danger':
|
|
84
|
-
return 'assertive'
|
|
85
|
-
default:
|
|
86
|
-
return unreachable(variant)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function variantToFont(variant: Variant) {
|
|
91
|
-
switch (variant) {
|
|
92
|
-
case 'Overlay':
|
|
93
|
-
return 'text5'
|
|
94
|
-
case 'Default':
|
|
95
|
-
return 'text2'
|
|
96
|
-
case 'Primary':
|
|
97
|
-
return 'text5'
|
|
98
|
-
case 'Navigation':
|
|
99
|
-
return 'text5'
|
|
100
|
-
case 'Danger':
|
|
101
|
-
return 'text5'
|
|
102
|
-
default:
|
|
103
|
-
return unreachable(variant)
|
|
104
|
-
}
|
|
105
|
-
}
|
|
49
|
+
export default Button
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { unreachable } from '../../../_lib'
|
|
2
|
+
import type { Variant } from '..'
|
|
3
|
+
|
|
4
|
+
export function variantToBackground(variant: Variant) {
|
|
5
|
+
switch (variant) {
|
|
6
|
+
case 'Overlay':
|
|
7
|
+
return 'surface4'
|
|
8
|
+
case 'Default':
|
|
9
|
+
return 'surface3'
|
|
10
|
+
case 'Primary':
|
|
11
|
+
return 'brand'
|
|
12
|
+
case 'Navigation':
|
|
13
|
+
return 'surface6'
|
|
14
|
+
case 'Danger':
|
|
15
|
+
return 'assertive'
|
|
16
|
+
default:
|
|
17
|
+
return unreachable(variant)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { unreachable } from '../../../_lib'
|
|
2
|
+
import type { Variant } from '..'
|
|
3
|
+
|
|
4
|
+
export function variantToFont(variant: Variant) {
|
|
5
|
+
switch (variant) {
|
|
6
|
+
case 'Overlay':
|
|
7
|
+
return 'text5'
|
|
8
|
+
case 'Default':
|
|
9
|
+
return 'text2'
|
|
10
|
+
case 'Primary':
|
|
11
|
+
return 'text5'
|
|
12
|
+
case 'Navigation':
|
|
13
|
+
return 'text5'
|
|
14
|
+
case 'Danger':
|
|
15
|
+
return 'text5'
|
|
16
|
+
default:
|
|
17
|
+
return unreachable(variant)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Storyshots Checkbox
|
|
3
|
+
exports[`Storyshots Checkbox Invalid 1`] = `
|
|
4
4
|
.c0 {
|
|
5
5
|
position: relative;
|
|
6
6
|
display: -webkit-box;
|
|
@@ -17,7 +17,7 @@ exports[`Storyshots Checkbox Labelled 1`] = `
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.c0:disabled,
|
|
20
|
-
.c0[aria-disabled]:not([aria-disabled=false]) {
|
|
20
|
+
.c0[aria-disabled]:not([aria-disabled='false']) {
|
|
21
21
|
opacity: 0.32;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -35,55 +35,223 @@ exports[`Storyshots Checkbox Labelled 1`] = `
|
|
|
35
35
|
width: 20px;
|
|
36
36
|
height: 20px;
|
|
37
37
|
border-radius: 4px;
|
|
38
|
-
-webkit-transition: 0.2s box-shadow;
|
|
39
|
-
transition: 0.2s box-shadow;
|
|
40
|
-
-webkit-transition: all 0.2s !important;
|
|
41
|
-
transition: all 0.2s !important;
|
|
38
|
+
-webkit-transition: 0.2s box-shadow,0.2s background-color;
|
|
39
|
+
transition: 0.2s box-shadow,0.2s background-color;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
.c2[type='checkbox']:checked {
|
|
45
43
|
background-color: var(--charcoal-brand);
|
|
46
|
-
-webkit-transition: 0.2s background-color;
|
|
47
|
-
transition: 0.2s background-color;
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
.c2[type='checkbox']:checked:
|
|
51
|
-
.c2[type='checkbox']:checked
|
|
46
|
+
.c2[type='checkbox']:checked:not(:disabled):not([aria-disabled]):hover,
|
|
47
|
+
.c2[type='checkbox']:checked[aria-disabled='false']:hover {
|
|
52
48
|
background-color: var(--charcoal-brand-hover);
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
.c2[type='checkbox']:checked:
|
|
56
|
-
.c2[type='checkbox']:checked
|
|
51
|
+
.c2[type='checkbox']:checked:not(:disabled):not([aria-disabled]):active,
|
|
52
|
+
.c2[type='checkbox']:checked[aria-disabled='false']:active {
|
|
57
53
|
background-color: var(--charcoal-brand-press);
|
|
58
54
|
}
|
|
59
55
|
|
|
56
|
+
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus,
|
|
57
|
+
.c2[type='checkbox'][aria-disabled='false']:focus,
|
|
58
|
+
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):active,
|
|
59
|
+
.c2[type='checkbox'][aria-disabled='false']:active {
|
|
60
|
+
outline: none;
|
|
61
|
+
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
|
|
65
|
+
.c2[type='checkbox'][aria-disabled='false']:focus:not(:focus-visible),
|
|
66
|
+
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
|
|
67
|
+
.c2[type='checkbox'][aria-disabled='false']:active:not(:focus-visible) {
|
|
68
|
+
outline: none;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus-visible,
|
|
72
|
+
.c2[type='checkbox'][aria-disabled='false']:focus-visible {
|
|
73
|
+
outline: none;
|
|
74
|
+
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.c2[type='checkbox']:not(:disabled):not([aria-disabled])[aria-invalid='true'],
|
|
78
|
+
.c2[type='checkbox'][aria-disabled='false'][aria-invalid='true'] {
|
|
79
|
+
box-shadow: 0 0 0 4px rgba(255,43,0,0.32);
|
|
80
|
+
}
|
|
81
|
+
|
|
60
82
|
.c2[type='checkbox']:not(:checked) {
|
|
61
83
|
border-width: 2px;
|
|
62
84
|
border-style: solid;
|
|
63
|
-
border-color:
|
|
85
|
+
border-color: var(--charcoal-text4);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.c3 {
|
|
89
|
+
position: absolute;
|
|
90
|
+
top: -2px;
|
|
91
|
+
left: -2px;
|
|
92
|
+
box-sizing: border-box;
|
|
93
|
+
display: -webkit-box;
|
|
94
|
+
display: -webkit-flex;
|
|
95
|
+
display: -ms-flexbox;
|
|
96
|
+
display: flex;
|
|
97
|
+
-webkit-align-items: center;
|
|
98
|
+
-webkit-box-align: center;
|
|
99
|
+
-ms-flex-align: center;
|
|
100
|
+
align-items: center;
|
|
101
|
+
-webkit-box-pack: center;
|
|
102
|
+
-webkit-justify-content: center;
|
|
103
|
+
-ms-flex-pack: center;
|
|
104
|
+
justify-content: center;
|
|
105
|
+
width: 24px;
|
|
106
|
+
height: 24px;
|
|
107
|
+
color: var(--charcoal-text5);
|
|
108
|
+
visibility: hidden;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.c4 {
|
|
112
|
+
color: var(--charcoal-text2);
|
|
113
|
+
font-size: 14px;
|
|
114
|
+
line-height: 20px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
<div
|
|
118
|
+
data-dark={false}
|
|
119
|
+
>
|
|
120
|
+
<label
|
|
121
|
+
aria-disabled={false}
|
|
122
|
+
className="c0"
|
|
123
|
+
>
|
|
124
|
+
<div
|
|
125
|
+
className="c1"
|
|
126
|
+
>
|
|
127
|
+
<input
|
|
128
|
+
aria-invalid={true}
|
|
129
|
+
checked={false}
|
|
130
|
+
className="c2"
|
|
131
|
+
disabled={false}
|
|
132
|
+
name="labelled"
|
|
133
|
+
onBlur={[Function]}
|
|
134
|
+
onChange={[Function]}
|
|
135
|
+
onClick={[Function]}
|
|
136
|
+
onDragStart={[Function]}
|
|
137
|
+
onFocus={[Function]}
|
|
138
|
+
onKeyDown={[Function]}
|
|
139
|
+
onKeyUp={[Function]}
|
|
140
|
+
onMouseDown={[Function]}
|
|
141
|
+
onMouseEnter={[Function]}
|
|
142
|
+
onMouseLeave={[Function]}
|
|
143
|
+
onMouseUp={[Function]}
|
|
144
|
+
onTouchCancel={[Function]}
|
|
145
|
+
onTouchEnd={[Function]}
|
|
146
|
+
onTouchMove={[Function]}
|
|
147
|
+
onTouchStart={[Function]}
|
|
148
|
+
type="checkbox"
|
|
149
|
+
/>
|
|
150
|
+
<div
|
|
151
|
+
aria-hidden={true}
|
|
152
|
+
checked={false}
|
|
153
|
+
className="c3"
|
|
154
|
+
>
|
|
155
|
+
<pixiv-icon
|
|
156
|
+
name="24/Check"
|
|
157
|
+
unsafe-non-guideline-scale={0.6666666666666666}
|
|
158
|
+
/>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
<div
|
|
162
|
+
className="c4"
|
|
163
|
+
>
|
|
164
|
+
同意する
|
|
165
|
+
</div>
|
|
166
|
+
</label>
|
|
167
|
+
</div>
|
|
168
|
+
`;
|
|
169
|
+
|
|
170
|
+
exports[`Storyshots Checkbox Labelled 1`] = `
|
|
171
|
+
.c0 {
|
|
172
|
+
position: relative;
|
|
173
|
+
display: -webkit-box;
|
|
174
|
+
display: -webkit-flex;
|
|
175
|
+
display: -ms-flexbox;
|
|
176
|
+
display: flex;
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
gap: 4px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.c0:disabled,
|
|
182
|
+
.c0[aria-disabled]:not([aria-disabled=false]) {
|
|
183
|
+
cursor: default;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.c0:disabled,
|
|
187
|
+
.c0[aria-disabled]:not([aria-disabled='false']) {
|
|
188
|
+
opacity: 0.32;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.c1 {
|
|
192
|
+
position: relative;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.c2[type='checkbox'] {
|
|
196
|
+
-webkit-appearance: none;
|
|
197
|
+
-moz-appearance: none;
|
|
198
|
+
appearance: none;
|
|
199
|
+
display: block;
|
|
200
|
+
cursor: pointer;
|
|
201
|
+
margin: 0;
|
|
202
|
+
width: 20px;
|
|
203
|
+
height: 20px;
|
|
204
|
+
border-radius: 4px;
|
|
205
|
+
-webkit-transition: 0.2s box-shadow,0.2s background-color;
|
|
206
|
+
transition: 0.2s box-shadow,0.2s background-color;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.c2[type='checkbox']:checked {
|
|
210
|
+
background-color: var(--charcoal-brand);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.c2[type='checkbox']:checked:not(:disabled):not([aria-disabled]):hover,
|
|
214
|
+
.c2[type='checkbox']:checked[aria-disabled='false']:hover {
|
|
215
|
+
background-color: var(--charcoal-brand-hover);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.c2[type='checkbox']:checked:not(:disabled):not([aria-disabled]):active,
|
|
219
|
+
.c2[type='checkbox']:checked[aria-disabled='false']:active {
|
|
220
|
+
background-color: var(--charcoal-brand-press);
|
|
64
221
|
}
|
|
65
222
|
|
|
66
223
|
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus,
|
|
67
|
-
.c2[type='checkbox'][aria-disabled=false]:focus,
|
|
224
|
+
.c2[type='checkbox'][aria-disabled='false']:focus,
|
|
68
225
|
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):active,
|
|
69
|
-
.c2[type='checkbox'][aria-disabled=false]:active {
|
|
226
|
+
.c2[type='checkbox'][aria-disabled='false']:active {
|
|
70
227
|
outline: none;
|
|
71
228
|
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
|
|
72
229
|
}
|
|
73
230
|
|
|
74
231
|
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
|
|
75
|
-
.c2[type='checkbox'][aria-disabled=false]:focus:not(:focus-visible),
|
|
232
|
+
.c2[type='checkbox'][aria-disabled='false']:focus:not(:focus-visible),
|
|
76
233
|
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
|
|
77
|
-
.c2[type='checkbox'][aria-disabled=false]:active:not(:focus-visible) {
|
|
234
|
+
.c2[type='checkbox'][aria-disabled='false']:active:not(:focus-visible) {
|
|
78
235
|
outline: none;
|
|
79
236
|
}
|
|
80
237
|
|
|
81
238
|
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus-visible,
|
|
82
|
-
.c2[type='checkbox'][aria-disabled=false]:focus-visible {
|
|
239
|
+
.c2[type='checkbox'][aria-disabled='false']:focus-visible {
|
|
83
240
|
outline: none;
|
|
84
241
|
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
|
|
85
242
|
}
|
|
86
243
|
|
|
244
|
+
.c2[type='checkbox']:not(:disabled):not([aria-disabled])[aria-invalid='true'],
|
|
245
|
+
.c2[type='checkbox'][aria-disabled='false'][aria-invalid='true'] {
|
|
246
|
+
box-shadow: 0 0 0 4px rgba(255,43,0,0.32);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.c2[type='checkbox']:not(:checked) {
|
|
250
|
+
border-width: 2px;
|
|
251
|
+
border-style: solid;
|
|
252
|
+
border-color: var(--charcoal-text4);
|
|
253
|
+
}
|
|
254
|
+
|
|
87
255
|
.c3 {
|
|
88
256
|
position: absolute;
|
|
89
257
|
top: -2px;
|
|
@@ -249,7 +417,7 @@ exports[`Storyshots Checkbox Unlabelled 1`] = `
|
|
|
249
417
|
}
|
|
250
418
|
|
|
251
419
|
.c0:disabled,
|
|
252
|
-
.c0[aria-disabled]:not([aria-disabled=false]) {
|
|
420
|
+
.c0[aria-disabled]:not([aria-disabled='false']) {
|
|
253
421
|
opacity: 0.32;
|
|
254
422
|
}
|
|
255
423
|
|
|
@@ -267,55 +435,56 @@ exports[`Storyshots Checkbox Unlabelled 1`] = `
|
|
|
267
435
|
width: 20px;
|
|
268
436
|
height: 20px;
|
|
269
437
|
border-radius: 4px;
|
|
270
|
-
-webkit-transition: 0.2s box-shadow;
|
|
271
|
-
transition: 0.2s box-shadow;
|
|
272
|
-
-webkit-transition: all 0.2s !important;
|
|
273
|
-
transition: all 0.2s !important;
|
|
438
|
+
-webkit-transition: 0.2s box-shadow,0.2s background-color;
|
|
439
|
+
transition: 0.2s box-shadow,0.2s background-color;
|
|
274
440
|
}
|
|
275
441
|
|
|
276
442
|
.c2[type='checkbox']:checked {
|
|
277
443
|
background-color: var(--charcoal-brand);
|
|
278
|
-
-webkit-transition: 0.2s background-color;
|
|
279
|
-
transition: 0.2s background-color;
|
|
280
444
|
}
|
|
281
445
|
|
|
282
|
-
.c2[type='checkbox']:checked:
|
|
283
|
-
.c2[type='checkbox']:checked
|
|
446
|
+
.c2[type='checkbox']:checked:not(:disabled):not([aria-disabled]):hover,
|
|
447
|
+
.c2[type='checkbox']:checked[aria-disabled='false']:hover {
|
|
284
448
|
background-color: var(--charcoal-brand-hover);
|
|
285
449
|
}
|
|
286
450
|
|
|
287
|
-
.c2[type='checkbox']:checked:
|
|
288
|
-
.c2[type='checkbox']:checked
|
|
451
|
+
.c2[type='checkbox']:checked:not(:disabled):not([aria-disabled]):active,
|
|
452
|
+
.c2[type='checkbox']:checked[aria-disabled='false']:active {
|
|
289
453
|
background-color: var(--charcoal-brand-press);
|
|
290
454
|
}
|
|
291
455
|
|
|
292
|
-
.c2[type='checkbox']:not(:checked) {
|
|
293
|
-
border-width: 2px;
|
|
294
|
-
border-style: solid;
|
|
295
|
-
border-color: #adadad;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
456
|
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus,
|
|
299
|
-
.c2[type='checkbox'][aria-disabled=false]:focus,
|
|
457
|
+
.c2[type='checkbox'][aria-disabled='false']:focus,
|
|
300
458
|
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):active,
|
|
301
|
-
.c2[type='checkbox'][aria-disabled=false]:active {
|
|
459
|
+
.c2[type='checkbox'][aria-disabled='false']:active {
|
|
302
460
|
outline: none;
|
|
303
461
|
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
|
|
304
462
|
}
|
|
305
463
|
|
|
306
464
|
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
|
|
307
|
-
.c2[type='checkbox'][aria-disabled=false]:focus:not(:focus-visible),
|
|
465
|
+
.c2[type='checkbox'][aria-disabled='false']:focus:not(:focus-visible),
|
|
308
466
|
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
|
|
309
|
-
.c2[type='checkbox'][aria-disabled=false]:active:not(:focus-visible) {
|
|
467
|
+
.c2[type='checkbox'][aria-disabled='false']:active:not(:focus-visible) {
|
|
310
468
|
outline: none;
|
|
311
469
|
}
|
|
312
470
|
|
|
313
471
|
.c2[type='checkbox']:not(:disabled):not([aria-disabled]):focus-visible,
|
|
314
|
-
.c2[type='checkbox'][aria-disabled=false]:focus-visible {
|
|
472
|
+
.c2[type='checkbox'][aria-disabled='false']:focus-visible {
|
|
315
473
|
outline: none;
|
|
316
474
|
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
|
|
317
475
|
}
|
|
318
476
|
|
|
477
|
+
.c2[type='checkbox']:not(:disabled):not([aria-disabled])[aria-invalid='true'],
|
|
478
|
+
.c2[type='checkbox'][aria-disabled='false'][aria-invalid='true'] {
|
|
479
|
+
box-shadow: 0 0 0 4px rgba(255,43,0,0.32);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.c2[type='checkbox']:not(:checked) {
|
|
483
|
+
border-width: 2px;
|
|
484
|
+
border-style: solid;
|
|
485
|
+
border-color: var(--charcoal-text4);
|
|
486
|
+
}
|
|
487
|
+
|
|
319
488
|
.c3 {
|
|
320
489
|
position: absolute;
|
|
321
490
|
top: -2px;
|
|
@@ -1,85 +1,103 @@
|
|
|
1
1
|
import { action } from '@storybook/addon-actions'
|
|
2
2
|
import Checkbox from '.'
|
|
3
|
-
import {
|
|
3
|
+
import { Meta, StoryObj } from '@storybook/react'
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Checkbox',
|
|
7
7
|
component: Checkbox,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type Props = {
|
|
11
|
-
checked: boolean
|
|
12
|
-
defaultChecked: boolean
|
|
13
|
-
disabled: boolean
|
|
14
|
-
readonly: boolean
|
|
15
|
-
className?: string
|
|
16
|
-
invalid: boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const Labelled: Story<Props> = (props) => {
|
|
20
|
-
return (
|
|
21
|
-
<div>
|
|
22
|
-
<div style={{ marginBottom: '1em' }}>
|
|
23
|
-
<Checkbox
|
|
24
|
-
{...props}
|
|
25
|
-
name="labelled"
|
|
26
|
-
label="label"
|
|
27
|
-
onBlur={action('blur')}
|
|
28
|
-
onClick={action('click')}
|
|
29
|
-
onChange={action('change')}
|
|
30
|
-
onFocus={action('focus')}
|
|
31
|
-
>
|
|
32
|
-
同意する
|
|
33
|
-
</Checkbox>
|
|
34
|
-
</div>
|
|
8
|
+
} as Meta<typeof Checkbox>
|
|
35
9
|
|
|
10
|
+
export const Labelled: StoryObj<typeof Checkbox> = {
|
|
11
|
+
args: {
|
|
12
|
+
checked: false,
|
|
13
|
+
defaultChecked: false,
|
|
14
|
+
disabled: false,
|
|
15
|
+
readonly: false,
|
|
16
|
+
invalid: false,
|
|
17
|
+
},
|
|
18
|
+
render: (props) => {
|
|
19
|
+
return (
|
|
36
20
|
<div>
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
</
|
|
49
|
-
</
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
21
|
+
<div style={{ marginBottom: '1em' }}>
|
|
22
|
+
<Checkbox
|
|
23
|
+
{...props}
|
|
24
|
+
name="labelled"
|
|
25
|
+
label="label"
|
|
26
|
+
onBlur={action('blur')}
|
|
27
|
+
onClick={action('click')}
|
|
28
|
+
onChange={action('change')}
|
|
29
|
+
onFocus={action('focus')}
|
|
30
|
+
>
|
|
31
|
+
同意する
|
|
32
|
+
</Checkbox>
|
|
33
|
+
</div>
|
|
54
34
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
35
|
+
<div>
|
|
36
|
+
<Checkbox
|
|
37
|
+
{...props}
|
|
38
|
+
name="labelled"
|
|
39
|
+
label="label"
|
|
40
|
+
onBlur={action('blur')}
|
|
41
|
+
onClick={action('click')}
|
|
42
|
+
onChange={action('change')}
|
|
43
|
+
onFocus={action('focus')}
|
|
44
|
+
>
|
|
45
|
+
<span style={{ width: 200, display: 'block' }}>
|
|
46
|
+
同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する同意する
|
|
47
|
+
</span>
|
|
48
|
+
</Checkbox>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
},
|
|
61
53
|
}
|
|
62
54
|
|
|
63
|
-
export const
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
export const Invalid: StoryObj<typeof Checkbox> = {
|
|
56
|
+
args: {
|
|
57
|
+
checked: false,
|
|
58
|
+
defaultChecked: false,
|
|
59
|
+
disabled: false,
|
|
60
|
+
readonly: false,
|
|
61
|
+
},
|
|
62
|
+
render: (props) => {
|
|
63
|
+
return (
|
|
66
64
|
<Checkbox
|
|
67
65
|
{...props}
|
|
68
|
-
name="
|
|
66
|
+
name="labelled"
|
|
69
67
|
label="label"
|
|
68
|
+
invalid
|
|
70
69
|
onBlur={action('blur')}
|
|
71
70
|
onClick={action('click')}
|
|
72
71
|
onChange={action('change')}
|
|
73
72
|
onFocus={action('focus')}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
>
|
|
74
|
+
同意する
|
|
75
|
+
</Checkbox>
|
|
76
|
+
)
|
|
77
|
+
},
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
Unlabelled
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
export const Unlabelled: StoryObj<typeof Checkbox> = {
|
|
81
|
+
args: {
|
|
82
|
+
checked: false,
|
|
83
|
+
defaultChecked: false,
|
|
84
|
+
disabled: false,
|
|
85
|
+
readonly: false,
|
|
86
|
+
invalid: false,
|
|
87
|
+
},
|
|
88
|
+
render: (props) => {
|
|
89
|
+
return (
|
|
90
|
+
<div>
|
|
91
|
+
<Checkbox
|
|
92
|
+
{...props}
|
|
93
|
+
name="unlabelled"
|
|
94
|
+
label="label"
|
|
95
|
+
onBlur={action('blur')}
|
|
96
|
+
onClick={action('click')}
|
|
97
|
+
onChange={action('change')}
|
|
98
|
+
onFocus={action('focus')}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
)
|
|
102
|
+
},
|
|
85
103
|
}
|