@aleph-alpha/ui-library 7.0.1 → 7.1.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/system/components/UiSlider/step-marks.d.ts +45 -0
- package/dist/system/components/UiSlider/types.d.ts +28 -0
- package/dist/system/components/core/slider/Slider.vue.d.ts +21 -1
- package/dist/system/icons/story-sidebar-icons.json +74 -17
- package/dist/system/lib.js +2026 -1912
- package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
- package/dist/system/story-sidebar-icons.json +74 -17
- package/package.json +15 -10
- package/src/components/UiAccordion/UiAccordion.guidance.md +66 -0
- package/src/components/UiAccordion/UiAccordion.stories.ts +131 -139
- package/src/components/UiAlert/UiAlert.guidance.md +66 -0
- package/src/components/UiAlert/UiAlert.stories.ts +167 -143
- package/src/components/UiAlertDialog/UiAlertDialog.guidance.md +66 -0
- package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +136 -112
- package/src/components/UiAutocomplete/UiAutocomplete.guidance.md +66 -0
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +123 -99
- package/src/components/UiAvatar/UiAvatar.guidance.md +63 -0
- package/src/components/UiAvatar/UiAvatar.stories.ts +340 -0
- package/src/components/UiAvatar/UiAvatarImage.vue +5 -1
- package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +14 -0
- package/src/components/UiBadge/UiBadge.guidance.md +65 -0
- package/src/components/UiBadge/UiBadge.stories.ts +325 -0
- package/src/components/UiBreadcrumb/UiBreadcrumb.guidance.md +67 -0
- package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +165 -141
- package/src/components/UiButton/UiButton.stories.ts +5 -2
- package/src/components/UiButtonGroup/UiButtonGroup.guidance.md +63 -0
- package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +91 -67
- package/src/components/UiCalendar/UiCalendar.guidance.md +65 -0
- package/src/components/UiCalendar/UiCalendar.stories.ts +103 -110
- package/src/components/UiCard/UiCard.guidance.md +65 -0
- package/src/components/UiCard/UiCard.stories.ts +393 -0
- package/src/components/UiCheckbox/UiCheckbox.guidance.md +62 -0
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +18 -56
- package/src/components/UiChip/UiChip.guidance.md +64 -0
- package/src/components/UiChip/UiChip.stories.ts +162 -138
- package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +291 -0
- package/src/components/UiCodeBlock/UiCodeBlock.vue +2 -1
- package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +18 -0
- package/src/components/UiDialog/UiDialog.guidance.md +66 -0
- package/src/components/UiDialog/UiDialog.stories.ts +90 -66
- package/src/components/UiDrawer/UiDrawer.guidance.md +66 -0
- package/src/components/UiDrawer/UiDrawer.stories.ts +186 -162
- package/src/components/UiDropdownMenu/UiDropdownMenu.guidance.md +68 -0
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +127 -86
- package/src/components/UiEmpty/UiEmpty.guidance.md +66 -0
- package/src/components/UiEmpty/UiEmpty.stories.ts +370 -15
- package/src/components/UiFadeMask/UiFadeMask.stories.ts +66 -0
- package/src/components/UiField/UiField.guidance.md +63 -0
- package/src/components/UiField/UiField.stories.ts +90 -113
- package/src/components/UiFileType/UiFileType.stories.ts +254 -0
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +74 -72
- package/src/components/UiIcon/UiIcon.stories.ts +256 -1
- package/src/components/UiInput/UiInput.guidance.md +64 -0
- package/src/components/UiInput/UiInput.stories.ts +132 -80
- package/src/components/UiInputGroup/UiInputGroup.guidance.md +66 -0
- package/src/components/UiInputGroup/UiInputGroup.stories.ts +127 -103
- package/src/components/UiItem/UiItem.guidance.md +66 -0
- package/src/components/UiItem/UiItem.stories.ts +81 -28
- package/src/components/UiKbd/UiKbd.guidance.md +65 -0
- package/src/components/UiKbd/UiKbd.stories.ts +373 -3
- package/src/components/UiLabel/UiLabel.guidance.md +65 -0
- package/src/components/UiLabel/UiLabel.stories.ts +163 -139
- package/src/components/UiListbox/UiListbox.stories.ts +197 -195
- package/src/components/UiNavigationMenu/UiNavigationMenu.guidance.md +66 -0
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +169 -169
- package/src/components/UiPopover/UiPopover.guidance.md +65 -0
- package/src/components/UiPopover/UiPopover.stories.ts +115 -91
- package/src/components/UiProgress/UiProgress.guidance.md +65 -0
- package/src/components/UiProgress/UiProgress.stories.ts +300 -0
- package/src/components/UiRadioGroup/UiRadioGroup.guidance.md +66 -0
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +163 -139
- package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +128 -127
- package/src/components/UiResizable/UiResizable.guidance.md +65 -0
- package/src/components/UiResizable/UiResizable.stories.ts +176 -152
- package/src/components/UiSelect/UiSelect.guidance.md +66 -0
- package/src/components/UiSelect/UiSelect.stories.ts +150 -126
- package/src/components/UiSeparator/UiSeparator.guidance.md +64 -0
- package/src/components/UiSeparator/UiSeparator.stories.ts +350 -0
- package/src/components/UiSheet/UiSheet.guidance.md +66 -0
- package/src/components/UiSheet/UiSheet.stories.ts +194 -170
- package/src/components/UiSkeleton/UiSkeleton.guidance.md +65 -0
- package/src/components/UiSkeleton/UiSkeleton.stories.ts +253 -0
- package/src/components/UiSlider/UiSlider.guidance.md +66 -0
- package/src/components/UiSlider/UiSlider.stories.ts +885 -153
- package/src/components/UiSlider/UiSlider.vue +109 -1
- package/src/components/UiSlider/__tests__/UiSliderValueAndSteps.test.ts +210 -0
- package/src/components/UiSlider/__tests__/step-marks.test.ts +94 -0
- package/src/components/UiSlider/step-marks.ts +96 -0
- package/src/components/UiSlider/types.ts +32 -0
- package/src/components/UiSnackbar/UiSnackbar.guidance.md +66 -0
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +106 -96
- package/src/components/UiSpinner/UiSpinner.guidance.md +65 -0
- package/src/components/UiSpinner/UiSpinner.stories.ts +249 -0
- package/src/components/UiStepper/UiStepper.guidance.md +66 -0
- package/src/components/UiStepper/UiStepper.stories.ts +142 -124
- package/src/components/UiSwitch/UiSwitch.guidance.md +66 -0
- package/src/components/UiSwitch/UiSwitch.stories.ts +170 -146
- package/src/components/UiTable/UiTable.guidance.md +66 -0
- package/src/components/UiTable/UiTable.stories.ts +530 -12
- package/src/components/UiTabs/UiTabs.guidance.md +66 -0
- package/src/components/UiTabs/UiTabs.stories.ts +174 -150
- package/src/components/UiTagsInput/UiTagsInput.stories.ts +154 -152
- package/src/components/UiTextarea/UiTextarea.guidance.md +66 -0
- package/src/components/UiTextarea/UiTextarea.stories.ts +86 -62
- package/src/components/UiToggle/UiToggle.guidance.md +66 -0
- package/src/components/UiToggle/UiToggle.stories.ts +183 -159
- package/src/components/UiToggleGroup/UiToggleGroup.guidance.md +64 -0
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +222 -200
- package/src/components/UiTooltip/UiTooltip.guidance.md +66 -0
- package/src/components/UiTooltip/UiTooltip.stories.ts +90 -66
- package/src/components/core/slider/Slider.vue +16 -6
- package/src/patterns/UiDataTable/UiDataTable.guidance.md +66 -0
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +177 -155
- package/src/patterns/UiDatePicker/UiDatePicker.guidance.md +66 -0
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +136 -112
- package/src/patterns/UiFileUpload/UiFileItem.stories.ts +77 -75
- package/src/patterns/UiFileUpload/UiFileUpload.guidance.md +68 -0
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +169 -145
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +103 -101
- package/src/patterns/UiLayout/UiLayoutContent.stories.ts +14 -13
- package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +65 -65
- package/src/patterns/UiPlaceholder/types.ts +1 -0
- package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +86 -84
- package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
|
@@ -10,6 +10,16 @@ import {
|
|
|
10
10
|
} from './index';
|
|
11
11
|
import { UiButton } from '../UiButton';
|
|
12
12
|
import { UiDialog, UiDialogContent, UiDialogTrigger } from '../UiDialog';
|
|
13
|
+
import {
|
|
14
|
+
accessibilityRequirementsTemplate,
|
|
15
|
+
designNotesStory,
|
|
16
|
+
guidanceLinks,
|
|
17
|
+
guidanceSectionClass,
|
|
18
|
+
parseGuidance,
|
|
19
|
+
} from '../../../.storybook/guidance';
|
|
20
|
+
import guidanceMarkdown from './UiSnackbar.guidance.md?raw';
|
|
21
|
+
|
|
22
|
+
const guidance = parseGuidance(guidanceMarkdown);
|
|
13
23
|
|
|
14
24
|
/**
|
|
15
25
|
* UiSnackbar is a transient toast notification for non-blocking feedback.
|
|
@@ -51,6 +61,9 @@ const meta: Meta<typeof UiSnackbar> = {
|
|
|
51
61
|
visibleToasts: 3,
|
|
52
62
|
containerAriaLabel: 'Notifications',
|
|
53
63
|
},
|
|
64
|
+
parameters: {
|
|
65
|
+
docs: { links: guidanceLinks(guidance) },
|
|
66
|
+
},
|
|
54
67
|
};
|
|
55
68
|
|
|
56
69
|
export default meta;
|
|
@@ -169,6 +182,99 @@ export const Default: Story = {
|
|
|
169
182
|
},
|
|
170
183
|
};
|
|
171
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Usage, guidelines, and do's and don'ts from the Figma documentation.
|
|
187
|
+
*/
|
|
188
|
+
export const DesignNotes: Story = {
|
|
189
|
+
...designNotesStory(guidance),
|
|
190
|
+
tags: ['!autodocs'],
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Accessibility guidance for conveying outcomes without relying on colour,
|
|
195
|
+
* comfortable targets, generous timing, and the accessible theme.
|
|
196
|
+
*/
|
|
197
|
+
export const Accessibility: Story = {
|
|
198
|
+
render: () => ({
|
|
199
|
+
components: { UiSnackbarContent },
|
|
200
|
+
setup() {
|
|
201
|
+
const noop = () => {};
|
|
202
|
+
return { noop };
|
|
203
|
+
},
|
|
204
|
+
template: `
|
|
205
|
+
<section class="${guidanceSectionClass}">
|
|
206
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
207
|
+
Accessibility
|
|
208
|
+
</h2>
|
|
209
|
+
|
|
210
|
+
${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
|
|
211
|
+
|
|
212
|
+
<div class="flex flex-col gap-2">
|
|
213
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
214
|
+
Enable accessibility theme
|
|
215
|
+
</h3>
|
|
216
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
217
|
+
When accessibility is required, enable our accessibility theme.
|
|
218
|
+
This increases contrast and ensures there are no color contrast
|
|
219
|
+
issues.
|
|
220
|
+
</p>
|
|
221
|
+
</div>
|
|
222
|
+
|
|
223
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
224
|
+
<div class="flex flex-col gap-3">
|
|
225
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
226
|
+
Default
|
|
227
|
+
</h3>
|
|
228
|
+
<div class="flex justify-center border border-border-surface-default p-6">
|
|
229
|
+
<div class="flex w-full max-w-sm items-center rounded border border-border-surface-default bg-background-surface-floating p-4 pl-5 shadow-[0px_4px_24px_0px_#00000033]">
|
|
230
|
+
<UiSnackbarContent
|
|
231
|
+
embedded
|
|
232
|
+
title="Title Text"
|
|
233
|
+
description="This is a toast description."
|
|
234
|
+
icon-mode="success"
|
|
235
|
+
action-label="Undo"
|
|
236
|
+
:on-close-toast="noop"
|
|
237
|
+
/>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
243
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
244
|
+
Accessible
|
|
245
|
+
</h3>
|
|
246
|
+
<div class="flex justify-center border border-border-surface-default p-6">
|
|
247
|
+
<div class="flex w-full max-w-sm items-center rounded border border-border-surface-default bg-background-surface-floating p-4 pl-5 shadow-[0px_4px_24px_0px_#00000033]">
|
|
248
|
+
<UiSnackbarContent
|
|
249
|
+
embedded
|
|
250
|
+
title="Title Text"
|
|
251
|
+
description="This is a toast description."
|
|
252
|
+
icon-mode="success"
|
|
253
|
+
action-label="Undo"
|
|
254
|
+
:on-close-toast="noop"
|
|
255
|
+
/>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
</section>
|
|
261
|
+
`,
|
|
262
|
+
}),
|
|
263
|
+
tags: ['!autodocs'],
|
|
264
|
+
parameters: {
|
|
265
|
+
surface: 'primary',
|
|
266
|
+
a11y: { test: 'off' },
|
|
267
|
+
chromatic: {
|
|
268
|
+
disableSnapshot: true,
|
|
269
|
+
},
|
|
270
|
+
docs: {
|
|
271
|
+
canvas: {
|
|
272
|
+
sourceState: 'none',
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
|
|
172
278
|
const withDescriptionTemplateSource = `<script setup lang="ts">
|
|
173
279
|
import { UiSnackbar, showSnackbar, UiButton } from '@aleph-alpha/ui-library'
|
|
174
280
|
</script>
|
|
@@ -1035,102 +1141,6 @@ export const WithDialog: Story = {
|
|
|
1035
1141
|
},
|
|
1036
1142
|
};
|
|
1037
1143
|
|
|
1038
|
-
/**
|
|
1039
|
-
* Accessibility guidance for conveying outcomes without relying on colour,
|
|
1040
|
-
* comfortable targets, generous timing, and the accessible theme.
|
|
1041
|
-
*/
|
|
1042
|
-
export const Accessibility: Story = {
|
|
1043
|
-
render: () => ({
|
|
1044
|
-
components: { UiSnackbarContent },
|
|
1045
|
-
setup() {
|
|
1046
|
-
const noop = () => {};
|
|
1047
|
-
return { noop };
|
|
1048
|
-
},
|
|
1049
|
-
template: `
|
|
1050
|
-
<section class="flex w-full flex-col gap-6 p-4">
|
|
1051
|
-
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
1052
|
-
Accessibility
|
|
1053
|
-
</h2>
|
|
1054
|
-
|
|
1055
|
-
<div class="flex flex-col gap-2">
|
|
1056
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1057
|
-
Requirements
|
|
1058
|
-
</h3>
|
|
1059
|
-
<ul class="body-m-regular flex list-disc flex-col gap-1 pl-6 text-content-on-surface-primary">
|
|
1060
|
-
<li>The outcome is carried by the icon and the words, so colour is never the only signal</li>
|
|
1061
|
-
<li>Success, error and warning are distinguishable by icon shape, not only by hue</li>
|
|
1062
|
-
<li>Text holds contrast against the snackbar's own surface, which sits over arbitrary content</li>
|
|
1063
|
-
<li>The action is a comfortable target and keeps a visible focus state</li>
|
|
1064
|
-
<li>The snackbar stays long enough to be read unhurriedly, and longer when it carries an action</li>
|
|
1065
|
-
<li>Anything important is also available in the interface, since a snackbar is easy to miss</li>
|
|
1066
|
-
</ul>
|
|
1067
|
-
</div>
|
|
1068
|
-
|
|
1069
|
-
<div class="flex flex-col gap-2">
|
|
1070
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1071
|
-
Enable accessibility theme
|
|
1072
|
-
</h3>
|
|
1073
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
1074
|
-
When accessibility is required, enable our accessibility theme.
|
|
1075
|
-
This increases contrast and ensures there are no color contrast
|
|
1076
|
-
issues.
|
|
1077
|
-
</p>
|
|
1078
|
-
</div>
|
|
1079
|
-
|
|
1080
|
-
<div class="grid gap-4 md:grid-cols-2">
|
|
1081
|
-
<div class="flex flex-col gap-3">
|
|
1082
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
1083
|
-
Default
|
|
1084
|
-
</h3>
|
|
1085
|
-
<div class="flex justify-center border border-border-surface-default p-6">
|
|
1086
|
-
<div class="flex w-full max-w-sm items-center rounded border border-border-surface-default bg-background-surface-floating p-4 pl-5 shadow-[0px_4px_24px_0px_#00000033]">
|
|
1087
|
-
<UiSnackbarContent
|
|
1088
|
-
embedded
|
|
1089
|
-
title="Title Text"
|
|
1090
|
-
description="This is a toast description."
|
|
1091
|
-
icon-mode="success"
|
|
1092
|
-
action-label="Undo"
|
|
1093
|
-
:on-close-toast="noop"
|
|
1094
|
-
/>
|
|
1095
|
-
</div>
|
|
1096
|
-
</div>
|
|
1097
|
-
</div>
|
|
1098
|
-
|
|
1099
|
-
<div class="accessible-theme flex flex-col gap-3">
|
|
1100
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
1101
|
-
Accessible
|
|
1102
|
-
</h3>
|
|
1103
|
-
<div class="flex justify-center border border-border-surface-default p-6">
|
|
1104
|
-
<div class="flex w-full max-w-sm items-center rounded border border-border-surface-default bg-background-surface-floating p-4 pl-5 shadow-[0px_4px_24px_0px_#00000033]">
|
|
1105
|
-
<UiSnackbarContent
|
|
1106
|
-
embedded
|
|
1107
|
-
title="Title Text"
|
|
1108
|
-
description="This is a toast description."
|
|
1109
|
-
icon-mode="success"
|
|
1110
|
-
action-label="Undo"
|
|
1111
|
-
:on-close-toast="noop"
|
|
1112
|
-
/>
|
|
1113
|
-
</div>
|
|
1114
|
-
</div>
|
|
1115
|
-
</div>
|
|
1116
|
-
</div>
|
|
1117
|
-
</section>
|
|
1118
|
-
`,
|
|
1119
|
-
}),
|
|
1120
|
-
tags: ['!autodocs'],
|
|
1121
|
-
parameters: {
|
|
1122
|
-
a11y: { test: 'off' },
|
|
1123
|
-
chromatic: {
|
|
1124
|
-
disableSnapshot: true,
|
|
1125
|
-
},
|
|
1126
|
-
docs: {
|
|
1127
|
-
canvas: {
|
|
1128
|
-
sourceState: 'none',
|
|
1129
|
-
},
|
|
1130
|
-
},
|
|
1131
|
-
},
|
|
1132
|
-
};
|
|
1133
|
-
|
|
1134
1144
|
/*
|
|
1135
1145
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
1136
1146
|
* Interaction & accessibility tests (play functions)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
figma: '29207:71656'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<!-- Synced from Figma by scripts/sync-figma-docs.mjs. Edit the copy in Figma: changes made here are overwritten. -->
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
The Spinner component says that something is happening without claiming to know how long it will take. That honesty is its whole value: it does not promise a finish line it cannot see.
|
|
10
|
+
|
|
11
|
+
Use it for short, indeterminate waits — a request in flight, a button working. Progress is right when the proportion is knowable, and Skeleton when the shape of the incoming content is.
|
|
12
|
+
|
|
13
|
+
### Size to its context
|
|
14
|
+
|
|
15
|
+
A spinner belongs to the thing it is waiting on:
|
|
16
|
+
|
|
17
|
+
- Sizes 3 and 4 inside buttons, fields and rows
|
|
18
|
+
- Sizes 5 and 6 for a panel or a section
|
|
19
|
+
- Size 8 where a whole view is loading
|
|
20
|
+
- Placed where the result will appear, not elsewhere on the page
|
|
21
|
+
|
|
22
|
+
### Say what is happening
|
|
23
|
+
|
|
24
|
+
A spinner alone leaves the user guessing:
|
|
25
|
+
|
|
26
|
+
1. Placed where the result will appear
|
|
27
|
+
2. Paired with a word where the wait may be more than a moment
|
|
28
|
+
3. Replacing the thing it is waiting on, rather than sitting beside it
|
|
29
|
+
4. Replaced by the result, or by a message explaining the failure
|
|
30
|
+
|
|
31
|
+
### Consistency
|
|
32
|
+
|
|
33
|
+
Every spinner follows the same rules:
|
|
34
|
+
|
|
35
|
+
- Spinner, in five sizes
|
|
36
|
+
- One size per context: inline, panel, or full view
|
|
37
|
+
- One speed across a product
|
|
38
|
+
- Always replaced by a result or an explanation
|
|
39
|
+
|
|
40
|
+
## Do
|
|
41
|
+
|
|
42
|
+
- Place the spinner where the result will appear
|
|
43
|
+
- Match the size to the context: inline, panel or full view
|
|
44
|
+
- Add a word where the wait may be more than a moment
|
|
45
|
+
- Replace the spinner with the result, or with an error message
|
|
46
|
+
- Keep one rotation speed across a product
|
|
47
|
+
- Use Progress instead when the proportion is knowable
|
|
48
|
+
|
|
49
|
+
## Don't
|
|
50
|
+
|
|
51
|
+
- Spin indefinitely with no timeout or explanation
|
|
52
|
+
- Use a spinner where the proportion is known — use Progress
|
|
53
|
+
- Put a spinner somewhere other than where the result appears
|
|
54
|
+
- Use several spinners for one wait
|
|
55
|
+
- Make the spinner large enough to dominate the view
|
|
56
|
+
- Spin fast enough to be distracting
|
|
57
|
+
|
|
58
|
+
## Accessibility
|
|
59
|
+
|
|
60
|
+
- The spinner is paired with a word wherever the wait may be more than a moment
|
|
61
|
+
- Its rotation is smooth and moderate, so it does not distract or discomfort
|
|
62
|
+
- Its contrast against the surface behind it is enough to be seen at the smallest size used
|
|
63
|
+
- It sits where the result will appear, so its meaning is clear from position
|
|
64
|
+
- A failure ends in a visible message, never in a spinner left turning
|
|
65
|
+
- The spinner is not the only indication that the interface is busy
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { expect, userEvent, within } from 'storybook/test';
|
|
2
3
|
import UiSpinner from './UiSpinner.vue';
|
|
4
|
+
import {
|
|
5
|
+
accessibilityStory,
|
|
6
|
+
designNotesStory,
|
|
7
|
+
guidanceLinks,
|
|
8
|
+
parseGuidance,
|
|
9
|
+
} from '../../../.storybook/guidance';
|
|
10
|
+
import guidanceMarkdown from './UiSpinner.guidance.md?raw';
|
|
11
|
+
|
|
12
|
+
const guidance = parseGuidance(guidanceMarkdown);
|
|
3
13
|
|
|
4
14
|
/**
|
|
5
15
|
* UiSpinner is a circular animated indicator for indeterminate, in-progress operations.
|
|
@@ -23,6 +33,9 @@ const meta: Meta<typeof UiSpinner> = {
|
|
|
23
33
|
args: {
|
|
24
34
|
ariaLabel: 'Loading',
|
|
25
35
|
},
|
|
36
|
+
parameters: {
|
|
37
|
+
docs: { links: guidanceLinks(guidance) },
|
|
38
|
+
},
|
|
26
39
|
};
|
|
27
40
|
|
|
28
41
|
export default meta;
|
|
@@ -55,6 +68,45 @@ export const Default: Story = {
|
|
|
55
68
|
},
|
|
56
69
|
},
|
|
57
70
|
},
|
|
71
|
+
play: async ({ canvasElement, step }) => {
|
|
72
|
+
// Scenario (UiSpinner): with no label passed, the spinner still announces
|
|
73
|
+
// that something is loading.
|
|
74
|
+
const canvas = within(canvasElement);
|
|
75
|
+
|
|
76
|
+
await step(
|
|
77
|
+
'interaction: exposes a status role named "Loading" by default',
|
|
78
|
+
async () => {
|
|
79
|
+
await expect(
|
|
80
|
+
canvas.getByRole('status', { name: 'Loading' }),
|
|
81
|
+
).toBeVisible();
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Usage, guidelines, and do's and don'ts from the Figma documentation.
|
|
89
|
+
*/
|
|
90
|
+
export const DesignNotes: Story = {
|
|
91
|
+
...designNotesStory(guidance),
|
|
92
|
+
tags: ['!autodocs'],
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Accessibility guidance from the Figma documentation, with the component in
|
|
97
|
+
* the default and accessible themes.
|
|
98
|
+
*/
|
|
99
|
+
export const Accessibility: Story = {
|
|
100
|
+
...accessibilityStory({
|
|
101
|
+
requirements: guidance.accessibility,
|
|
102
|
+
example: {
|
|
103
|
+
components: { UiSpinner },
|
|
104
|
+
template: `
|
|
105
|
+
<UiSpinner aria-label="Loading results" />
|
|
106
|
+
`,
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
109
|
+
tags: ['!autodocs'],
|
|
58
110
|
};
|
|
59
111
|
|
|
60
112
|
const sizesTemplateSource = `<script setup lang="ts">
|
|
@@ -146,3 +198,200 @@ export const InlineWithText: Story = {
|
|
|
146
198
|
},
|
|
147
199
|
},
|
|
148
200
|
};
|
|
201
|
+
|
|
202
|
+
const renderTestSpinners = () => ({
|
|
203
|
+
components: { UiSpinner },
|
|
204
|
+
template: `
|
|
205
|
+
<div class="flex flex-col gap-4">
|
|
206
|
+
<UiSpinner />
|
|
207
|
+
<div class="flex items-center gap-2">
|
|
208
|
+
<UiSpinner aria-label="Loading results" />
|
|
209
|
+
<span class="body-s-regular">Fetching the latest results</span>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
`,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* A spinner reports status but takes no input, so it is never a tab stop.
|
|
217
|
+
* Hidden test-only story.
|
|
218
|
+
*/
|
|
219
|
+
export const KeyboardNavigation: Story = {
|
|
220
|
+
name: 'test - Keyboard Navigation',
|
|
221
|
+
tags: ['!dev', '!autodocs'],
|
|
222
|
+
parameters: {
|
|
223
|
+
// Focus moves during the play function.
|
|
224
|
+
chromatic: { disableSnapshot: true },
|
|
225
|
+
docs: {
|
|
226
|
+
description: {
|
|
227
|
+
story:
|
|
228
|
+
'Press `Tab`: focus skips the spinners, which are not interactive.',
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
render: renderTestSpinners,
|
|
233
|
+
play: async ({ canvasElement, step }) => {
|
|
234
|
+
// Scenario (UiSpinner): a keyboard user tabs through a loading page and
|
|
235
|
+
// never lands on a spinner.
|
|
236
|
+
const canvas = within(canvasElement);
|
|
237
|
+
|
|
238
|
+
await step('keyboard: spinners are not tab stops', async () => {
|
|
239
|
+
await userEvent.tab();
|
|
240
|
+
await expect(canvasElement.contains(document.activeElement)).toBe(false);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
await step('keyboard: no spinner carries a tabindex', async () => {
|
|
244
|
+
for (const spinner of canvas.getAllByRole('status')) {
|
|
245
|
+
await expect(spinner).not.toHaveAttribute('tabindex');
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* What assistive technology announces: a status named for the wait, either
|
|
253
|
+
* the default "Loading" or a specific label (WCAG 4.1.3). Hidden test-only
|
|
254
|
+
* story.
|
|
255
|
+
*/
|
|
256
|
+
export const ScreenReader: Story = {
|
|
257
|
+
name: 'test - Screen Reader',
|
|
258
|
+
tags: ['!dev', '!autodocs'],
|
|
259
|
+
parameters: {
|
|
260
|
+
docs: {
|
|
261
|
+
description: {
|
|
262
|
+
story:
|
|
263
|
+
'Verifies the status role and loading announcement for default and labelled spinners.',
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
render: renderTestSpinners,
|
|
268
|
+
play: async ({ canvasElement, step }) => {
|
|
269
|
+
// Scenario (UiSpinner): a screen-reader user hears what is loading, via a
|
|
270
|
+
// status message rather than a silent animation.
|
|
271
|
+
const canvas = within(canvasElement);
|
|
272
|
+
|
|
273
|
+
await step(
|
|
274
|
+
'screen-reader: the spinner is a status message (WCAG 4.1.3)',
|
|
275
|
+
async () => {
|
|
276
|
+
await expect(canvas.getAllByRole('status')).toHaveLength(2);
|
|
277
|
+
},
|
|
278
|
+
);
|
|
279
|
+
|
|
280
|
+
await step(
|
|
281
|
+
'screen-reader: the default spinner announces "Loading"',
|
|
282
|
+
async () => {
|
|
283
|
+
await expect(
|
|
284
|
+
canvas.getByRole('status', { name: 'Loading' }),
|
|
285
|
+
).toHaveAccessibleName('Loading');
|
|
286
|
+
},
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
await step(
|
|
290
|
+
'screen-reader: ariaLabel replaces the default announcement',
|
|
291
|
+
async () => {
|
|
292
|
+
const labelled = canvas.getByRole('status', {
|
|
293
|
+
name: 'Loading results',
|
|
294
|
+
});
|
|
295
|
+
await expect(labelled).toHaveAttribute('aria-label', 'Loading results');
|
|
296
|
+
await expect(labelled).not.toHaveAttribute('aria-hidden', 'true');
|
|
297
|
+
},
|
|
298
|
+
);
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
|
|
304
|
+
* try 400% reflow (WCAG 1.4.10). Hidden test-only story.
|
|
305
|
+
*/
|
|
306
|
+
export const ZoomMagnification: Story = {
|
|
307
|
+
name: 'test - Zoom Magnification',
|
|
308
|
+
tags: ['!dev', '!autodocs'],
|
|
309
|
+
globals: { zoom: '200' },
|
|
310
|
+
parameters: {
|
|
311
|
+
// Zoom changes the layout scale; the accessible-reflow Chromatic mode
|
|
312
|
+
// already covers magnified snapshots, so skip this one.
|
|
313
|
+
chromatic: { disableSnapshot: true },
|
|
314
|
+
docs: {
|
|
315
|
+
description: {
|
|
316
|
+
story:
|
|
317
|
+
'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
render: renderTestSpinners,
|
|
322
|
+
play: async ({ canvasElement, step }) => {
|
|
323
|
+
// Scenario (UiSpinner): at 200% page zoom the spinners and their text stay
|
|
324
|
+
// visible and inside the viewport.
|
|
325
|
+
const canvas = within(canvasElement);
|
|
326
|
+
|
|
327
|
+
await step(
|
|
328
|
+
'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
|
|
329
|
+
async () => {
|
|
330
|
+
await expect(document.documentElement.style.zoom).toBe('200%');
|
|
331
|
+
},
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
await step(
|
|
335
|
+
'zoom: spinners and their text stay visible in the viewport',
|
|
336
|
+
async () => {
|
|
337
|
+
await expect(
|
|
338
|
+
canvas.getByText('Fetching the latest results'),
|
|
339
|
+
).toBeVisible();
|
|
340
|
+
for (const spinner of canvas.getAllByRole('status')) {
|
|
341
|
+
await expect(spinner).toBeVisible();
|
|
342
|
+
const { left, right } = spinner.getBoundingClientRect();
|
|
343
|
+
await expect(left).toBeGreaterThanOrEqual(0);
|
|
344
|
+
await expect(right).toBeLessThanOrEqual(window.innerWidth + 1);
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
);
|
|
348
|
+
},
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
|
|
353
|
+
* toolbar. Hidden test-only story.
|
|
354
|
+
*/
|
|
355
|
+
export const MobileBreakpoint: Story = {
|
|
356
|
+
name: 'test - Mobile Breakpoint',
|
|
357
|
+
tags: ['!dev', '!autodocs'],
|
|
358
|
+
globals: { mediaBreakpoint: 'reflow' },
|
|
359
|
+
parameters: {
|
|
360
|
+
// Reflow snapshots are already covered by the accessible-reflow mode.
|
|
361
|
+
chromatic: { disableSnapshot: true },
|
|
362
|
+
docs: {
|
|
363
|
+
description: {
|
|
364
|
+
story:
|
|
365
|
+
'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
render: renderTestSpinners,
|
|
370
|
+
play: async ({ canvasElement, step }) => {
|
|
371
|
+
// Scenario (UiSpinner): at the 320px mobile breakpoint the spinners and
|
|
372
|
+
// their text fit without sideways scrolling.
|
|
373
|
+
const canvas = within(canvasElement);
|
|
374
|
+
|
|
375
|
+
await step('mobile: spinners render at the 320px breakpoint', async () => {
|
|
376
|
+
for (const spinner of canvas.getAllByRole('status')) {
|
|
377
|
+
await expect(spinner).toBeVisible();
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
await step(
|
|
382
|
+
'mobile: the layout fits without sideways scrolling (WCAG 1.4.10 Reflow)',
|
|
383
|
+
async () => {
|
|
384
|
+
const { scrollWidth, clientWidth } = document.documentElement;
|
|
385
|
+
await expect(scrollWidth).toBeLessThanOrEqual(clientWidth + 1);
|
|
386
|
+
},
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
await step(
|
|
390
|
+
'mobile: spinners add no touch targets of their own',
|
|
391
|
+
async () => {
|
|
392
|
+
// A spinner takes no input, so 2.5.8 doesn't apply to it.
|
|
393
|
+
await expect(canvas.queryAllByRole('button')).toHaveLength(0);
|
|
394
|
+
},
|
|
395
|
+
);
|
|
396
|
+
},
|
|
397
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
figma: '29209:4981'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<!-- Synced from Figma by scripts/sync-figma-docs.mjs. Edit the copy in Figma: changes made here are overwritten. -->
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
The Stepper component lays out a multi-step process and marks where the user has got to. Its value is orientation: it answers how far in am I, and how much is left, before the user commits to starting.
|
|
10
|
+
|
|
11
|
+
Use it when steps are genuinely ordered and the whole path is worth showing. A process of two steps does not need one, and a process the user can do in any order is not a stepper.
|
|
12
|
+
|
|
13
|
+
### Three states, always distinguishable
|
|
14
|
+
|
|
15
|
+
A stepper is read at a glance, so the states have to separate cleanly:
|
|
16
|
+
|
|
17
|
+
- Complete steps are marked as done, not merely as past
|
|
18
|
+
- The active step is the loudest thing in the row
|
|
19
|
+
- Pending steps recede but stay legible
|
|
20
|
+
- The connector between steps shows which part of the path is behind
|
|
21
|
+
|
|
22
|
+
### Label the steps, not the numbers
|
|
23
|
+
|
|
24
|
+
A number tells the user nothing about the step:
|
|
25
|
+
|
|
26
|
+
1. Label names what the step asks for
|
|
27
|
+
2. Description adds what the label cannot, where it helps
|
|
28
|
+
3. Number, icon or status fills the trigger, by type
|
|
29
|
+
4. The same label appears as the heading of the step's own screen
|
|
30
|
+
|
|
31
|
+
### Consistency
|
|
32
|
+
|
|
33
|
+
Every stepper is built from the same parts:
|
|
34
|
+
|
|
35
|
+
- Stepper, horizontal or vertical, at md or sm
|
|
36
|
+
- Trigger type: number, icon or status
|
|
37
|
+
- Trigger variants: pending, active and complete
|
|
38
|
+
- Step label, centred or left aligned, with an optional description
|
|
39
|
+
- Connectors between steps, and up to five steps
|
|
40
|
+
|
|
41
|
+
## Do
|
|
42
|
+
|
|
43
|
+
- Label every step, so the numbers are not doing the work
|
|
44
|
+
- Keep the active step the most prominent thing in the row
|
|
45
|
+
- Mark complete steps as done, distinctly from pending ones
|
|
46
|
+
- Go vertical when the labels do not fit horizontally
|
|
47
|
+
- Keep the step count to a handful, grouping sub-steps inside one step
|
|
48
|
+
- Repeat the step's label as the heading of its own screen
|
|
49
|
+
|
|
50
|
+
## Don't
|
|
51
|
+
|
|
52
|
+
- Use a stepper for two steps
|
|
53
|
+
- Use a stepper where the order does not matter
|
|
54
|
+
- Show numbers with no labels
|
|
55
|
+
- Let the labels truncate rather than switching to vertical
|
|
56
|
+
- Change the number of steps part-way through the process
|
|
57
|
+
- Rely on colour alone to separate complete, active and pending
|
|
58
|
+
|
|
59
|
+
## Accessibility
|
|
60
|
+
|
|
61
|
+
- Complete, active and pending differ in shape and weight, not colour alone
|
|
62
|
+
- The complete state carries a mark, such as a tick, rather than only a fill change
|
|
63
|
+
- Labels stay legible at the sm size and when they wrap
|
|
64
|
+
- The active step is identifiable without relying on the connector's colour
|
|
65
|
+
- Triggers and labels are comfortable targets where steps can be revisited
|
|
66
|
+
- Reading order follows the step order, horizontally or vertically as laid out
|