@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.
- package/dist/_lib/useClassNames.d.ts +2 -2
- package/dist/_lib/useClassNames.d.ts.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index.d.ts +11 -0
- package/dist/components/Checkbox/CheckboxInput/index.d.ts.map +1 -0
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts +9 -0
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts.map +1 -0
- package/dist/components/Checkbox/index.d.ts +9 -7
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Clickable/index.d.ts +10 -13
- package/dist/components/Clickable/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/FieldLabel/index.d.ts +1 -0
- package/dist/components/FieldLabel/index.d.ts.map +1 -1
- package/dist/components/IconButton/index.d.ts +7 -5
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index.d.ts +1 -0
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/Modal/Dialog/index.d.ts +6 -24
- package/dist/components/Modal/Dialog/index.d.ts.map +1 -1
- package/dist/components/Modal/ModalPlumbing.d.ts +10 -3
- package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts +3 -5
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts +1 -0
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/Switch/SwitchInput/index.d.ts +9 -0
- package/dist/components/Switch/SwitchInput/index.d.ts.map +1 -0
- package/dist/components/Switch/SwitchWithLabel.d.ts +9 -0
- package/dist/components/Switch/SwitchWithLabel.d.ts.map +1 -0
- package/dist/components/Switch/index.d.ts +4 -15
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/TagItem/index.d.ts +14 -15
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts +28 -18
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts +32 -19
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/index.cjs.js +390 -776
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +732 -28
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +415 -799
- package/dist/index.esm.js.map +1 -1
- package/dist/styled.d.ts +4 -4
- package/package.json +11 -10
- package/src/_lib/useClassNames.ts +3 -9
- package/src/components/Checkbox/CheckboxInput/__snapshots__/index.story.storyshot +77 -0
- package/src/components/Checkbox/CheckboxInput/index.css +111 -0
- package/src/components/{CheckboxInput → Checkbox/CheckboxInput}/index.story.tsx +16 -0
- package/src/components/Checkbox/CheckboxInput/index.tsx +47 -0
- package/src/components/Checkbox/CheckboxWithLabel.tsx +24 -0
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +53 -134
- package/src/components/Checkbox/index.css +2 -2
- package/src/components/Checkbox/index.story.tsx +16 -11
- package/src/components/Checkbox/index.tsx +23 -15
- package/src/components/Clickable/__snapshots__/index.story.storyshot +2 -78
- package/src/components/Clickable/index.css +41 -0
- package/src/components/Clickable/index.story.tsx +1 -1
- package/src/components/Clickable/index.tsx +25 -85
- package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +10 -135
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +308 -1014
- package/src/components/DropdownSelector/index.tsx +9 -38
- package/src/components/FieldLabel/index.css +35 -0
- package/src/components/FieldLabel/index.tsx +15 -105
- package/src/components/IconButton/__snapshots__/index.story.storyshot +12 -288
- package/src/components/IconButton/index.css +118 -0
- package/src/components/IconButton/index.story.tsx +2 -2
- package/src/components/IconButton/index.tsx +41 -118
- package/src/components/LoadingSpinner/__snapshots__/LoadingSpinnerIcon.story.storyshot +2 -17
- package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +40 -128
- package/src/components/LoadingSpinner/index.css +42 -0
- package/src/components/LoadingSpinner/index.tsx +26 -52
- package/src/components/Modal/Dialog/index.css +44 -0
- package/src/components/Modal/Dialog/index.tsx +13 -57
- package/src/components/Modal/ModalPlumbing.css +40 -0
- package/src/components/Modal/ModalPlumbing.tsx +22 -61
- package/src/components/Modal/__snapshots__/index.story.storyshot +459 -1881
- package/src/components/Modal/index.css +36 -0
- package/src/components/Modal/index.tsx +26 -73
- package/src/components/Radio/__snapshots__/index.story.storyshot +50 -775
- package/src/components/Radio/index.css +97 -0
- package/src/components/Radio/index.story.tsx +1 -10
- package/src/components/Radio/index.test.tsx +0 -1
- package/src/components/Radio/index.tsx +50 -161
- package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +30 -260
- package/src/components/SegmentedControl/index.css +50 -0
- package/src/components/SegmentedControl/index.tsx +20 -89
- package/src/components/Switch/SwitchInput/index.css +82 -0
- package/src/components/Switch/SwitchInput/index.tsx +40 -0
- package/src/components/Switch/SwitchWithLabel.tsx +24 -0
- package/src/components/Switch/__snapshots__/index.story.storyshot +29 -532
- package/src/components/Switch/index.css +23 -0
- package/src/components/Switch/index.story.tsx +5 -0
- package/src/components/Switch/index.tsx +43 -140
- package/src/components/TagItem/__snapshots__/index.story.storyshot +153 -1130
- package/src/components/TagItem/index.css +140 -0
- package/src/components/TagItem/index.story.tsx +1 -1
- package/src/components/TagItem/index.tsx +76 -220
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +203 -1357
- package/src/components/TextArea/index.tsx +68 -91
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +274 -1614
- package/src/components/TextField/index.tsx +77 -105
- package/src/index.ts +0 -7
- package/src/type.d.ts +6 -0
- package/dist/components/CheckboxInput/index.d.ts +0 -9
- package/dist/components/CheckboxInput/index.d.ts.map +0 -1
- package/dist/components/MultiSelect/context.d.ts +0 -14
- package/dist/components/MultiSelect/context.d.ts.map +0 -1
- package/dist/components/MultiSelect/index.d.ts +0 -36
- package/dist/components/MultiSelect/index.d.ts.map +0 -1
- package/src/components/CheckboxInput/__snapshots__/index.story.storyshot +0 -109
- package/src/components/CheckboxInput/index.css +0 -77
- package/src/components/CheckboxInput/index.tsx +0 -53
- package/src/components/MultiSelect/__snapshots__/index.story.storyshot +0 -1054
- package/src/components/MultiSelect/context.ts +0 -23
- package/src/components/MultiSelect/index.story.tsx +0 -112
- package/src/components/MultiSelect/index.test.tsx +0 -263
- package/src/components/MultiSelect/index.tsx +0 -282
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@charcoal-ui/icons'
|
|
2
|
-
import IconButton from '.'
|
|
2
|
+
import IconButton, { IconButtonProps } from '.'
|
|
3
3
|
import { Meta, StoryObj } from '@storybook/react'
|
|
4
4
|
|
|
5
5
|
export default {
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
parameters: {
|
|
9
9
|
layout: 'centered',
|
|
10
10
|
},
|
|
11
|
-
} as Meta<
|
|
11
|
+
} as Meta<IconButtonProps<'button'>>
|
|
12
12
|
|
|
13
13
|
export const Default: StoryObj<typeof IconButton> = {
|
|
14
14
|
args: {
|
|
@@ -1,135 +1,58 @@
|
|
|
1
|
-
import { forwardRef } from 'react'
|
|
2
|
-
import
|
|
3
|
-
import Clickable, { ClickableElement, ClickableProps } from '../Clickable'
|
|
1
|
+
import React, { ForwardedRef, forwardRef, useMemo } from 'react'
|
|
2
|
+
import { useClassNames } from '../../_lib/useClassNames'
|
|
4
3
|
import type { KnownIconType } from '@charcoal-ui/icons'
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
import './index.css'
|
|
6
6
|
|
|
7
7
|
type Variant = 'Default' | 'Overlay'
|
|
8
8
|
type Size = 'XS' | 'S' | 'M'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export type IconButtonProps<T extends React.ElementType = 'button'> = {
|
|
11
11
|
readonly variant?: Variant
|
|
12
12
|
readonly size?: Size
|
|
13
13
|
readonly icon: keyof KnownIconType
|
|
14
14
|
readonly isActive?: boolean
|
|
15
|
-
|
|
15
|
+
as?: T
|
|
16
|
+
componentAs?: React.ComponentPropsWithRef<T>['as']
|
|
17
|
+
} & Omit<React.ComponentPropsWithRef<T>, 'children' | 'as'>
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
const IconButton = forwardRef(function IconButtonInner<
|
|
20
|
+
T extends React.ElementType
|
|
21
|
+
>(
|
|
22
|
+
{
|
|
23
|
+
variant = 'Default',
|
|
24
|
+
size = 'M',
|
|
25
|
+
icon,
|
|
26
|
+
isActive = false,
|
|
27
|
+
componentAs,
|
|
28
|
+
as,
|
|
29
|
+
...rest
|
|
30
|
+
}: IconButtonProps<T>,
|
|
31
|
+
ref: ForwardedRef<HTMLButtonElement>
|
|
32
|
+
) {
|
|
33
|
+
validateIconSize(size, icon)
|
|
34
|
+
const Component = useMemo(() => as ?? 'button', [as])
|
|
35
|
+
const classNames = useClassNames('charcoal-icon-button', rest.className)
|
|
18
36
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
$size={size}
|
|
36
|
-
$variant={variant}
|
|
37
|
-
$isActive={isActive}
|
|
38
|
-
>
|
|
39
|
-
<pixiv-icon name={icon} />
|
|
40
|
-
</StyledIconButton>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
)
|
|
37
|
+
return (
|
|
38
|
+
<Component
|
|
39
|
+
{...rest}
|
|
40
|
+
as={componentAs}
|
|
41
|
+
ref={ref}
|
|
42
|
+
className={classNames}
|
|
43
|
+
data-size={size}
|
|
44
|
+
data-active={isActive}
|
|
45
|
+
data-variant={variant}
|
|
46
|
+
>
|
|
47
|
+
<pixiv-icon name={icon} />
|
|
48
|
+
</Component>
|
|
49
|
+
)
|
|
50
|
+
}) as <T extends React.ElementType = 'button'>(
|
|
51
|
+
p: IconButtonProps<T>
|
|
52
|
+
) => JSX.Element
|
|
44
53
|
|
|
45
54
|
export default IconButton
|
|
46
55
|
|
|
47
|
-
type StyledIconButtonProps = Required<{
|
|
48
|
-
[key in keyof Pick<
|
|
49
|
-
StyledProps,
|
|
50
|
-
'size' | 'variant' | 'isActive'
|
|
51
|
-
> as `$${key}`]: StyledProps[key]
|
|
52
|
-
}>
|
|
53
|
-
|
|
54
|
-
const StyledIconButton = styled(Clickable).attrs<
|
|
55
|
-
StyledIconButtonProps,
|
|
56
|
-
ReturnType<typeof styledProps>
|
|
57
|
-
>(styledProps)<StyledIconButtonProps>`
|
|
58
|
-
user-select: none;
|
|
59
|
-
|
|
60
|
-
width: ${(p) => p.$width}px;
|
|
61
|
-
height: ${(p) => p.$height}px;
|
|
62
|
-
display: flex;
|
|
63
|
-
align-items: center;
|
|
64
|
-
justify-content: center;
|
|
65
|
-
color: var(${({ $font }) => `--charcoal-${$font}`});
|
|
66
|
-
background-color: var(${({ $background }) => `--charcoal-${$background}`});
|
|
67
|
-
border-radius: 999999px;
|
|
68
|
-
transition: 0.2s background-color, 0.2s box-shadow;
|
|
69
|
-
|
|
70
|
-
&:not(:disabled):not([aria-disabled]),
|
|
71
|
-
&[aria-disabled='false'] {
|
|
72
|
-
${({ $isActive, $background, $font }) =>
|
|
73
|
-
$isActive
|
|
74
|
-
? css`
|
|
75
|
-
color: var(--charcoal-${$font}-press);
|
|
76
|
-
background-color: var(--charcoal-${$background}-press);
|
|
77
|
-
`
|
|
78
|
-
: css`
|
|
79
|
-
&:hover {
|
|
80
|
-
color: var(--charcoal-${$font}-hover);
|
|
81
|
-
background-color: var(--charcoal-${$background}-hover);
|
|
82
|
-
}
|
|
83
|
-
&:active {
|
|
84
|
-
color: var(--charcoal-${$font}-press);
|
|
85
|
-
background-color: var(--charcoal-${$background}-press);
|
|
86
|
-
}
|
|
87
|
-
`}
|
|
88
|
-
${focusVisibleFocusRingCss}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
&:disabled,
|
|
92
|
-
&[aria-disabled]:not([aria-disabled='false']) {
|
|
93
|
-
opacity: 0.32;
|
|
94
|
-
}
|
|
95
|
-
`
|
|
96
|
-
|
|
97
|
-
function styledProps({ $size, $variant }: StyledIconButtonProps) {
|
|
98
|
-
return {
|
|
99
|
-
...variantToProps($variant),
|
|
100
|
-
...sizeToProps($size),
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function variantToProps(variant: Variant) {
|
|
105
|
-
switch (variant) {
|
|
106
|
-
case 'Default':
|
|
107
|
-
return { $font: 'text3', $background: 'transparent' } as const
|
|
108
|
-
case 'Overlay':
|
|
109
|
-
return { $font: 'text5', $background: 'surface4' } as const
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function sizeToProps(size: Size) {
|
|
114
|
-
switch (size) {
|
|
115
|
-
case 'XS':
|
|
116
|
-
return {
|
|
117
|
-
$width: 20,
|
|
118
|
-
$height: 20,
|
|
119
|
-
}
|
|
120
|
-
case 'S':
|
|
121
|
-
return {
|
|
122
|
-
$width: 32,
|
|
123
|
-
$height: 32,
|
|
124
|
-
}
|
|
125
|
-
case 'M':
|
|
126
|
-
return {
|
|
127
|
-
$width: 40,
|
|
128
|
-
$height: 40,
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
56
|
/**
|
|
134
57
|
* validates matches of size and icon
|
|
135
58
|
*/
|
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`Storybook Tests LoadingSpinnerIcon Icon 1`] = `
|
|
4
|
-
.c0 {
|
|
5
|
-
width: 1em;
|
|
6
|
-
height: 1em;
|
|
7
|
-
border-radius: 1em;
|
|
8
|
-
background-color: currentColor;
|
|
9
|
-
-webkit-animation: cNZOgq 1s both ease-out;
|
|
10
|
-
animation: cNZOgq 1s both ease-out;
|
|
11
|
-
-webkit-animation-iteration-count: infinite;
|
|
12
|
-
animation-iteration-count: infinite;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.c0[data-reset-animation] {
|
|
16
|
-
-webkit-animation: none;
|
|
17
|
-
animation: none;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
4
|
<div
|
|
21
5
|
data-dark={false}
|
|
22
6
|
>
|
|
23
7
|
<div
|
|
24
|
-
className="
|
|
8
|
+
className="charcoal-loading-spinner-icon"
|
|
9
|
+
data-once={false}
|
|
25
10
|
role="presentation"
|
|
26
11
|
/>
|
|
27
12
|
</div>
|
|
@@ -1,45 +1,23 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`Storybook Tests LoadingSpinner Default 1`] = `
|
|
4
|
-
.c0 {
|
|
5
|
-
box-sizing: content-box;
|
|
6
|
-
margin: auto;
|
|
7
|
-
padding: 16px;
|
|
8
|
-
border-radius: 8px;
|
|
9
|
-
font-size: 48px;
|
|
10
|
-
width: 48px;
|
|
11
|
-
height: 48px;
|
|
12
|
-
opacity: 0.84;
|
|
13
|
-
color: var(--charcoal-text4);
|
|
14
|
-
background-color: var(--charcoal-background1);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.c1 {
|
|
18
|
-
width: 1em;
|
|
19
|
-
height: 1em;
|
|
20
|
-
border-radius: 1em;
|
|
21
|
-
background-color: currentColor;
|
|
22
|
-
-webkit-animation: cNZOgq 1s both ease-out;
|
|
23
|
-
animation: cNZOgq 1s both ease-out;
|
|
24
|
-
-webkit-animation-iteration-count: infinite;
|
|
25
|
-
animation-iteration-count: infinite;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.c1[data-reset-animation] {
|
|
29
|
-
-webkit-animation: none;
|
|
30
|
-
animation: none;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
4
|
<div
|
|
34
5
|
data-dark={false}
|
|
35
6
|
>
|
|
36
7
|
<div
|
|
37
|
-
className="
|
|
8
|
+
className="charcoal-loading-spinner"
|
|
9
|
+
data-transparent={false}
|
|
38
10
|
role="progressbar"
|
|
39
|
-
|
|
11
|
+
style={
|
|
12
|
+
Object {
|
|
13
|
+
"--charcoal-loading-spinner-padding": "16px",
|
|
14
|
+
"--charcoal-loading-spinner-size": "48px",
|
|
15
|
+
}
|
|
16
|
+
}
|
|
40
17
|
>
|
|
41
18
|
<div
|
|
42
|
-
className="
|
|
19
|
+
className="charcoal-loading-spinner-icon"
|
|
20
|
+
data-once={false}
|
|
43
21
|
role="presentation"
|
|
44
22
|
/>
|
|
45
23
|
</div>
|
|
@@ -47,45 +25,23 @@ exports[`Storybook Tests LoadingSpinner Default 1`] = `
|
|
|
47
25
|
`;
|
|
48
26
|
|
|
49
27
|
exports[`Storybook Tests LoadingSpinner Padding 1`] = `
|
|
50
|
-
.c0 {
|
|
51
|
-
box-sizing: content-box;
|
|
52
|
-
margin: auto;
|
|
53
|
-
padding: 24px;
|
|
54
|
-
border-radius: 8px;
|
|
55
|
-
font-size: 48px;
|
|
56
|
-
width: 48px;
|
|
57
|
-
height: 48px;
|
|
58
|
-
opacity: 0.84;
|
|
59
|
-
color: var(--charcoal-text4);
|
|
60
|
-
background-color: var(--charcoal-background1);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.c1 {
|
|
64
|
-
width: 1em;
|
|
65
|
-
height: 1em;
|
|
66
|
-
border-radius: 1em;
|
|
67
|
-
background-color: currentColor;
|
|
68
|
-
-webkit-animation: cNZOgq 1s both ease-out;
|
|
69
|
-
animation: cNZOgq 1s both ease-out;
|
|
70
|
-
-webkit-animation-iteration-count: infinite;
|
|
71
|
-
animation-iteration-count: infinite;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.c1[data-reset-animation] {
|
|
75
|
-
-webkit-animation: none;
|
|
76
|
-
animation: none;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
28
|
<div
|
|
80
29
|
data-dark={false}
|
|
81
30
|
>
|
|
82
31
|
<div
|
|
83
|
-
className="
|
|
32
|
+
className="charcoal-loading-spinner"
|
|
33
|
+
data-transparent={false}
|
|
84
34
|
role="progressbar"
|
|
85
|
-
|
|
35
|
+
style={
|
|
36
|
+
Object {
|
|
37
|
+
"--charcoal-loading-spinner-padding": "24px",
|
|
38
|
+
"--charcoal-loading-spinner-size": "48px",
|
|
39
|
+
}
|
|
40
|
+
}
|
|
86
41
|
>
|
|
87
42
|
<div
|
|
88
|
-
className="
|
|
43
|
+
className="charcoal-loading-spinner-icon"
|
|
44
|
+
data-once={false}
|
|
89
45
|
role="presentation"
|
|
90
46
|
/>
|
|
91
47
|
</div>
|
|
@@ -93,45 +49,23 @@ exports[`Storybook Tests LoadingSpinner Padding 1`] = `
|
|
|
93
49
|
`;
|
|
94
50
|
|
|
95
51
|
exports[`Storybook Tests LoadingSpinner Size 1`] = `
|
|
96
|
-
.c0 {
|
|
97
|
-
box-sizing: content-box;
|
|
98
|
-
margin: auto;
|
|
99
|
-
padding: 16px;
|
|
100
|
-
border-radius: 8px;
|
|
101
|
-
font-size: 128px;
|
|
102
|
-
width: 128px;
|
|
103
|
-
height: 128px;
|
|
104
|
-
opacity: 0.84;
|
|
105
|
-
color: var(--charcoal-text4);
|
|
106
|
-
background-color: var(--charcoal-background1);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.c1 {
|
|
110
|
-
width: 1em;
|
|
111
|
-
height: 1em;
|
|
112
|
-
border-radius: 1em;
|
|
113
|
-
background-color: currentColor;
|
|
114
|
-
-webkit-animation: cNZOgq 1s both ease-out;
|
|
115
|
-
animation: cNZOgq 1s both ease-out;
|
|
116
|
-
-webkit-animation-iteration-count: infinite;
|
|
117
|
-
animation-iteration-count: infinite;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.c1[data-reset-animation] {
|
|
121
|
-
-webkit-animation: none;
|
|
122
|
-
animation: none;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
52
|
<div
|
|
126
53
|
data-dark={false}
|
|
127
54
|
>
|
|
128
55
|
<div
|
|
129
|
-
className="
|
|
56
|
+
className="charcoal-loading-spinner"
|
|
57
|
+
data-transparent={false}
|
|
130
58
|
role="progressbar"
|
|
131
|
-
|
|
59
|
+
style={
|
|
60
|
+
Object {
|
|
61
|
+
"--charcoal-loading-spinner-padding": "16px",
|
|
62
|
+
"--charcoal-loading-spinner-size": "128px",
|
|
63
|
+
}
|
|
64
|
+
}
|
|
132
65
|
>
|
|
133
66
|
<div
|
|
134
|
-
className="
|
|
67
|
+
className="charcoal-loading-spinner-icon"
|
|
68
|
+
data-once={false}
|
|
135
69
|
role="presentation"
|
|
136
70
|
/>
|
|
137
71
|
</div>
|
|
@@ -139,45 +73,23 @@ exports[`Storybook Tests LoadingSpinner Size 1`] = `
|
|
|
139
73
|
`;
|
|
140
74
|
|
|
141
75
|
exports[`Storybook Tests LoadingSpinner Transparent 1`] = `
|
|
142
|
-
.c0 {
|
|
143
|
-
box-sizing: content-box;
|
|
144
|
-
margin: auto;
|
|
145
|
-
padding: 16px;
|
|
146
|
-
border-radius: 8px;
|
|
147
|
-
font-size: 48px;
|
|
148
|
-
width: 48px;
|
|
149
|
-
height: 48px;
|
|
150
|
-
opacity: 0.84;
|
|
151
|
-
color: var(--charcoal-text4);
|
|
152
|
-
background-color: var(--charcoal-transparent);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.c1 {
|
|
156
|
-
width: 1em;
|
|
157
|
-
height: 1em;
|
|
158
|
-
border-radius: 1em;
|
|
159
|
-
background-color: currentColor;
|
|
160
|
-
-webkit-animation: cNZOgq 1s both ease-out;
|
|
161
|
-
animation: cNZOgq 1s both ease-out;
|
|
162
|
-
-webkit-animation-iteration-count: infinite;
|
|
163
|
-
animation-iteration-count: infinite;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.c1[data-reset-animation] {
|
|
167
|
-
-webkit-animation: none;
|
|
168
|
-
animation: none;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
76
|
<div
|
|
172
77
|
data-dark={false}
|
|
173
78
|
>
|
|
174
79
|
<div
|
|
175
|
-
className="
|
|
80
|
+
className="charcoal-loading-spinner"
|
|
81
|
+
data-transparent={true}
|
|
176
82
|
role="progressbar"
|
|
177
|
-
|
|
83
|
+
style={
|
|
84
|
+
Object {
|
|
85
|
+
"--charcoal-loading-spinner-padding": "16px",
|
|
86
|
+
"--charcoal-loading-spinner-size": "48px",
|
|
87
|
+
}
|
|
88
|
+
}
|
|
178
89
|
>
|
|
179
90
|
<div
|
|
180
|
-
className="
|
|
91
|
+
className="charcoal-loading-spinner-icon"
|
|
92
|
+
data-once={false}
|
|
181
93
|
role="presentation"
|
|
182
94
|
/>
|
|
183
95
|
</div>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.charcoal-loading-spinner {
|
|
2
|
+
box-sizing: content-box;
|
|
3
|
+
margin: auto;
|
|
4
|
+
padding: var(--charcoal-loading-spinner-padding);
|
|
5
|
+
border-radius: 8px;
|
|
6
|
+
font-size: var(--charcoal-loading-spinner-size);
|
|
7
|
+
width: var(--charcoal-loading-spinner-size);
|
|
8
|
+
height: var(--charcoal-loading-spinner-size);
|
|
9
|
+
opacity: 0.84;
|
|
10
|
+
color: var(--charcoal-text4);
|
|
11
|
+
background-color: var(--charcoal-background1);
|
|
12
|
+
}
|
|
13
|
+
.charcoal-loading-spinner[data-transparent='true'] {
|
|
14
|
+
background-color: var(--charcoal-transparent);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@keyframes charcoal-loading-spinner-icon-scale-out {
|
|
18
|
+
from {
|
|
19
|
+
transform: scale(0);
|
|
20
|
+
opacity: 1;
|
|
21
|
+
}
|
|
22
|
+
to {
|
|
23
|
+
transform: scale(1);
|
|
24
|
+
opacity: 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.charcoal-loading-spinner-icon {
|
|
29
|
+
width: 1em;
|
|
30
|
+
height: 1em;
|
|
31
|
+
border-radius: 1em;
|
|
32
|
+
background-color: currentColor;
|
|
33
|
+
animation: charcoal-loading-spinner-icon-scale-out 1s both ease-out;
|
|
34
|
+
animation-iteration-count: infinite;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.charcoal-loading-spinner-icon[data-reset-animation] {
|
|
38
|
+
animation: none;
|
|
39
|
+
}
|
|
40
|
+
.charcoal-loading-spinner-icon[data-once='true'] {
|
|
41
|
+
animation-iteration-count: 1;
|
|
42
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { forwardRef, useImperativeHandle, useRef, memo } from 'react'
|
|
2
|
-
import
|
|
2
|
+
import { useClassNames } from '../../_lib/useClassNames'
|
|
3
|
+
|
|
4
|
+
import './index.css'
|
|
3
5
|
|
|
4
6
|
export type LoadingSpinnerProps = {
|
|
5
7
|
readonly size?: number
|
|
@@ -10,68 +12,33 @@ export type LoadingSpinnerProps = {
|
|
|
10
12
|
|
|
11
13
|
const LoadingSpinner = forwardRef<HTMLDivElement, LoadingSpinnerProps>(
|
|
12
14
|
function LoadingSpinnerInner(
|
|
13
|
-
{ size = 48, padding = 16, transparent = false,
|
|
15
|
+
{ size = 48, padding = 16, transparent = false, ...props },
|
|
14
16
|
ref
|
|
15
17
|
) {
|
|
18
|
+
const classNames = useClassNames(
|
|
19
|
+
'charcoal-loading-spinner',
|
|
20
|
+
props.className
|
|
21
|
+
)
|
|
22
|
+
|
|
16
23
|
return (
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
<div
|
|
25
|
+
role="progressbar"
|
|
26
|
+
style={{
|
|
27
|
+
'--charcoal-loading-spinner-size': `${size}px`,
|
|
28
|
+
'--charcoal-loading-spinner-padding': `${padding}px`,
|
|
29
|
+
}}
|
|
30
|
+
data-transparent={transparent}
|
|
31
|
+
className={classNames}
|
|
22
32
|
ref={ref}
|
|
23
33
|
>
|
|
24
34
|
<LoadingSpinnerIcon />
|
|
25
|
-
</
|
|
35
|
+
</div>
|
|
26
36
|
)
|
|
27
37
|
}
|
|
28
38
|
)
|
|
29
39
|
|
|
30
40
|
export default memo(LoadingSpinner)
|
|
31
41
|
|
|
32
|
-
const LoadingSpinnerRoot = styled.div.attrs({ role: 'progressbar' })<{
|
|
33
|
-
size: number
|
|
34
|
-
padding: number
|
|
35
|
-
transparent: boolean
|
|
36
|
-
}>`
|
|
37
|
-
box-sizing: content-box;
|
|
38
|
-
margin: auto;
|
|
39
|
-
padding: ${(props) => props.padding}px;
|
|
40
|
-
border-radius: 8px;
|
|
41
|
-
font-size: ${(props) => props.size}px;
|
|
42
|
-
width: ${(props) => props.size}px;
|
|
43
|
-
height: ${(props) => props.size}px;
|
|
44
|
-
opacity: 0.84;
|
|
45
|
-
color: var(--charcoal-text4);
|
|
46
|
-
background-color: ${({ transparent }) =>
|
|
47
|
-
`var(--charcoal-${transparent ? 'transparent' : 'background1'})`};
|
|
48
|
-
`
|
|
49
|
-
|
|
50
|
-
const scaleOut = keyframes`
|
|
51
|
-
from {
|
|
52
|
-
transform: scale(0);
|
|
53
|
-
opacity: 1;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
to {
|
|
57
|
-
transform: scale(1);
|
|
58
|
-
opacity: 0;
|
|
59
|
-
}
|
|
60
|
-
`
|
|
61
|
-
|
|
62
|
-
const Icon = styled.div.attrs({ role: 'presentation' })<{ once: boolean }>`
|
|
63
|
-
width: 1em;
|
|
64
|
-
height: 1em;
|
|
65
|
-
border-radius: 1em;
|
|
66
|
-
background-color: currentColor;
|
|
67
|
-
animation: ${scaleOut} 1s both ease-out;
|
|
68
|
-
animation-iteration-count: ${(p) => (p.once ? 1 : 'infinite')};
|
|
69
|
-
|
|
70
|
-
&[data-reset-animation] {
|
|
71
|
-
animation: none;
|
|
72
|
-
}
|
|
73
|
-
`
|
|
74
|
-
|
|
75
42
|
type Props = {
|
|
76
43
|
once?: boolean
|
|
77
44
|
}
|
|
@@ -96,6 +63,13 @@ export const LoadingSpinnerIcon = forwardRef<LoadingSpinnerIconHandler, Props>(
|
|
|
96
63
|
},
|
|
97
64
|
}))
|
|
98
65
|
|
|
99
|
-
return
|
|
66
|
+
return (
|
|
67
|
+
<div
|
|
68
|
+
role="presentation"
|
|
69
|
+
ref={iconRef}
|
|
70
|
+
data-once={once}
|
|
71
|
+
className="charcoal-loading-spinner-icon"
|
|
72
|
+
/>
|
|
73
|
+
)
|
|
100
74
|
}
|
|
101
75
|
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.charcoal-modal-dialog {
|
|
2
|
+
margin: auto;
|
|
3
|
+
position: relative;
|
|
4
|
+
height: fit-content;
|
|
5
|
+
width: 440px;
|
|
6
|
+
|
|
7
|
+
background-color: var(--charcoal-surface1);
|
|
8
|
+
border-radius: 24px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.charcoal-modal-dialog[data-size='S'] {
|
|
12
|
+
width: 336px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.charcoal-modal-dialog[data-size='M'] {
|
|
16
|
+
width: 440px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.charcoal-modal-dialog[data-size='L'] {
|
|
20
|
+
width: 648px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@media (max-width: 743px) {
|
|
24
|
+
.charcoal-modal-dialog {
|
|
25
|
+
max-width: 440px;
|
|
26
|
+
width: calc(100% - 48px);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.charcoal-modal-dialog[data-bottom-sheet='true'],
|
|
30
|
+
.charcoal-modal-dialog[data-bottom-sheet='full'] {
|
|
31
|
+
max-width: unset;
|
|
32
|
+
width: 100%;
|
|
33
|
+
border-radius: 0;
|
|
34
|
+
margin: auto 0 0 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.charcoal-modal-dialog[data-bottom-sheet='full'] {
|
|
38
|
+
min-height: 100%;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.charcoal-modal-dialog:focus {
|
|
43
|
+
outline: none;
|
|
44
|
+
}
|