@usefui/components 1.7.0 → 1.7.2
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +14 -124
- package/dist/index.d.ts +14 -124
- package/dist/index.js +128 -328
- package/dist/index.mjs +127 -320
- package/package.json +3 -3
- package/src/badge/Badge.stories.tsx +32 -0
- package/src/badge/index.tsx +4 -0
- package/src/badge/styles/index.ts +26 -0
- package/src/button/Button.stories.tsx +93 -0
- package/src/button/styles/index.ts +23 -31
- package/src/dialog/index.tsx +17 -20
- package/src/dialog/styles/index.ts +0 -2
- package/src/dropdown/Dropdown.stories.tsx +87 -0
- package/src/dropdown/index.tsx +13 -1
- package/src/dropdown/styles/index.ts +14 -6
- package/src/field/styles/index.ts +7 -21
- package/src/index.ts +0 -3
- package/src/message-bubble/MessageBubble.stories.tsx +27 -7
- package/src/message-bubble/index.tsx +6 -2
- package/src/resizable/Resizable.stories.tsx +19 -22
- package/src/resizable/index.tsx +9 -5
- package/src/resizable/styles/index.ts +5 -2
- package/src/__tests__/Tree.test.tsx +0 -275
- package/src/tree/Tree.stories.tsx +0 -141
- package/src/tree/hooks/tree-node-provider.tsx +0 -50
- package/src/tree/hooks/tree-provider.tsx +0 -75
- package/src/tree/index.tsx +0 -231
- package/src/tree/styles/index.ts +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usefui/components",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Open Source React components library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"react-dom": "^19.2.4",
|
|
32
32
|
"styled-components": "^5.3.11",
|
|
33
33
|
"typescript": "^5.9.3",
|
|
34
|
+
"@usefui/core": "^1.4.0",
|
|
34
35
|
"@usefui/tokens": "^1.7.0",
|
|
35
|
-
"@usefui/hooks": "^1.4.0"
|
|
36
|
-
"@usefui/core": "^1.4.0"
|
|
36
|
+
"@usefui/hooks": "^1.4.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"test": "vitest run --coverage --logHeapUsage",
|
|
@@ -80,3 +80,35 @@ export const Variants: Story = {
|
|
|
80
80
|
);
|
|
81
81
|
},
|
|
82
82
|
};
|
|
83
|
+
export const Emphasis: Story = {
|
|
84
|
+
render: ({ ...args }) => {
|
|
85
|
+
return (
|
|
86
|
+
<div className="flex g-medium-30">
|
|
87
|
+
<Badge emphasis variant="primary">
|
|
88
|
+
Primary
|
|
89
|
+
</Badge>
|
|
90
|
+
<Badge emphasis variant="secondary">
|
|
91
|
+
Secondary
|
|
92
|
+
</Badge>
|
|
93
|
+
<Badge emphasis variant="border">
|
|
94
|
+
Border
|
|
95
|
+
</Badge>
|
|
96
|
+
<Badge emphasis variant="meta">
|
|
97
|
+
Meta
|
|
98
|
+
</Badge>
|
|
99
|
+
<Badge emphasis variant="hint">
|
|
100
|
+
Hint
|
|
101
|
+
</Badge>
|
|
102
|
+
<Badge emphasis variant="success">
|
|
103
|
+
Success
|
|
104
|
+
</Badge>
|
|
105
|
+
<Badge emphasis variant="warning">
|
|
106
|
+
Warning
|
|
107
|
+
</Badge>
|
|
108
|
+
<Badge emphasis variant="danger">
|
|
109
|
+
Error
|
|
110
|
+
</Badge>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
},
|
|
114
|
+
};
|
package/src/badge/index.tsx
CHANGED
|
@@ -21,6 +21,7 @@ export interface IBadgeProperties
|
|
|
21
21
|
IComponentSize,
|
|
22
22
|
React.ComponentProps<"div"> {
|
|
23
23
|
variant?: TComponentVariant | TComponentVariantExtended;
|
|
24
|
+
emphasis?: boolean;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -36,12 +37,14 @@ export interface IBadgeProperties
|
|
|
36
37
|
* @param {TComponentShape} props.shape - The shape of the component. Defaults to `smooth`.
|
|
37
38
|
* @param {ComponentSizeEnum} props.sizing - The size of the component. Defaults to "small".
|
|
38
39
|
* @param {string} props.variant - The style definition used by the component.
|
|
40
|
+
* @param {boolean} props.emphasis - Emphasis change the style definition used by the component.
|
|
39
41
|
* @param {ReactNode} props.children - The content to be rendered inside the Badge.
|
|
40
42
|
* @returns {ReactElement} The Badge component.
|
|
41
43
|
*/
|
|
42
44
|
export const Badge = (props: IBadgeProperties) => {
|
|
43
45
|
const {
|
|
44
46
|
raw = false,
|
|
47
|
+
emphasis = false,
|
|
45
48
|
sizing = ComponentSizeEnum.Small,
|
|
46
49
|
variant = ComponentVariantEnum.Primary,
|
|
47
50
|
shape = ComponentShapeEnum.Smooth,
|
|
@@ -55,6 +58,7 @@ export const Badge = (props: IBadgeProperties) => {
|
|
|
55
58
|
data-variant={variant}
|
|
56
59
|
data-shape={shape}
|
|
57
60
|
data-size={sizing}
|
|
61
|
+
data-emphasis={emphasis}
|
|
58
62
|
{...restProps}
|
|
59
63
|
>
|
|
60
64
|
{children}
|
|
@@ -96,6 +96,28 @@ const BadgeVariantStyles = css`
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
`;
|
|
99
|
+
const BadgeEmphasisVariantStyles = css`
|
|
100
|
+
&[data-variant="danger"] {
|
|
101
|
+
background-color: var(--color-red) !important;
|
|
102
|
+
color: var(--color-mono-white) !important;
|
|
103
|
+
}
|
|
104
|
+
&[data-variant="warning"] {
|
|
105
|
+
background-color: var(--color-orange) !important;
|
|
106
|
+
color: var(--color-mono-dark) !important;
|
|
107
|
+
}
|
|
108
|
+
&[data-variant="success"] {
|
|
109
|
+
background-color: var(--color-green) !important;
|
|
110
|
+
color: var(--color-mono-white) !important;
|
|
111
|
+
}
|
|
112
|
+
&[data-variant="meta"] {
|
|
113
|
+
background-color: var(--color-blue) !important;
|
|
114
|
+
color: var(--color-mono-white) !important;
|
|
115
|
+
}
|
|
116
|
+
&[data-variant="hint"] {
|
|
117
|
+
background-color: var(--color-purple) !important;
|
|
118
|
+
color: var(--color-mono-white) !important;
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
99
121
|
const BadgeShapeStyles = css`
|
|
100
122
|
&[data-shape="square"] {
|
|
101
123
|
border-radius: 0;
|
|
@@ -134,5 +156,9 @@ export const BadgeWrapper = styled.div<any>`
|
|
|
134
156
|
${BadgeVariantStyles}
|
|
135
157
|
${BadgeShapeStyles}
|
|
136
158
|
${BadgeSizeStyles}
|
|
159
|
+
|
|
160
|
+
&[data-emphasis="true"] {
|
|
161
|
+
${BadgeEmphasisVariantStyles}
|
|
162
|
+
}
|
|
137
163
|
}
|
|
138
164
|
`;
|
|
@@ -18,6 +18,29 @@ const meta = {
|
|
|
18
18
|
} satisfies Meta<typeof Button>;
|
|
19
19
|
export default meta;
|
|
20
20
|
|
|
21
|
+
const Icon = (props: React.ComponentProps<"svg">) => {
|
|
22
|
+
return (
|
|
23
|
+
<svg
|
|
24
|
+
focusable="false"
|
|
25
|
+
aria-hidden="true"
|
|
26
|
+
viewBox="0 0 24 24"
|
|
27
|
+
width="24"
|
|
28
|
+
height="24"
|
|
29
|
+
stroke="currentColor"
|
|
30
|
+
fill="currentColor"
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
<path
|
|
34
|
+
fill="none"
|
|
35
|
+
d="M20 6L9.71429 17L4 10.8889"
|
|
36
|
+
strokeWidth="2"
|
|
37
|
+
strokeLinecap="round"
|
|
38
|
+
strokeLinejoin="round"
|
|
39
|
+
/>
|
|
40
|
+
</svg>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
21
44
|
type Story = StoryObj<typeof meta>;
|
|
22
45
|
export const Default: Story = {
|
|
23
46
|
render: ({ ...args }) => <Button {...args} />,
|
|
@@ -77,6 +100,76 @@ export const Variants: Story = {
|
|
|
77
100
|
);
|
|
78
101
|
},
|
|
79
102
|
};
|
|
103
|
+
export const VariantsWithIcon: Story = {
|
|
104
|
+
render: ({ ...args }) => {
|
|
105
|
+
return (
|
|
106
|
+
<Page>
|
|
107
|
+
<Page.Content className="flex flex-column g-medium-30 align-center justify-center">
|
|
108
|
+
<div className="flex align-center justify-center g-medium-30 flex-wrap">
|
|
109
|
+
<Button variant="accent">
|
|
110
|
+
<span className="color-mono-white">With Icon</span>
|
|
111
|
+
<Icon stroke="white" />
|
|
112
|
+
</Button>
|
|
113
|
+
</div>
|
|
114
|
+
<div className="flex align-center justify-center g-medium-30 flex-wrap">
|
|
115
|
+
<Button variant="primary">
|
|
116
|
+
With Icon
|
|
117
|
+
<Icon stroke="var(--color-red)" />
|
|
118
|
+
</Button>
|
|
119
|
+
<Button variant="secondary">
|
|
120
|
+
With Icon
|
|
121
|
+
<Icon />
|
|
122
|
+
</Button>
|
|
123
|
+
<Button variant="tertiary">
|
|
124
|
+
With Icon
|
|
125
|
+
<Icon />
|
|
126
|
+
</Button>
|
|
127
|
+
<Button variant="mono">
|
|
128
|
+
With Icon
|
|
129
|
+
<Icon />
|
|
130
|
+
</Button>
|
|
131
|
+
<Button variant="border">
|
|
132
|
+
With Icon
|
|
133
|
+
<Icon />
|
|
134
|
+
</Button>
|
|
135
|
+
</div>
|
|
136
|
+
<div className="flex align-center justify-center g-medium-30 flex-wrap">
|
|
137
|
+
<Button variant="hint">
|
|
138
|
+
With Icon
|
|
139
|
+
<Icon stroke="white" />
|
|
140
|
+
</Button>
|
|
141
|
+
<Button variant="meta">
|
|
142
|
+
With Icon
|
|
143
|
+
<Icon stroke="white" />
|
|
144
|
+
</Button>
|
|
145
|
+
<Button variant="success">
|
|
146
|
+
With Icon
|
|
147
|
+
<Icon stroke="white" />
|
|
148
|
+
</Button>
|
|
149
|
+
<Button variant="danger">
|
|
150
|
+
With Icon
|
|
151
|
+
<Icon stroke="white" />
|
|
152
|
+
</Button>
|
|
153
|
+
<Button variant="warning">
|
|
154
|
+
With Icon
|
|
155
|
+
<Icon stroke="black" />
|
|
156
|
+
</Button>
|
|
157
|
+
</div>
|
|
158
|
+
<div className="flex align-center justify-center g-medium-30 flex-wrap">
|
|
159
|
+
<Button variant="link">
|
|
160
|
+
With Icon
|
|
161
|
+
<Icon />
|
|
162
|
+
</Button>
|
|
163
|
+
<Button variant="ghost">
|
|
164
|
+
With Icon
|
|
165
|
+
<Icon />
|
|
166
|
+
</Button>
|
|
167
|
+
</div>
|
|
168
|
+
</Page.Content>
|
|
169
|
+
</Page>
|
|
170
|
+
);
|
|
171
|
+
},
|
|
172
|
+
};
|
|
80
173
|
export const Animations: Story = {
|
|
81
174
|
render: ({ ...args }) => {
|
|
82
175
|
return (
|
|
@@ -58,25 +58,6 @@ const ButtonIconStyles = css`
|
|
|
58
58
|
svg {
|
|
59
59
|
width: var(--fontsize-medium-20);
|
|
60
60
|
height: var(--fontsize-medium-20);
|
|
61
|
-
fill: currentColor;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
svg {
|
|
65
|
-
opacity: 0.6;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
&:hover,
|
|
69
|
-
&:focus,
|
|
70
|
-
&:active {
|
|
71
|
-
svg {
|
|
72
|
-
opacity: 1;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&[data-variant="primary"] {
|
|
77
|
-
svg {
|
|
78
|
-
fill: var(--body-color);
|
|
79
|
-
}
|
|
80
61
|
}
|
|
81
62
|
`;
|
|
82
63
|
const ButtonSizeStyles = css`
|
|
@@ -132,7 +113,6 @@ const ButtonBeforeDefaultStyles = css`
|
|
|
132
113
|
`;
|
|
133
114
|
const ButtonVariantsStyles = css`
|
|
134
115
|
&[data-variant="primary"] {
|
|
135
|
-
color: var(--body-color-alpha-80);
|
|
136
116
|
background-color: var(--font-color);
|
|
137
117
|
background: linear-gradient(
|
|
138
118
|
180deg,
|
|
@@ -142,6 +122,11 @@ const ButtonVariantsStyles = css`
|
|
|
142
122
|
background-size: 100% 200%;
|
|
143
123
|
background-position: 0% 50%;
|
|
144
124
|
|
|
125
|
+
color: var(--body-color-alpha-80) !important;
|
|
126
|
+
svg * {
|
|
127
|
+
stroke: var(--body-color-alpha-80) !important;
|
|
128
|
+
}
|
|
129
|
+
|
|
145
130
|
::before {
|
|
146
131
|
${ButtonBeforeDefaultStyles}
|
|
147
132
|
border-color: var(--body-color-alpha-20);
|
|
@@ -160,7 +145,6 @@ const ButtonVariantsStyles = css`
|
|
|
160
145
|
}
|
|
161
146
|
}
|
|
162
147
|
&[data-variant="secondary"] {
|
|
163
|
-
color: var(--font-color-alpha-60);
|
|
164
148
|
border-color: var(--font-color-alpha-10);
|
|
165
149
|
|
|
166
150
|
background-color: var(--body-color);
|
|
@@ -172,6 +156,8 @@ const ButtonVariantsStyles = css`
|
|
|
172
156
|
background-size: 100% 200%;
|
|
173
157
|
background-position: 0% 50%;
|
|
174
158
|
|
|
159
|
+
color: var(--font-color-alpha-60) !important;
|
|
160
|
+
|
|
175
161
|
::before {
|
|
176
162
|
${ButtonBeforeDefaultStyles}
|
|
177
163
|
border-color: var(--font-color-alpha-10);
|
|
@@ -188,8 +174,6 @@ const ButtonVariantsStyles = css`
|
|
|
188
174
|
}
|
|
189
175
|
}
|
|
190
176
|
&[data-variant="tertiary"] {
|
|
191
|
-
color: var(--font-color-alpha-60);
|
|
192
|
-
|
|
193
177
|
background-color: transparent;
|
|
194
178
|
background: linear-gradient(
|
|
195
179
|
-180deg,
|
|
@@ -199,6 +183,8 @@ const ButtonVariantsStyles = css`
|
|
|
199
183
|
background-size: 100% 200%;
|
|
200
184
|
background-position: 0% 10%;
|
|
201
185
|
|
|
186
|
+
color: var(--font-color-alpha-60) !important;
|
|
187
|
+
|
|
202
188
|
&:hover,
|
|
203
189
|
&:focus,
|
|
204
190
|
&:active {
|
|
@@ -214,8 +200,8 @@ const ButtonVariantsStyles = css`
|
|
|
214
200
|
}
|
|
215
201
|
}
|
|
216
202
|
&[data-variant="mono"] {
|
|
217
|
-
color: var(--font-color-alpha-80);
|
|
218
203
|
background-color: var(--contrast-color);
|
|
204
|
+
color: var(--font-color-alpha-80) !important;
|
|
219
205
|
|
|
220
206
|
::before {
|
|
221
207
|
${ButtonBeforeDefaultStyles}
|
|
@@ -234,9 +220,9 @@ const ButtonVariantsStyles = css`
|
|
|
234
220
|
}
|
|
235
221
|
}
|
|
236
222
|
&[data-variant="border"] {
|
|
237
|
-
color: var(--font-color-alpha-60);
|
|
238
223
|
background-color: transparent;
|
|
239
224
|
border-color: var(--font-color-alpha-10);
|
|
225
|
+
color: var(--font-color-alpha-60) !important;
|
|
240
226
|
|
|
241
227
|
&:hover,
|
|
242
228
|
&:focus,
|
|
@@ -278,7 +264,6 @@ const ButtonVariantsStyles = css`
|
|
|
278
264
|
}
|
|
279
265
|
|
|
280
266
|
&[data-variant="meta"] {
|
|
281
|
-
color: var(--alpha-mono-white-80);
|
|
282
267
|
background-color: var(--color-blue);
|
|
283
268
|
background: linear-gradient(
|
|
284
269
|
180deg,
|
|
@@ -288,6 +273,8 @@ const ButtonVariantsStyles = css`
|
|
|
288
273
|
background-size: 100% 200%;
|
|
289
274
|
background-position: 0% 50%;
|
|
290
275
|
|
|
276
|
+
color: var(--alpha-mono-white-80) !important;
|
|
277
|
+
|
|
291
278
|
::before {
|
|
292
279
|
${ButtonBeforeDefaultStyles}
|
|
293
280
|
border-color: var(--tint-blue-30);
|
|
@@ -308,7 +295,6 @@ const ButtonVariantsStyles = css`
|
|
|
308
295
|
}
|
|
309
296
|
}
|
|
310
297
|
&[data-variant="hint"] {
|
|
311
|
-
color: var(--alpha-mono-white-80);
|
|
312
298
|
background-color: var(--color-purple);
|
|
313
299
|
background: linear-gradient(
|
|
314
300
|
180deg,
|
|
@@ -318,6 +304,8 @@ const ButtonVariantsStyles = css`
|
|
|
318
304
|
background-size: 100% 200%;
|
|
319
305
|
background-position: 0% 50%;
|
|
320
306
|
|
|
307
|
+
color: var(--alpha-mono-white-80) !important;
|
|
308
|
+
|
|
321
309
|
::before {
|
|
322
310
|
${ButtonBeforeDefaultStyles}
|
|
323
311
|
border-color: var(--shade-purple-20);
|
|
@@ -334,7 +322,6 @@ const ButtonVariantsStyles = css`
|
|
|
334
322
|
}
|
|
335
323
|
}
|
|
336
324
|
&[data-variant="success"] {
|
|
337
|
-
color: var(--alpha-mono-white-90);
|
|
338
325
|
background-color: var(--shade-green-30);
|
|
339
326
|
background: linear-gradient(
|
|
340
327
|
180deg,
|
|
@@ -344,6 +331,8 @@ const ButtonVariantsStyles = css`
|
|
|
344
331
|
background-size: 100% 200%;
|
|
345
332
|
background-position: 0% 50%;
|
|
346
333
|
|
|
334
|
+
color: var(--alpha-mono-white-80) !important;
|
|
335
|
+
|
|
347
336
|
::before {
|
|
348
337
|
${ButtonBeforeDefaultStyles}
|
|
349
338
|
border-color: var(--shade-green-20);
|
|
@@ -360,7 +349,6 @@ const ButtonVariantsStyles = css`
|
|
|
360
349
|
}
|
|
361
350
|
}
|
|
362
351
|
&[data-variant="danger"] {
|
|
363
|
-
color: var(--alpha-mono-white-80);
|
|
364
352
|
background-color: var(--color-red);
|
|
365
353
|
background: linear-gradient(
|
|
366
354
|
180deg,
|
|
@@ -370,6 +358,8 @@ const ButtonVariantsStyles = css`
|
|
|
370
358
|
background-size: 100% 200%;
|
|
371
359
|
background-position: 0% 50%;
|
|
372
360
|
|
|
361
|
+
color: var(--alpha-mono-white-80) !important;
|
|
362
|
+
|
|
373
363
|
::before {
|
|
374
364
|
${ButtonBeforeDefaultStyles}
|
|
375
365
|
border-color: var(--tint-red-60);
|
|
@@ -389,7 +379,6 @@ const ButtonVariantsStyles = css`
|
|
|
389
379
|
}
|
|
390
380
|
}
|
|
391
381
|
&[data-variant="warning"] {
|
|
392
|
-
color: var(--alpha-mono-dark-80);
|
|
393
382
|
background-color: var(--color-orange);
|
|
394
383
|
background: linear-gradient(
|
|
395
384
|
180deg,
|
|
@@ -399,6 +388,8 @@ const ButtonVariantsStyles = css`
|
|
|
399
388
|
background-size: 100% 200%;
|
|
400
389
|
background-position: 0% 50%;
|
|
401
390
|
|
|
391
|
+
color: var(--alpha-mono-dark-80) !important;
|
|
392
|
+
|
|
402
393
|
::before {
|
|
403
394
|
${ButtonBeforeDefaultStyles}
|
|
404
395
|
border-color: var(--tint-orange-30);
|
|
@@ -476,7 +467,8 @@ export const ButtonWrapper = styled.button`
|
|
|
476
467
|
${ButtonSizeStyles}
|
|
477
468
|
${ButtonShapeStyles}
|
|
478
469
|
${ButtonVariantsStyles}
|
|
479
|
-
|
|
470
|
+
|
|
471
|
+
&[data-rawIcon="false"] {
|
|
480
472
|
${ButtonIconStyles}
|
|
481
473
|
}
|
|
482
474
|
}
|
package/src/dialog/index.tsx
CHANGED
|
@@ -20,7 +20,8 @@ import {
|
|
|
20
20
|
} from "../../../../types";
|
|
21
21
|
|
|
22
22
|
export interface IDialogItemProperties
|
|
23
|
-
extends
|
|
23
|
+
extends
|
|
24
|
+
IComponentStyling,
|
|
24
25
|
IComponentSize,
|
|
25
26
|
IScrollAreaProperties,
|
|
26
27
|
React.ComponentProps<"dialog"> {
|
|
@@ -64,26 +65,22 @@ const Dialog = (props: IDialogItemProperties) => {
|
|
|
64
65
|
}, []);
|
|
65
66
|
|
|
66
67
|
if (lock) useDisabledScroll(Boolean(states.open));
|
|
67
|
-
|
|
68
|
+
if (!states.open) return null;
|
|
68
69
|
return (
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{children}
|
|
84
|
-
</ScrollArea>
|
|
85
|
-
)}
|
|
86
|
-
</>
|
|
70
|
+
<ScrollArea
|
|
71
|
+
as={DialogWrapper}
|
|
72
|
+
role="dialog"
|
|
73
|
+
tabIndex={-1}
|
|
74
|
+
id={String(contentId)}
|
|
75
|
+
open={Boolean(states.open)}
|
|
76
|
+
aria-labelledby={String(triggerId)}
|
|
77
|
+
data-state={applyDataState(Boolean(states.open))}
|
|
78
|
+
data-size={sizing}
|
|
79
|
+
data-raw={Boolean(raw)}
|
|
80
|
+
{...restProps}
|
|
81
|
+
>
|
|
82
|
+
{children}
|
|
83
|
+
</ScrollArea>
|
|
87
84
|
);
|
|
88
85
|
};
|
|
89
86
|
Dialog.displayName = "Dialog";
|
|
@@ -136,3 +136,90 @@ export const RadioItem: Story = {
|
|
|
136
136
|
</DropdownMenu.Root>
|
|
137
137
|
),
|
|
138
138
|
};
|
|
139
|
+
export const Variants: Story = {
|
|
140
|
+
render: ({ ...args }) => (
|
|
141
|
+
<>
|
|
142
|
+
<DropdownMenu.Root>
|
|
143
|
+
<DropdownMenu>
|
|
144
|
+
<DropdownMenu.Trigger variant="secondary">
|
|
145
|
+
Actions
|
|
146
|
+
</DropdownMenu.Trigger>
|
|
147
|
+
|
|
148
|
+
<DropdownMenu.Content className="flex flex-column g-small-60">
|
|
149
|
+
<DropdownMenu.Item
|
|
150
|
+
className="flex justify-between align-center"
|
|
151
|
+
radio
|
|
152
|
+
>
|
|
153
|
+
Cut
|
|
154
|
+
<Badge variant="border">
|
|
155
|
+
<span className="fs-small-50">⌘X</span>
|
|
156
|
+
</Badge>
|
|
157
|
+
</DropdownMenu.Item>
|
|
158
|
+
|
|
159
|
+
<DropdownMenu.Item
|
|
160
|
+
className="flex justify-between align-center"
|
|
161
|
+
radio
|
|
162
|
+
>
|
|
163
|
+
Copy
|
|
164
|
+
<Badge variant="border">
|
|
165
|
+
<span className="fs-small-50">⌘C</span>
|
|
166
|
+
</Badge>
|
|
167
|
+
</DropdownMenu.Item>
|
|
168
|
+
|
|
169
|
+
<DropdownMenu.Item
|
|
170
|
+
className="flex justify-between align-center"
|
|
171
|
+
radio
|
|
172
|
+
>
|
|
173
|
+
Paste
|
|
174
|
+
<Badge variant="border">
|
|
175
|
+
<span className="fs-small-50">⌘V</span>
|
|
176
|
+
</Badge>
|
|
177
|
+
</DropdownMenu.Item>
|
|
178
|
+
</DropdownMenu.Content>
|
|
179
|
+
</DropdownMenu>
|
|
180
|
+
</DropdownMenu.Root>
|
|
181
|
+
<DropdownMenu.Root>
|
|
182
|
+
<DropdownMenu>
|
|
183
|
+
<DropdownMenu.Trigger variant="secondary">
|
|
184
|
+
Actions
|
|
185
|
+
</DropdownMenu.Trigger>
|
|
186
|
+
|
|
187
|
+
<DropdownMenu.Content
|
|
188
|
+
className="flex flex-column g-small-60"
|
|
189
|
+
variant="contrast"
|
|
190
|
+
>
|
|
191
|
+
<DropdownMenu.Item
|
|
192
|
+
className="flex justify-between align-center"
|
|
193
|
+
radio
|
|
194
|
+
>
|
|
195
|
+
Cut
|
|
196
|
+
<Badge variant="border">
|
|
197
|
+
<span className="fs-small-50">⌘X</span>
|
|
198
|
+
</Badge>
|
|
199
|
+
</DropdownMenu.Item>
|
|
200
|
+
|
|
201
|
+
<DropdownMenu.Item
|
|
202
|
+
className="flex justify-between align-center"
|
|
203
|
+
radio
|
|
204
|
+
>
|
|
205
|
+
Copy
|
|
206
|
+
<Badge variant="border">
|
|
207
|
+
<span className="fs-small-50">⌘C</span>
|
|
208
|
+
</Badge>
|
|
209
|
+
</DropdownMenu.Item>
|
|
210
|
+
|
|
211
|
+
<DropdownMenu.Item
|
|
212
|
+
className="flex justify-between align-center"
|
|
213
|
+
radio
|
|
214
|
+
>
|
|
215
|
+
Paste
|
|
216
|
+
<Badge variant="border">
|
|
217
|
+
<span className="fs-small-50">⌘V</span>
|
|
218
|
+
</Badge>
|
|
219
|
+
</DropdownMenu.Item>
|
|
220
|
+
</DropdownMenu.Content>
|
|
221
|
+
</DropdownMenu>
|
|
222
|
+
</DropdownMenu.Root>
|
|
223
|
+
</>
|
|
224
|
+
),
|
|
225
|
+
};
|
package/src/dropdown/index.tsx
CHANGED
|
@@ -11,11 +11,14 @@ import {
|
|
|
11
11
|
IComponentStyling,
|
|
12
12
|
IComponentSize,
|
|
13
13
|
ComponentSideEnum,
|
|
14
|
+
ComponentSizeEnum,
|
|
14
15
|
} from "../../../../types";
|
|
15
16
|
|
|
17
|
+
type DropdownContentVariant = "body" | "contrast";
|
|
16
18
|
export interface IDropdownContentProperties
|
|
17
19
|
extends IComponentStyling, IComponentSize, React.ComponentPropsWithRef<"ul"> {
|
|
18
20
|
defaultOpen?: boolean;
|
|
21
|
+
variant?: DropdownContentVariant;
|
|
19
22
|
}
|
|
20
23
|
export interface IDropdownItemProperties
|
|
21
24
|
extends IComponentStyling, React.ComponentProps<"li"> {
|
|
@@ -133,6 +136,7 @@ DropdownMenuTrigger.displayName = "DropdownMenu.Trigger";
|
|
|
133
136
|
* @param {IDropdownContentProperties} props - The props for the DropdownMenu.Content component.
|
|
134
137
|
* @param {boolean} props.raw - Define whether the component is styled or not.
|
|
135
138
|
* @param {ComponentSizeEnum} props.sizing - The size of the component. Defaults to "medium".
|
|
139
|
+
* @param {DropdownContentVariant} props.variant - The variant of the component. Defaults to "body".
|
|
136
140
|
* @param {boolean} props.defaultOpen - The initial open state of the dropdown menu. Defaults to false.
|
|
137
141
|
* @param {ReactNode} props.children - The content to be rendered inside the dropdown menu.
|
|
138
142
|
* @returns {ReactElement} The DropdownMenu.Content component.
|
|
@@ -141,7 +145,14 @@ const DropdownMenuContent = React.forwardRef<
|
|
|
141
145
|
HTMLUListElement,
|
|
142
146
|
IDropdownContentProperties
|
|
143
147
|
>((props, _) => {
|
|
144
|
-
const {
|
|
148
|
+
const {
|
|
149
|
+
raw,
|
|
150
|
+
sizing = ComponentSizeEnum.Medium,
|
|
151
|
+
variant = "body",
|
|
152
|
+
defaultOpen,
|
|
153
|
+
children,
|
|
154
|
+
...restProps
|
|
155
|
+
} = props;
|
|
145
156
|
const { id, states, methods } = useDropdownMenu();
|
|
146
157
|
const { toggleOpen, setContentProps } = methods;
|
|
147
158
|
|
|
@@ -227,6 +238,7 @@ const DropdownMenuContent = React.forwardRef<
|
|
|
227
238
|
aria-labelledby={id.split("|").at(0)}
|
|
228
239
|
data-state={applyDataState(Boolean(states.open))}
|
|
229
240
|
data-sizing={sizing}
|
|
241
|
+
data-variant={variant}
|
|
230
242
|
data-side={
|
|
231
243
|
hasEnoughHorizontalSpace
|
|
232
244
|
? ComponentSideEnum.Left
|
|
@@ -22,7 +22,15 @@ const ContentWrapperSizes = css`
|
|
|
22
22
|
max-width: var(--large);
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
|
+
const ContentWrapperVariants = css`
|
|
26
|
+
&[data-variant="body"] {
|
|
27
|
+
background-color: var(--body-color);
|
|
28
|
+
}
|
|
25
29
|
|
|
30
|
+
&[data-variant="contrast"] {
|
|
31
|
+
background-color: var(--contrast-color);
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
26
34
|
export const RootWrapper = styled.div`
|
|
27
35
|
position: relative;
|
|
28
36
|
`;
|
|
@@ -49,13 +57,14 @@ export const ContentWrapper = styled.ul<any>`
|
|
|
49
57
|
padding: var(--measurement-medium-30);
|
|
50
58
|
margin: var(--measurement-medium-10) 0;
|
|
51
59
|
|
|
52
|
-
background-color: var(--body-color);
|
|
53
60
|
border: var(--measurement-small-10) solid var(--font-color-alpha-10);
|
|
54
61
|
border-radius: var(--measurement-medium-30);
|
|
55
62
|
|
|
56
63
|
z-index: var(--depth-default-100);
|
|
57
64
|
|
|
58
65
|
${ContentWrapperSizes}
|
|
66
|
+
${ContentWrapperVariants}
|
|
67
|
+
|
|
59
68
|
animation-duration: 0.2s;
|
|
60
69
|
animation-name: slide-in;
|
|
61
70
|
animation-fill-mode: backwards;
|
|
@@ -71,14 +80,13 @@ export const ItemWrapper = styled.li<any>`
|
|
|
71
80
|
&[data-raw="false"] {
|
|
72
81
|
padding: var(--measurement-medium-10) var(--measurement-medium-30);
|
|
73
82
|
border-radius: var(--measurement-medium-20);
|
|
83
|
+
color: var(--font-color);
|
|
74
84
|
|
|
75
|
-
text-align: left;
|
|
76
|
-
font-weight: 600;
|
|
77
85
|
letter-spacing: calc(
|
|
78
86
|
var(--fontsize-small-10) - ((var(--fontsize-small-10) * 1.066))
|
|
79
87
|
);
|
|
80
|
-
font-size:
|
|
81
|
-
|
|
88
|
+
font-size: inherit;
|
|
89
|
+
text-align: left;
|
|
82
90
|
|
|
83
91
|
outline: none;
|
|
84
92
|
cursor: pointer;
|
|
@@ -90,7 +98,7 @@ export const ItemWrapper = styled.li<any>`
|
|
|
90
98
|
&:active,
|
|
91
99
|
&:focus-within,
|
|
92
100
|
&:has(:active) {
|
|
93
|
-
background-color: var(--
|
|
101
|
+
background-color: var(--font-color-alpha-10);
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
|