@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
|
@@ -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 UiSeparator from './UiSeparator.vue';
|
|
4
|
+
import {
|
|
5
|
+
accessibilityStory,
|
|
6
|
+
designNotesStory,
|
|
7
|
+
guidanceLinks,
|
|
8
|
+
parseGuidance,
|
|
9
|
+
} from '../../../.storybook/guidance';
|
|
10
|
+
import guidanceMarkdown from './UiSeparator.guidance.md?raw';
|
|
11
|
+
|
|
12
|
+
const guidance = parseGuidance(guidanceMarkdown);
|
|
3
13
|
|
|
4
14
|
/**
|
|
5
15
|
* UiSeparator is a horizontal or vertical divider that semantically and visually separates groups of content.
|
|
@@ -25,12 +35,18 @@ const meta: Meta<typeof UiSeparator> = {
|
|
|
25
35
|
orientation: 'horizontal',
|
|
26
36
|
decorative: true,
|
|
27
37
|
},
|
|
38
|
+
parameters: {
|
|
39
|
+
docs: { links: guidanceLinks(guidance) },
|
|
40
|
+
},
|
|
28
41
|
};
|
|
29
42
|
|
|
30
43
|
export default meta;
|
|
31
44
|
|
|
32
45
|
type Story = StoryObj<typeof UiSeparator>;
|
|
33
46
|
|
|
47
|
+
const getSeparators = (canvasElement: HTMLElement) =>
|
|
48
|
+
canvasElement.querySelectorAll<HTMLElement>('[data-slot="separator"]');
|
|
49
|
+
|
|
34
50
|
const defaultTemplateSource = `<script setup lang="ts">
|
|
35
51
|
import { UiSeparator } from '@aleph-alpha/ui-library'
|
|
36
52
|
</script>
|
|
@@ -77,6 +93,53 @@ export const Default: Story = {
|
|
|
77
93
|
},
|
|
78
94
|
},
|
|
79
95
|
},
|
|
96
|
+
play: async ({ canvasElement, step }) => {
|
|
97
|
+
// Scenario (UiSeparator): by default the line is decorative, so the
|
|
98
|
+
// headings carry the grouping and the line is skipped.
|
|
99
|
+
const canvas = within(canvasElement);
|
|
100
|
+
const [separator] = getSeparators(canvasElement);
|
|
101
|
+
|
|
102
|
+
await step(
|
|
103
|
+
'interaction: a default separator is decorative (role="none")',
|
|
104
|
+
async () => {
|
|
105
|
+
await expect(separator).toHaveAttribute('role', 'none');
|
|
106
|
+
await expect(canvas.queryByRole('separator')).not.toBeInTheDocument();
|
|
107
|
+
},
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
await step('interaction: renders horizontally by default', async () => {
|
|
111
|
+
await expect(separator).toHaveAttribute('data-orientation', 'horizontal');
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Usage, guidelines, and do's and don'ts from the Figma documentation.
|
|
118
|
+
*/
|
|
119
|
+
export const DesignNotes: Story = {
|
|
120
|
+
...designNotesStory(guidance),
|
|
121
|
+
tags: ['!autodocs'],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Accessibility guidance from the Figma documentation, with the component in
|
|
126
|
+
* the default and accessible themes.
|
|
127
|
+
*/
|
|
128
|
+
export const Accessibility: Story = {
|
|
129
|
+
...accessibilityStory({
|
|
130
|
+
requirements: guidance.accessibility,
|
|
131
|
+
example: {
|
|
132
|
+
components: { UiSeparator },
|
|
133
|
+
template: `
|
|
134
|
+
<div class="w-40">
|
|
135
|
+
<p class="body-s-regular">Account</p>
|
|
136
|
+
<UiSeparator class="my-2" />
|
|
137
|
+
<p class="body-s-regular">Billing</p>
|
|
138
|
+
</div>
|
|
139
|
+
`,
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
tags: ['!autodocs'],
|
|
80
143
|
};
|
|
81
144
|
|
|
82
145
|
const verticalTemplateSource = `<script setup lang="ts">
|
|
@@ -121,6 +184,64 @@ export const Vertical: Story = {
|
|
|
121
184
|
},
|
|
122
185
|
},
|
|
123
186
|
},
|
|
187
|
+
play: async ({ canvasElement, step }) => {
|
|
188
|
+
// Scenario (UiSeparator): vertical dividers sit between inline links and
|
|
189
|
+
// stay decorative, so the items are read as a plain list of words.
|
|
190
|
+
await step('interaction: each divider renders vertically', async () => {
|
|
191
|
+
const separators = getSeparators(canvasElement);
|
|
192
|
+
await expect(separators).toHaveLength(3);
|
|
193
|
+
for (const separator of separators) {
|
|
194
|
+
await expect(separator).toHaveAttribute('data-orientation', 'vertical');
|
|
195
|
+
await expect(separator).toHaveAttribute('role', 'none');
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const semanticTemplateSource = `<script setup lang="ts">
|
|
202
|
+
import { UiSeparator } from '@aleph-alpha/ui-library'
|
|
203
|
+
</script>
|
|
204
|
+
|
|
205
|
+
<template>
|
|
206
|
+
<div class="flex flex-col gap-y-4">
|
|
207
|
+
<p class="body-s-regular">Signed in as jane@example.com</p>
|
|
208
|
+
<UiSeparator :decorative="false" />
|
|
209
|
+
<p class="body-s-regular">Workspace settings</p>
|
|
210
|
+
</div>
|
|
211
|
+
</template>`;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Semantic separator (`:decorative="false"`) for a boundary that assistive
|
|
215
|
+
* technology should announce, such as between groups in a menu.
|
|
216
|
+
*/
|
|
217
|
+
export const Semantic: Story = {
|
|
218
|
+
render: () => ({
|
|
219
|
+
components: { UiSeparator },
|
|
220
|
+
template: `<div class="flex flex-col gap-y-4">
|
|
221
|
+
<p class="body-s-regular">Signed in as jane@example.com</p>
|
|
222
|
+
<UiSeparator :decorative="false" />
|
|
223
|
+
<p class="body-s-regular">Workspace settings</p>
|
|
224
|
+
</div>`,
|
|
225
|
+
}),
|
|
226
|
+
parameters: {
|
|
227
|
+
docs: {
|
|
228
|
+
source: {
|
|
229
|
+
code: semanticTemplateSource,
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
play: async ({ canvasElement, step }) => {
|
|
234
|
+
// Scenario (UiSeparator): a non-decorative separator is exposed as a
|
|
235
|
+
// real boundary between the two groups.
|
|
236
|
+
const canvas = within(canvasElement);
|
|
237
|
+
|
|
238
|
+
await step(
|
|
239
|
+
'interaction: a non-decorative separator has the separator role',
|
|
240
|
+
async () => {
|
|
241
|
+
await expect(canvas.getByRole('separator')).toBeInTheDocument();
|
|
242
|
+
},
|
|
243
|
+
);
|
|
244
|
+
},
|
|
124
245
|
};
|
|
125
246
|
|
|
126
247
|
const cardTemplateSource = `<script setup lang="ts">
|
|
@@ -180,3 +301,232 @@ export const InCard: Story = {
|
|
|
180
301
|
},
|
|
181
302
|
},
|
|
182
303
|
};
|
|
304
|
+
|
|
305
|
+
const renderTestSeparators = () => ({
|
|
306
|
+
components: { UiSeparator },
|
|
307
|
+
template: `
|
|
308
|
+
<div class="flex w-full max-w-sm flex-col gap-y-4">
|
|
309
|
+
<p class="body-s-regular">Account</p>
|
|
310
|
+
<UiSeparator />
|
|
311
|
+
<p class="body-s-regular">Billing</p>
|
|
312
|
+
<UiSeparator :decorative="false" />
|
|
313
|
+
<div class="flex h-5 items-center gap-x-4 body-s-regular">
|
|
314
|
+
<span>Docs</span>
|
|
315
|
+
<UiSeparator orientation="vertical" />
|
|
316
|
+
<span>Source</span>
|
|
317
|
+
<UiSeparator orientation="vertical" :decorative="false" />
|
|
318
|
+
<span>Support</span>
|
|
319
|
+
</div>
|
|
320
|
+
</div>
|
|
321
|
+
`,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Separators are never interactive, so there is nothing to focus: the
|
|
326
|
+
* keyboard check asserts they stay out of the tab order. Hidden test-only
|
|
327
|
+
* story.
|
|
328
|
+
*/
|
|
329
|
+
export const KeyboardNavigation: Story = {
|
|
330
|
+
name: 'test - Keyboard Navigation',
|
|
331
|
+
tags: ['!dev', '!autodocs'],
|
|
332
|
+
parameters: {
|
|
333
|
+
// Focus moves during the play function.
|
|
334
|
+
chromatic: { disableSnapshot: true },
|
|
335
|
+
docs: {
|
|
336
|
+
description: {
|
|
337
|
+
story:
|
|
338
|
+
'Press `Tab`: focus skips every separator, decorative or semantic.',
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
render: renderTestSeparators,
|
|
343
|
+
play: async ({ canvasElement, step }) => {
|
|
344
|
+
// Scenario (UiSeparator): a keyboard user tabs through the page and never
|
|
345
|
+
// lands on a divider, even a semantic one.
|
|
346
|
+
await step('keyboard: separators are not tab stops', async () => {
|
|
347
|
+
await userEvent.tab();
|
|
348
|
+
await expect(canvasElement.contains(document.activeElement)).toBe(false);
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
await step('keyboard: no separator carries a tabindex', async () => {
|
|
352
|
+
for (const separator of getSeparators(canvasElement)) {
|
|
353
|
+
await expect(separator).not.toHaveAttribute('tabindex');
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Decorative separators are skipped; semantic ones are announced as a
|
|
361
|
+
* boundary with their orientation (WCAG 1.3.1). Hidden test-only story.
|
|
362
|
+
*/
|
|
363
|
+
export const ScreenReader: Story = {
|
|
364
|
+
name: 'test - Screen Reader',
|
|
365
|
+
tags: ['!dev', '!autodocs'],
|
|
366
|
+
parameters: {
|
|
367
|
+
docs: {
|
|
368
|
+
description: {
|
|
369
|
+
story:
|
|
370
|
+
'Verifies which separators assistive technology announces, and with which orientation.',
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
render: renderTestSeparators,
|
|
375
|
+
play: async ({ canvasElement, step }) => {
|
|
376
|
+
// Scenario (UiSeparator): a screen-reader user hears only the boundaries
|
|
377
|
+
// that were marked semantic, never the decorative lines.
|
|
378
|
+
const canvas = within(canvasElement);
|
|
379
|
+
const separators = [...getSeparators(canvasElement)];
|
|
380
|
+
|
|
381
|
+
await step(
|
|
382
|
+
'screen-reader: decorative separators are hidden (role="none")',
|
|
383
|
+
async () => {
|
|
384
|
+
const decorative = separators.filter(
|
|
385
|
+
(separator) => separator.getAttribute('role') === 'none',
|
|
386
|
+
);
|
|
387
|
+
await expect(decorative).toHaveLength(2);
|
|
388
|
+
},
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
await step(
|
|
392
|
+
'screen-reader: only semantic separators are announced',
|
|
393
|
+
async () => {
|
|
394
|
+
await expect(canvas.getAllByRole('separator')).toHaveLength(2);
|
|
395
|
+
},
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
await step(
|
|
399
|
+
'screen-reader: a vertical semantic separator announces its orientation',
|
|
400
|
+
async () => {
|
|
401
|
+
const vertical = canvas
|
|
402
|
+
.getAllByRole('separator')
|
|
403
|
+
.find(
|
|
404
|
+
(separator) =>
|
|
405
|
+
separator.getAttribute('data-orientation') === 'vertical',
|
|
406
|
+
);
|
|
407
|
+
await expect(vertical).toBeDefined();
|
|
408
|
+
await expect(vertical).toHaveAttribute('aria-orientation', 'vertical');
|
|
409
|
+
},
|
|
410
|
+
);
|
|
411
|
+
|
|
412
|
+
await step(
|
|
413
|
+
'screen-reader: the grouping is also carried by the text around it',
|
|
414
|
+
async () => {
|
|
415
|
+
for (const label of ['Account', 'Billing', 'Docs', 'Source']) {
|
|
416
|
+
await expect(canvas.getByText(label)).toBeVisible();
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
);
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
|
|
425
|
+
* try 400% reflow (WCAG 1.4.10). Hidden test-only story.
|
|
426
|
+
*/
|
|
427
|
+
export const ZoomMagnification: Story = {
|
|
428
|
+
name: 'test - Zoom Magnification',
|
|
429
|
+
tags: ['!dev', '!autodocs'],
|
|
430
|
+
globals: { zoom: '200' },
|
|
431
|
+
parameters: {
|
|
432
|
+
// Zoom changes the layout scale; the accessible-reflow Chromatic mode
|
|
433
|
+
// already covers magnified snapshots, so skip this one.
|
|
434
|
+
chromatic: { disableSnapshot: true },
|
|
435
|
+
docs: {
|
|
436
|
+
description: {
|
|
437
|
+
story:
|
|
438
|
+
'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
render: renderTestSeparators,
|
|
443
|
+
play: async ({ canvasElement, step }) => {
|
|
444
|
+
// Scenario (UiSeparator): at 200% page zoom horizontal and vertical lines
|
|
445
|
+
// keep their orientation and stay inside the viewport.
|
|
446
|
+
await step(
|
|
447
|
+
'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
|
|
448
|
+
async () => {
|
|
449
|
+
await expect(document.documentElement.style.zoom).toBe('200%');
|
|
450
|
+
},
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
await step(
|
|
454
|
+
'zoom: horizontal and vertical separators keep their orientation',
|
|
455
|
+
async () => {
|
|
456
|
+
const orientations = [...getSeparators(canvasElement)].map(
|
|
457
|
+
(separator) => separator.getAttribute('data-orientation'),
|
|
458
|
+
);
|
|
459
|
+
await expect(orientations).toEqual([
|
|
460
|
+
'horizontal',
|
|
461
|
+
'horizontal',
|
|
462
|
+
'vertical',
|
|
463
|
+
'vertical',
|
|
464
|
+
]);
|
|
465
|
+
},
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
await step('zoom: separators stay inside the viewport', async () => {
|
|
469
|
+
for (const separator of getSeparators(canvasElement)) {
|
|
470
|
+
const { left, right } = separator.getBoundingClientRect();
|
|
471
|
+
await expect(left).toBeGreaterThanOrEqual(0);
|
|
472
|
+
await expect(right).toBeLessThanOrEqual(window.innerWidth + 1);
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
},
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
|
|
480
|
+
* toolbar. Hidden test-only story.
|
|
481
|
+
*/
|
|
482
|
+
export const MobileBreakpoint: Story = {
|
|
483
|
+
name: 'test - Mobile Breakpoint',
|
|
484
|
+
tags: ['!dev', '!autodocs'],
|
|
485
|
+
globals: { mediaBreakpoint: 'reflow' },
|
|
486
|
+
parameters: {
|
|
487
|
+
// Reflow snapshots are already covered by the accessible-reflow mode.
|
|
488
|
+
chromatic: { disableSnapshot: true },
|
|
489
|
+
docs: {
|
|
490
|
+
description: {
|
|
491
|
+
story:
|
|
492
|
+
'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
render: renderTestSeparators,
|
|
497
|
+
play: async ({ canvasElement, step }) => {
|
|
498
|
+
// Scenario (UiSeparator): at the 320px mobile breakpoint horizontal lines
|
|
499
|
+
// span the narrow column and vertical dividers stay inline, without
|
|
500
|
+
// sideways scrolling.
|
|
501
|
+
const canvas = within(canvasElement);
|
|
502
|
+
|
|
503
|
+
await step(
|
|
504
|
+
'mobile: both orientations render at the 320px breakpoint',
|
|
505
|
+
async () => {
|
|
506
|
+
await expect(canvas.getByText('Support')).toBeVisible();
|
|
507
|
+
await expect(getSeparators(canvasElement)).toHaveLength(4);
|
|
508
|
+
},
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
await step(
|
|
512
|
+
'mobile: the layout fits without sideways scrolling (WCAG 1.4.10 Reflow)',
|
|
513
|
+
async () => {
|
|
514
|
+
const { scrollWidth, clientWidth } = document.documentElement;
|
|
515
|
+
await expect(scrollWidth).toBeLessThanOrEqual(clientWidth + 1);
|
|
516
|
+
for (const separator of getSeparators(canvasElement)) {
|
|
517
|
+
const { right } = separator.getBoundingClientRect();
|
|
518
|
+
await expect(right).toBeLessThanOrEqual(window.innerWidth + 1);
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
await step(
|
|
524
|
+
'mobile: separators add no touch targets of their own',
|
|
525
|
+
async () => {
|
|
526
|
+
// A separator takes no input, so 2.5.8 doesn't apply to it.
|
|
527
|
+
await expect(canvas.queryAllByRole('button')).toHaveLength(0);
|
|
528
|
+
await expect(canvas.queryAllByRole('link')).toHaveLength(0);
|
|
529
|
+
},
|
|
530
|
+
);
|
|
531
|
+
},
|
|
532
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
figma: '29207:503'
|
|
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 Sheet component slides a panel in from an edge of the screen and holds content that complements what is behind it. The main view stays in place, so the panel reads as a companion rather than a replacement.
|
|
10
|
+
|
|
11
|
+
Use it for secondary content and side tasks on wide layouts — filters, details, settings. Dialog is right when the task deserves the centre of the screen, and a page once the content outgrows a panel.
|
|
12
|
+
|
|
13
|
+
### Complementary, not primary
|
|
14
|
+
|
|
15
|
+
A sheet sits alongside the main view, so it has to belong there:
|
|
16
|
+
|
|
17
|
+
- The content relates to what is visible behind it
|
|
18
|
+
- The title names what the panel holds
|
|
19
|
+
- The main view keeps its place and its scroll position
|
|
20
|
+
- Closing the sheet changes nothing the user has to redo
|
|
21
|
+
|
|
22
|
+
### Pick the edge by meaning
|
|
23
|
+
|
|
24
|
+
Where the panel enters tells the user what kind of content it is:
|
|
25
|
+
|
|
26
|
+
1. Right for details and secondary tasks, on left-to-right layouts
|
|
27
|
+
2. Left for navigation and structure
|
|
28
|
+
3. Bottom for content reached from the bottom of the screen
|
|
29
|
+
4. One edge per kind of content, held across the product
|
|
30
|
+
|
|
31
|
+
### Consistency
|
|
32
|
+
|
|
33
|
+
Every sheet is built from the same parts:
|
|
34
|
+
|
|
35
|
+
- Sheet panel, at the md or sm breakpoint
|
|
36
|
+
- Position: left, right, top or bottom
|
|
37
|
+
- Title, and an optional description
|
|
38
|
+
- Content slot
|
|
39
|
+
- Close icon, with default, hover and focus states
|
|
40
|
+
|
|
41
|
+
## Do
|
|
42
|
+
|
|
43
|
+
- Keep the panel's content related to the view behind it
|
|
44
|
+
- Use one edge per kind of content, across the whole product
|
|
45
|
+
- Name what the panel holds in the title
|
|
46
|
+
- Keep the main view's scroll position while the sheet is open
|
|
47
|
+
- Use the sm breakpoint on narrow screens rather than shrinking md
|
|
48
|
+
- Keep the close icon in the same corner everywhere
|
|
49
|
+
|
|
50
|
+
## Don't
|
|
51
|
+
|
|
52
|
+
- Put the primary task of a screen in a sheet
|
|
53
|
+
- Open a sheet from another sheet
|
|
54
|
+
- Change the entry edge between screens
|
|
55
|
+
- Remove the close icon
|
|
56
|
+
- Use a sheet where the content has nothing to do with the view behind it
|
|
57
|
+
- Let the panel's content scroll the title out of reach
|
|
58
|
+
|
|
59
|
+
## Accessibility
|
|
60
|
+
|
|
61
|
+
- The panel separates from the page by surface and edge, not by the dimming alone
|
|
62
|
+
- Title, content and close follow one another in reading order
|
|
63
|
+
- The close icon is a comfortable target and keeps a visible focus state of its own
|
|
64
|
+
- Text and controls hold their contrast against the panel's own surface
|
|
65
|
+
- The title stays in place while the content scrolls, so the panel's purpose stays visible
|
|
66
|
+
- Entry motion is short and from a consistent edge, so the panel's arrival is predictable
|