@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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
figma: '29209:71667'
|
|
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 Tabs component switches between sections that belong to the same subject, in the same place on the screen. The user stays where they are and changes what they are looking at.
|
|
10
|
+
|
|
11
|
+
Use tabs for alternate views of one thing — details, activity, settings for the same record. Going to a different subject is navigation, not a tab.
|
|
12
|
+
|
|
13
|
+
### One subject, several views
|
|
14
|
+
|
|
15
|
+
Tabs only work if the sections are peers:
|
|
16
|
+
|
|
17
|
+
- Every tab shows a view of the same subject
|
|
18
|
+
- The sections are alternatives, never sequential steps
|
|
19
|
+
- Switching a tab changes nothing but the view
|
|
20
|
+
- The active tab is unmistakable at a glance
|
|
21
|
+
|
|
22
|
+
### Keep the row readable
|
|
23
|
+
|
|
24
|
+
The row of triggers is the whole control, so protect it:
|
|
25
|
+
|
|
26
|
+
1. Labels are one or two words, phrased in parallel
|
|
27
|
+
2. The first tab is the one most users want
|
|
28
|
+
3. A badge on a tab counts what is inside it
|
|
29
|
+
4. The row stays on one line: fewer tabs rather than a wrapped row
|
|
30
|
+
|
|
31
|
+
### Consistency
|
|
32
|
+
|
|
33
|
+
Every tab set is built from the same parts:
|
|
34
|
+
|
|
35
|
+
- Tabs, holding up to eight triggers
|
|
36
|
+
- Trigger, active or inactive
|
|
37
|
+
- Trigger states: default, focus and disabled
|
|
38
|
+
- Optional icon and badge on a trigger
|
|
39
|
+
- One tab row position per context
|
|
40
|
+
|
|
41
|
+
## Do
|
|
42
|
+
|
|
43
|
+
- Keep every tab a view of the same subject
|
|
44
|
+
- Use one or two words per label, phrased in parallel
|
|
45
|
+
- Put the tab most users want first, and make it the default
|
|
46
|
+
- Use a badge to count what is inside a tab
|
|
47
|
+
- Keep the row to one line
|
|
48
|
+
- Preserve each tab's state when the user comes back to it
|
|
49
|
+
|
|
50
|
+
## Don't
|
|
51
|
+
|
|
52
|
+
- Use tabs for sequential steps — use Stepper
|
|
53
|
+
- Use tabs to navigate to a different subject
|
|
54
|
+
- Let the tab row wrap to two lines
|
|
55
|
+
- Disable a tab with no explanation
|
|
56
|
+
- Rely on colour alone to mark the active tab
|
|
57
|
+
- Change the tab order between visits
|
|
58
|
+
|
|
59
|
+
## Accessibility
|
|
60
|
+
|
|
61
|
+
- The active tab differs by weight and an underline or fill, not by colour alone
|
|
62
|
+
- Focus is visible on a trigger and distinguishable from the active state
|
|
63
|
+
- Disabled tabs are distinguishable by more than reduced opacity
|
|
64
|
+
- Triggers are comfortable targets, with enough space between adjacent labels
|
|
65
|
+
- The panel appears directly below its own tab row, so reading order matches visual order
|
|
66
|
+
- Badge counts on a trigger stay legible without crowding the label
|
|
@@ -2,6 +2,16 @@ import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
|
2
2
|
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
3
3
|
import { ref, watch } from 'vue';
|
|
4
4
|
import { UiTabs, UiTabsList, UiTabsTrigger, UiTabsContent } from './index';
|
|
5
|
+
import {
|
|
6
|
+
accessibilityRequirementsTemplate,
|
|
7
|
+
designNotesStory,
|
|
8
|
+
guidanceLinks,
|
|
9
|
+
guidanceSectionClass,
|
|
10
|
+
parseGuidance,
|
|
11
|
+
} from '../../../.storybook/guidance';
|
|
12
|
+
import guidanceMarkdown from './UiTabs.guidance.md?raw';
|
|
13
|
+
|
|
14
|
+
const guidance = parseGuidance(guidanceMarkdown);
|
|
5
15
|
|
|
6
16
|
/**
|
|
7
17
|
* UiTabs is a set of switchable content panels selected by their tab triggers.
|
|
@@ -36,6 +46,9 @@ const meta: Meta<typeof UiTabs> = {
|
|
|
36
46
|
orientation: 'horizontal',
|
|
37
47
|
activationMode: 'automatic',
|
|
38
48
|
},
|
|
49
|
+
parameters: {
|
|
50
|
+
docs: { links: guidanceLinks(guidance) },
|
|
51
|
+
},
|
|
39
52
|
};
|
|
40
53
|
|
|
41
54
|
export default meta;
|
|
@@ -184,6 +197,167 @@ export const Default: Story = {
|
|
|
184
197
|
},
|
|
185
198
|
};
|
|
186
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Usage, guidelines, and do's and don'ts from the Figma documentation.
|
|
202
|
+
*/
|
|
203
|
+
export const DesignNotes: Story = {
|
|
204
|
+
...designNotesStory(guidance),
|
|
205
|
+
tags: ['!autodocs'],
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Accessibility guidance for tablists: a named set of tabs, keyboard
|
|
210
|
+
* operability, a selected state that survives without colour, and disabled
|
|
211
|
+
* tabs that stay visible — shown side by side in the default and accessible
|
|
212
|
+
* themes.
|
|
213
|
+
*/
|
|
214
|
+
export const Accessibility: Story = {
|
|
215
|
+
tags: ['!autodocs'],
|
|
216
|
+
parameters: {
|
|
217
|
+
surface: 'primary',
|
|
218
|
+
a11y: { test: 'off' },
|
|
219
|
+
chromatic: { disableSnapshot: true },
|
|
220
|
+
docs: {
|
|
221
|
+
canvas: {
|
|
222
|
+
sourceState: 'none',
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
render: () => ({
|
|
227
|
+
components: { UiTabs, UiTabsList, UiTabsTrigger, UiTabsContent },
|
|
228
|
+
setup() {
|
|
229
|
+
const defaultValue = ref('account');
|
|
230
|
+
const accessibleValue = ref('account');
|
|
231
|
+
return { defaultValue, accessibleValue };
|
|
232
|
+
},
|
|
233
|
+
template: `
|
|
234
|
+
<section class="${guidanceSectionClass}">
|
|
235
|
+
<div>
|
|
236
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
237
|
+
Accessibility
|
|
238
|
+
</h2>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
|
|
242
|
+
|
|
243
|
+
<div class="flex flex-col gap-6">
|
|
244
|
+
<div class="flex flex-col gap-2">
|
|
245
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
246
|
+
Use tabs for in-page panels, not site navigation
|
|
247
|
+
</h3>
|
|
248
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
249
|
+
Tabs switch related views inside a single page region. For
|
|
250
|
+
top-level page navigation, use
|
|
251
|
+
<code>UiNavigationMenu</code> so the destination is a link rather
|
|
252
|
+
than a tab.
|
|
253
|
+
</p>
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
<div class="flex flex-col gap-2">
|
|
257
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
258
|
+
The tablist is one tab stop
|
|
259
|
+
</h3>
|
|
260
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
261
|
+
<code>Tab</code> enters the list on the selected tab. The arrow
|
|
262
|
+
keys move between tabs — Left/Right when horizontal, Up/Down when
|
|
263
|
+
vertical — looping at the ends and stepping over disabled ones.
|
|
264
|
+
A second <code>Tab</code> leaves for the selected panel. Do not
|
|
265
|
+
add your own <code>tabindex</code>; it breaks this roving-focus
|
|
266
|
+
contract (WCAG 2.1.1 Keyboard, 2.4.3 Focus Order).
|
|
267
|
+
</p>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<div class="flex flex-col gap-2">
|
|
271
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
272
|
+
Automatic vs manual activation
|
|
273
|
+
</h3>
|
|
274
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
275
|
+
Automatic mode (the default) activates a tab as soon as it
|
|
276
|
+
receives focus, which is what most users expect. Use
|
|
277
|
+
<code>activation-mode="manual"</code> when panel content is
|
|
278
|
+
expensive to render: arrow keys then only move focus, and
|
|
279
|
+
<code>Enter</code> or <code>Space</code> confirms the choice.
|
|
280
|
+
</p>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<div class="flex flex-col gap-2">
|
|
284
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
285
|
+
Do not rely on the selected fill alone
|
|
286
|
+
</h3>
|
|
287
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
288
|
+
The selected tab is filled, and the same information reaches
|
|
289
|
+
everyone else through <code>aria-selected</code> (WCAG 1.4.1 Use
|
|
290
|
+
of Color). Keep disabled tabs in the list so the full set of
|
|
291
|
+
choices stays visible.
|
|
292
|
+
</p>
|
|
293
|
+
</div>
|
|
294
|
+
|
|
295
|
+
<div class="flex flex-col gap-2">
|
|
296
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
297
|
+
Enable accessibility theme
|
|
298
|
+
</h3>
|
|
299
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
300
|
+
When accessibility is required, enable our accessibility theme.
|
|
301
|
+
This increases contrast and makes sure there are no color
|
|
302
|
+
contrast issues.
|
|
303
|
+
</p>
|
|
304
|
+
</div>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
308
|
+
<div class="flex flex-col gap-3">
|
|
309
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
310
|
+
Default
|
|
311
|
+
</h3>
|
|
312
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
313
|
+
<UiTabs v-model="defaultValue">
|
|
314
|
+
<UiTabsList aria-label="Account settings">
|
|
315
|
+
<UiTabsTrigger value="account">Account</UiTabsTrigger>
|
|
316
|
+
<UiTabsTrigger value="password" disabled>Password</UiTabsTrigger>
|
|
317
|
+
<UiTabsTrigger value="settings">Settings</UiTabsTrigger>
|
|
318
|
+
</UiTabsList>
|
|
319
|
+
<UiTabsContent value="account">
|
|
320
|
+
<p class="body-s-regular p-4 text-content-on-surface-muted">Account panel.</p>
|
|
321
|
+
</UiTabsContent>
|
|
322
|
+
<UiTabsContent value="password">
|
|
323
|
+
<p class="body-s-regular p-4 text-content-on-surface-muted">Password panel.</p>
|
|
324
|
+
</UiTabsContent>
|
|
325
|
+
<UiTabsContent value="settings">
|
|
326
|
+
<p class="body-s-regular p-4 text-content-on-surface-muted">Settings panel.</p>
|
|
327
|
+
</UiTabsContent>
|
|
328
|
+
</UiTabs>
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
|
|
332
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
333
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
334
|
+
Accessible
|
|
335
|
+
</h3>
|
|
336
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
337
|
+
<UiTabs v-model="accessibleValue">
|
|
338
|
+
<UiTabsList aria-label="Account settings">
|
|
339
|
+
<UiTabsTrigger value="account">Account</UiTabsTrigger>
|
|
340
|
+
<UiTabsTrigger value="password" disabled>Password</UiTabsTrigger>
|
|
341
|
+
<UiTabsTrigger value="settings">Settings</UiTabsTrigger>
|
|
342
|
+
</UiTabsList>
|
|
343
|
+
<UiTabsContent value="account">
|
|
344
|
+
<p class="body-s-regular p-4 text-content-on-surface-muted">Account panel.</p>
|
|
345
|
+
</UiTabsContent>
|
|
346
|
+
<UiTabsContent value="password">
|
|
347
|
+
<p class="body-s-regular p-4 text-content-on-surface-muted">Password panel.</p>
|
|
348
|
+
</UiTabsContent>
|
|
349
|
+
<UiTabsContent value="settings">
|
|
350
|
+
<p class="body-s-regular p-4 text-content-on-surface-muted">Settings panel.</p>
|
|
351
|
+
</UiTabsContent>
|
|
352
|
+
</UiTabs>
|
|
353
|
+
</div>
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
</section>
|
|
357
|
+
`,
|
|
358
|
+
}),
|
|
359
|
+
};
|
|
360
|
+
|
|
187
361
|
const withDisabledTabTemplateSource = `<script setup lang="ts">
|
|
188
362
|
import {
|
|
189
363
|
UiTabs,
|
|
@@ -632,156 +806,6 @@ export const Controlled: Story = {
|
|
|
632
806
|
},
|
|
633
807
|
};
|
|
634
808
|
|
|
635
|
-
/**
|
|
636
|
-
* Accessibility guidance for tablists: a named set of tabs, keyboard
|
|
637
|
-
* operability, a selected state that survives without colour, and disabled
|
|
638
|
-
* tabs that stay visible — shown side by side in the default and accessible
|
|
639
|
-
* themes.
|
|
640
|
-
*/
|
|
641
|
-
export const Accessibility: Story = {
|
|
642
|
-
tags: ['!autodocs'],
|
|
643
|
-
parameters: {
|
|
644
|
-
a11y: { test: 'off' },
|
|
645
|
-
chromatic: { disableSnapshot: true },
|
|
646
|
-
docs: {
|
|
647
|
-
canvas: {
|
|
648
|
-
sourceState: 'none',
|
|
649
|
-
},
|
|
650
|
-
},
|
|
651
|
-
},
|
|
652
|
-
render: () => ({
|
|
653
|
-
components: { UiTabs, UiTabsList, UiTabsTrigger, UiTabsContent },
|
|
654
|
-
setup() {
|
|
655
|
-
const defaultValue = ref('account');
|
|
656
|
-
const accessibleValue = ref('account');
|
|
657
|
-
return { defaultValue, accessibleValue };
|
|
658
|
-
},
|
|
659
|
-
template: `
|
|
660
|
-
<section class="flex flex-col gap-6 p-4">
|
|
661
|
-
<div>
|
|
662
|
-
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
663
|
-
Accessibility
|
|
664
|
-
</h2>
|
|
665
|
-
</div>
|
|
666
|
-
|
|
667
|
-
<div class="flex flex-col gap-6">
|
|
668
|
-
<div class="flex flex-col gap-2">
|
|
669
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
670
|
-
Use tabs for in-page panels, not site navigation
|
|
671
|
-
</h3>
|
|
672
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
673
|
-
Tabs switch related views inside a single page region. For
|
|
674
|
-
top-level page navigation, use
|
|
675
|
-
<code>UiNavigationMenu</code> so the destination is a link rather
|
|
676
|
-
than a tab.
|
|
677
|
-
</p>
|
|
678
|
-
</div>
|
|
679
|
-
|
|
680
|
-
<div class="flex flex-col gap-2">
|
|
681
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
682
|
-
The tablist is one tab stop
|
|
683
|
-
</h3>
|
|
684
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
685
|
-
<code>Tab</code> enters the list on the selected tab. The arrow
|
|
686
|
-
keys move between tabs — Left/Right when horizontal, Up/Down when
|
|
687
|
-
vertical — looping at the ends and stepping over disabled ones.
|
|
688
|
-
A second <code>Tab</code> leaves for the selected panel. Do not
|
|
689
|
-
add your own <code>tabindex</code>; it breaks this roving-focus
|
|
690
|
-
contract (WCAG 2.1.1 Keyboard, 2.4.3 Focus Order).
|
|
691
|
-
</p>
|
|
692
|
-
</div>
|
|
693
|
-
|
|
694
|
-
<div class="flex flex-col gap-2">
|
|
695
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
696
|
-
Automatic vs manual activation
|
|
697
|
-
</h3>
|
|
698
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
699
|
-
Automatic mode (the default) activates a tab as soon as it
|
|
700
|
-
receives focus, which is what most users expect. Use
|
|
701
|
-
<code>activation-mode="manual"</code> when panel content is
|
|
702
|
-
expensive to render: arrow keys then only move focus, and
|
|
703
|
-
<code>Enter</code> or <code>Space</code> confirms the choice.
|
|
704
|
-
</p>
|
|
705
|
-
</div>
|
|
706
|
-
|
|
707
|
-
<div class="flex flex-col gap-2">
|
|
708
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
709
|
-
Do not rely on the selected fill alone
|
|
710
|
-
</h3>
|
|
711
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
712
|
-
The selected tab is filled, and the same information reaches
|
|
713
|
-
everyone else through <code>aria-selected</code> (WCAG 1.4.1 Use
|
|
714
|
-
of Color). Keep disabled tabs in the list so the full set of
|
|
715
|
-
choices stays visible.
|
|
716
|
-
</p>
|
|
717
|
-
</div>
|
|
718
|
-
|
|
719
|
-
<div class="flex flex-col gap-2">
|
|
720
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
721
|
-
Enable accessibility theme
|
|
722
|
-
</h3>
|
|
723
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
724
|
-
When accessibility is required, enable our accessibility theme.
|
|
725
|
-
This increases contrast and makes sure there are no color
|
|
726
|
-
contrast issues.
|
|
727
|
-
</p>
|
|
728
|
-
</div>
|
|
729
|
-
</div>
|
|
730
|
-
|
|
731
|
-
<div class="grid gap-4 md:grid-cols-2">
|
|
732
|
-
<div class="flex flex-col gap-3">
|
|
733
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
734
|
-
Default
|
|
735
|
-
</h3>
|
|
736
|
-
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
737
|
-
<UiTabs v-model="defaultValue">
|
|
738
|
-
<UiTabsList aria-label="Account settings">
|
|
739
|
-
<UiTabsTrigger value="account">Account</UiTabsTrigger>
|
|
740
|
-
<UiTabsTrigger value="password" disabled>Password</UiTabsTrigger>
|
|
741
|
-
<UiTabsTrigger value="settings">Settings</UiTabsTrigger>
|
|
742
|
-
</UiTabsList>
|
|
743
|
-
<UiTabsContent value="account">
|
|
744
|
-
<p class="body-s-regular p-4 text-content-on-surface-muted">Account panel.</p>
|
|
745
|
-
</UiTabsContent>
|
|
746
|
-
<UiTabsContent value="password">
|
|
747
|
-
<p class="body-s-regular p-4 text-content-on-surface-muted">Password panel.</p>
|
|
748
|
-
</UiTabsContent>
|
|
749
|
-
<UiTabsContent value="settings">
|
|
750
|
-
<p class="body-s-regular p-4 text-content-on-surface-muted">Settings panel.</p>
|
|
751
|
-
</UiTabsContent>
|
|
752
|
-
</UiTabs>
|
|
753
|
-
</div>
|
|
754
|
-
</div>
|
|
755
|
-
|
|
756
|
-
<div class="accessible-theme flex flex-col gap-3">
|
|
757
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
758
|
-
Accessible
|
|
759
|
-
</h3>
|
|
760
|
-
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
761
|
-
<UiTabs v-model="accessibleValue">
|
|
762
|
-
<UiTabsList aria-label="Account settings">
|
|
763
|
-
<UiTabsTrigger value="account">Account</UiTabsTrigger>
|
|
764
|
-
<UiTabsTrigger value="password" disabled>Password</UiTabsTrigger>
|
|
765
|
-
<UiTabsTrigger value="settings">Settings</UiTabsTrigger>
|
|
766
|
-
</UiTabsList>
|
|
767
|
-
<UiTabsContent value="account">
|
|
768
|
-
<p class="body-s-regular p-4 text-content-on-surface-muted">Account panel.</p>
|
|
769
|
-
</UiTabsContent>
|
|
770
|
-
<UiTabsContent value="password">
|
|
771
|
-
<p class="body-s-regular p-4 text-content-on-surface-muted">Password panel.</p>
|
|
772
|
-
</UiTabsContent>
|
|
773
|
-
<UiTabsContent value="settings">
|
|
774
|
-
<p class="body-s-regular p-4 text-content-on-surface-muted">Settings panel.</p>
|
|
775
|
-
</UiTabsContent>
|
|
776
|
-
</UiTabs>
|
|
777
|
-
</div>
|
|
778
|
-
</div>
|
|
779
|
-
</div>
|
|
780
|
-
</section>
|
|
781
|
-
`,
|
|
782
|
-
}),
|
|
783
|
-
};
|
|
784
|
-
|
|
785
809
|
// Test-only stories drive the test-runner (interactive/a11y checks) but are
|
|
786
810
|
// hidden from the Storybook sidebar and docs via the `!dev` / `!autodocs`
|
|
787
811
|
// tags. They keep the implicit `test` tag, so they still run in CI and appear
|