@charcoal-ui/react 3.1.2-beta.6 → 3.2.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/components/Button/index.d.ts +2 -12
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Checkbox/performance.test.d.ts +4 -0
- package/dist/components/Checkbox/performance.test.d.ts.map +1 -0
- package/dist/components/Checkbox/snapshot.test.d.ts +2 -0
- package/dist/components/Checkbox/snapshot.test.d.ts.map +1 -0
- package/dist/index.cjs.js +35 -44
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +35 -44
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
- package/src/components/Button/__snapshots__/index.test.tsx.snap +0 -155
- package/src/components/Button/index.tsx +37 -54
- package/src/components/Checkbox/__snapshots__/snapshot.test.tsx.snap +763 -0
- package/src/components/Checkbox/performance.test.tsx +30 -0
- package/src/components/Checkbox/snapshot.test.tsx +66 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charcoal-ui/react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"typescript": "^4.9.5"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@charcoal-ui/icons": "^3.
|
|
53
|
-
"@charcoal-ui/styled": "^3.
|
|
54
|
-
"@charcoal-ui/theme": "^3.
|
|
55
|
-
"@charcoal-ui/utils": "^3.
|
|
52
|
+
"@charcoal-ui/icons": "^3.2.0",
|
|
53
|
+
"@charcoal-ui/styled": "^3.2.0",
|
|
54
|
+
"@charcoal-ui/theme": "^3.2.0",
|
|
55
|
+
"@charcoal-ui/utils": "^3.2.0",
|
|
56
56
|
"@react-aria/button": "^3.7.0",
|
|
57
57
|
"@react-aria/checkbox": "^3.8.0",
|
|
58
58
|
"@react-aria/dialog": "^3.5.0",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"url": "https://github.com/pixiv/charcoal.git",
|
|
89
89
|
"directory": "packages/react"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "495dc492d64a159618461a074b2315547eeda99f"
|
|
92
92
|
}
|
|
@@ -118,8 +118,6 @@ exports[`Basic <Button>Hello</Button> 1`] = `
|
|
|
118
118
|
<button
|
|
119
119
|
className="c0 c1"
|
|
120
120
|
disabled={false}
|
|
121
|
-
height={40}
|
|
122
|
-
size="M"
|
|
123
121
|
>
|
|
124
122
|
Hello
|
|
125
123
|
</button>
|
|
@@ -224,161 +222,8 @@ exports[`Link <Button to="#">Hello</Button> 1`] = `
|
|
|
224
222
|
|
|
225
223
|
<a
|
|
226
224
|
aria-disabled={false}
|
|
227
|
-
background="surface3"
|
|
228
225
|
className="c0 c1"
|
|
229
|
-
font="text2"
|
|
230
|
-
height={40}
|
|
231
226
|
href="#"
|
|
232
|
-
padding={24}
|
|
233
|
-
size="M"
|
|
234
|
-
theme={
|
|
235
|
-
Object {
|
|
236
|
-
"border": Object {
|
|
237
|
-
"default": Object {
|
|
238
|
-
"color": "rgba(0,0,0,0.08)",
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
"borderRadius": Object {
|
|
242
|
-
"16": 16,
|
|
243
|
-
"24": 24,
|
|
244
|
-
"4": 4,
|
|
245
|
-
"8": 8,
|
|
246
|
-
"none": 0,
|
|
247
|
-
"oval": 999999,
|
|
248
|
-
},
|
|
249
|
-
"breakpoint": Object {
|
|
250
|
-
"screen1": 744,
|
|
251
|
-
"screen2": 952,
|
|
252
|
-
"screen3": 1160,
|
|
253
|
-
"screen4": 1368,
|
|
254
|
-
},
|
|
255
|
-
"color": Object {
|
|
256
|
-
"assertive": "#ff2b00",
|
|
257
|
-
"background1": "#ffffff",
|
|
258
|
-
"background2": "#f5f5f5",
|
|
259
|
-
"border": "rgba(0,0,0,0.08)",
|
|
260
|
-
"brand": "#0096fa",
|
|
261
|
-
"icon6": "rgba(255,255,255,0.28)",
|
|
262
|
-
"link1": "#3d7699",
|
|
263
|
-
"link2": "rgba(255,255,255,0.36)",
|
|
264
|
-
"success": "#b1cc29",
|
|
265
|
-
"surface1": "#ffffff",
|
|
266
|
-
"surface10": "rgba(0,0,0,0.16)",
|
|
267
|
-
"surface2": "rgba(0,0,0,0.02)",
|
|
268
|
-
"surface3": "rgba(0,0,0,0.04)",
|
|
269
|
-
"surface4": "rgba(0,0,0,0.32)",
|
|
270
|
-
"surface6": "rgba(0,0,0,0.88)",
|
|
271
|
-
"surface7": "rgba(0,0,0,0.02)",
|
|
272
|
-
"surface8": "rgba(0,0,0,0.88)",
|
|
273
|
-
"surface9": "#ffffff",
|
|
274
|
-
"text1": "#1f1f1f",
|
|
275
|
-
"text2": "#474747",
|
|
276
|
-
"text3": "#858585",
|
|
277
|
-
"text4": "#adadad",
|
|
278
|
-
"text5": "#ffffff",
|
|
279
|
-
"transparent": "rgba(0,0,0,0)",
|
|
280
|
-
"updatedItem": "rgba(0,150,250,0.04)",
|
|
281
|
-
"warning": "#ffaf0f",
|
|
282
|
-
},
|
|
283
|
-
"effect": Object {
|
|
284
|
-
"hover": Object {
|
|
285
|
-
"color": "rgba(0,0,0,0.04)",
|
|
286
|
-
"type": "alpha",
|
|
287
|
-
},
|
|
288
|
-
"press": Object {
|
|
289
|
-
"color": "rgba(0,0,0,0.16)",
|
|
290
|
-
"type": "alpha",
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
"elementEffect": Object {
|
|
294
|
-
"disabled": Object {
|
|
295
|
-
"opacity": 0.32,
|
|
296
|
-
"type": "opacity",
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
"gradientColor": Object {
|
|
300
|
-
"callToAction": Array [
|
|
301
|
-
Object {
|
|
302
|
-
"color": "#d1ff1a",
|
|
303
|
-
"ratio": 0,
|
|
304
|
-
},
|
|
305
|
-
Object {
|
|
306
|
-
"color": "#1ad1ff",
|
|
307
|
-
"ratio": 100,
|
|
308
|
-
},
|
|
309
|
-
],
|
|
310
|
-
"surface5": Array [
|
|
311
|
-
Object {
|
|
312
|
-
"color": "rgba(0,0,0,0.32)",
|
|
313
|
-
"ratio": 0,
|
|
314
|
-
},
|
|
315
|
-
Object {
|
|
316
|
-
"color": "rgba(0,0,0,0)",
|
|
317
|
-
"ratio": 100,
|
|
318
|
-
},
|
|
319
|
-
],
|
|
320
|
-
},
|
|
321
|
-
"grid": Object {
|
|
322
|
-
"unit": Object {
|
|
323
|
-
"column": 80,
|
|
324
|
-
"gutter": 24,
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
"outline": Object {
|
|
328
|
-
"assertive": Object {
|
|
329
|
-
"color": "rgba(255,43,0,0.32)",
|
|
330
|
-
"weight": 4,
|
|
331
|
-
},
|
|
332
|
-
"default": Object {
|
|
333
|
-
"color": "rgba(0,150,250,0.32)",
|
|
334
|
-
"weight": 4,
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
"spacing": Object {
|
|
338
|
-
"0": 0,
|
|
339
|
-
"104": 104,
|
|
340
|
-
"16": 16,
|
|
341
|
-
"168": 168,
|
|
342
|
-
"24": 24,
|
|
343
|
-
"272": 272,
|
|
344
|
-
"4": 4,
|
|
345
|
-
"40": 40,
|
|
346
|
-
"440": 440,
|
|
347
|
-
"64": 64,
|
|
348
|
-
"8": 8,
|
|
349
|
-
},
|
|
350
|
-
"transition": Object {
|
|
351
|
-
"default": Object {
|
|
352
|
-
"duration": 0.2,
|
|
353
|
-
},
|
|
354
|
-
},
|
|
355
|
-
"typography": Object {
|
|
356
|
-
"size": Object {
|
|
357
|
-
"12": Object {
|
|
358
|
-
"fontSize": 12,
|
|
359
|
-
"lineHeight": 20,
|
|
360
|
-
},
|
|
361
|
-
"14": Object {
|
|
362
|
-
"fontSize": 14,
|
|
363
|
-
"lineHeight": 22,
|
|
364
|
-
},
|
|
365
|
-
"16": Object {
|
|
366
|
-
"fontSize": 16,
|
|
367
|
-
"lineHeight": 24,
|
|
368
|
-
},
|
|
369
|
-
"20": Object {
|
|
370
|
-
"fontSize": 20,
|
|
371
|
-
"lineHeight": 28,
|
|
372
|
-
},
|
|
373
|
-
"32": Object {
|
|
374
|
-
"fontSize": 32,
|
|
375
|
-
"lineHeight": 40,
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
variant="Default"
|
|
382
227
|
>
|
|
383
228
|
Hello
|
|
384
229
|
</a>
|
|
@@ -8,21 +8,17 @@ type Variant = 'Primary' | 'Default' | 'Overlay' | 'Danger' | 'Navigation'
|
|
|
8
8
|
type Size = 'S' | 'M'
|
|
9
9
|
|
|
10
10
|
interface StyledProps {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
$variant: Variant
|
|
12
|
+
$fullWidth: boolean
|
|
13
|
+
$size: Size
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type ButtonProps = Partial<{
|
|
14
17
|
variant: Variant
|
|
15
|
-
/**
|
|
16
|
-
* ボタンのサイズ
|
|
17
|
-
*/
|
|
18
18
|
size: Size
|
|
19
|
-
/**
|
|
20
|
-
* 幅を最大まで広げて描画
|
|
21
|
-
*/
|
|
22
19
|
fullWidth: boolean
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type ButtonProps = Partial<StyledProps> & ClickableProps
|
|
20
|
+
}> &
|
|
21
|
+
ClickableProps
|
|
26
22
|
|
|
27
23
|
const Button = forwardRef<ClickableElement, ButtonProps>(function Button(
|
|
28
24
|
{
|
|
@@ -39,9 +35,9 @@ const Button = forwardRef<ClickableElement, ButtonProps>(function Button(
|
|
|
39
35
|
<StyledButton
|
|
40
36
|
{...rest}
|
|
41
37
|
disabled={disabled}
|
|
42
|
-
variant={variant}
|
|
43
|
-
size={size}
|
|
44
|
-
fullWidth={fixed}
|
|
38
|
+
$variant={variant}
|
|
39
|
+
$size={size}
|
|
40
|
+
$fullWidth={fixed}
|
|
45
41
|
ref={ref}
|
|
46
42
|
>
|
|
47
43
|
{children}
|
|
@@ -50,15 +46,8 @@ const Button = forwardRef<ClickableElement, ButtonProps>(function Button(
|
|
|
50
46
|
})
|
|
51
47
|
export default Button
|
|
52
48
|
|
|
53
|
-
const StyledButton = styled(Clickable)
|
|
54
|
-
|
|
55
|
-
shouldForwardProp(prop) {
|
|
56
|
-
// fixed は <button> 要素に渡ってはいけない
|
|
57
|
-
return prop !== 'fullWidth'
|
|
58
|
-
},
|
|
59
|
-
})
|
|
60
|
-
.attrs<StyledProps, ReturnType<typeof styledProps>>(styledProps)`
|
|
61
|
-
width: ${(p) => (p.fullWidth ? 'stretch' : 'min-content')};
|
|
49
|
+
const StyledButton = styled(Clickable)<StyledProps>`
|
|
50
|
+
width: ${(p) => (p.$fullWidth ? 'stretch' : 'min-content')};
|
|
62
51
|
display: inline-grid;
|
|
63
52
|
align-items: center;
|
|
64
53
|
justify-content: center;
|
|
@@ -68,55 +57,49 @@ const StyledButton = styled(Clickable)
|
|
|
68
57
|
|
|
69
58
|
${(p) =>
|
|
70
59
|
theme((o) => [
|
|
71
|
-
o.font[p
|
|
72
|
-
o.bg[p
|
|
60
|
+
o.font[variantToFont(p.$variant)].hover.press,
|
|
61
|
+
o.bg[variantToBackgraund(p.$variant)].hover.press,
|
|
73
62
|
o.typography(14).bold.preserveHalfLeading,
|
|
74
|
-
o.padding.horizontal(p
|
|
63
|
+
o.padding.horizontal(p.$size === 'M' ? 24 : 16),
|
|
75
64
|
o.disabled,
|
|
76
65
|
o.borderRadius('oval'),
|
|
77
66
|
o.outline.default.focus,
|
|
78
67
|
])}
|
|
79
68
|
|
|
80
69
|
/* よく考えたらheight=32って定義が存在しないな... */
|
|
81
|
-
height: ${(p) => p
|
|
70
|
+
height: ${(p) => (p.$size === 'M' ? 40 : 32)}px;
|
|
82
71
|
`
|
|
83
72
|
|
|
84
|
-
function
|
|
85
|
-
return {
|
|
86
|
-
...props,
|
|
87
|
-
...variantToProps(props.variant),
|
|
88
|
-
...sizeToProps(props.size),
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function variantToProps(variant: Variant) {
|
|
73
|
+
function variantToBackgraund(variant: Variant) {
|
|
93
74
|
switch (variant) {
|
|
94
75
|
case 'Overlay':
|
|
95
|
-
return
|
|
76
|
+
return 'surface4'
|
|
96
77
|
case 'Default':
|
|
97
|
-
return
|
|
78
|
+
return 'surface3'
|
|
98
79
|
case 'Primary':
|
|
99
|
-
return
|
|
80
|
+
return 'brand'
|
|
100
81
|
case 'Navigation':
|
|
101
|
-
return
|
|
82
|
+
return 'surface6'
|
|
102
83
|
case 'Danger':
|
|
103
|
-
return
|
|
84
|
+
return 'assertive'
|
|
104
85
|
default:
|
|
105
86
|
return unreachable(variant)
|
|
106
87
|
}
|
|
107
88
|
}
|
|
108
89
|
|
|
109
|
-
function
|
|
110
|
-
switch (
|
|
111
|
-
case '
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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)
|
|
121
104
|
}
|
|
122
105
|
}
|