@aleph-alpha/ui-library 7.0.1 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/system/icons/story-sidebar-icons.json +74 -17
- package/dist/system/lib.js +8 -5
- package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
- package/dist/system/story-sidebar-icons.json +74 -17
- package/package.json +8 -3
- 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 +150 -126
- 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/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 +74 -72
- package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
|
@@ -14,6 +14,16 @@ import {
|
|
|
14
14
|
ListIcon,
|
|
15
15
|
UnderlineIcon,
|
|
16
16
|
} from '@/icons/lucide';
|
|
17
|
+
import {
|
|
18
|
+
accessibilityRequirementsTemplate,
|
|
19
|
+
designNotesStory,
|
|
20
|
+
guidanceLinks,
|
|
21
|
+
guidanceSectionClass,
|
|
22
|
+
parseGuidance,
|
|
23
|
+
} from '../../../.storybook/guidance';
|
|
24
|
+
import guidanceMarkdown from './UiToggleGroup.guidance.md?raw';
|
|
25
|
+
|
|
26
|
+
const guidance = parseGuidance(guidanceMarkdown);
|
|
17
27
|
|
|
18
28
|
interface ToggleItemConfig {
|
|
19
29
|
value: string;
|
|
@@ -61,6 +71,7 @@ const meta: Meta<typeof UiToggleGroup> = {
|
|
|
61
71
|
tags: ['autodocs'],
|
|
62
72
|
parameters: {
|
|
63
73
|
docs: {
|
|
74
|
+
links: guidanceLinks(guidance),
|
|
64
75
|
description: {
|
|
65
76
|
component:
|
|
66
77
|
'A set of two-state buttons that can be toggled on or off. Supports single selection (like radio buttons) or multiple selection (like checkboxes). Use for toolbar actions, formatting options, or view toggles.',
|
|
@@ -267,6 +278,217 @@ export const Default: Story = {
|
|
|
267
278
|
},
|
|
268
279
|
};
|
|
269
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Usage, guidelines, and do's and don'ts from the Figma documentation.
|
|
283
|
+
*/
|
|
284
|
+
export const DesignNotes: Story = {
|
|
285
|
+
...designNotesStory(guidance),
|
|
286
|
+
tags: ['!autodocs'],
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Accessibility guidance for toggle groups: a named group, named items, a
|
|
291
|
+
* single tab stop with arrow-key navigation inside, and a pressed state that
|
|
292
|
+
* survives without colour — shown side by side in the default and accessible
|
|
293
|
+
* themes.
|
|
294
|
+
*/
|
|
295
|
+
export const Accessibility: Story = {
|
|
296
|
+
tags: ['!autodocs'],
|
|
297
|
+
parameters: {
|
|
298
|
+
surface: 'primary',
|
|
299
|
+
a11y: { test: 'off' },
|
|
300
|
+
chromatic: { disableSnapshot: true },
|
|
301
|
+
controls: { disable: true },
|
|
302
|
+
docs: {
|
|
303
|
+
canvas: {
|
|
304
|
+
sourceState: 'none',
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
render: () => ({
|
|
309
|
+
components: { UiToggleGroup, UiToggleGroupItem, UiIcon },
|
|
310
|
+
setup() {
|
|
311
|
+
const defaultValue = ref<string>('center');
|
|
312
|
+
const defaultSoftValue = ref<string>('center');
|
|
313
|
+
const accessibleValue = ref<string>('center');
|
|
314
|
+
const accessibleSoftValue = ref<string>('center');
|
|
315
|
+
return {
|
|
316
|
+
defaultValue,
|
|
317
|
+
defaultSoftValue,
|
|
318
|
+
accessibleValue,
|
|
319
|
+
accessibleSoftValue,
|
|
320
|
+
alignmentItems,
|
|
321
|
+
};
|
|
322
|
+
},
|
|
323
|
+
template: `
|
|
324
|
+
<section class="${guidanceSectionClass}">
|
|
325
|
+
<div>
|
|
326
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
327
|
+
Accessibility
|
|
328
|
+
</h2>
|
|
329
|
+
</div>
|
|
330
|
+
|
|
331
|
+
${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
|
|
332
|
+
|
|
333
|
+
<div class="flex flex-col gap-6">
|
|
334
|
+
<div class="flex flex-col gap-2">
|
|
335
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
336
|
+
Give the group an accessible name
|
|
337
|
+
</h3>
|
|
338
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
339
|
+
The group renders as <code>role="group"</code>, which screen
|
|
340
|
+
readers announce with no name of its own. Pass an
|
|
341
|
+
<code>aria-label</code> such as "Text formatting" so the items are
|
|
342
|
+
heard in context rather than as three loose buttons.
|
|
343
|
+
</p>
|
|
344
|
+
</div>
|
|
345
|
+
|
|
346
|
+
<div class="flex flex-col gap-2">
|
|
347
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
348
|
+
Name every item, including icon-only ones
|
|
349
|
+
</h3>
|
|
350
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
351
|
+
<code>UiIcon</code> renders <code>aria-hidden</code>, so an item
|
|
352
|
+
containing only an icon has no accessible name. Give each item an
|
|
353
|
+
<code>aria-label</code> that describes the control — "Bold", not
|
|
354
|
+
"Bold (on)" — because <code>aria-pressed</code> already carries
|
|
355
|
+
the state.
|
|
356
|
+
</p>
|
|
357
|
+
</div>
|
|
358
|
+
|
|
359
|
+
<div class="flex flex-col gap-2">
|
|
360
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
361
|
+
Keep the visible text inside the accessible name
|
|
362
|
+
</h3>
|
|
363
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
364
|
+
When an item shows text next to its icon, the
|
|
365
|
+
<code>aria-label</code> must contain those words — "Align left"
|
|
366
|
+
alongside the visible "Left" is fine, "Justify" is not. Otherwise
|
|
367
|
+
speech-input users cannot activate the item by saying what they
|
|
368
|
+
see (WCAG 2.5.3 Label in Name).
|
|
369
|
+
</p>
|
|
370
|
+
</div>
|
|
371
|
+
|
|
372
|
+
<div class="flex flex-col gap-2">
|
|
373
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
374
|
+
The group is one tab stop
|
|
375
|
+
</h3>
|
|
376
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
377
|
+
<code>Tab</code> enters the group once — landing on the pressed
|
|
378
|
+
item, or the first one — and the arrow keys move between items,
|
|
379
|
+
looping at the ends and stepping over disabled ones. A second
|
|
380
|
+
<code>Tab</code> leaves the group. Do not add your own
|
|
381
|
+
<code>tabindex</code>; it breaks this roving-focus contract
|
|
382
|
+
(WCAG 2.1.1 Keyboard, 2.4.3 Focus Order).
|
|
383
|
+
</p>
|
|
384
|
+
</div>
|
|
385
|
+
|
|
386
|
+
<div class="flex flex-col gap-2">
|
|
387
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
388
|
+
Do not rely on the fill alone
|
|
389
|
+
</h3>
|
|
390
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
391
|
+
Selected items are filled with a muted surface, and
|
|
392
|
+
<code>soft</code> makes that fill quieter still. Neither is the
|
|
393
|
+
real signal: the same information reaches everyone through
|
|
394
|
+
<code>aria-pressed</code> (WCAG 1.4.1 Use of Color). In a
|
|
395
|
+
single-choice group that is what tells assistive technology which
|
|
396
|
+
option is active, so never express selection by colour alone.
|
|
397
|
+
</p>
|
|
398
|
+
</div>
|
|
399
|
+
|
|
400
|
+
<div class="flex flex-col gap-2">
|
|
401
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
402
|
+
A group is not a radio group
|
|
403
|
+
</h3>
|
|
404
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
405
|
+
Even with <code>type="single"</code> the items stay toggle buttons
|
|
406
|
+
with <code>aria-pressed</code>, not radios with
|
|
407
|
+
<code>aria-checked</code>. If the choice is a form value that must
|
|
408
|
+
be submitted, use <code>UiRadioGroup</code> instead; use this
|
|
409
|
+
group for view and formatting controls that act immediately.
|
|
410
|
+
</p>
|
|
411
|
+
</div>
|
|
412
|
+
|
|
413
|
+
<div class="flex flex-col gap-2">
|
|
414
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
415
|
+
Every size is large enough to tap
|
|
416
|
+
</h3>
|
|
417
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
418
|
+
The sizes differ in padding rather than in a fixed box, and every
|
|
419
|
+
one of them clears the 24×24px floor in WCAG 2.5.8 Target Size
|
|
420
|
+
(Minimum) — including <code>sm</code>, and including icon-only
|
|
421
|
+
items, which carry the target without help from a label.
|
|
422
|
+
</p>
|
|
423
|
+
</div>
|
|
424
|
+
|
|
425
|
+
<div class="flex flex-col gap-2">
|
|
426
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
427
|
+
Selected items keep their contrast when focused
|
|
428
|
+
</h3>
|
|
429
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
430
|
+
Hover, focus and press are drawn as an overlay on top of the
|
|
431
|
+
item's own fill, so a selected item that is also focused stays
|
|
432
|
+
readable instead of washing out. The focus ring itself only
|
|
433
|
+
appears for keyboard focus, which is why clicking an item does not
|
|
434
|
+
leave it looking selected (WCAG 2.4.7 Focus Visible).
|
|
435
|
+
</p>
|
|
436
|
+
</div>
|
|
437
|
+
|
|
438
|
+
<div class="flex flex-col gap-2">
|
|
439
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
440
|
+
Enable accessibility theme
|
|
441
|
+
</h3>
|
|
442
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
443
|
+
When accessibility is required, enable our accessibility theme.
|
|
444
|
+
This increases contrast and makes sure there are no color contrast
|
|
445
|
+
issues.
|
|
446
|
+
</p>
|
|
447
|
+
</div>
|
|
448
|
+
</div>
|
|
449
|
+
|
|
450
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
451
|
+
<div class="flex flex-col gap-3">
|
|
452
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
453
|
+
Default
|
|
454
|
+
</h3>
|
|
455
|
+
<div class="flex min-h-20 flex-col items-center justify-center gap-4 border border-border-surface-default p-6">
|
|
456
|
+
<UiToggleGroup v-model="defaultValue" type="single" variant="outline" aria-label="Text alignment">
|
|
457
|
+
<UiToggleGroupItem v-for="item in alignmentItems" :key="item.value" :value="item.value" :aria-label="item.label">
|
|
458
|
+
<UiIcon :name="item.icon" :size="16" />
|
|
459
|
+
</UiToggleGroupItem>
|
|
460
|
+
</UiToggleGroup>
|
|
461
|
+
<UiToggleGroup v-model="defaultSoftValue" type="single" variant="outline" soft aria-label="Text alignment, soft fill">
|
|
462
|
+
<UiToggleGroupItem v-for="item in alignmentItems" :key="item.value" :value="item.value" :aria-label="item.label">
|
|
463
|
+
<UiIcon :name="item.icon" :size="16" />
|
|
464
|
+
</UiToggleGroupItem>
|
|
465
|
+
</UiToggleGroup>
|
|
466
|
+
</div>
|
|
467
|
+
</div>
|
|
468
|
+
|
|
469
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
470
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
471
|
+
Accessible
|
|
472
|
+
</h3>
|
|
473
|
+
<div class="flex min-h-20 flex-col items-center justify-center gap-4 border border-border-surface-default p-6">
|
|
474
|
+
<UiToggleGroup v-model="accessibleValue" type="single" variant="outline" aria-label="Text alignment">
|
|
475
|
+
<UiToggleGroupItem v-for="item in alignmentItems" :key="item.value" :value="item.value" :aria-label="item.label">
|
|
476
|
+
<UiIcon :name="item.icon" :size="16" />
|
|
477
|
+
</UiToggleGroupItem>
|
|
478
|
+
</UiToggleGroup>
|
|
479
|
+
<UiToggleGroup v-model="accessibleSoftValue" type="single" variant="outline" soft aria-label="Text alignment, soft fill">
|
|
480
|
+
<UiToggleGroupItem v-for="item in alignmentItems" :key="item.value" :value="item.value" :aria-label="item.label">
|
|
481
|
+
<UiIcon :name="item.icon" :size="16" />
|
|
482
|
+
</UiToggleGroupItem>
|
|
483
|
+
</UiToggleGroup>
|
|
484
|
+
</div>
|
|
485
|
+
</div>
|
|
486
|
+
</div>
|
|
487
|
+
</section>
|
|
488
|
+
`,
|
|
489
|
+
}),
|
|
490
|
+
};
|
|
491
|
+
|
|
270
492
|
const outlineTemplateSource = `<script setup lang="ts">
|
|
271
493
|
import { ref } from 'vue'
|
|
272
494
|
import { UiToggleGroup, UiToggleGroupItem, UiIcon } from '@aleph-alpha/ui-library'
|
|
@@ -1373,206 +1595,6 @@ export const AllStates: Story = {
|
|
|
1373
1595
|
},
|
|
1374
1596
|
};
|
|
1375
1597
|
|
|
1376
|
-
/**
|
|
1377
|
-
* Accessibility guidance for toggle groups: a named group, named items, a
|
|
1378
|
-
* single tab stop with arrow-key navigation inside, and a pressed state that
|
|
1379
|
-
* survives without colour — shown side by side in the default and accessible
|
|
1380
|
-
* themes.
|
|
1381
|
-
*/
|
|
1382
|
-
export const Accessibility: Story = {
|
|
1383
|
-
tags: ['!autodocs'],
|
|
1384
|
-
parameters: {
|
|
1385
|
-
a11y: { test: 'off' },
|
|
1386
|
-
chromatic: { disableSnapshot: true },
|
|
1387
|
-
controls: { disable: true },
|
|
1388
|
-
docs: {
|
|
1389
|
-
canvas: {
|
|
1390
|
-
sourceState: 'none',
|
|
1391
|
-
},
|
|
1392
|
-
},
|
|
1393
|
-
},
|
|
1394
|
-
render: () => ({
|
|
1395
|
-
components: { UiToggleGroup, UiToggleGroupItem, UiIcon },
|
|
1396
|
-
setup() {
|
|
1397
|
-
const defaultValue = ref<string>('center');
|
|
1398
|
-
const defaultSoftValue = ref<string>('center');
|
|
1399
|
-
const accessibleValue = ref<string>('center');
|
|
1400
|
-
const accessibleSoftValue = ref<string>('center');
|
|
1401
|
-
return {
|
|
1402
|
-
defaultValue,
|
|
1403
|
-
defaultSoftValue,
|
|
1404
|
-
accessibleValue,
|
|
1405
|
-
accessibleSoftValue,
|
|
1406
|
-
alignmentItems,
|
|
1407
|
-
};
|
|
1408
|
-
},
|
|
1409
|
-
template: `
|
|
1410
|
-
<section class="flex flex-col gap-6 p-4">
|
|
1411
|
-
<div>
|
|
1412
|
-
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
1413
|
-
Accessibility
|
|
1414
|
-
</h2>
|
|
1415
|
-
</div>
|
|
1416
|
-
|
|
1417
|
-
<div class="flex flex-col gap-6">
|
|
1418
|
-
<div class="flex flex-col gap-2">
|
|
1419
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1420
|
-
Give the group an accessible name
|
|
1421
|
-
</h3>
|
|
1422
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
1423
|
-
The group renders as <code>role="group"</code>, which screen
|
|
1424
|
-
readers announce with no name of its own. Pass an
|
|
1425
|
-
<code>aria-label</code> such as "Text formatting" so the items are
|
|
1426
|
-
heard in context rather than as three loose buttons.
|
|
1427
|
-
</p>
|
|
1428
|
-
</div>
|
|
1429
|
-
|
|
1430
|
-
<div class="flex flex-col gap-2">
|
|
1431
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1432
|
-
Name every item, including icon-only ones
|
|
1433
|
-
</h3>
|
|
1434
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
1435
|
-
<code>UiIcon</code> renders <code>aria-hidden</code>, so an item
|
|
1436
|
-
containing only an icon has no accessible name. Give each item an
|
|
1437
|
-
<code>aria-label</code> that describes the control — "Bold", not
|
|
1438
|
-
"Bold (on)" — because <code>aria-pressed</code> already carries
|
|
1439
|
-
the state.
|
|
1440
|
-
</p>
|
|
1441
|
-
</div>
|
|
1442
|
-
|
|
1443
|
-
<div class="flex flex-col gap-2">
|
|
1444
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1445
|
-
Keep the visible text inside the accessible name
|
|
1446
|
-
</h3>
|
|
1447
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
1448
|
-
When an item shows text next to its icon, the
|
|
1449
|
-
<code>aria-label</code> must contain those words — "Align left"
|
|
1450
|
-
alongside the visible "Left" is fine, "Justify" is not. Otherwise
|
|
1451
|
-
speech-input users cannot activate the item by saying what they
|
|
1452
|
-
see (WCAG 2.5.3 Label in Name).
|
|
1453
|
-
</p>
|
|
1454
|
-
</div>
|
|
1455
|
-
|
|
1456
|
-
<div class="flex flex-col gap-2">
|
|
1457
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1458
|
-
The group is one tab stop
|
|
1459
|
-
</h3>
|
|
1460
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
1461
|
-
<code>Tab</code> enters the group once — landing on the pressed
|
|
1462
|
-
item, or the first one — and the arrow keys move between items,
|
|
1463
|
-
looping at the ends and stepping over disabled ones. A second
|
|
1464
|
-
<code>Tab</code> leaves the group. Do not add your own
|
|
1465
|
-
<code>tabindex</code>; it breaks this roving-focus contract
|
|
1466
|
-
(WCAG 2.1.1 Keyboard, 2.4.3 Focus Order).
|
|
1467
|
-
</p>
|
|
1468
|
-
</div>
|
|
1469
|
-
|
|
1470
|
-
<div class="flex flex-col gap-2">
|
|
1471
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1472
|
-
Do not rely on the fill alone
|
|
1473
|
-
</h3>
|
|
1474
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
1475
|
-
Selected items are filled with a muted surface, and
|
|
1476
|
-
<code>soft</code> makes that fill quieter still. Neither is the
|
|
1477
|
-
real signal: the same information reaches everyone through
|
|
1478
|
-
<code>aria-pressed</code> (WCAG 1.4.1 Use of Color). In a
|
|
1479
|
-
single-choice group that is what tells assistive technology which
|
|
1480
|
-
option is active, so never express selection by colour alone.
|
|
1481
|
-
</p>
|
|
1482
|
-
</div>
|
|
1483
|
-
|
|
1484
|
-
<div class="flex flex-col gap-2">
|
|
1485
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1486
|
-
A group is not a radio group
|
|
1487
|
-
</h3>
|
|
1488
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
1489
|
-
Even with <code>type="single"</code> the items stay toggle buttons
|
|
1490
|
-
with <code>aria-pressed</code>, not radios with
|
|
1491
|
-
<code>aria-checked</code>. If the choice is a form value that must
|
|
1492
|
-
be submitted, use <code>UiRadioGroup</code> instead; use this
|
|
1493
|
-
group for view and formatting controls that act immediately.
|
|
1494
|
-
</p>
|
|
1495
|
-
</div>
|
|
1496
|
-
|
|
1497
|
-
<div class="flex flex-col gap-2">
|
|
1498
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1499
|
-
Every size is large enough to tap
|
|
1500
|
-
</h3>
|
|
1501
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
1502
|
-
The sizes differ in padding rather than in a fixed box, and every
|
|
1503
|
-
one of them clears the 24×24px floor in WCAG 2.5.8 Target Size
|
|
1504
|
-
(Minimum) — including <code>sm</code>, and including icon-only
|
|
1505
|
-
items, which carry the target without help from a label.
|
|
1506
|
-
</p>
|
|
1507
|
-
</div>
|
|
1508
|
-
|
|
1509
|
-
<div class="flex flex-col gap-2">
|
|
1510
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1511
|
-
Selected items keep their contrast when focused
|
|
1512
|
-
</h3>
|
|
1513
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
1514
|
-
Hover, focus and press are drawn as an overlay on top of the
|
|
1515
|
-
item's own fill, so a selected item that is also focused stays
|
|
1516
|
-
readable instead of washing out. The focus ring itself only
|
|
1517
|
-
appears for keyboard focus, which is why clicking an item does not
|
|
1518
|
-
leave it looking selected (WCAG 2.4.7 Focus Visible).
|
|
1519
|
-
</p>
|
|
1520
|
-
</div>
|
|
1521
|
-
|
|
1522
|
-
<div class="flex flex-col gap-2">
|
|
1523
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
1524
|
-
Enable accessibility theme
|
|
1525
|
-
</h3>
|
|
1526
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
1527
|
-
When accessibility is required, enable our accessibility theme.
|
|
1528
|
-
This increases contrast and makes sure there are no color contrast
|
|
1529
|
-
issues.
|
|
1530
|
-
</p>
|
|
1531
|
-
</div>
|
|
1532
|
-
</div>
|
|
1533
|
-
|
|
1534
|
-
<div class="grid gap-4 md:grid-cols-2">
|
|
1535
|
-
<div class="flex flex-col gap-3">
|
|
1536
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
1537
|
-
Default
|
|
1538
|
-
</h3>
|
|
1539
|
-
<div class="flex min-h-20 flex-col items-center justify-center gap-4 border border-border-surface-default p-6">
|
|
1540
|
-
<UiToggleGroup v-model="defaultValue" type="single" variant="outline" aria-label="Text alignment">
|
|
1541
|
-
<UiToggleGroupItem v-for="item in alignmentItems" :key="item.value" :value="item.value" :aria-label="item.label">
|
|
1542
|
-
<UiIcon :name="item.icon" :size="16" />
|
|
1543
|
-
</UiToggleGroupItem>
|
|
1544
|
-
</UiToggleGroup>
|
|
1545
|
-
<UiToggleGroup v-model="defaultSoftValue" type="single" variant="outline" soft aria-label="Text alignment, soft fill">
|
|
1546
|
-
<UiToggleGroupItem v-for="item in alignmentItems" :key="item.value" :value="item.value" :aria-label="item.label">
|
|
1547
|
-
<UiIcon :name="item.icon" :size="16" />
|
|
1548
|
-
</UiToggleGroupItem>
|
|
1549
|
-
</UiToggleGroup>
|
|
1550
|
-
</div>
|
|
1551
|
-
</div>
|
|
1552
|
-
|
|
1553
|
-
<div class="accessible-theme flex flex-col gap-3">
|
|
1554
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
1555
|
-
Accessible
|
|
1556
|
-
</h3>
|
|
1557
|
-
<div class="flex min-h-20 flex-col items-center justify-center gap-4 border border-border-surface-default p-6">
|
|
1558
|
-
<UiToggleGroup v-model="accessibleValue" type="single" variant="outline" aria-label="Text alignment">
|
|
1559
|
-
<UiToggleGroupItem v-for="item in alignmentItems" :key="item.value" :value="item.value" :aria-label="item.label">
|
|
1560
|
-
<UiIcon :name="item.icon" :size="16" />
|
|
1561
|
-
</UiToggleGroupItem>
|
|
1562
|
-
</UiToggleGroup>
|
|
1563
|
-
<UiToggleGroup v-model="accessibleSoftValue" type="single" variant="outline" soft aria-label="Text alignment, soft fill">
|
|
1564
|
-
<UiToggleGroupItem v-for="item in alignmentItems" :key="item.value" :value="item.value" :aria-label="item.label">
|
|
1565
|
-
<UiIcon :name="item.icon" :size="16" />
|
|
1566
|
-
</UiToggleGroupItem>
|
|
1567
|
-
</UiToggleGroup>
|
|
1568
|
-
</div>
|
|
1569
|
-
</div>
|
|
1570
|
-
</div>
|
|
1571
|
-
</section>
|
|
1572
|
-
`,
|
|
1573
|
-
}),
|
|
1574
|
-
};
|
|
1575
|
-
|
|
1576
1598
|
// Test-only stories drive the test-runner (interactive/a11y checks) but are
|
|
1577
1599
|
// hidden from the Storybook sidebar and docs via the `!dev` / `!autodocs`
|
|
1578
1600
|
// tags. They keep the implicit `test` tag, so they still run in CI and appear
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
figma: '29211:71890'
|
|
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 Tooltip component names or clarifies the element the user is pointing at or has focused. It exists to remove ambiguity from an icon or a truncated label, in as few words as possible.
|
|
10
|
+
|
|
11
|
+
Use it for a name, a shortcut, or a short clarification. Because it appears only on hover or focus and then disappears, nothing inside it can be information the user needs — Popover and Hover Card cover those cases.
|
|
12
|
+
|
|
13
|
+
### A few words, never a paragraph
|
|
14
|
+
|
|
15
|
+
A tooltip is read in passing, so it has to be short:
|
|
16
|
+
|
|
17
|
+
- Names an icon, or spells out a truncated label
|
|
18
|
+
- Shows the keyboard shortcut for the action, where there is one
|
|
19
|
+
- Says nothing the user could not do without
|
|
20
|
+
- Never repeats a label that is already visible
|
|
21
|
+
|
|
22
|
+
### Point at the thing
|
|
23
|
+
|
|
24
|
+
Position is what attaches the words to their subject:
|
|
25
|
+
|
|
26
|
+
1. The pointer indicates the element being described
|
|
27
|
+
2. The tooltip sits close, without covering the element
|
|
28
|
+
3. It flips side rather than running off screen
|
|
29
|
+
4. One side per context, so tooltips behave predictably
|
|
30
|
+
|
|
31
|
+
### Consistency
|
|
32
|
+
|
|
33
|
+
Every tooltip is built from the same parts:
|
|
34
|
+
|
|
35
|
+
- Tooltip, default or rich
|
|
36
|
+
- Pointer: none, top, right, bottom or left
|
|
37
|
+
- Tooltip text, kept to a few words
|
|
38
|
+
- An optional keyboard shortcut
|
|
39
|
+
- One delay and one side per context
|
|
40
|
+
|
|
41
|
+
## Do
|
|
42
|
+
|
|
43
|
+
- Keep the text to a few words
|
|
44
|
+
- Use a tooltip on every icon-only control
|
|
45
|
+
- Show the keyboard shortcut alongside the name where there is one
|
|
46
|
+
- Position the tooltip close without covering its subject
|
|
47
|
+
- Flip the side rather than letting the tooltip run off screen
|
|
48
|
+
- Use the same delay throughout a product
|
|
49
|
+
|
|
50
|
+
## Don't
|
|
51
|
+
|
|
52
|
+
- Put information the user needs in a tooltip
|
|
53
|
+
- Put a link or a control inside a tooltip — use Popover
|
|
54
|
+
- Repeat a label that is already visible
|
|
55
|
+
- Write more than a line of text
|
|
56
|
+
- Cover the element the tooltip describes
|
|
57
|
+
- Appear instantly, or linger after the pointer leaves
|
|
58
|
+
|
|
59
|
+
## Accessibility
|
|
60
|
+
|
|
61
|
+
- Nothing essential lives only in a tooltip, since hover is not available to every user
|
|
62
|
+
- The tooltip appears on focus as well as on hover, so it is reachable without a pointer
|
|
63
|
+
- Text holds contrast against the tooltip's own surface, which sits over arbitrary content
|
|
64
|
+
- The tooltip does not cover its subject, so the user keeps their reference point
|
|
65
|
+
- The pointer makes the subject unambiguous where several controls sit close together
|
|
66
|
+
- Text is short enough to read before attention moves on, and legible at the tooltip's size
|