@ds-mo/ui 0.2.3 → 0.3.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/Accordion/Accordion.d.ts +29 -0
- package/dist/components/Accordion/Accordion.d.ts.map +1 -0
- package/dist/components/Accordion/index.d.ts +3 -0
- package/dist/components/Accordion/index.d.ts.map +1 -0
- package/dist/components/Badge/Badge.d.ts +18 -0
- package/dist/components/Badge/Badge.d.ts.map +1 -0
- package/dist/components/Badge/index.d.ts +3 -0
- package/dist/components/Badge/index.d.ts.map +1 -0
- package/dist/components/Banner/Banner.d.ts +16 -0
- package/dist/components/Banner/Banner.d.ts.map +1 -0
- package/dist/components/Banner/index.d.ts +3 -0
- package/dist/components/Banner/index.d.ts.map +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +15 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts.map +1 -0
- package/dist/components/Breadcrumb/index.d.ts +3 -0
- package/dist/components/Breadcrumb/index.d.ts.map +1 -0
- package/dist/components/Button/Button.d.ts +85 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/index.d.ts +3 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +26 -0
- package/dist/components/ButtonGroup/ButtonGroup.d.ts.map +1 -0
- package/dist/components/ButtonGroup/index.d.ts +3 -0
- package/dist/components/ButtonGroup/index.d.ts.map +1 -0
- package/dist/components/Card/Card.d.ts +20 -0
- package/dist/components/Card/Card.d.ts.map +1 -0
- package/dist/components/Card/index.d.ts +3 -0
- package/dist/components/Card/index.d.ts.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +18 -0
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox/index.d.ts +3 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -0
- package/dist/components/Divider/Divider.d.ts +9 -0
- package/dist/components/Divider/Divider.d.ts.map +1 -0
- package/dist/components/Divider/index.d.ts +3 -0
- package/dist/components/Divider/index.d.ts.map +1 -0
- package/dist/components/EmptyState/EmptyState.d.ts +9 -0
- package/dist/components/EmptyState/EmptyState.d.ts.map +1 -0
- package/dist/components/EmptyState/index.d.ts +3 -0
- package/dist/components/EmptyState/index.d.ts.map +1 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.d.ts +18 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/ErrorBoundary/index.d.ts +3 -0
- package/dist/components/ErrorBoundary/index.d.ts.map +1 -0
- package/dist/components/Fade/Fade.d.ts +11 -0
- package/dist/components/Fade/Fade.d.ts.map +1 -0
- package/dist/components/Fade/index.d.ts +3 -0
- package/dist/components/Fade/index.d.ts.map +1 -0
- package/dist/components/Field/Field.d.ts +9 -0
- package/dist/components/Field/Field.d.ts.map +1 -0
- package/dist/components/Field/index.d.ts +3 -0
- package/dist/components/Field/index.d.ts.map +1 -0
- package/dist/components/Header/Header.d.ts +12 -0
- package/dist/components/Header/Header.d.ts.map +1 -0
- package/dist/components/Header/index.d.ts +3 -0
- package/dist/components/Header/index.d.ts.map +1 -0
- package/dist/components/Input/Input.d.ts +27 -0
- package/dist/components/Input/Input.d.ts.map +1 -0
- package/dist/components/Input/index.d.ts +3 -0
- package/dist/components/Input/index.d.ts.map +1 -0
- package/dist/components/LabelWrap/LabelWrap.d.ts +27 -0
- package/dist/components/LabelWrap/LabelWrap.d.ts.map +1 -0
- package/dist/components/LabelWrap/index.d.ts +2 -0
- package/dist/components/LabelWrap/index.d.ts.map +1 -0
- package/dist/components/Loader/Loader.d.ts +33 -0
- package/dist/components/Loader/Loader.d.ts.map +1 -0
- package/dist/components/Loader/index.d.ts +3 -0
- package/dist/components/Loader/index.d.ts.map +1 -0
- package/dist/components/Menu/DestructiveMenuItem.d.ts +12 -0
- package/dist/components/Menu/DestructiveMenuItem.d.ts.map +1 -0
- package/dist/components/Menu/Menu.d.ts +55 -0
- package/dist/components/Menu/Menu.d.ts.map +1 -0
- package/dist/components/Menu/MenuItem.d.ts +33 -0
- package/dist/components/Menu/MenuItem.d.ts.map +1 -0
- package/dist/components/Menu/index.d.ts +7 -0
- package/dist/components/Menu/index.d.ts.map +1 -0
- package/dist/components/Modal/Modal.d.ts +15 -0
- package/dist/components/Modal/Modal.d.ts.map +1 -0
- package/dist/components/Modal/index.d.ts +3 -0
- package/dist/components/Modal/index.d.ts.map +1 -0
- package/dist/components/Pagination/Pagination.d.ts +16 -0
- package/dist/components/Pagination/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination/index.d.ts +3 -0
- package/dist/components/Pagination/index.d.ts.map +1 -0
- package/dist/components/Radio/Radio.d.ts +35 -0
- package/dist/components/Radio/Radio.d.ts.map +1 -0
- package/dist/components/Radio/index.d.ts +3 -0
- package/dist/components/Radio/index.d.ts.map +1 -0
- package/dist/components/Scrollbar/Scrollbar.d.ts +13 -0
- package/dist/components/Scrollbar/Scrollbar.d.ts.map +1 -0
- package/dist/components/Scrollbar/index.d.ts +3 -0
- package/dist/components/Scrollbar/index.d.ts.map +1 -0
- package/dist/components/Select/Select.d.ts +22 -0
- package/dist/components/Select/Select.d.ts.map +1 -0
- package/dist/components/Select/index.d.ts +3 -0
- package/dist/components/Select/index.d.ts.map +1 -0
- package/dist/components/Sidebar/Sidebar.d.ts +15 -0
- package/dist/components/Sidebar/Sidebar.d.ts.map +1 -0
- package/dist/components/Sidebar/SidebarItem.d.ts +14 -0
- package/dist/components/Sidebar/SidebarItem.d.ts.map +1 -0
- package/dist/components/Sidebar/SidebarSection.d.ts +10 -0
- package/dist/components/Sidebar/SidebarSection.d.ts.map +1 -0
- package/dist/components/Sidebar/index.d.ts +7 -0
- package/dist/components/Sidebar/index.d.ts.map +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +17 -0
- package/dist/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/dist/components/Skeleton/index.d.ts +3 -0
- package/dist/components/Skeleton/index.d.ts.map +1 -0
- package/dist/components/Slider/Slider.d.ts +16 -0
- package/dist/components/Slider/Slider.d.ts.map +1 -0
- package/dist/components/Slider/index.d.ts +3 -0
- package/dist/components/Slider/index.d.ts.map +1 -0
- package/dist/components/Surface/Surface.d.ts +59 -0
- package/dist/components/Surface/Surface.d.ts.map +1 -0
- package/dist/components/Surface/index.d.ts +3 -0
- package/dist/components/Surface/index.d.ts.map +1 -0
- package/dist/components/Tab/Tab.d.ts +21 -0
- package/dist/components/Tab/Tab.d.ts.map +1 -0
- package/dist/components/Tab/index.d.ts +3 -0
- package/dist/components/Tab/index.d.ts.map +1 -0
- package/dist/components/TabGroup/TabGroup.d.ts +26 -0
- package/dist/components/TabGroup/TabGroup.d.ts.map +1 -0
- package/dist/components/TabGroup/index.d.ts +3 -0
- package/dist/components/TabGroup/index.d.ts.map +1 -0
- package/dist/components/Table/Table.d.ts +46 -0
- package/dist/components/Table/Table.d.ts.map +1 -0
- package/dist/components/Table/index.d.ts +3 -0
- package/dist/components/Table/index.d.ts.map +1 -0
- package/dist/components/Tag/Tag.d.ts +38 -0
- package/dist/components/Tag/Tag.d.ts.map +1 -0
- package/dist/components/Tag/index.d.ts +3 -0
- package/dist/components/Tag/index.d.ts.map +1 -0
- package/dist/components/Text/Text.d.ts +41 -0
- package/dist/components/Text/Text.d.ts.map +1 -0
- package/dist/components/Text/index.d.ts +3 -0
- package/dist/components/Text/index.d.ts.map +1 -0
- package/dist/components/Toast/Toast.d.ts +33 -0
- package/dist/components/Toast/Toast.d.ts.map +1 -0
- package/dist/components/Toast/index.d.ts +3 -0
- package/dist/components/Toast/index.d.ts.map +1 -0
- package/dist/components/Toggle/Toggle.d.ts +17 -0
- package/dist/components/Toggle/Toggle.d.ts.map +1 -0
- package/dist/components/Toggle/index.d.ts +3 -0
- package/dist/components/Toggle/index.d.ts.map +1 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +35 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts.map +1 -0
- package/dist/components/ToggleButton/index.d.ts +3 -0
- package/dist/components/ToggleButton/index.d.ts.map +1 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.d.ts +24 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.d.ts.map +1 -0
- package/dist/components/ToggleButtonGroup/index.d.ts +3 -0
- package/dist/components/ToggleButtonGroup/index.d.ts.map +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +17 -0
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip/index.d.ts +3 -0
- package/dist/components/Tooltip/index.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +82 -969
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1641 -1165
- package/dist/index.js.map +1 -1
- package/dist/r/badge.json +1 -1
- package/dist/r/banner.json +2 -2
- package/dist/r/loader.json +2 -2
- package/dist/r/menu.json +4 -4
- package/dist/r/select.json +1 -1
- package/dist/r/tab-group.json +1 -1
- package/dist/r/tab.json +1 -1
- package/dist/r/toast.json +1 -1
- package/dist/r/toggle.json +1 -1
- package/dist/types/icons.d.ts +14 -0
- package/dist/types/icons.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/cn.d.ts +5 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/css-tokens.d.ts +11 -0
- package/dist/utils/css-tokens.d.ts.map +1 -0
- package/package.json +17 -12
- package/src/components/Accordion/Accordion.tsx +10 -1
- package/src/components/Badge/Badge.stories.tsx +32 -0
- package/src/components/Badge/Badge.tsx +19 -2
- package/src/components/Banner/Banner.module.css +38 -0
- package/src/components/Banner/Banner.tsx +34 -4
- package/src/components/Button/Button.mdx +143 -0
- package/src/components/Button/Button.stories.tsx +1 -1
- package/src/components/Button/Button.tsx +42 -11
- package/src/components/Checkbox/Checkbox.tsx +6 -3
- package/src/components/Field/Field.tsx +20 -7
- package/src/components/Input/Input.module.css +21 -0
- package/src/components/Input/Input.tsx +62 -21
- package/src/components/Loader/Loader.module.css +17 -0
- package/src/components/Loader/Loader.stories.tsx +9 -0
- package/src/components/Loader/Loader.tsx +42 -20
- package/src/components/Menu/DestructiveMenuItem.tsx +59 -6
- package/src/components/Menu/Menu.tsx +160 -11
- package/src/components/Menu/MenuItem.module.css +2 -0
- package/src/components/Menu/MenuItem.tsx +48 -5
- package/src/components/Modal/Modal.tsx +81 -4
- package/src/components/Radio/Radio.tsx +117 -29
- package/src/components/Scrollbar/Scrollbar.module.css +5 -0
- package/src/components/Scrollbar/Scrollbar.tsx +18 -4
- package/src/components/Select/Select.tsx +139 -9
- package/src/components/Sidebar/Sidebar.module.css +7 -0
- package/src/components/Sidebar/Sidebar.tsx +102 -4
- package/src/components/Slider/Slider.module.css +5 -1
- package/src/components/Slider/Slider.stories.tsx +25 -0
- package/src/components/Slider/Slider.tsx +4 -4
- package/src/components/Tab/Tab.tsx +32 -2
- package/src/components/TabGroup/TabGroup.stories.tsx +46 -15
- package/src/components/TabGroup/TabGroup.tsx +77 -10
- package/src/components/Table/Table.module.css +10 -0
- package/src/components/Table/Table.tsx +58 -29
- package/src/components/Tag/Tag.tsx +5 -2
- package/src/components/Toast/Toast.tsx +44 -8
- package/src/components/Toggle/Toggle.tsx +23 -22
- package/src/components/Tooltip/Tooltip.tsx +42 -6
|
@@ -30,12 +30,50 @@
|
|
|
30
30
|
.bannerBody {
|
|
31
31
|
padding: var(--dimension-space-075);
|
|
32
32
|
min-height: var(--dimension-size-400);
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: flex-start;
|
|
35
|
+
gap: var(--dimension-space-075);
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
.message {
|
|
36
39
|
color: var(--banner-content);
|
|
37
40
|
line-height: var(--typography-lineheight-md);
|
|
38
41
|
display: block;
|
|
42
|
+
flex: 1;
|
|
43
|
+
min-width: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.dismiss {
|
|
47
|
+
background: none;
|
|
48
|
+
border: none;
|
|
49
|
+
margin: 0;
|
|
50
|
+
padding: var(--dimension-space-025);
|
|
51
|
+
color: var(--banner-content);
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
flex-shrink: 0;
|
|
57
|
+
border-radius: var(--dimension-radius-050);
|
|
58
|
+
position: relative;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.dismiss::before {
|
|
62
|
+
content: '';
|
|
63
|
+
position: absolute;
|
|
64
|
+
inset: 0;
|
|
65
|
+
border-radius: inherit;
|
|
66
|
+
background-color: transparent;
|
|
67
|
+
transition: var(--effect-transition-interaction-background-short-2);
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.dismiss:hover::before { background-color: var(--color-interaction-hover); }
|
|
72
|
+
.dismiss:active::before { background-color: var(--color-interaction-pressed); }
|
|
73
|
+
|
|
74
|
+
.dismiss:focus-visible {
|
|
75
|
+
outline: var(--dimension-stroke-width-025) solid var(--color-interaction-focus);
|
|
76
|
+
outline-offset: var(--dimension-stroke-width-015);
|
|
39
77
|
}
|
|
40
78
|
|
|
41
79
|
.floatingPosition {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
+
import { Cross } from '@ds-mo/icons';
|
|
3
4
|
import { Surface } from '@/components/Surface';
|
|
4
5
|
import { Text } from '@/components/Text';
|
|
5
6
|
import { getCssTimeMs } from '@/utils/css-tokens';
|
|
@@ -22,6 +23,8 @@ export interface BannerProps {
|
|
|
22
23
|
className?: string;
|
|
23
24
|
floating?: boolean;
|
|
24
25
|
onDismiss?: () => void;
|
|
26
|
+
/** Accessible label for the dismiss button. Defaults to "Dismiss". */
|
|
27
|
+
dismissLabel?: string;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
const getContentColorVar = (intent: BannerIntent, contrast: BannerContrast): string => {
|
|
@@ -38,6 +41,7 @@ export const Banner: React.FC<BannerProps> = ({
|
|
|
38
41
|
className = '',
|
|
39
42
|
floating = false,
|
|
40
43
|
onDismiss,
|
|
44
|
+
dismissLabel = 'Dismiss',
|
|
41
45
|
}) => {
|
|
42
46
|
const toastDurationMs = getCssTimeMs('--effect-animation-delay-long-2', TOAST_DURATION_FALLBACK_MS);
|
|
43
47
|
const messageColor = getContentColorVar(intent, contrast);
|
|
@@ -45,18 +49,28 @@ export const Banner: React.FC<BannerProps> = ({
|
|
|
45
49
|
const dismissTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
46
50
|
const closeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
47
51
|
|
|
48
|
-
const
|
|
52
|
+
const beginClose = useCallback(() => {
|
|
49
53
|
if (dismissTimerRef.current) clearTimeout(dismissTimerRef.current);
|
|
50
54
|
if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
|
|
51
|
-
dismissTimerRef.current =
|
|
52
|
-
|
|
55
|
+
dismissTimerRef.current = null;
|
|
56
|
+
if (floating) {
|
|
53
57
|
setIsClosing(true);
|
|
54
58
|
closeTimerRef.current = setTimeout(() => {
|
|
55
59
|
closeTimerRef.current = null;
|
|
56
60
|
onDismiss?.();
|
|
57
61
|
}, FADE_OUT_DURATION_MS);
|
|
62
|
+
} else {
|
|
63
|
+
onDismiss?.();
|
|
64
|
+
}
|
|
65
|
+
}, [floating, onDismiss]);
|
|
66
|
+
|
|
67
|
+
const scheduleDismiss = useCallback(() => {
|
|
68
|
+
if (dismissTimerRef.current) clearTimeout(dismissTimerRef.current);
|
|
69
|
+
dismissTimerRef.current = setTimeout(() => {
|
|
70
|
+
dismissTimerRef.current = null;
|
|
71
|
+
beginClose();
|
|
58
72
|
}, toastDurationMs);
|
|
59
|
-
}, [
|
|
73
|
+
}, [beginClose, toastDurationMs]);
|
|
60
74
|
|
|
61
75
|
useEffect(() => {
|
|
62
76
|
if (floating && message) scheduleDismiss();
|
|
@@ -66,10 +80,16 @@ export const Banner: React.FC<BannerProps> = ({
|
|
|
66
80
|
};
|
|
67
81
|
}, [floating, message, scheduleDismiss]);
|
|
68
82
|
|
|
83
|
+
const isAssertive = intent === 'negative';
|
|
84
|
+
const role = isAssertive ? 'alert' : 'status';
|
|
85
|
+
const ariaLive = isAssertive ? undefined : 'polite';
|
|
86
|
+
|
|
69
87
|
const content = (
|
|
70
88
|
<div
|
|
71
89
|
className={`${styles.bannerWrapper} ${className}`.trim()}
|
|
72
90
|
style={{ '--banner-content': messageColor } as React.CSSProperties}
|
|
91
|
+
role={role}
|
|
92
|
+
aria-live={ariaLive}
|
|
73
93
|
>
|
|
74
94
|
<Surface
|
|
75
95
|
elevation={floating ? 'floating' : 'elevated'}
|
|
@@ -87,6 +107,16 @@ export const Banner: React.FC<BannerProps> = ({
|
|
|
87
107
|
<Text variant="text-body-medium" as="span" className={styles.message}>
|
|
88
108
|
{message}
|
|
89
109
|
</Text>
|
|
110
|
+
{onDismiss && (
|
|
111
|
+
<button
|
|
112
|
+
type="button"
|
|
113
|
+
className={styles.dismiss}
|
|
114
|
+
onClick={beginClose}
|
|
115
|
+
aria-label={dismissLabel}
|
|
116
|
+
>
|
|
117
|
+
<Cross size={16} />
|
|
118
|
+
</button>
|
|
119
|
+
)}
|
|
90
120
|
</div>
|
|
91
121
|
</Surface>
|
|
92
122
|
</div>
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Meta, Title, Subtitle, Canvas, Controls, Primary } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as ButtonStories from './Button.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={ButtonStories} />
|
|
5
|
+
|
|
6
|
+
<Title />
|
|
7
|
+
|
|
8
|
+
<Subtitle>
|
|
9
|
+
Buttons trigger actions. They are the primary way users commit to a decision —
|
|
10
|
+
saving a record, opening a dialog, navigating somewhere meaningful.
|
|
11
|
+
</Subtitle>
|
|
12
|
+
|
|
13
|
+
A button should make its purpose obvious from its label, its visual weight, and
|
|
14
|
+
its position on the page. The right button in the right place is invisible — it
|
|
15
|
+
just feels like the next step. The wrong button competes for attention and slows
|
|
16
|
+
the user down.
|
|
17
|
+
|
|
18
|
+
## Playground
|
|
19
|
+
|
|
20
|
+
Use the controls below to explore every prop the component accepts. This is the
|
|
21
|
+
fastest way to understand how `variant`, `intent`, `contrast`, and `elevation`
|
|
22
|
+
combine.
|
|
23
|
+
|
|
24
|
+
<Primary />
|
|
25
|
+
|
|
26
|
+
<Controls />
|
|
27
|
+
|
|
28
|
+
## When to use
|
|
29
|
+
|
|
30
|
+
Reach for a button when the user needs to perform an **action** — submit a form,
|
|
31
|
+
delete a record, open a panel, run a process. If the user is navigating between
|
|
32
|
+
pages or sections, prefer a link instead. Buttons are for verbs; links are for
|
|
33
|
+
nouns.
|
|
34
|
+
|
|
35
|
+
A page should have **one** clearly dominant button. If two actions look equally
|
|
36
|
+
important, the user has to stop and read both before deciding — which is exactly
|
|
37
|
+
the moment of friction good hierarchy avoids.
|
|
38
|
+
|
|
39
|
+
## Variants
|
|
40
|
+
|
|
41
|
+
`primary` is filled and carries the strongest visual weight. Use it for the one
|
|
42
|
+
action you most want the user to take on a given screen.
|
|
43
|
+
|
|
44
|
+
`secondary` is a softer treatment for actions that matter but should not compete
|
|
45
|
+
with the primary action. Use `elevation="none"` to get the ghost treatment for
|
|
46
|
+
tertiary actions like cancel, dismiss, or inline controls.
|
|
47
|
+
|
|
48
|
+
<Canvas of={ButtonStories.Variants} />
|
|
49
|
+
|
|
50
|
+
> **Do** pair one `primary` with one or more `secondary` buttons in a form footer.
|
|
51
|
+
>
|
|
52
|
+
> **Don't** stack two `primary` buttons next to each other — only one action can
|
|
53
|
+
> be the primary one.
|
|
54
|
+
|
|
55
|
+
## Intent
|
|
56
|
+
|
|
57
|
+
Intent communicates the **meaning** of the action through color. Most buttons
|
|
58
|
+
should use `brand` (the default) or `neutral`. Reserve semantic intents for
|
|
59
|
+
moments when the meaning genuinely matches.
|
|
60
|
+
|
|
61
|
+
<Canvas of={ButtonStories.Intents} />
|
|
62
|
+
|
|
63
|
+
- `brand` — the default for primary calls-to-action
|
|
64
|
+
- `neutral` — for actions that should not draw color, like filters or toolbar controls
|
|
65
|
+
- `negative` — for destructive actions (delete, remove, discard)
|
|
66
|
+
- `positive` — for confirmations of a successful state, used sparingly
|
|
67
|
+
- `warning` / `caution` — for actions that need a moment of pause
|
|
68
|
+
- `ai` — reserved for AI-generated or AI-triggering actions
|
|
69
|
+
- `none` — inverted styling for use on colored or dark surfaces
|
|
70
|
+
|
|
71
|
+
> **Don't** use `negative` intent for a cancel button. Cancel is not destructive;
|
|
72
|
+
> it is the absence of an action. Use `secondary` with no intent.
|
|
73
|
+
|
|
74
|
+
## Sizes
|
|
75
|
+
|
|
76
|
+
Pick a size from the surrounding density, not the importance of the action.
|
|
77
|
+
Forms and dialogs use `md`. Compact toolbars and table rows use `sm` or `xs`.
|
|
78
|
+
Hero sections and marketing surfaces can use `lg`.
|
|
79
|
+
|
|
80
|
+
<Canvas of={ButtonStories.Sizes} />
|
|
81
|
+
|
|
82
|
+
## Icons
|
|
83
|
+
|
|
84
|
+
A leading icon can clarify a button's purpose at a glance — but only when the
|
|
85
|
+
icon's meaning is unambiguous. If you have to think about which icon to pick,
|
|
86
|
+
the label alone is doing a better job.
|
|
87
|
+
|
|
88
|
+
<Canvas of={ButtonStories.IconAndLabel} />
|
|
89
|
+
|
|
90
|
+
Icon-only buttons must always have an `aria-label`. Without it, screen readers
|
|
91
|
+
announce nothing meaningful, and keyboard users lose all context.
|
|
92
|
+
|
|
93
|
+
<Canvas of={ButtonStories.IconOnly} />
|
|
94
|
+
|
|
95
|
+
## States
|
|
96
|
+
|
|
97
|
+
Buttons have several states that communicate progress or availability:
|
|
98
|
+
|
|
99
|
+
- `inactive` — the action is not currently available, but may become available
|
|
100
|
+
- `loading` — the action is in flight; prevents double-submission
|
|
101
|
+
- `rounded` — pill-shaped variant for filter chips and compact actions
|
|
102
|
+
|
|
103
|
+
<Canvas of={ButtonStories.Loading} />
|
|
104
|
+
|
|
105
|
+
<Canvas of={ButtonStories.Inactive} />
|
|
106
|
+
|
|
107
|
+
> **Do** use `loading` for any async action that takes longer than ~200ms.
|
|
108
|
+
> Without it, users will click again, often submitting twice.
|
|
109
|
+
|
|
110
|
+
## Full width
|
|
111
|
+
|
|
112
|
+
Use `fullWidth` inside narrow containers like mobile sheets, side panels, or
|
|
113
|
+
form footers where the button should fill the available width. Avoid full-width
|
|
114
|
+
buttons on wide desktop layouts — they read as banner CTAs and feel heavy.
|
|
115
|
+
|
|
116
|
+
<Canvas of={ButtonStories.FullWidth} />
|
|
117
|
+
|
|
118
|
+
## On colored surfaces
|
|
119
|
+
|
|
120
|
+
When a button sits on a colored or dark surface, set the `background` prop so
|
|
121
|
+
the button can adapt its contrast to remain legible. The `BackgroundContext`
|
|
122
|
+
story below demonstrates every variant against every supported surface.
|
|
123
|
+
|
|
124
|
+
<Canvas of={ButtonStories.BackgroundContext} />
|
|
125
|
+
|
|
126
|
+
## Accessibility
|
|
127
|
+
|
|
128
|
+
- Every button must have a discernible name — either visible text in `label` or
|
|
129
|
+
an `aria-label` for icon-only buttons.
|
|
130
|
+
- The `inactive` state is **not** the same as the HTML `disabled` attribute.
|
|
131
|
+
`inactive` keeps the button focusable and announceable; truly disabled buttons
|
|
132
|
+
vanish from the tab order and frustrate users who can't tell why an action
|
|
133
|
+
isn't working.
|
|
134
|
+
- Touch targets meet the 24×24 CSS pixel minimum at all sizes; `xs` is intended
|
|
135
|
+
for dense desktop UIs and should not be used on mobile.
|
|
136
|
+
|
|
137
|
+
## Full reference matrix
|
|
138
|
+
|
|
139
|
+
The matrix below renders every meaningful combination of `variant`, `intent`,
|
|
140
|
+
`contrast`, `elevation`, `size`, and state on a single canvas. Use it as a
|
|
141
|
+
visual regression reference when changing tokens or styles.
|
|
142
|
+
|
|
143
|
+
<Canvas of={ButtonStories.Matrix} />
|
|
@@ -66,7 +66,7 @@ const ELEVATIONS: ButtonElevation[] = ['elevated', 'flat', 'none', 'floating'];
|
|
|
66
66
|
|
|
67
67
|
const col: React.CSSProperties = { display: 'flex', flexDirection: 'column', gap: 8, alignItems: 'flex-start' };
|
|
68
68
|
const row: React.CSSProperties = { display: 'flex', gap: 8, alignItems: 'center' };
|
|
69
|
-
const lbl = (
|
|
69
|
+
const lbl = (_text: string): React.CSSProperties => ({ fontSize: 10, fontFamily: 'monospace', color: '#888', minWidth: 80, flexShrink: 0 });
|
|
70
70
|
const section = (text: string) => (
|
|
71
71
|
<div style={{ fontSize: 11, fontWeight: 600, letterSpacing: '0.05em', textTransform: 'uppercase', color: '#555', marginTop: 8 }}>
|
|
72
72
|
{text}
|
|
@@ -14,13 +14,11 @@ export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
|
14
14
|
export type ButtonContrast = 'strong' | 'bold' | 'medium' | 'faint';
|
|
15
15
|
export type ButtonBackground = 'faint' | 'medium' | 'bold' | 'strong' | 'always-dark';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
interface ButtonBaseProps {
|
|
18
18
|
/** Polymorphic element type. Defaults to 'button'. */
|
|
19
19
|
as?: React.ElementType;
|
|
20
20
|
/** Visual variant. Defaults to 'primary'. */
|
|
21
21
|
variant?: ButtonVariant;
|
|
22
|
-
/** Label text. */
|
|
23
|
-
label?: string;
|
|
24
22
|
/** Leading icon component from @ds-mo/icons. */
|
|
25
23
|
icon?: IconComponent;
|
|
26
24
|
/** Semantic intent. Defaults to 'brand'. */
|
|
@@ -67,12 +65,24 @@ export interface ButtonProps {
|
|
|
67
65
|
inactive?: boolean;
|
|
68
66
|
type?: 'button' | 'submit' | 'reset';
|
|
69
67
|
id?: string;
|
|
70
|
-
'aria-label'?: string;
|
|
71
68
|
href?: string;
|
|
72
69
|
target?: string;
|
|
73
70
|
rel?: string;
|
|
74
71
|
}
|
|
75
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Accessible-name requirement: a Button must expose text via `label`,
|
|
75
|
+
* `aria-label`, or `aria-labelledby`. Icon-only buttons that omit all three
|
|
76
|
+
* fail at the call site (TypeScript), with a runtime warning as a soft
|
|
77
|
+
* fallback for callers that bypass the type system.
|
|
78
|
+
*/
|
|
79
|
+
type ButtonAccessibleNameProps =
|
|
80
|
+
| { label: string; 'aria-label'?: string; 'aria-labelledby'?: string }
|
|
81
|
+
| { label?: string; 'aria-label': string; 'aria-labelledby'?: string }
|
|
82
|
+
| { label?: string; 'aria-label'?: string; 'aria-labelledby': string };
|
|
83
|
+
|
|
84
|
+
export type ButtonProps = ButtonBaseProps & ButtonAccessibleNameProps;
|
|
85
|
+
|
|
76
86
|
const ICON_SIZE_MAP: Record<ButtonSize, number> = { xs: 12, sm: 16, md: 20, lg: 24 };
|
|
77
87
|
|
|
78
88
|
const TEXT_STYLE_MAP: Record<ButtonSize, string> = {
|
|
@@ -84,8 +94,8 @@ const TEXT_STYLE_MAP: Record<ButtonSize, string> = {
|
|
|
84
94
|
|
|
85
95
|
|
|
86
96
|
export const Button = forwardRef<HTMLElement, ButtonProps>(
|
|
87
|
-
(
|
|
88
|
-
{
|
|
97
|
+
(props, ref) => {
|
|
98
|
+
const {
|
|
89
99
|
as,
|
|
90
100
|
variant = 'primary',
|
|
91
101
|
label,
|
|
@@ -109,14 +119,16 @@ export const Button = forwardRef<HTMLElement, ButtonProps>(
|
|
|
109
119
|
type = 'button',
|
|
110
120
|
id,
|
|
111
121
|
'aria-label': ariaLabel,
|
|
122
|
+
'aria-labelledby': ariaLabelledBy,
|
|
112
123
|
href,
|
|
113
124
|
target,
|
|
114
125
|
rel,
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
) => {
|
|
126
|
+
} = props;
|
|
127
|
+
|
|
118
128
|
const Component = (as ?? 'button') as React.ElementType;
|
|
119
129
|
const isButton = !as || as === 'button';
|
|
130
|
+
const isLink = as === 'a';
|
|
131
|
+
const isCustomInteractive = !isButton && !isLink;
|
|
120
132
|
const isInteractive = !inactive && !loading;
|
|
121
133
|
|
|
122
134
|
const hasIcon = !!Icon;
|
|
@@ -153,7 +165,11 @@ export const Button = forwardRef<HTMLElement, ButtonProps>(
|
|
|
153
165
|
className,
|
|
154
166
|
);
|
|
155
167
|
|
|
156
|
-
|
|
168
|
+
if (isIconOnly && !ariaLabel && !ariaLabelledBy) {
|
|
169
|
+
console.warn(
|
|
170
|
+
'[@ds-mo/ui Button] Icon-only Button is missing an accessible name. Provide `label`, `aria-label`, or `aria-labelledby`.'
|
|
171
|
+
);
|
|
172
|
+
}
|
|
157
173
|
|
|
158
174
|
const extraProps: Record<string, unknown> = {};
|
|
159
175
|
if (isButton) {
|
|
@@ -164,6 +180,19 @@ export const Button = forwardRef<HTMLElement, ButtonProps>(
|
|
|
164
180
|
if (target) extraProps.target = target;
|
|
165
181
|
if (rel) extraProps.rel = rel;
|
|
166
182
|
|
|
183
|
+
if (isCustomInteractive) {
|
|
184
|
+
extraProps.role = 'button';
|
|
185
|
+
extraProps.tabIndex = isInteractive ? 0 : -1;
|
|
186
|
+
if (isInteractive) {
|
|
187
|
+
extraProps.onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {
|
|
188
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
189
|
+
e.preventDefault();
|
|
190
|
+
(e.currentTarget as HTMLElement).click();
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
167
196
|
return (
|
|
168
197
|
<Component
|
|
169
198
|
ref={ref}
|
|
@@ -173,7 +202,9 @@ export const Button = forwardRef<HTMLElement, ButtonProps>(
|
|
|
173
202
|
onClick={isInteractive ? onClick : undefined}
|
|
174
203
|
onMouseEnter={isInteractive ? onMouseEnter : undefined}
|
|
175
204
|
onMouseLeave={isInteractive ? onMouseLeave : undefined}
|
|
176
|
-
aria-label={
|
|
205
|
+
aria-label={ariaLabel}
|
|
206
|
+
aria-labelledby={ariaLabelledBy}
|
|
207
|
+
aria-disabled={inactive || loading || undefined}
|
|
177
208
|
aria-busy={loading || undefined}
|
|
178
209
|
{...extraProps}
|
|
179
210
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
1
|
+
import React, { forwardRef, useId } from 'react';
|
|
2
2
|
import { cn } from '@/utils/cn';
|
|
3
3
|
import { Text } from '@/components/Text';
|
|
4
4
|
import type { IconComponent } from '@/types/icons';
|
|
@@ -34,6 +34,7 @@ export const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(
|
|
|
34
34
|
},
|
|
35
35
|
ref
|
|
36
36
|
) => {
|
|
37
|
+
const labelId = useId();
|
|
37
38
|
const handleClick = () => {
|
|
38
39
|
if (!inactive) onChange?.(!checked);
|
|
39
40
|
};
|
|
@@ -46,7 +47,9 @@ export const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(
|
|
|
46
47
|
ref={ref}
|
|
47
48
|
role="checkbox"
|
|
48
49
|
aria-checked={indeterminate ? 'mixed' : checked}
|
|
49
|
-
aria-
|
|
50
|
+
aria-disabled={inactive || undefined}
|
|
51
|
+
aria-labelledby={labelId}
|
|
52
|
+
data-inactive={inactive || undefined}
|
|
50
53
|
tabIndex={inactive ? -1 : 0}
|
|
51
54
|
className={cn(styles.checkbox, inactive && styles.inactive, className)}
|
|
52
55
|
onClick={handleClick}
|
|
@@ -57,7 +60,7 @@ export const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(
|
|
|
57
60
|
{(checked || indeterminate) && <span className={styles.checkmark}>{indeterminate ? '−' : '✓'}</span>}
|
|
58
61
|
</span>
|
|
59
62
|
)}
|
|
60
|
-
<Text variant="text-body-medium" as="span" color="inherit">
|
|
63
|
+
<Text id={labelId} variant="text-body-medium" as="span" color="inherit">
|
|
61
64
|
{label}
|
|
62
65
|
</Text>
|
|
63
66
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
1
|
+
import React, { forwardRef, useId, isValidElement, cloneElement } from 'react';
|
|
2
2
|
import { cn } from '@/utils/cn';
|
|
3
3
|
import { Text } from '@/components/Text';
|
|
4
4
|
import styles from './Field.module.css';
|
|
@@ -11,12 +11,25 @@ export interface FieldProps {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const Field = forwardRef<HTMLDivElement, FieldProps>(
|
|
14
|
-
({ label, children, id, className }, ref) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
({ label, children, id, className }, ref) => {
|
|
15
|
+
const generatedId = useId();
|
|
16
|
+
const fieldId = id ?? generatedId;
|
|
17
|
+
|
|
18
|
+
let content = children;
|
|
19
|
+
if (isValidElement(children)) {
|
|
20
|
+
const childProps = children.props as { id?: string };
|
|
21
|
+
if (childProps.id === undefined) {
|
|
22
|
+
content = cloneElement(children as React.ReactElement<{ id?: string }>, { id: fieldId });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div ref={ref} className={cn(styles.field, className)}>
|
|
28
|
+
<Text variant="text-body-small-emphasis" as="label" htmlFor={fieldId}>{label}</Text>
|
|
29
|
+
{content}
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
20
33
|
);
|
|
21
34
|
|
|
22
35
|
Field.displayName = 'Field';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--dimension-space-050);
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
1
8
|
.wrapper {
|
|
2
9
|
width: 100%;
|
|
3
10
|
height: var(--dimension-size-400);
|
|
@@ -13,6 +20,20 @@
|
|
|
13
20
|
box-shadow: inset 0 0 0 1.25px var(--color-foreground-bold-brand);
|
|
14
21
|
}
|
|
15
22
|
|
|
23
|
+
.wrapperError {
|
|
24
|
+
box-shadow: inset 0 0 0 1.25px var(--color-border-bold-negative);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.wrapperError:focus-within {
|
|
28
|
+
box-shadow: inset 0 0 0 1.25px var(--color-border-bold-negative);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.errorText {
|
|
32
|
+
font-size: var(--typography-fontsize-sm);
|
|
33
|
+
line-height: var(--typography-lineheight-sm);
|
|
34
|
+
color: var(--color-foreground-bold-negative);
|
|
35
|
+
}
|
|
36
|
+
|
|
16
37
|
.row {
|
|
17
38
|
display: flex;
|
|
18
39
|
align-items: center;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
1
|
+
import React, { forwardRef, useEffect, useId } from 'react';
|
|
2
2
|
import { cn } from '@/utils/cn';
|
|
3
3
|
import type { IconComponent } from '@/types/icons';
|
|
4
4
|
import styles from './Input.module.css';
|
|
@@ -20,8 +20,19 @@ export interface InputProps {
|
|
|
20
20
|
/** Icon for clear button (search type). */
|
|
21
21
|
clearIcon?: IconComponent;
|
|
22
22
|
'aria-label'?: string;
|
|
23
|
+
'aria-labelledby'?: string;
|
|
24
|
+
'aria-describedby'?: string;
|
|
25
|
+
/** Marks the input as invalid; sets `aria-invalid` and applies error styling. */
|
|
26
|
+
error?: boolean;
|
|
27
|
+
/** Message rendered below the input when `error` is true; auto-linked via `aria-describedby`. */
|
|
28
|
+
errorMessage?: string;
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
const isDevEnv = (): boolean => {
|
|
32
|
+
const meta = import.meta as { env?: { DEV?: boolean } };
|
|
33
|
+
return Boolean(meta.env?.DEV);
|
|
34
|
+
};
|
|
35
|
+
|
|
25
36
|
export const Input = forwardRef<HTMLDivElement, InputProps>(
|
|
26
37
|
(
|
|
27
38
|
{
|
|
@@ -37,37 +48,67 @@ export const Input = forwardRef<HTMLDivElement, InputProps>(
|
|
|
37
48
|
suffix,
|
|
38
49
|
clearIcon: ClearIcon,
|
|
39
50
|
'aria-label': ariaLabel,
|
|
51
|
+
'aria-labelledby': ariaLabelledBy,
|
|
52
|
+
'aria-describedby': ariaDescribedBy,
|
|
53
|
+
error = false,
|
|
54
|
+
errorMessage,
|
|
40
55
|
},
|
|
41
56
|
ref
|
|
42
57
|
) => {
|
|
58
|
+
const reactId = useId();
|
|
59
|
+
const errorId = `${reactId}-error`;
|
|
43
60
|
const showClear = type === 'search' && value.length > 0 && !inactive;
|
|
61
|
+
const showErrorMessage = error && Boolean(errorMessage);
|
|
62
|
+
|
|
63
|
+
const describedBy =
|
|
64
|
+
[ariaDescribedBy, showErrorMessage ? errorId : undefined].filter(Boolean).join(' ') ||
|
|
65
|
+
undefined;
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!isDevEnv()) return;
|
|
69
|
+
if (!id && !ariaLabel && !ariaLabelledBy) {
|
|
70
|
+
console.warn(
|
|
71
|
+
'[@ds-mo/ui] <Input> is missing an accessible name. Provide one of: `id` (paired with a <label htmlFor>), `aria-label`, or `aria-labelledby`.'
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}, [id, ariaLabel, ariaLabelledBy]);
|
|
44
75
|
|
|
45
76
|
const handleClear = () => {
|
|
46
77
|
onChange({ target: { value: '' } } as React.ChangeEvent<HTMLInputElement>);
|
|
47
78
|
};
|
|
48
79
|
|
|
49
80
|
return (
|
|
50
|
-
<div
|
|
51
|
-
<div className={styles.
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
81
|
+
<div className={styles.container}>
|
|
82
|
+
<div ref={ref} className={cn(styles.wrapper, error && styles.wrapperError, className)}>
|
|
83
|
+
<div className={styles.row}>
|
|
84
|
+
<input
|
|
85
|
+
type={type}
|
|
86
|
+
id={id}
|
|
87
|
+
value={value}
|
|
88
|
+
onChange={onChange}
|
|
89
|
+
onKeyDown={onKeyDown}
|
|
90
|
+
placeholder={placeholder}
|
|
91
|
+
className={styles.input}
|
|
92
|
+
autoFocus={autoFocus}
|
|
93
|
+
disabled={inactive}
|
|
94
|
+
aria-label={ariaLabel}
|
|
95
|
+
aria-labelledby={ariaLabelledBy}
|
|
96
|
+
aria-describedby={describedBy}
|
|
97
|
+
aria-invalid={error || undefined}
|
|
98
|
+
/>
|
|
99
|
+
{showClear && (
|
|
100
|
+
<button type="button" className={styles.clearButton} onClick={handleClear} aria-label="Clear">
|
|
101
|
+
{ClearIcon ? <ClearIcon size={16} /> : <span aria-hidden>×</span>}
|
|
102
|
+
</button>
|
|
103
|
+
)}
|
|
104
|
+
{suffix && <div className={styles.suffix}>{suffix}</div>}
|
|
105
|
+
</div>
|
|
70
106
|
</div>
|
|
107
|
+
{showErrorMessage && (
|
|
108
|
+
<div id={errorId} role="alert" className={styles.errorText}>
|
|
109
|
+
{errorMessage}
|
|
110
|
+
</div>
|
|
111
|
+
)}
|
|
71
112
|
</div>
|
|
72
113
|
);
|
|
73
114
|
}
|
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
animation: spin 0.75s linear infinite;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
.status {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.visuallyHidden {
|
|
12
|
+
position: absolute;
|
|
13
|
+
width: 1px;
|
|
14
|
+
height: 1px;
|
|
15
|
+
padding: 0;
|
|
16
|
+
margin: -1px;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
clip: rect(0, 0, 0, 0);
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
border: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
6
23
|
@keyframes spin {
|
|
7
24
|
from { transform: rotate(0deg); }
|
|
8
25
|
to { transform: rotate(360deg); }
|
|
@@ -14,6 +14,15 @@ type Story = StoryObj<typeof Loader>;
|
|
|
14
14
|
|
|
15
15
|
export const Default: Story = {};
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Standalone usage with an accessible label. Wraps the spinner in a
|
|
19
|
+
* `role="status"` live region and renders a visually-hidden label so
|
|
20
|
+
* screen readers announce the loading state on mount.
|
|
21
|
+
*/
|
|
22
|
+
export const WithLabel: Story = {
|
|
23
|
+
args: { label: 'Loading' },
|
|
24
|
+
};
|
|
25
|
+
|
|
17
26
|
/** Shows how stroke weight scales naturally with size — same as icon strokes. */
|
|
18
27
|
export const Sizes: Story = {
|
|
19
28
|
render: () => (
|