@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.
Files changed (100) hide show
  1. package/dist/_lib/compat.d.ts +1 -0
  2. package/dist/_lib/compat.d.ts.map +1 -1
  3. package/dist/components/Button/StyledButton.d.ts +12 -0
  4. package/dist/components/Button/StyledButton.d.ts.map +1 -0
  5. package/dist/components/Button/index.d.ts +2 -2
  6. package/dist/components/Button/index.d.ts.map +1 -1
  7. package/dist/components/Button/lib/variantToBackground.d.ts +3 -0
  8. package/dist/components/Button/lib/variantToBackground.d.ts.map +1 -0
  9. package/dist/components/Button/lib/variantToFont.d.ts +3 -0
  10. package/dist/components/Button/lib/variantToFont.d.ts.map +1 -0
  11. package/dist/components/Checkbox/index.d.ts.map +1 -1
  12. package/dist/components/Checkbox/index.story.d.ts +6 -15
  13. package/dist/components/Checkbox/index.story.d.ts.map +1 -1
  14. package/dist/components/Clickable/index.story.d.ts +4 -6
  15. package/dist/components/Clickable/index.story.d.ts.map +1 -1
  16. package/dist/components/DropdownSelector/DropdownMenuItem.d.ts.map +1 -1
  17. package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
  18. package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
  19. package/dist/components/DropdownSelector/index.d.ts.map +1 -1
  20. package/dist/components/DropdownSelector/index.story.d.ts +1 -0
  21. package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
  22. package/dist/components/FieldLabel/index.d.ts.map +1 -1
  23. package/dist/components/Icon/index.story.d.ts +1 -1
  24. package/dist/components/IconButton/index.d.ts.map +1 -1
  25. package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
  26. package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
  27. package/dist/components/Modal/index.d.ts.map +1 -1
  28. package/dist/components/Modal/index.story.d.ts +1 -0
  29. package/dist/components/Modal/index.story.d.ts.map +1 -1
  30. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  31. package/dist/components/MultiSelect/index.story.d.ts +2 -0
  32. package/dist/components/MultiSelect/index.story.d.ts.map +1 -1
  33. package/dist/components/Radio/index.d.ts.map +1 -1
  34. package/dist/components/SegmentedControl/RadioGroupContext.d.ts +1 -1
  35. package/dist/components/SegmentedControl/RadioGroupContext.d.ts.map +1 -1
  36. package/dist/components/SegmentedControl/index.d.ts.map +1 -1
  37. package/dist/components/Switch/index.d.ts.map +1 -1
  38. package/dist/components/TagItem/index.d.ts.map +1 -1
  39. package/dist/components/TextField/TextField.story.d.ts.map +1 -1
  40. package/dist/components/TextField/index.d.ts.map +1 -1
  41. package/dist/index.cjs.js +1026 -384
  42. package/dist/index.cjs.js.map +1 -1
  43. package/dist/index.esm.js +991 -349
  44. package/dist/index.esm.js.map +1 -1
  45. package/dist/styled.d.ts +4 -4
  46. package/package.json +18 -21
  47. package/src/_lib/compat.ts +8 -0
  48. package/src/components/Button/StyledButton.tsx +66 -0
  49. package/src/components/Button/__snapshots__/index.story.storyshot +312 -592
  50. package/src/components/Button/index.tsx +14 -70
  51. package/src/components/Button/lib/variantToBackground.tsx +19 -0
  52. package/src/components/Button/lib/variantToFont.tsx +19 -0
  53. package/src/components/Checkbox/__snapshots__/index.story.storyshot +209 -40
  54. package/src/components/Checkbox/index.story.tsx +82 -64
  55. package/src/components/Checkbox/index.tsx +47 -17
  56. package/src/components/Clickable/__snapshots__/index.story.storyshot +4 -0
  57. package/src/components/Clickable/index.story.tsx +12 -9
  58. package/src/components/Clickable/index.tsx +1 -0
  59. package/src/components/DropdownSelector/DropdownMenuItem.tsx +6 -3
  60. package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +3 -10
  61. package/src/components/DropdownSelector/ListItem/index.tsx +6 -4
  62. package/src/components/DropdownSelector/MenuItemGroup/index.tsx +1 -1
  63. package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +4 -13
  64. package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +20 -37
  65. package/src/components/DropdownSelector/Popover/index.tsx +5 -8
  66. package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +227 -294
  67. package/src/components/DropdownSelector/index.story.tsx +33 -0
  68. package/src/components/DropdownSelector/index.tsx +63 -20
  69. package/src/components/FieldLabel/index.tsx +77 -12
  70. package/src/components/IconButton/__snapshots__/index.story.storyshot +30 -54
  71. package/src/components/IconButton/index.tsx +51 -26
  72. package/src/components/LoadingSpinner/index.tsx +3 -6
  73. package/src/components/Modal/Dialog/index.tsx +1 -1
  74. package/src/components/Modal/ModalPlumbing.tsx +26 -5
  75. package/src/components/Modal/__snapshots__/index.story.storyshot +2450 -108
  76. package/src/components/Modal/index.story.tsx +27 -0
  77. package/src/components/Modal/index.tsx +19 -4
  78. package/src/components/MultiSelect/__snapshots__/index.story.storyshot +528 -25
  79. package/src/components/MultiSelect/index.story.tsx +60 -0
  80. package/src/components/MultiSelect/index.tsx +82 -22
  81. package/src/components/Radio/__snapshots__/index.story.storyshot +32 -49
  82. package/src/components/Radio/index.tsx +71 -23
  83. package/src/components/SegmentedControl/RadioGroupContext.tsx +1 -1
  84. package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +9 -10
  85. package/src/components/SegmentedControl/index.tsx +36 -16
  86. package/src/components/Switch/__snapshots__/index.story.storyshot +6 -18
  87. package/src/components/Switch/index.tsx +10 -15
  88. package/src/components/TagItem/__snapshots__/index.story.storyshot +39 -158
  89. package/src/components/TagItem/index.tsx +84 -19
  90. package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +55 -91
  91. package/src/components/TextField/TextField.story.tsx +35 -18
  92. package/src/components/TextField/__snapshots__/TextField.story.storyshot +92 -148
  93. package/src/components/TextField/index.tsx +0 -1
  94. package/dist/components/Checkbox/performance.test.d.ts +0 -4
  95. package/dist/components/Checkbox/performance.test.d.ts.map +0 -1
  96. package/dist/components/Checkbox/snapshot.test.d.ts +0 -2
  97. package/dist/components/Checkbox/snapshot.test.d.ts.map +0 -1
  98. package/src/components/Checkbox/__snapshots__/snapshot.test.tsx.snap +0 -763
  99. package/src/components/Checkbox/performance.test.tsx +0 -30
  100. package/src/components/Checkbox/snapshot.test.tsx +0 -66
@@ -65,6 +65,39 @@ export const Basic: Story<DropdownSelectorProps> = (
65
65
 
66
66
  Basic.args = { ...baseProps }
67
67
 
68
+ export const LongNames: Story<DropdownSelectorProps> = (
69
+ props: DropdownSelectorProps
70
+ ) => {
71
+ const [selected, setSelected] = useState('10')
72
+ return (
73
+ <div
74
+ style={{
75
+ width: 288,
76
+ }}
77
+ >
78
+ <DropdownSelector
79
+ {...props}
80
+ onChange={(value) => {
81
+ setSelected(value)
82
+ }}
83
+ value={selected}
84
+ label="label"
85
+ >
86
+ <DropdownMenuItem value={'10'}>
87
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit,
88
+ </DropdownMenuItem>
89
+ <DropdownMenuItem value={'20'}>
90
+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
91
+ </DropdownMenuItem>
92
+ <DropdownMenuItem value={'30'}>
93
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
94
+ nisi ut aliquip ex ea commodo consequat.
95
+ </DropdownMenuItem>
96
+ </DropdownSelector>
97
+ </div>
98
+ )
99
+ }
100
+
68
101
  function PlaygroundDropdownSelector(props: Partial<DropdownSelectorProps>) {
69
102
  const [selected, setSelected] = useState('10')
70
103
  return (
@@ -1,9 +1,8 @@
1
1
  import { ReactNode, useState, useRef } from 'react'
2
- import styled from 'styled-components'
2
+ import styled, { css } from 'styled-components'
3
3
  import { disabledSelector } from '@charcoal-ui/utils'
4
4
  import Icon from '../Icon'
5
5
  import FieldLabel from '../FieldLabel'
6
- import { theme } from '../../styled'
7
6
  import { DropdownPopover } from './DropdownPopover'
8
7
  import { findPreviewRecursive } from './utils/findPreviewRecursive'
9
8
  import MenuList, { MenuListChildren } from './MenuList'
@@ -90,14 +89,13 @@ const DropdownSelectorRoot = styled.div`
90
89
 
91
90
  ${disabledSelector} {
92
91
  cursor: default;
93
- ${theme((o) => o.disabled)}
92
+ opacity: 0.32;
94
93
  }
95
94
  `
96
95
 
97
96
  const DropdownFieldLabel = styled(FieldLabel)`
98
97
  width: 100%;
99
-
100
- ${theme((o) => o.margin.bottom(8))}
98
+ margin-bottom: 8px;
101
99
  `
102
100
 
103
101
  const DropdownButton = styled.button<{ invalid?: boolean }>`
@@ -110,36 +108,81 @@ const DropdownButton = styled.button<{ invalid?: boolean }>`
110
108
  box-sizing: border-box;
111
109
  border: none;
112
110
  cursor: pointer;
111
+ gap: 4px;
113
112
 
114
113
  ${disabledSelector} {
115
114
  cursor: default;
116
115
  }
117
116
 
117
+ padding-right: 8px;
118
+ padding-left: 8px;
119
+ background-color: var(--charcoal-surface3);
120
+ border-radius: 4px;
121
+
122
+ transition: 0.2s box-shadow, 0.2s background-color;
123
+
124
+ &:not(:disabled):not([aria-disabled]),
125
+ &[aria-disabled='false'] {
126
+ &:focus,
127
+ &:active,
128
+ &:focus-visible {
129
+ outline: none;
130
+ box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
131
+ }
132
+ &:hover {
133
+ background-color: var(--charcoal-surface3-hover);
134
+ }
135
+ }
136
+
118
137
  ${({ invalid }) =>
119
- theme((o) => [
120
- o.padding.horizontal(8),
121
- o.outline.default.focus,
122
- o.bg.surface3,
123
- o.borderRadius(4),
124
- invalid === true && o.outline.assertive,
125
- ])}
138
+ invalid === true &&
139
+ css`
140
+ &:not(:disabled):not([aria-disabled]),
141
+ &[aria-disabled='false'] {
142
+ box-shadow: 0 0 0 4px rgba(255, 43, 0, 0.32);
143
+ }
144
+ `}
126
145
  `
127
146
 
128
147
  const DropdownButtonText = styled.span`
129
148
  text-align: left;
130
-
131
- ${theme((o) => [o.typography(14), o.font.text2])}
149
+ font-size: 14px;
150
+ line-height: 22px;
151
+ display: flow-root;
152
+ color: var(--charcoal-text2);
153
+ overflow: hidden;
154
+ text-overflow: ellipsis;
155
+ white-space: nowrap;
132
156
  `
133
157
 
134
158
  const DropdownButtonIcon = styled(Icon)`
135
- ${theme((o) => [o.font.text2])}
159
+ color: var(--charcoal-text2);
136
160
  `
137
161
 
138
162
  const AssertiveText = styled.div<{ invalid?: boolean }>`
163
+ margin-top: 8px;
164
+ font-size: 14px;
165
+ color: var(--charcoal-text2);
166
+ line-height: 22px;
167
+ display: flow-root;
168
+ &::before {
169
+ display: block;
170
+ width: 0;
171
+ height: 0;
172
+ content: '';
173
+ margin-top: -4px;
174
+ }
175
+ &::after {
176
+ display: block;
177
+ width: 0;
178
+ height: 0;
179
+ content: '';
180
+ margin-bottom: -4px;
181
+ }
182
+
139
183
  ${({ invalid }) =>
140
- theme((o) => [
141
- o.typography(14),
142
- o.margin.top(8),
143
- invalid === true ? o.font.assertive : o.font.text2,
144
- ])}
184
+ invalid === true &&
185
+ css`
186
+ color: var(--charcoal-assertive);
187
+ `}
145
188
  `
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react'
2
2
  import styled from 'styled-components'
3
- import { createTheme } from '@charcoal-ui/styled'
4
3
 
5
4
  export interface FieldLabelProps
6
5
  extends React.LabelHTMLAttributes<HTMLLabelElement> {
@@ -41,22 +40,88 @@ const FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(
41
40
 
42
41
  export default FieldLabel
43
42
 
44
- const theme = createTheme(styled)
45
-
46
43
  const Label = styled.label`
47
- ${theme((o) => [o.typography(14).bold, o.font.text1])}
44
+ font-size: 14px;
45
+ line-height: 22px;
46
+ font-weight: bold;
47
+ display: flow-root;
48
+ color: var(--charcoal-text1);
49
+
50
+ &::before {
51
+ display: block;
52
+ width: 0;
53
+ height: 0;
54
+ content: '';
55
+ margin-top: -4px;
56
+ }
57
+ &::after {
58
+ display: block;
59
+ width: 0;
60
+ height: 0;
61
+ content: '';
62
+ margin-bottom: -4px;
63
+ }
48
64
  `
49
65
 
50
66
  const RequiredText = styled.span`
51
- ${theme((o) => [o.typography(14), o.font.text2])}
67
+ font-size: 14px;
68
+ line-height: 22px;
69
+ display: flow-root;
70
+ color: var(--charcoal-text2);
71
+
72
+ &::before {
73
+ display: block;
74
+ width: 0;
75
+ height: 0;
76
+ content: '';
77
+ margin-top: -4px;
78
+ }
79
+ &::after {
80
+ display: block;
81
+ width: 0;
82
+ height: 0;
83
+ content: '';
84
+ margin-bottom: -4px;
85
+ }
52
86
  `
53
87
 
54
88
  const SubLabelClickable = styled.div`
55
- ${theme((o) => [
56
- o.typography(14),
57
- o.font.text3.hover.press,
58
- o.outline.default.focus,
59
- ])}
89
+ font-size: 14px;
90
+ line-height: 22px;
91
+ display: flow-root;
92
+ color: var(--charcoal-text3);
93
+ transition: 0.2s color, 0.2s box-shadow;
94
+
95
+ &::before {
96
+ display: block;
97
+ width: 0;
98
+ height: 0;
99
+ content: '';
100
+ margin-top: -4px;
101
+ }
102
+ &::after {
103
+ display: block;
104
+ width: 0;
105
+ height: 0;
106
+ content: '';
107
+ margin-bottom: -4px;
108
+ }
109
+
110
+ &:not(:disabled):not([aria-disabled]),
111
+ &[aria-disabled='false'] {
112
+ &:hover {
113
+ color: var(--charcoal-text3-hover);
114
+ }
115
+ &:active {
116
+ color: var(--charcoal-text3-press);
117
+ }
118
+ &:active,
119
+ &:focus,
120
+ &:focus-visible {
121
+ outline: none;
122
+ box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
123
+ }
124
+ }
60
125
  `
61
126
 
62
127
  const FieldLabelWrapper = styled.div`
@@ -64,10 +129,10 @@ const FieldLabelWrapper = styled.div`
64
129
  align-items: center;
65
130
 
66
131
  > ${RequiredText} {
67
- ${theme((o) => o.margin.left(4))}
132
+ margin-left: 4px;
68
133
  }
69
134
 
70
135
  > ${SubLabelClickable} {
71
- ${theme((o) => o.margin.left('auto'))}
136
+ margin-left: auto;
72
137
  }
73
138
  `
@@ -17,6 +17,8 @@ exports[`Storyshots IconButton Default M 1`] = `
17
17
  -ms-letter-spacing: inherit;
18
18
  letter-spacing: inherit;
19
19
  word-spacing: inherit;
20
+ -webkit-text-decoration: none;
21
+ text-decoration: none;
20
22
  font: inherit;
21
23
  margin: 0;
22
24
  overflow: visible;
@@ -63,40 +65,29 @@ exports[`Storyshots IconButton Default M 1`] = `
63
65
  transition: 0.2s background-color,0.2s box-shadow;
64
66
  }
65
67
 
66
- .c1:hover:not(:disabled):not([aria-disabled]),
67
- .c1:hover[aria-disabled=false] {
68
- background-color: var(--charcoal-transparent-hover);
68
+ .c1:not(:disabled):not([aria-disabled]):hover,
69
+ .c1[aria-disabled='false']:hover {
70
+ background-color: var( --charcoal-transparent-hover );
69
71
  }
70
72
 
71
- .c1:active:not(:disabled):not([aria-disabled]),
72
- .c1:active[aria-disabled=false] {
73
- background-color: var(--charcoal-transparent-press);
74
- }
75
-
76
- .c1:disabled,
77
- .c1[aria-disabled]:not([aria-disabled=false]) {
78
- opacity: 0.32;
73
+ .c1:not(:disabled):not([aria-disabled]):active,
74
+ .c1[aria-disabled='false']:active {
75
+ background-color: var( --charcoal-transparent-press );
79
76
  }
80
77
 
81
78
  .c1:not(:disabled):not([aria-disabled]):focus,
82
- .c1[aria-disabled=false]:focus,
79
+ .c1[aria-disabled='false']:focus,
83
80
  .c1:not(:disabled):not([aria-disabled]):active,
84
- .c1[aria-disabled=false]:active {
81
+ .c1[aria-disabled='false']:active,
82
+ .c1:not(:disabled):not([aria-disabled]):focus-visible,
83
+ .c1[aria-disabled='false']:focus-visible {
85
84
  outline: none;
86
85
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
87
86
  }
88
87
 
89
- .c1:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
90
- .c1[aria-disabled=false]:focus:not(:focus-visible),
91
- .c1:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
92
- .c1[aria-disabled=false]:active:not(:focus-visible) {
93
- outline: none;
94
- }
95
-
96
- .c1:not(:disabled):not([aria-disabled]):focus-visible,
97
- .c1[aria-disabled=false]:focus-visible {
98
- outline: none;
99
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
88
+ .c1:disabled,
89
+ .c1[aria-disabled]:not([aria-disabled='false']) {
90
+ opacity: 0.32;
100
91
  }
101
92
 
102
93
  <div
@@ -104,10 +95,7 @@ exports[`Storyshots IconButton Default M 1`] = `
104
95
  >
105
96
  <button
106
97
  className="c0 c1"
107
- height={40}
108
- size="M"
109
98
  title="close"
110
- width={40}
111
99
  >
112
100
  <pixiv-icon
113
101
  name="24/Close"
@@ -133,6 +121,8 @@ exports[`Storyshots IconButton Overlay M 1`] = `
133
121
  -ms-letter-spacing: inherit;
134
122
  letter-spacing: inherit;
135
123
  word-spacing: inherit;
124
+ -webkit-text-decoration: none;
125
+ text-decoration: none;
136
126
  font: inherit;
137
127
  margin: 0;
138
128
  overflow: visible;
@@ -179,40 +169,29 @@ exports[`Storyshots IconButton Overlay M 1`] = `
179
169
  transition: 0.2s background-color,0.2s box-shadow;
180
170
  }
181
171
 
182
- .c1:hover:not(:disabled):not([aria-disabled]),
183
- .c1:hover[aria-disabled=false] {
184
- background-color: var(--charcoal-surface4-hover);
172
+ .c1:not(:disabled):not([aria-disabled]):hover,
173
+ .c1[aria-disabled='false']:hover {
174
+ background-color: var( --charcoal-surface4-hover );
185
175
  }
186
176
 
187
- .c1:active:not(:disabled):not([aria-disabled]),
188
- .c1:active[aria-disabled=false] {
189
- background-color: var(--charcoal-surface4-press);
190
- }
191
-
192
- .c1:disabled,
193
- .c1[aria-disabled]:not([aria-disabled=false]) {
194
- opacity: 0.32;
177
+ .c1:not(:disabled):not([aria-disabled]):active,
178
+ .c1[aria-disabled='false']:active {
179
+ background-color: var( --charcoal-surface4-press );
195
180
  }
196
181
 
197
182
  .c1:not(:disabled):not([aria-disabled]):focus,
198
- .c1[aria-disabled=false]:focus,
183
+ .c1[aria-disabled='false']:focus,
199
184
  .c1:not(:disabled):not([aria-disabled]):active,
200
- .c1[aria-disabled=false]:active {
185
+ .c1[aria-disabled='false']:active,
186
+ .c1:not(:disabled):not([aria-disabled]):focus-visible,
187
+ .c1[aria-disabled='false']:focus-visible {
201
188
  outline: none;
202
189
  box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
203
190
  }
204
191
 
205
- .c1:not(:disabled):not([aria-disabled]):focus:not(:focus-visible),
206
- .c1[aria-disabled=false]:focus:not(:focus-visible),
207
- .c1:not(:disabled):not([aria-disabled]):active:not(:focus-visible),
208
- .c1[aria-disabled=false]:active:not(:focus-visible) {
209
- outline: none;
210
- }
211
-
212
- .c1:not(:disabled):not([aria-disabled]):focus-visible,
213
- .c1[aria-disabled=false]:focus-visible {
214
- outline: none;
215
- box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
192
+ .c1:disabled,
193
+ .c1[aria-disabled]:not([aria-disabled='false']) {
194
+ opacity: 0.32;
216
195
  }
217
196
 
218
197
  <div
@@ -220,10 +199,7 @@ exports[`Storyshots IconButton Overlay M 1`] = `
220
199
  >
221
200
  <button
222
201
  className="c0 c1"
223
- height={40}
224
- size="M"
225
202
  title="close"
226
- width={40}
227
203
  >
228
204
  <pixiv-icon
229
205
  name="24/Close"
@@ -1,6 +1,5 @@
1
1
  import { forwardRef } from 'react'
2
2
  import styled from 'styled-components'
3
- import { theme } from '../../styled'
4
3
  import Clickable, { ClickableElement, ClickableProps } from '../Clickable'
5
4
  import type { KnownIconType } from '@charcoal-ui/icons'
6
5
 
@@ -22,7 +21,7 @@ const IconButton = forwardRef<ClickableElement, IconButtonProps>(
22
21
  ) {
23
22
  validateIconSize(size, icon)
24
23
  return (
25
- <StyledIconButton {...rest} ref={ref} variant={variant} size={size}>
24
+ <StyledIconButton {...rest} ref={ref} $size={size} $variant={variant}>
26
25
  <pixiv-icon name={icon} />
27
26
  </StyledIconButton>
28
27
  )
@@ -31,42 +30,68 @@ const IconButton = forwardRef<ClickableElement, IconButtonProps>(
31
30
 
32
31
  export default IconButton
33
32
 
33
+ type StyledIconButtonProps = Required<{
34
+ [key in keyof Pick<
35
+ StyledProps,
36
+ 'size' | 'variant'
37
+ > as `$${key}`]: StyledProps[key]
38
+ }>
39
+
34
40
  const StyledIconButton = styled(Clickable).attrs<
35
- Required<StyledProps>,
41
+ StyledIconButtonProps,
36
42
  ReturnType<typeof styledProps>
37
- >(styledProps)`
43
+ >(styledProps)<StyledIconButtonProps>`
38
44
  user-select: none;
39
45
 
40
- width: ${(p) => p.width}px;
41
- height: ${(p) => p.height}px;
46
+ width: ${(p) => p.$width}px;
47
+ height: ${(p) => p.$height}px;
42
48
  display: flex;
43
49
  align-items: center;
44
50
  justify-content: center;
51
+ color: var(${({ $font }) => `--charcoal-${$font}`});
52
+ background-color: var(${({ $background }) => `--charcoal-${$background}`});
53
+ border-radius: 999999px;
54
+ transition: 0.2s background-color, 0.2s box-shadow;
55
+
56
+ &:not(:disabled):not([aria-disabled]),
57
+ &[aria-disabled='false'] {
58
+ &:hover {
59
+ background-color: var(
60
+ ${({ $background }) => `--charcoal-${$background}-hover`}
61
+ );
62
+ }
63
+ &:active {
64
+ background-color: var(
65
+ ${({ $background }) => `--charcoal-${$background}-press`}
66
+ );
67
+ }
68
+ &:focus,
69
+ &:active,
70
+ &:focus-visible {
71
+ outline: none;
72
+ box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
73
+ }
74
+ }
45
75
 
46
- ${({ font, background }) =>
47
- theme((o) => [
48
- o.font[font],
49
- o.bg[background].hover.press,
50
- o.disabled,
51
- o.borderRadius('oval'),
52
- o.outline.default.focus,
53
- ])}
76
+ &:disabled,
77
+ &[aria-disabled]:not([aria-disabled='false']) {
78
+ opacity: 0.32;
79
+ }
54
80
  `
55
81
 
56
- function styledProps(props: Required<StyledProps>) {
82
+ function styledProps({ $size, $variant }: StyledIconButtonProps) {
57
83
  return {
58
- ...props,
59
- ...variantToProps(props.variant),
60
- ...sizeToProps(props.size),
84
+ ...variantToProps($variant),
85
+ ...sizeToProps($size),
61
86
  }
62
87
  }
63
88
 
64
89
  function variantToProps(variant: Variant) {
65
90
  switch (variant) {
66
91
  case 'Default':
67
- return { font: 'text3', background: 'transparent' } as const
92
+ return { $font: 'text3', $background: 'transparent' } as const
68
93
  case 'Overlay':
69
- return { font: 'text5', background: 'surface4' } as const
94
+ return { $font: 'text5', $background: 'surface4' } as const
70
95
  }
71
96
  }
72
97
 
@@ -74,18 +99,18 @@ function sizeToProps(size: Size) {
74
99
  switch (size) {
75
100
  case 'XS':
76
101
  return {
77
- width: 20,
78
- height: 20,
102
+ $width: 20,
103
+ $height: 20,
79
104
  }
80
105
  case 'S':
81
106
  return {
82
- width: 32,
83
- height: 32,
107
+ $width: 32,
108
+ $height: 32,
84
109
  }
85
110
  case 'M':
86
111
  return {
87
- width: 40,
88
- height: 40,
112
+ $width: 40,
113
+ $height: 40,
89
114
  }
90
115
  }
91
116
  }
@@ -1,6 +1,5 @@
1
1
  import { forwardRef, useImperativeHandle, useRef, memo } from 'react'
2
2
  import styled, { keyframes } from 'styled-components'
3
- import { theme } from '../../styled'
4
3
 
5
4
  export type LoadingSpinnerProps = {
6
5
  readonly size?: number
@@ -43,11 +42,9 @@ const LoadingSpinnerRoot = styled.div.attrs({ role: 'progressbar' })<{
43
42
  width: ${(props) => props.size}px;
44
43
  height: ${(props) => props.size}px;
45
44
  opacity: 0.84;
46
- ${({ transparent }) =>
47
- theme((o) => [
48
- o.font.text4,
49
- transparent ? o.bg.transparent : o.bg.background1,
50
- ])}
45
+ color: var(--charcoal-text4);
46
+ background-color: ${({ transparent }) =>
47
+ `var(--charcoal-${transparent ? 'transparent' : 'background1'})`};
51
48
  `
52
49
 
53
50
  const scaleOut = keyframes`
@@ -57,7 +57,7 @@ const AnimatedStyledDialogDiv = animated(styled.div<{
57
57
  }
58
58
  }}px;
59
59
 
60
- background-color: ${({ theme }) => theme.color.background1};
60
+ background-color: var(--charcoal-surface1);
61
61
  border-radius: 24px;
62
62
 
63
63
  @media ${({ theme }) => maxWidth(theme.breakpoint.screen1)} {
@@ -1,6 +1,5 @@
1
1
  import { BottomSheet, ModalContext, ModalTitle } from '.'
2
2
  import styled, { css } from 'styled-components'
3
- import { theme } from '../../styled'
4
3
  import { useContext } from 'react'
5
4
  import { maxWidth } from '@charcoal-ui/utils'
6
5
 
@@ -30,15 +29,35 @@ const ModalHeaderRoot = styled.div<{
30
29
  `
31
30
 
32
31
  const StyledModalTitle = styled(ModalTitle)`
33
- ${theme((o) => [o.font.text1, o.typography(16).bold])}
32
+ color: var(--charcoal-text1);
33
+ font-size: 16px;
34
+ line-height: 24px;
35
+ font-weight: bold;
36
+ display: flow-root;
37
+
38
+ &::before {
39
+ display: block;
40
+ width: 0;
41
+ height: 0;
42
+ content: '';
43
+ margin-top: -4px;
44
+ }
45
+ &::after {
46
+ display: block;
47
+ width: 0;
48
+ height: 0;
49
+ content: '';
50
+ margin-bottom: -4px;
51
+ }
34
52
  `
35
53
 
36
54
  export const ModalAlign = styled.div`
37
- ${theme((o) => [o.padding.horizontal(16)])}
55
+ padding-left: 16px;
56
+ padding-right: 16px;
38
57
  `
39
58
 
40
59
  export const ModalBody = styled.div`
41
- ${theme((o) => [o.padding.bottom(40)])}
60
+ padding-bottom: 40px;
42
61
  `
43
62
 
44
63
  export const ModalButtons = styled.div`
@@ -46,5 +65,7 @@ export const ModalButtons = styled.div`
46
65
  grid-auto-flow: row;
47
66
  grid-row-gap: 8px;
48
67
 
49
- ${theme((o) => [o.padding.horizontal(16).top(16)])}
68
+ padding-top: 16px;
69
+ padding-left: 16px;
70
+ padding-right: 16px;
50
71
  `