@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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
figma: '29194:70102'
|
|
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 Dialog component opens a focused task over the current page and hands the user back where they were. Everything behind it is inert, so the dialog holds the whole of the user’s attention for as long as it is open.
|
|
10
|
+
|
|
11
|
+
Use it for a short, self-contained task the user should finish without losing their place. Use Alert Dialog when the point is confirming a consequence, and a page when the task is long enough to deserve one.
|
|
12
|
+
|
|
13
|
+
### One task, finishable
|
|
14
|
+
|
|
15
|
+
A dialog is a promise that this will be quick:
|
|
16
|
+
|
|
17
|
+
- The task fits without the dialog needing to scroll on a normal screen
|
|
18
|
+
- The title names the task, not the object
|
|
19
|
+
- Every field in it belongs to that one task
|
|
20
|
+
- Closing is always possible, and never loses more than the dialog holds
|
|
21
|
+
|
|
22
|
+
### Read from title to action
|
|
23
|
+
|
|
24
|
+
The content follows a fixed order, so build it in that order:
|
|
25
|
+
|
|
26
|
+
1. Title, naming the task
|
|
27
|
+
2. Description, only where the task needs framing
|
|
28
|
+
3. Content, holding the fields or the information
|
|
29
|
+
4. Actions, with the confirming action last
|
|
30
|
+
|
|
31
|
+
### Consistency
|
|
32
|
+
|
|
33
|
+
Every dialog is built from the same parts:
|
|
34
|
+
|
|
35
|
+
- Dialog surface, at the lg or sm breakpoint
|
|
36
|
+
- Overlay, separating it from the page beneath
|
|
37
|
+
- Title, and an optional description
|
|
38
|
+
- Content slot, holding a form or text
|
|
39
|
+
- Close icon, and the cancel and confirm actions
|
|
40
|
+
|
|
41
|
+
## Do
|
|
42
|
+
|
|
43
|
+
- Name the task in the title
|
|
44
|
+
- Keep the dialog short enough to avoid scrolling at the lg breakpoint
|
|
45
|
+
- Offer both a close icon and a cancel action
|
|
46
|
+
- Label the confirming action with the verb it performs
|
|
47
|
+
- Use the sm breakpoint on narrow screens rather than shrinking lg
|
|
48
|
+
- Return the user exactly where they were on close
|
|
49
|
+
|
|
50
|
+
## Don't
|
|
51
|
+
|
|
52
|
+
- Put a long or multi-step task in a dialog
|
|
53
|
+
- Open a dialog from another dialog
|
|
54
|
+
- Remove the close icon to force a decision
|
|
55
|
+
- Use a dialog to confirm a consequence — use Alert Dialog
|
|
56
|
+
- Let the title and actions scroll away with the content
|
|
57
|
+
- Leave the user unsure what closing will discard
|
|
58
|
+
|
|
59
|
+
## Accessibility
|
|
60
|
+
|
|
61
|
+
- The dialog separates from the page by surface and elevation, not by the overlay's dimming alone
|
|
62
|
+
- Title, description, content and actions follow one another in reading order
|
|
63
|
+
- The close icon is a comfortable target and keeps a visible focus state of its own
|
|
64
|
+
- Confirm and cancel are distinguishable by shape and weight, not only by fill
|
|
65
|
+
- Text and fields keep their contrast against the dialog's own surface
|
|
66
|
+
- At the sm breakpoint the actions stay wide enough to hit and the title stays legible
|
|
@@ -14,6 +14,16 @@ import { UiButton } from '../UiButton';
|
|
|
14
14
|
import { UiField, UiFieldContent, UiFieldLabel } from '../UiField';
|
|
15
15
|
import { UiIcon } from '../UiIcon';
|
|
16
16
|
import { UiInput } from '../UiInput';
|
|
17
|
+
import {
|
|
18
|
+
accessibilityRequirementsTemplate,
|
|
19
|
+
designNotesStory,
|
|
20
|
+
guidanceLinks,
|
|
21
|
+
guidanceSectionClass,
|
|
22
|
+
parseGuidance,
|
|
23
|
+
} from '../../../.storybook/guidance';
|
|
24
|
+
import guidanceMarkdown from './UiDialog.guidance.md?raw';
|
|
25
|
+
|
|
26
|
+
const guidance = parseGuidance(guidanceMarkdown);
|
|
17
27
|
|
|
18
28
|
/**
|
|
19
29
|
* Modal dialog (reka-ui + design tokens). **`UiDialogContent`** defaults to **`max-w-[50vw]`**; use **`maxWidth`** with a preset (`max-w-sm` … `max-w-2xl`, `max-w-none`, etc.) to override. A dismiss control is pinned to the top-right corner of the panel (8px from the top and right edges) unless **`show-close-button`** is false or you use the **`#header`** slot (then add your own **`UiDialogClose`**).
|
|
@@ -39,6 +49,9 @@ const meta: Meta<typeof UiDialog> = {
|
|
|
39
49
|
open: false,
|
|
40
50
|
modal: true,
|
|
41
51
|
},
|
|
52
|
+
parameters: {
|
|
53
|
+
docs: { links: guidanceLinks(guidance) },
|
|
54
|
+
},
|
|
42
55
|
};
|
|
43
56
|
|
|
44
57
|
export default meta;
|
|
@@ -159,6 +172,83 @@ export const Default: Story = {
|
|
|
159
172
|
},
|
|
160
173
|
};
|
|
161
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Usage, guidelines, and do's and don'ts from the Figma documentation.
|
|
177
|
+
*/
|
|
178
|
+
export const DesignNotes: Story = {
|
|
179
|
+
...designNotesStory(guidance),
|
|
180
|
+
tags: ['!autodocs'],
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Accessibility guidance for labelled triggers, dialog naming, focus trap, and contrast.
|
|
185
|
+
* Shows the dialog panel inline (default vs. accessible theme) as a static preview.
|
|
186
|
+
*/
|
|
187
|
+
export const Accessibility: Story = {
|
|
188
|
+
render: () => ({
|
|
189
|
+
components: {
|
|
190
|
+
UiButton,
|
|
191
|
+
UiIcon,
|
|
192
|
+
},
|
|
193
|
+
template: `
|
|
194
|
+
<section class="${guidanceSectionClass}">
|
|
195
|
+
<div>
|
|
196
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
197
|
+
Accessibility
|
|
198
|
+
</h2>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
|
|
202
|
+
|
|
203
|
+
<div class="flex flex-col gap-6">
|
|
204
|
+
<div class="flex flex-col gap-2">
|
|
205
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
206
|
+
Enable accessibility theme
|
|
207
|
+
</h3>
|
|
208
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
209
|
+
When accessibility is required, enable our accessibility theme. This
|
|
210
|
+
increases contrast and ensures there are no color contrast issues.
|
|
211
|
+
</p>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
216
|
+
<div class="flex flex-col gap-3">
|
|
217
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
218
|
+
Default
|
|
219
|
+
</h3>
|
|
220
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
221
|
+
${accessibilityDialogPreview}
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
226
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
227
|
+
Accessible
|
|
228
|
+
</h3>
|
|
229
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
230
|
+
${accessibilityDialogPreview}
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
</section>
|
|
235
|
+
`,
|
|
236
|
+
}),
|
|
237
|
+
tags: ['!autodocs'],
|
|
238
|
+
parameters: {
|
|
239
|
+
surface: 'primary',
|
|
240
|
+
a11y: { test: 'off' },
|
|
241
|
+
chromatic: {
|
|
242
|
+
disableSnapshot: true,
|
|
243
|
+
},
|
|
244
|
+
docs: {
|
|
245
|
+
canvas: {
|
|
246
|
+
sourceState: 'none',
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
|
|
162
252
|
const contentStoryTemplateSource = `<script setup lang="ts">
|
|
163
253
|
import {
|
|
164
254
|
UiDialog,
|
|
@@ -788,72 +878,6 @@ const accessibilityDialogPreview = `
|
|
|
788
878
|
</div>
|
|
789
879
|
`;
|
|
790
880
|
|
|
791
|
-
/**
|
|
792
|
-
* Accessibility guidance for labelled triggers, dialog naming, focus trap, and contrast.
|
|
793
|
-
* Shows the dialog panel inline (default vs. accessible theme) as a static preview.
|
|
794
|
-
*/
|
|
795
|
-
export const Accessibility: Story = {
|
|
796
|
-
render: () => ({
|
|
797
|
-
components: {
|
|
798
|
-
UiButton,
|
|
799
|
-
UiIcon,
|
|
800
|
-
},
|
|
801
|
-
template: `
|
|
802
|
-
<section class="flex flex-col gap-6 p-4">
|
|
803
|
-
<div>
|
|
804
|
-
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
805
|
-
Accessibility
|
|
806
|
-
</h2>
|
|
807
|
-
</div>
|
|
808
|
-
|
|
809
|
-
<div class="flex flex-col gap-6">
|
|
810
|
-
<div class="flex flex-col gap-2">
|
|
811
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
812
|
-
Enable accessibility theme
|
|
813
|
-
</h3>
|
|
814
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
815
|
-
When accessibility is required, enable our accessibility theme. This
|
|
816
|
-
increases contrast and ensures there are no color contrast issues.
|
|
817
|
-
</p>
|
|
818
|
-
</div>
|
|
819
|
-
</div>
|
|
820
|
-
|
|
821
|
-
<div class="grid gap-4 md:grid-cols-2">
|
|
822
|
-
<div class="flex flex-col gap-3">
|
|
823
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
824
|
-
Default
|
|
825
|
-
</h3>
|
|
826
|
-
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
827
|
-
${accessibilityDialogPreview}
|
|
828
|
-
</div>
|
|
829
|
-
</div>
|
|
830
|
-
|
|
831
|
-
<div class="accessible-theme flex flex-col gap-3">
|
|
832
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
833
|
-
Accessible
|
|
834
|
-
</h3>
|
|
835
|
-
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
836
|
-
${accessibilityDialogPreview}
|
|
837
|
-
</div>
|
|
838
|
-
</div>
|
|
839
|
-
</div>
|
|
840
|
-
</section>
|
|
841
|
-
`,
|
|
842
|
-
}),
|
|
843
|
-
tags: ['!autodocs'],
|
|
844
|
-
parameters: {
|
|
845
|
-
a11y: { test: 'off' },
|
|
846
|
-
chromatic: {
|
|
847
|
-
disableSnapshot: true,
|
|
848
|
-
},
|
|
849
|
-
docs: {
|
|
850
|
-
canvas: {
|
|
851
|
-
sourceState: 'none',
|
|
852
|
-
},
|
|
853
|
-
},
|
|
854
|
-
},
|
|
855
|
-
};
|
|
856
|
-
|
|
857
881
|
/*
|
|
858
882
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
859
883
|
* Interaction & accessibility tests (play functions)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
figma: '29197:536'
|
|
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 Drawer component slides a panel in from the edge of the screen and holds a task next to the view the user came from. Because it enters from an edge, it reads as an extension of the current context rather than an interruption.
|
|
10
|
+
|
|
11
|
+
Use it where a dialog would crowd the screen, on touch and narrow layouts especially. Sheet covers the same idea on wide desktop layouts, and a page is right once the task grows past a panel.
|
|
12
|
+
|
|
13
|
+
### An extension, not an interruption
|
|
14
|
+
|
|
15
|
+
A drawer keeps the user attached to where they were:
|
|
16
|
+
|
|
17
|
+
- The task inside relates to what sits behind the drawer
|
|
18
|
+
- The header names the task, the description sets it up
|
|
19
|
+
- The panel enters from the same edge every time in a product
|
|
20
|
+
- Closing returns the user to the same scroll position
|
|
21
|
+
|
|
22
|
+
### Header, content, footer
|
|
23
|
+
|
|
24
|
+
The panel is read from top to bottom, so build it that way:
|
|
25
|
+
|
|
26
|
+
1. Header, with the title and an optional description
|
|
27
|
+
2. Content, holding the fields or the figures
|
|
28
|
+
3. Footer, holding the confirming and cancelling actions
|
|
29
|
+
4. Header and footer stay in place while the content scrolls
|
|
30
|
+
|
|
31
|
+
### Consistency
|
|
32
|
+
|
|
33
|
+
Every drawer is built from the same parts:
|
|
34
|
+
|
|
35
|
+
- Drawer panel, at the md or sm breakpoint
|
|
36
|
+
- Header, with title and description, optional
|
|
37
|
+
- Content slot, holding a form or a set of figures
|
|
38
|
+
- Footer, with the actions, optional
|
|
39
|
+
- One entry edge across a product
|
|
40
|
+
|
|
41
|
+
## Do
|
|
42
|
+
|
|
43
|
+
- Enter from the same edge everywhere in a product
|
|
44
|
+
- Keep the header and footer in place while the content scrolls
|
|
45
|
+
- Name the task in the title
|
|
46
|
+
- Use the sm breakpoint on narrow screens instead of shrinking md
|
|
47
|
+
- Return the user to the same scroll position on close
|
|
48
|
+
- Keep the actions in the footer, where they can always be reached
|
|
49
|
+
|
|
50
|
+
## Don't
|
|
51
|
+
|
|
52
|
+
- Open a drawer from another drawer
|
|
53
|
+
- Put a long, multi-step task in a drawer
|
|
54
|
+
- Let the footer actions scroll out of reach
|
|
55
|
+
- Change the entry edge between screens
|
|
56
|
+
- Use a drawer where the content is unrelated to the view behind it
|
|
57
|
+
- Remove every way of closing it
|
|
58
|
+
|
|
59
|
+
## Accessibility
|
|
60
|
+
|
|
61
|
+
- The panel separates from the page by surface and edge, not by the dimming alone
|
|
62
|
+
- Header, content and footer follow one another in reading order
|
|
63
|
+
- The footer actions stay visible and comfortable targets at the sm breakpoint
|
|
64
|
+
- Every action in the panel keeps a visible focus state
|
|
65
|
+
- Close is reachable without scrolling, wherever the content sits
|
|
66
|
+
- Entry motion is short and from a consistent edge, so the panel's arrival is predictable
|
|
@@ -12,6 +12,16 @@ import {
|
|
|
12
12
|
} from '.';
|
|
13
13
|
import { UiButton } from '../UiButton';
|
|
14
14
|
import { ref, watch } from 'vue';
|
|
15
|
+
import {
|
|
16
|
+
accessibilityRequirementsTemplate,
|
|
17
|
+
designNotesStory,
|
|
18
|
+
guidanceLinks,
|
|
19
|
+
guidanceSectionClass,
|
|
20
|
+
parseGuidance,
|
|
21
|
+
} from '../../../.storybook/guidance';
|
|
22
|
+
import guidanceMarkdown from './UiDrawer.guidance.md?raw';
|
|
23
|
+
|
|
24
|
+
const guidance = parseGuidance(guidanceMarkdown);
|
|
15
25
|
|
|
16
26
|
/**
|
|
17
27
|
* UiDrawer presents content in a bottom-sheet style overlay.
|
|
@@ -37,6 +47,9 @@ const meta: Meta<typeof UiDrawer> = {
|
|
|
37
47
|
open: false,
|
|
38
48
|
modal: true,
|
|
39
49
|
},
|
|
50
|
+
parameters: {
|
|
51
|
+
docs: { links: guidanceLinks(guidance) },
|
|
52
|
+
},
|
|
40
53
|
};
|
|
41
54
|
|
|
42
55
|
export default meta;
|
|
@@ -175,6 +188,179 @@ export const Default: Story = {
|
|
|
175
188
|
},
|
|
176
189
|
};
|
|
177
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Usage, guidelines, and do's and don'ts from the Figma documentation.
|
|
193
|
+
*/
|
|
194
|
+
export const DesignNotes: Story = {
|
|
195
|
+
...designNotesStory(guidance),
|
|
196
|
+
tags: ['!autodocs'],
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Accessibility guidance for naming the drawer, describing it, keeping it
|
|
201
|
+
* dismissible, and contrast.
|
|
202
|
+
*/
|
|
203
|
+
export const Accessibility: Story = {
|
|
204
|
+
render: () => ({
|
|
205
|
+
components: {
|
|
206
|
+
UiDrawer,
|
|
207
|
+
UiDrawerClose,
|
|
208
|
+
UiDrawerContent,
|
|
209
|
+
UiDrawerDescription,
|
|
210
|
+
UiDrawerFooter,
|
|
211
|
+
UiDrawerHeader,
|
|
212
|
+
UiDrawerTitle,
|
|
213
|
+
UiDrawerTrigger,
|
|
214
|
+
UiButton,
|
|
215
|
+
},
|
|
216
|
+
setup() {
|
|
217
|
+
const defaultOpen = ref(false);
|
|
218
|
+
const accessibleOpen = ref(false);
|
|
219
|
+
return { defaultOpen, accessibleOpen };
|
|
220
|
+
},
|
|
221
|
+
template: `
|
|
222
|
+
<section class="${guidanceSectionClass}">
|
|
223
|
+
<div>
|
|
224
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
225
|
+
Accessibility
|
|
226
|
+
</h2>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
|
|
230
|
+
|
|
231
|
+
<div class="flex flex-col gap-6">
|
|
232
|
+
<div class="flex flex-col gap-2">
|
|
233
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
234
|
+
Always include a title
|
|
235
|
+
</h3>
|
|
236
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
237
|
+
<code>UiDrawerTitle</code> becomes the drawer's accessible name
|
|
238
|
+
via <code>aria-labelledby</code>. Without it the panel is
|
|
239
|
+
announced as an unnamed dialog, and a screen-reader user has no
|
|
240
|
+
idea what just opened.
|
|
241
|
+
</p>
|
|
242
|
+
</div>
|
|
243
|
+
|
|
244
|
+
<div class="flex flex-col gap-2">
|
|
245
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
246
|
+
Describe what the drawer is for
|
|
247
|
+
</h3>
|
|
248
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
249
|
+
<code>UiDrawerDescription</code> is wired up as
|
|
250
|
+
<code>aria-describedby</code>, so it is read straight after the
|
|
251
|
+
title. Keep it to one sentence that explains the purpose rather
|
|
252
|
+
than repeating the title.
|
|
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
|
+
Keep it dismissible from the keyboard
|
|
259
|
+
</h3>
|
|
260
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
261
|
+
A modal drawer traps focus, so it must always offer a way out.
|
|
262
|
+
<code>Escape</code> closes it and focus returns to the trigger;
|
|
263
|
+
add a <code>UiDrawerClose</code> button in the footer so the exit
|
|
264
|
+
is visible too.
|
|
265
|
+
</p>
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
<div class="flex flex-col gap-2">
|
|
269
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
270
|
+
The handle is decorative
|
|
271
|
+
</h3>
|
|
272
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
273
|
+
The grab handle at the top of the sheet is presentational only —
|
|
274
|
+
it is not focusable and announces nothing. Never make it the only
|
|
275
|
+
way to close the drawer.
|
|
276
|
+
</p>
|
|
277
|
+
</div>
|
|
278
|
+
|
|
279
|
+
<div class="flex flex-col gap-2">
|
|
280
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
281
|
+
Enable accessibility theme
|
|
282
|
+
</h3>
|
|
283
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
284
|
+
When accessibility is required, enable our accessibility theme.
|
|
285
|
+
This increases contrast and makes sure there are no color
|
|
286
|
+
contrast issues.
|
|
287
|
+
</p>
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
|
|
291
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
292
|
+
<div class="flex flex-col gap-3">
|
|
293
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
294
|
+
Default
|
|
295
|
+
</h3>
|
|
296
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
297
|
+
<UiDrawer v-model:open="defaultOpen">
|
|
298
|
+
<UiDrawerTrigger as-child>
|
|
299
|
+
<UiButton variant="outline">Open Drawer</UiButton>
|
|
300
|
+
</UiDrawerTrigger>
|
|
301
|
+
<UiDrawerContent>
|
|
302
|
+
<UiDrawerHeader>
|
|
303
|
+
<UiDrawerTitle>Drawer title</UiDrawerTitle>
|
|
304
|
+
<UiDrawerDescription>
|
|
305
|
+
Review the details below before continuing.
|
|
306
|
+
</UiDrawerDescription>
|
|
307
|
+
</UiDrawerHeader>
|
|
308
|
+
<div class="p-4 pt-0 body-s-regular">Put any content here.</div>
|
|
309
|
+
<UiDrawerFooter>
|
|
310
|
+
<UiDrawerClose as-child>
|
|
311
|
+
<UiButton>Close</UiButton>
|
|
312
|
+
</UiDrawerClose>
|
|
313
|
+
</UiDrawerFooter>
|
|
314
|
+
</UiDrawerContent>
|
|
315
|
+
</UiDrawer>
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
|
|
319
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
320
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
321
|
+
Accessible
|
|
322
|
+
</h3>
|
|
323
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
324
|
+
<UiDrawer v-model:open="accessibleOpen">
|
|
325
|
+
<UiDrawerTrigger as-child>
|
|
326
|
+
<UiButton variant="outline">Open Drawer</UiButton>
|
|
327
|
+
</UiDrawerTrigger>
|
|
328
|
+
<UiDrawerContent>
|
|
329
|
+
<UiDrawerHeader>
|
|
330
|
+
<UiDrawerTitle>Drawer title</UiDrawerTitle>
|
|
331
|
+
<UiDrawerDescription>
|
|
332
|
+
Review the details below before continuing.
|
|
333
|
+
</UiDrawerDescription>
|
|
334
|
+
</UiDrawerHeader>
|
|
335
|
+
<div class="p-4 pt-0 body-s-regular">Put any content here.</div>
|
|
336
|
+
<UiDrawerFooter>
|
|
337
|
+
<UiDrawerClose as-child>
|
|
338
|
+
<UiButton>Close</UiButton>
|
|
339
|
+
</UiDrawerClose>
|
|
340
|
+
</UiDrawerFooter>
|
|
341
|
+
</UiDrawerContent>
|
|
342
|
+
</UiDrawer>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
</div>
|
|
346
|
+
</section>
|
|
347
|
+
`,
|
|
348
|
+
}),
|
|
349
|
+
tags: ['!autodocs'],
|
|
350
|
+
parameters: {
|
|
351
|
+
surface: 'primary',
|
|
352
|
+
a11y: { test: 'off' },
|
|
353
|
+
chromatic: {
|
|
354
|
+
disableSnapshot: true,
|
|
355
|
+
},
|
|
356
|
+
docs: {
|
|
357
|
+
canvas: {
|
|
358
|
+
sourceState: 'none',
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
|
|
178
364
|
const controlledTemplateSource = `<script setup lang="ts">
|
|
179
365
|
import {
|
|
180
366
|
UiDrawer,
|
|
@@ -668,168 +854,6 @@ export const OpenByDefault: Story = {
|
|
|
668
854
|
},
|
|
669
855
|
};
|
|
670
856
|
|
|
671
|
-
/**
|
|
672
|
-
* Accessibility guidance for naming the drawer, describing it, keeping it
|
|
673
|
-
* dismissible, and contrast.
|
|
674
|
-
*/
|
|
675
|
-
export const Accessibility: Story = {
|
|
676
|
-
render: () => ({
|
|
677
|
-
components: {
|
|
678
|
-
UiDrawer,
|
|
679
|
-
UiDrawerClose,
|
|
680
|
-
UiDrawerContent,
|
|
681
|
-
UiDrawerDescription,
|
|
682
|
-
UiDrawerFooter,
|
|
683
|
-
UiDrawerHeader,
|
|
684
|
-
UiDrawerTitle,
|
|
685
|
-
UiDrawerTrigger,
|
|
686
|
-
UiButton,
|
|
687
|
-
},
|
|
688
|
-
setup() {
|
|
689
|
-
const defaultOpen = ref(false);
|
|
690
|
-
const accessibleOpen = ref(false);
|
|
691
|
-
return { defaultOpen, accessibleOpen };
|
|
692
|
-
},
|
|
693
|
-
template: `
|
|
694
|
-
<section class="flex flex-col gap-6 p-4">
|
|
695
|
-
<div>
|
|
696
|
-
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
697
|
-
Accessibility
|
|
698
|
-
</h2>
|
|
699
|
-
</div>
|
|
700
|
-
|
|
701
|
-
<div class="flex flex-col gap-6">
|
|
702
|
-
<div class="flex flex-col gap-2">
|
|
703
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
704
|
-
Always include a title
|
|
705
|
-
</h3>
|
|
706
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
707
|
-
<code>UiDrawerTitle</code> becomes the drawer's accessible name
|
|
708
|
-
via <code>aria-labelledby</code>. Without it the panel is
|
|
709
|
-
announced as an unnamed dialog, and a screen-reader user has no
|
|
710
|
-
idea what just opened.
|
|
711
|
-
</p>
|
|
712
|
-
</div>
|
|
713
|
-
|
|
714
|
-
<div class="flex flex-col gap-2">
|
|
715
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
716
|
-
Describe what the drawer is for
|
|
717
|
-
</h3>
|
|
718
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
719
|
-
<code>UiDrawerDescription</code> is wired up as
|
|
720
|
-
<code>aria-describedby</code>, so it is read straight after the
|
|
721
|
-
title. Keep it to one sentence that explains the purpose rather
|
|
722
|
-
than repeating the title.
|
|
723
|
-
</p>
|
|
724
|
-
</div>
|
|
725
|
-
|
|
726
|
-
<div class="flex flex-col gap-2">
|
|
727
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
728
|
-
Keep it dismissible from the keyboard
|
|
729
|
-
</h3>
|
|
730
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
731
|
-
A modal drawer traps focus, so it must always offer a way out.
|
|
732
|
-
<code>Escape</code> closes it and focus returns to the trigger;
|
|
733
|
-
add a <code>UiDrawerClose</code> button in the footer so the exit
|
|
734
|
-
is visible too.
|
|
735
|
-
</p>
|
|
736
|
-
</div>
|
|
737
|
-
|
|
738
|
-
<div class="flex flex-col gap-2">
|
|
739
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
740
|
-
The handle is decorative
|
|
741
|
-
</h3>
|
|
742
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
743
|
-
The grab handle at the top of the sheet is presentational only —
|
|
744
|
-
it is not focusable and announces nothing. Never make it the only
|
|
745
|
-
way to close the drawer.
|
|
746
|
-
</p>
|
|
747
|
-
</div>
|
|
748
|
-
|
|
749
|
-
<div class="flex flex-col gap-2">
|
|
750
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
751
|
-
Enable accessibility theme
|
|
752
|
-
</h3>
|
|
753
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
754
|
-
When accessibility is required, enable our accessibility theme.
|
|
755
|
-
This increases contrast and makes sure there are no color
|
|
756
|
-
contrast issues.
|
|
757
|
-
</p>
|
|
758
|
-
</div>
|
|
759
|
-
</div>
|
|
760
|
-
|
|
761
|
-
<div class="grid gap-4 md:grid-cols-2">
|
|
762
|
-
<div class="flex flex-col gap-3">
|
|
763
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
764
|
-
Default
|
|
765
|
-
</h3>
|
|
766
|
-
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
767
|
-
<UiDrawer v-model:open="defaultOpen">
|
|
768
|
-
<UiDrawerTrigger as-child>
|
|
769
|
-
<UiButton variant="outline">Open Drawer</UiButton>
|
|
770
|
-
</UiDrawerTrigger>
|
|
771
|
-
<UiDrawerContent>
|
|
772
|
-
<UiDrawerHeader>
|
|
773
|
-
<UiDrawerTitle>Drawer title</UiDrawerTitle>
|
|
774
|
-
<UiDrawerDescription>
|
|
775
|
-
Review the details below before continuing.
|
|
776
|
-
</UiDrawerDescription>
|
|
777
|
-
</UiDrawerHeader>
|
|
778
|
-
<div class="p-4 pt-0 body-s-regular">Put any content here.</div>
|
|
779
|
-
<UiDrawerFooter>
|
|
780
|
-
<UiDrawerClose as-child>
|
|
781
|
-
<UiButton>Close</UiButton>
|
|
782
|
-
</UiDrawerClose>
|
|
783
|
-
</UiDrawerFooter>
|
|
784
|
-
</UiDrawerContent>
|
|
785
|
-
</UiDrawer>
|
|
786
|
-
</div>
|
|
787
|
-
</div>
|
|
788
|
-
|
|
789
|
-
<div class="accessible-theme flex flex-col gap-3">
|
|
790
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
791
|
-
Accessible
|
|
792
|
-
</h3>
|
|
793
|
-
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
794
|
-
<UiDrawer v-model:open="accessibleOpen">
|
|
795
|
-
<UiDrawerTrigger as-child>
|
|
796
|
-
<UiButton variant="outline">Open Drawer</UiButton>
|
|
797
|
-
</UiDrawerTrigger>
|
|
798
|
-
<UiDrawerContent>
|
|
799
|
-
<UiDrawerHeader>
|
|
800
|
-
<UiDrawerTitle>Drawer title</UiDrawerTitle>
|
|
801
|
-
<UiDrawerDescription>
|
|
802
|
-
Review the details below before continuing.
|
|
803
|
-
</UiDrawerDescription>
|
|
804
|
-
</UiDrawerHeader>
|
|
805
|
-
<div class="p-4 pt-0 body-s-regular">Put any content here.</div>
|
|
806
|
-
<UiDrawerFooter>
|
|
807
|
-
<UiDrawerClose as-child>
|
|
808
|
-
<UiButton>Close</UiButton>
|
|
809
|
-
</UiDrawerClose>
|
|
810
|
-
</UiDrawerFooter>
|
|
811
|
-
</UiDrawerContent>
|
|
812
|
-
</UiDrawer>
|
|
813
|
-
</div>
|
|
814
|
-
</div>
|
|
815
|
-
</div>
|
|
816
|
-
</section>
|
|
817
|
-
`,
|
|
818
|
-
}),
|
|
819
|
-
tags: ['!autodocs'],
|
|
820
|
-
parameters: {
|
|
821
|
-
a11y: { test: 'off' },
|
|
822
|
-
chromatic: {
|
|
823
|
-
disableSnapshot: true,
|
|
824
|
-
},
|
|
825
|
-
docs: {
|
|
826
|
-
canvas: {
|
|
827
|
-
sourceState: 'none',
|
|
828
|
-
},
|
|
829
|
-
},
|
|
830
|
-
},
|
|
831
|
-
};
|
|
832
|
-
|
|
833
857
|
/*
|
|
834
858
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
835
859
|
* Interaction & accessibility tests (play functions)
|