@aleph-alpha/ui-library 5.3.1 → 5.5.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/config.d.ts +38 -3
- package/config.js +103 -6
- package/dist/system/lib.js +8926 -8768
- package/dist/system/patterns/UiDataTable/UiDataTableFilterMenu.vue.d.ts +24 -0
- package/dist/system/patterns/UiDataTable/constants.d.ts +10 -0
- package/dist/system/patterns/UiDataTable/index.d.ts +1 -0
- package/dist/system/patterns/UiDataTable/types.d.ts +23 -1
- package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +173 -2
- package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +15 -1
- package/dist/system/patterns/UiFloatActions/types.d.ts +25 -1
- package/dist/system/story-sidebar-icons.json +5 -1
- package/docs/public-docs/getting-started-designers.md +3 -1
- package/package.json +5 -3
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +2 -1
- package/src/components/UiAutocomplete/UiAutocomplete.vue +5 -5
- package/src/components/UiButton/UiButton.stories.ts +14 -14
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +260 -9
- package/src/components/UiCheckbox/__tests__/UiCheckbox.test.ts +3 -18
- package/src/components/UiChip/UiChip.vue +1 -1
- package/src/components/UiDrawer/UiDrawer.stories.ts +2 -2
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +4 -4
- package/src/components/UiEmpty/UiEmpty.vue +2 -2
- package/src/components/UiField/UiField.stories.ts +610 -3
- package/src/components/UiField/UiFieldDescription.vue +7 -2
- package/src/components/UiField/UiFieldLabelInfo.vue +1 -1
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +2 -2
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +2 -2
- package/src/components/UiInput/UiInput.stories.ts +336 -2
- package/src/components/UiInput/UiInput.vue +3 -3
- package/src/components/UiInput/__tests__/UiInput.test.ts +20 -28
- package/src/components/UiItem/UiItem.stories.ts +236 -1
- package/src/components/UiItem/__tests__/UiItem.test.ts +11 -72
- package/src/components/UiKbd/UiKbd.stories.ts +14 -14
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +42 -42
- package/src/components/UiPopover/UiPopover.stories.ts +6 -6
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +2 -2
- package/src/components/UiResizable/UiResizable.stories.ts +6 -5
- package/src/components/UiSeparator/UiSeparator.stories.ts +6 -6
- package/src/components/UiSheet/UiSheet.stories.ts +2 -2
- package/src/components/UiSlider/UiSlider.stories.ts +8 -8
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +6 -6
- package/src/components/UiSnackbar/UiSnackbar.vue +4 -4
- package/src/components/UiSnackbar/UiSnackbarContent.vue +4 -4
- package/src/components/UiSpinner/UiSpinner.stories.ts +8 -8
- package/src/components/UiSwitch/UiSwitch.stories.ts +2 -2
- package/src/components/UiTabs/UiTabs.stories.ts +30 -30
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +5 -3
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +9 -9
- package/src/components/UiTooltip/UiTooltip.stories.ts +3 -3
- package/src/components/core/accordion/AccordionTrigger.vue +2 -2
- package/src/components/core/alert/AlertDescription.vue +1 -1
- package/src/components/core/badge/index.ts +1 -1
- package/src/components/core/button/index.ts +2 -2
- package/src/components/core/calendar/CalendarCellTrigger.vue +2 -2
- package/src/components/core/calendar/CalendarHeadCell.vue +1 -1
- package/src/components/core/card/CardDescription.vue +1 -1
- package/src/components/core/checkbox/Checkbox.vue +1 -2
- package/src/components/core/drawer/DrawerDescription.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuShortcut.vue +1 -1
- package/src/components/core/field/FieldDescription.vue +1 -1
- package/src/components/core/field/FieldLabel.vue +1 -1
- package/src/components/core/field/FieldSeparator.vue +1 -1
- package/src/components/core/input/Input.vue +2 -2
- package/src/components/core/item/index.ts +1 -1
- package/src/components/core/kbd/Kbd.vue +1 -1
- package/src/components/core/listbox/ListboxFilter.vue +1 -1
- package/src/components/core/listbox/ListboxGroupLabel.vue +4 -1
- package/src/components/core/listbox/ListboxItem.vue +1 -1
- package/src/components/core/native-select/NativeSelect.vue +3 -3
- package/src/components/core/navigation-menu/NavigationMenuLink.vue +1 -1
- package/src/components/core/navigation-menu/index.ts +1 -1
- package/src/components/core/radio-group/RadioGroupItem.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +2 -2
- package/src/components/core/range-calendar/RangeCalendarHeadCell.vue +1 -1
- package/src/components/core/select/SelectItem.vue +1 -1
- package/src/components/core/select/SelectLabel.vue +4 -1
- package/src/components/core/select/SelectTrigger.vue +1 -1
- package/src/components/core/sheet/SheetDescription.vue +3 -1
- package/src/components/core/switch/Switch.vue +1 -1
- package/src/components/core/table/TableCaption.vue +3 -1
- package/src/components/core/tabs/TabsList.vue +1 -1
- package/src/components/core/tabs/TabsTrigger.vue +1 -1
- package/src/components/core/tags-input/TagsInput.vue +1 -1
- package/src/components/core/tags-input/TagsInputInput.vue +1 -1
- package/src/components/core/tags-input/TagsInputItemDelete.vue +1 -1
- package/src/components/core/textarea/Textarea.vue +1 -1
- package/src/components/core/toggle/index.ts +3 -3
- package/src/components/core/toggle-group/index.ts +2 -2
- package/src/lib/useDrag.stories.ts +8 -8
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +913 -16
- package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +1 -1
- package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +91 -0
- package/src/patterns/UiDataTable/UiDataTablePagination.vue +1 -1
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +7 -184
- package/src/patterns/UiDataTable/constants.ts +12 -0
- package/src/patterns/UiDataTable/index.ts +1 -0
- package/src/patterns/UiDataTable/types.ts +24 -0
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +4 -4
- package/src/patterns/UiDatePicker/UiDatePicker.vue +1 -1
- package/src/patterns/UiFloatActions/UiFloatActionItems.vue +140 -12
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +1231 -438
- package/src/patterns/UiFloatActions/UiFloatActions.vue +1 -1
- package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +46 -24
- package/src/patterns/UiFloatActions/floatActionItemContext.ts +16 -1
- package/src/patterns/UiFloatActions/types.ts +28 -1
- package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +2 -2
- package/src/components/UiField/__tests__/UiFieldError.test.ts +0 -39
- package/src/patterns/UiFloatActions/__tests__/UiFloatActions.a11y.test.ts +0 -152
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
-
import {
|
|
2
|
+
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
3
|
+
import { reactive, ref, useId } from 'vue';
|
|
3
4
|
import UiFloatActions from './UiFloatActions.vue';
|
|
4
5
|
import { UiFloatActionItems } from './index';
|
|
5
6
|
import { UiIcon } from '../../components/UiIcon';
|
|
6
7
|
import { UiTooltip } from '../../components/UiTooltip';
|
|
8
|
+
import { UiSwitch } from '../../components/UiSwitch';
|
|
9
|
+
import { UiCheckbox } from '../../components/UiCheckbox';
|
|
7
10
|
import { useAnchorFloat } from '../../lib/useAnchorFloat';
|
|
8
11
|
import type { UiFloatActionsPlacement, UiFloatActionsTrigger } from './types';
|
|
9
12
|
|
|
@@ -89,213 +92,422 @@ const meta = {
|
|
|
89
92
|
export default meta;
|
|
90
93
|
type Story = StoryObj<typeof meta>;
|
|
91
94
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
useCardAnchor?: boolean;
|
|
97
|
-
showPagination?: boolean;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
function createFloatRender(config: FloatRenderConfig = {}) {
|
|
101
|
-
const {
|
|
102
|
-
helperText,
|
|
103
|
-
anchorText = 'Hover or Tab to this paragraph to reveal contextual actions.',
|
|
104
|
-
anchorClass = 'max-w-sm rounded-md border border-border-surface-default bg-background-surface-primary px-4 py-6 body-14-regular leading-6',
|
|
105
|
-
useCardAnchor = false,
|
|
106
|
-
showPagination = false,
|
|
107
|
-
} = config;
|
|
95
|
+
// A `UiFloatActionItems` button emits a native-style `click`. Play functions that
|
|
96
|
+
// assert the emit bind this module-level spy via `@click` and `mockClear()` it
|
|
97
|
+
// first (passing `onClick` through `args` wouldn't type-check).
|
|
98
|
+
const onItemClick = fn();
|
|
108
99
|
|
|
109
|
-
|
|
110
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Trigger modes: `hover`, `click`, `focus`, and `manual`.
|
|
102
|
+
* Each anchor renders as a focusable button, so keyboard users get the same
|
|
103
|
+
* `ui-focus-ring` treatment (matching UiButton: focus-ring border + 3px ring) as
|
|
104
|
+
* the rest of the library. Tab to any anchor to see the shared focus style.
|
|
105
|
+
*/
|
|
106
|
+
export const ShowModes: Story = {
|
|
107
|
+
name: 'Show modes',
|
|
108
|
+
render: () => ({
|
|
109
|
+
components: { UiFloatActions, UiFloatActionItems, UiIcon, UiSwitch },
|
|
111
110
|
setup() {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
const manualOpen = ref(false);
|
|
112
|
+
// `v-model` turns a toolbar into a single-select control: the active item
|
|
113
|
+
// gets the sliding background indicator.
|
|
114
|
+
const view = ref('grid');
|
|
115
|
+
const modes = [
|
|
116
|
+
{
|
|
117
|
+
trigger: 'hover' as const,
|
|
118
|
+
label: 'Hover',
|
|
119
|
+
hint: 'Point at or Tab to the anchor',
|
|
120
|
+
icon: 'edit',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
trigger: 'click' as const,
|
|
124
|
+
label: 'Click',
|
|
125
|
+
hint: 'Click or press Enter / Space',
|
|
126
|
+
icon: 'copy',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
trigger: 'focus' as const,
|
|
130
|
+
label: 'Focus',
|
|
131
|
+
hint: 'Tab to the anchor to reveal',
|
|
132
|
+
icon: 'message-circle',
|
|
120
133
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
args,
|
|
133
|
-
open,
|
|
134
|
-
page,
|
|
135
|
-
total,
|
|
136
|
-
previousPage,
|
|
137
|
-
nextPage,
|
|
138
|
-
helperText,
|
|
139
|
-
anchorText,
|
|
140
|
-
anchorClass,
|
|
141
|
-
useCardAnchor,
|
|
142
|
-
showPagination,
|
|
143
|
-
};
|
|
134
|
+
{
|
|
135
|
+
trigger: 'manual' as const,
|
|
136
|
+
label: 'Manual',
|
|
137
|
+
hint: 'Controlled via v-model:open',
|
|
138
|
+
icon: 'star',
|
|
139
|
+
},
|
|
140
|
+
];
|
|
141
|
+
return { modes, manualOpen, view };
|
|
144
142
|
},
|
|
145
143
|
template: `
|
|
146
|
-
<div
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
:trigger="args.trigger"
|
|
153
|
-
:placement="args.placement"
|
|
154
|
-
:offset="args.offset"
|
|
155
|
-
:open-delay="args.openDelay"
|
|
156
|
-
:close-delay="args.closeDelay"
|
|
157
|
-
:dismiss-on-outside-click="args.dismissOnOutsideClick"
|
|
158
|
-
:dismiss-on-escape="args.dismissOnEscape"
|
|
159
|
-
:aria-label="args.ariaLabel"
|
|
144
|
+
<div class="flex min-h-96 flex-col items-center gap-10 p-8">
|
|
145
|
+
<div class="grid w-full grid-cols-1 place-items-center gap-10 md:grid-cols-2">
|
|
146
|
+
<div
|
|
147
|
+
v-for="mode in modes"
|
|
148
|
+
:key="mode.trigger"
|
|
149
|
+
class="flex flex-col items-center gap-3"
|
|
160
150
|
>
|
|
161
|
-
<
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
<
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
</UiFloatActionItems>
|
|
179
|
-
<UiFloatActionItems v-if="showPagination" type="separator" />
|
|
180
|
-
<UiFloatActionItems v-if="showPagination" type="group">
|
|
181
|
-
<UiFloatActionItems
|
|
182
|
-
type="button"
|
|
183
|
-
aria-label="Previous match"
|
|
184
|
-
:disabled="page <= 1"
|
|
185
|
-
@click="previousPage"
|
|
186
|
-
>
|
|
187
|
-
<UiIcon name="chevron-left" size="s" />
|
|
151
|
+
<span class="label-14-medium text-content-on-surface-secondary">{{ mode.label }}</span>
|
|
152
|
+
<UiFloatActions
|
|
153
|
+
:trigger="mode.trigger"
|
|
154
|
+
:open="mode.trigger === 'manual' ? manualOpen : undefined"
|
|
155
|
+
placement="top"
|
|
156
|
+
:offset="10"
|
|
157
|
+
:aria-label="mode.label + ' actions'"
|
|
158
|
+
>
|
|
159
|
+
<template #container>
|
|
160
|
+
<span class="rounded-md border border-border-surface-default bg-background-surface-primary px-4 py-2 body-14-regular">
|
|
161
|
+
{{ mode.hint }}
|
|
162
|
+
</span>
|
|
163
|
+
</template>
|
|
164
|
+
<template #action>
|
|
165
|
+
<UiFloatActionItems :aria-label="mode.label + ' actions'">
|
|
166
|
+
<UiFloatActionItems type="button" :aria-label="mode.label">
|
|
167
|
+
<UiIcon :name="mode.icon" size="s" />
|
|
188
168
|
</UiFloatActionItems>
|
|
189
|
-
<UiFloatActionItems type="
|
|
190
|
-
|
|
191
|
-
type="button"
|
|
192
|
-
aria-label="Next match"
|
|
193
|
-
:disabled="page >= total"
|
|
194
|
-
@click="nextPage"
|
|
195
|
-
>
|
|
196
|
-
<UiIcon name="chevron-right" size="s" />
|
|
169
|
+
<UiFloatActionItems type="button" aria-label="More">
|
|
170
|
+
<UiIcon name="more-vertical" size="s" />
|
|
197
171
|
</UiFloatActionItems>
|
|
198
172
|
</UiFloatActionItems>
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
173
|
+
</template>
|
|
174
|
+
</UiFloatActions>
|
|
175
|
+
<label
|
|
176
|
+
v-if="mode.trigger === 'manual'"
|
|
177
|
+
class="flex items-center gap-2 label-14-regular text-content-on-surface-secondary"
|
|
178
|
+
>
|
|
179
|
+
<UiSwitch v-model="manualOpen" name="manual-open" />
|
|
180
|
+
{{ manualOpen ? 'Open' : 'Closed' }}
|
|
181
|
+
</label>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div class="grid w-full grid-cols-1 place-items-center gap-10 md:grid-cols-2">
|
|
186
|
+
<!-- Clickable: stateless action buttons revealed on hover -->
|
|
187
|
+
<div class="flex flex-col items-center gap-3">
|
|
188
|
+
<span class="label-14-medium text-content-on-surface-secondary">Clickable</span>
|
|
189
|
+
<UiFloatActions trigger="hover" placement="top" :offset="10" aria-label="Clickable actions">
|
|
190
|
+
<template #container>
|
|
191
|
+
<span class="rounded-md border border-border-surface-default bg-background-surface-primary px-4 py-2 body-14-regular">
|
|
192
|
+
Hover to reveal actions
|
|
193
|
+
</span>
|
|
194
|
+
</template>
|
|
195
|
+
<template #action>
|
|
196
|
+
<UiFloatActionItems aria-label="Clickable actions">
|
|
197
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
198
|
+
<UiIcon name="edit" size="s" />
|
|
199
|
+
</UiFloatActionItems>
|
|
200
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
201
|
+
<UiIcon name="copy" size="s" />
|
|
202
202
|
</UiFloatActionItems>
|
|
203
203
|
<UiFloatActionItems type="button" aria-label="Delete">
|
|
204
204
|
<UiIcon name="trash" size="s" />
|
|
205
205
|
</UiFloatActionItems>
|
|
206
|
-
</
|
|
206
|
+
</UiFloatActionItems>
|
|
207
|
+
</template>
|
|
208
|
+
</UiFloatActions>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<!-- Selectable (v-model): single-select with the sliding indicator, revealed on hover -->
|
|
212
|
+
<div class="flex flex-col items-center gap-3">
|
|
213
|
+
<span class="label-14-medium text-content-on-surface-secondary">Selectable (v-model)</span>
|
|
214
|
+
<UiFloatActions trigger="hover" placement="top" :offset="10" aria-label="Selectable view mode">
|
|
215
|
+
<template #container>
|
|
216
|
+
<span class="rounded-md border border-border-surface-default bg-background-surface-primary px-4 py-2 body-14-regular">
|
|
217
|
+
Hover to reveal view modes
|
|
218
|
+
</span>
|
|
219
|
+
</template>
|
|
220
|
+
<template #action>
|
|
221
|
+
<UiFloatActionItems v-model="view" aria-label="View mode">
|
|
222
|
+
<UiFloatActionItems type="button" value="grid" aria-label="Grid" class="w-auto gap-1.5 px-3 label-14-medium">
|
|
223
|
+
<UiIcon name="layout-grid" size="s" />Grid
|
|
224
|
+
</UiFloatActionItems>
|
|
225
|
+
<UiFloatActionItems type="button" value="list" aria-label="List" class="w-auto gap-1.5 px-3 label-14-medium">
|
|
226
|
+
<UiIcon name="list" size="s" />List
|
|
227
|
+
</UiFloatActionItems>
|
|
228
|
+
<UiFloatActionItems type="button" value="table" aria-label="Table" class="w-auto gap-1.5 px-3 label-14-medium">
|
|
229
|
+
<UiIcon name="table" size="s" />Table
|
|
230
|
+
</UiFloatActionItems>
|
|
231
|
+
</UiFloatActionItems>
|
|
232
|
+
</template>
|
|
233
|
+
</UiFloatActions>
|
|
234
|
+
<span class="label-12-regular text-content-on-surface-muted">Selected: {{ view }}</span>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
`,
|
|
239
|
+
}),
|
|
240
|
+
parameters: {
|
|
241
|
+
controls: { disable: true },
|
|
242
|
+
docs: { canvas: { sourceState: 'none' } },
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* A gallery of common `UiFloatActionItems` toolbar compositions.
|
|
248
|
+
* These are **examples** only — mix and match the item types (`button`, `text`,
|
|
249
|
+
* `input`, `separator`, `group`) and `orientation` to build your own toolbars.
|
|
250
|
+
*/
|
|
251
|
+
export const Examples: Story = {
|
|
252
|
+
name: 'Item examples',
|
|
253
|
+
render: () => ({
|
|
254
|
+
components: { UiFloatActionItems, UiIcon, UiCheckbox },
|
|
255
|
+
setup() {
|
|
256
|
+
// Toggle to turn the labelled (icon + text / text) toolbars into `v-model`
|
|
257
|
+
// single-select controls — each active item then shows the sliding
|
|
258
|
+
// background indicator. Icon-only and input toolbars stay stateless.
|
|
259
|
+
const withModel = ref(true);
|
|
260
|
+
const selection = reactive({
|
|
261
|
+
labels: 'fullscreen',
|
|
262
|
+
text: 'fullscreen',
|
|
263
|
+
vLabels: 'fullscreen',
|
|
264
|
+
vText: 'fullscreen',
|
|
265
|
+
});
|
|
266
|
+
return { withModel, selection };
|
|
267
|
+
},
|
|
268
|
+
template: `
|
|
269
|
+
<div class="flex min-h-96 flex-col items-center gap-8 p-8">
|
|
270
|
+
<p class="max-w-md text-center body-14-regular text-content-on-surface-secondary">
|
|
271
|
+
These are examples — combine the item types and orientation to compose your own toolbars.
|
|
272
|
+
</p>
|
|
273
|
+
|
|
274
|
+
<label class="flex items-center gap-2 label-14-medium text-content-on-surface-secondary">
|
|
275
|
+
<UiCheckbox name="examples-with-model" v-model="withModel" />
|
|
276
|
+
Enable v-model (active indicator)
|
|
277
|
+
</label>
|
|
278
|
+
|
|
279
|
+
<div class="grid grid-cols-[auto_1fr] items-center gap-x-6 gap-y-8">
|
|
280
|
+
<!-- Labelled toolbars (icon + text / text) support v-model in every orientation -->
|
|
281
|
+
<!-- Icon + text buttons -->
|
|
282
|
+
<UiFloatActionItems
|
|
283
|
+
aria-label="View options with labels"
|
|
284
|
+
class="justify-self-center"
|
|
285
|
+
:model-value="withModel ? selection.labels : undefined"
|
|
286
|
+
@update:model-value="selection.labels = $event"
|
|
287
|
+
>
|
|
288
|
+
<UiFloatActionItems type="button" value="fullscreen" aria-label="Fullscreen" class="w-auto gap-1.5 px-3 label-14-medium">
|
|
289
|
+
<UiIcon name="maximize" size="s" />Fullscreen
|
|
207
290
|
</UiFloatActionItems>
|
|
208
|
-
|
|
209
|
-
|
|
291
|
+
<UiFloatActionItems type="button" value="sidebar" aria-label="Sidebar" class="w-auto gap-1.5 px-3 label-14-medium">
|
|
292
|
+
<UiIcon name="panel-left" size="s" />Sidebar
|
|
293
|
+
</UiFloatActionItems>
|
|
294
|
+
<UiFloatActionItems type="button" value="dashboard" aria-label="Dashboard" class="w-auto gap-1.5 px-3 label-14-medium">
|
|
295
|
+
<UiIcon name="layout-grid" size="s" />Dashboard
|
|
296
|
+
</UiFloatActionItems>
|
|
297
|
+
</UiFloatActionItems>
|
|
298
|
+
<span class="label-14-regular text-content-on-surface-secondary">button (icon + text)</span>
|
|
299
|
+
|
|
300
|
+
<!-- Text-only buttons -->
|
|
301
|
+
<UiFloatActionItems
|
|
302
|
+
aria-label="View options"
|
|
303
|
+
class="justify-self-center"
|
|
304
|
+
:model-value="withModel ? selection.text : undefined"
|
|
305
|
+
@update:model-value="selection.text = $event"
|
|
306
|
+
>
|
|
307
|
+
<UiFloatActionItems type="button" value="fullscreen" aria-label="Fullscreen" class="w-auto px-3 label-14-medium">
|
|
308
|
+
Fullscreen
|
|
309
|
+
</UiFloatActionItems>
|
|
310
|
+
<UiFloatActionItems type="button" value="sidebar" aria-label="Sidebar" class="w-auto px-3 label-14-medium">
|
|
311
|
+
Sidebar
|
|
312
|
+
</UiFloatActionItems>
|
|
313
|
+
<UiFloatActionItems type="button" value="dashboard" aria-label="Dashboard" class="w-auto px-3 label-14-medium">
|
|
314
|
+
Dashboard
|
|
315
|
+
</UiFloatActionItems>
|
|
316
|
+
</UiFloatActionItems>
|
|
317
|
+
<span class="label-14-regular text-content-on-surface-secondary">button (text)</span>
|
|
318
|
+
|
|
319
|
+
<!-- Vertical with icon + text -->
|
|
320
|
+
<UiFloatActionItems
|
|
321
|
+
aria-label="Vertical view options with labels"
|
|
322
|
+
orientation="vertical"
|
|
323
|
+
class="justify-self-center"
|
|
324
|
+
:model-value="withModel ? selection.vLabels : undefined"
|
|
325
|
+
@update:model-value="selection.vLabels = $event"
|
|
326
|
+
>
|
|
327
|
+
<UiFloatActionItems type="button" value="fullscreen" aria-label="Fullscreen" class="w-full justify-start gap-1.5 px-3 label-14-medium">
|
|
328
|
+
<UiIcon name="maximize" size="s" />Fullscreen
|
|
329
|
+
</UiFloatActionItems>
|
|
330
|
+
<UiFloatActionItems type="button" value="sidebar" aria-label="Sidebar" class="w-full justify-start gap-1.5 px-3 label-14-medium">
|
|
331
|
+
<UiIcon name="panel-left" size="s" />Sidebar
|
|
332
|
+
</UiFloatActionItems>
|
|
333
|
+
<UiFloatActionItems type="button" value="dashboard" aria-label="Dashboard" class="w-full justify-start gap-1.5 px-3 label-14-medium">
|
|
334
|
+
<UiIcon name="layout-grid" size="s" />Dashboard
|
|
335
|
+
</UiFloatActionItems>
|
|
336
|
+
</UiFloatActionItems>
|
|
337
|
+
<span class="label-14-regular text-content-on-surface-secondary">button (icon + text) · vertical</span>
|
|
338
|
+
|
|
339
|
+
<!-- Vertical text only -->
|
|
340
|
+
<UiFloatActionItems
|
|
341
|
+
aria-label="Vertical view options"
|
|
342
|
+
orientation="vertical"
|
|
343
|
+
class="justify-self-center"
|
|
344
|
+
:model-value="withModel ? selection.vText : undefined"
|
|
345
|
+
@update:model-value="selection.vText = $event"
|
|
346
|
+
>
|
|
347
|
+
<UiFloatActionItems type="button" value="fullscreen" aria-label="Fullscreen" class="w-full justify-start px-3 label-14-medium">
|
|
348
|
+
Fullscreen
|
|
349
|
+
</UiFloatActionItems>
|
|
350
|
+
<UiFloatActionItems type="button" value="sidebar" aria-label="Sidebar" class="w-full justify-start px-3 label-14-medium">
|
|
351
|
+
Sidebar
|
|
352
|
+
</UiFloatActionItems>
|
|
353
|
+
<UiFloatActionItems type="button" value="dashboard" aria-label="Dashboard" class="w-full justify-start px-3 label-14-medium">
|
|
354
|
+
Dashboard
|
|
355
|
+
</UiFloatActionItems>
|
|
356
|
+
</UiFloatActionItems>
|
|
357
|
+
<span class="label-14-regular text-content-on-surface-secondary">button (text) · vertical</span>
|
|
358
|
+
|
|
359
|
+
<!-- Stateless toolbars (icon-only and inputs) — no v-model -->
|
|
360
|
+
<!-- Icon-only buttons -->
|
|
361
|
+
<UiFloatActionItems aria-label="View options icons" class="justify-self-center">
|
|
362
|
+
<UiFloatActionItems type="button" aria-label="Fullscreen">
|
|
363
|
+
<UiIcon name="maximize" size="s" />
|
|
364
|
+
</UiFloatActionItems>
|
|
365
|
+
<UiFloatActionItems type="button" aria-label="Sidebar">
|
|
366
|
+
<UiIcon name="panel-left" size="s" />
|
|
367
|
+
</UiFloatActionItems>
|
|
368
|
+
<UiFloatActionItems type="button" aria-label="Dashboard">
|
|
369
|
+
<UiIcon name="layout-grid" size="s" />
|
|
370
|
+
</UiFloatActionItems>
|
|
371
|
+
</UiFloatActionItems>
|
|
372
|
+
<span class="label-14-regular text-content-on-surface-secondary">button (icon only)</span>
|
|
373
|
+
|
|
374
|
+
<!-- Icon-only buttons (edit actions) -->
|
|
375
|
+
<UiFloatActionItems aria-label="Edit actions" class="justify-self-center">
|
|
376
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
377
|
+
<UiIcon name="edit" size="s" />
|
|
378
|
+
</UiFloatActionItems>
|
|
379
|
+
<UiFloatActionItems type="button" aria-label="Delete">
|
|
380
|
+
<UiIcon name="trash" size="s" />
|
|
381
|
+
</UiFloatActionItems>
|
|
382
|
+
</UiFloatActionItems>
|
|
383
|
+
<span class="label-14-regular text-content-on-surface-secondary">button (icon only)</span>
|
|
384
|
+
|
|
385
|
+
<!-- With input (pagination) -->
|
|
386
|
+
<UiFloatActionItems aria-label="Pagination" class="justify-self-center">
|
|
387
|
+
<UiFloatActionItems type="button" aria-label="Previous page">
|
|
388
|
+
<UiIcon name="chevron-left" size="s" />
|
|
389
|
+
</UiFloatActionItems>
|
|
390
|
+
<UiFloatActionItems type="input" aria-label="Page number" placeholder="0/0" class="w-14 text-center" />
|
|
391
|
+
<UiFloatActionItems type="button" aria-label="Next page">
|
|
392
|
+
<UiIcon name="chevron-right" size="s" />
|
|
393
|
+
</UiFloatActionItems>
|
|
394
|
+
</UiFloatActionItems>
|
|
395
|
+
<span class="label-14-regular text-content-on-surface-secondary">button + input + button</span>
|
|
396
|
+
|
|
397
|
+
<!-- With input (zoom level) -->
|
|
398
|
+
<UiFloatActionItems aria-label="Zoom" class="justify-self-center">
|
|
399
|
+
<UiFloatActionItems type="button" aria-label="Zoom out">
|
|
400
|
+
<UiIcon name="minus" size="s" />
|
|
401
|
+
</UiFloatActionItems>
|
|
402
|
+
<UiFloatActionItems type="input" aria-label="Zoom level" placeholder="100%" class="w-16 text-center" />
|
|
403
|
+
<UiFloatActionItems type="button" aria-label="Zoom in">
|
|
404
|
+
<UiIcon name="plus" size="s" />
|
|
405
|
+
</UiFloatActionItems>
|
|
406
|
+
</UiFloatActionItems>
|
|
407
|
+
<span class="label-14-regular text-content-on-surface-secondary">button + input + button</span>
|
|
408
|
+
</div>
|
|
210
409
|
</div>
|
|
211
410
|
`,
|
|
212
|
-
})
|
|
213
|
-
|
|
411
|
+
}),
|
|
412
|
+
parameters: {
|
|
413
|
+
controls: { disable: true },
|
|
414
|
+
docs: {
|
|
415
|
+
canvas: { sourceState: 'none' },
|
|
416
|
+
description: {
|
|
417
|
+
story:
|
|
418
|
+
'Example toolbars grouped by kind: the labelled variants (icon + text and text only, in both orientations) support v-model — toggle "Enable v-model" to give them a sliding active indicator. Below them, the stateless icon-only and input toolbars (edit actions, pagination, zoom) stay plain. These are examples — adapt them to your use case.',
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
};
|
|
214
423
|
|
|
215
|
-
const
|
|
424
|
+
const iconOnlyWithTooltipSource = `<script setup lang="ts">
|
|
216
425
|
import { UiFloatActions, UiFloatActionItems, UiIcon, UiTooltip } from '@aleph-alpha/ui-library';
|
|
217
426
|
</script>
|
|
218
427
|
|
|
219
428
|
<template>
|
|
220
|
-
<UiFloatActions trigger="hover" placement="top" :offset="10">
|
|
429
|
+
<UiFloatActions trigger="hover" placement="top" :offset="10" :open="true">
|
|
221
430
|
<template #container>
|
|
222
|
-
<p>Hover
|
|
431
|
+
<p>Hover an icon to reveal its tooltip.</p>
|
|
223
432
|
</template>
|
|
433
|
+
<!-- Teleport each tooltip into the top-layer panel (:to="panelEl") so it is
|
|
434
|
+
not painted underneath it. Use the tooltip's \`side\` to place it. -->
|
|
224
435
|
<template #action="{ panelEl }">
|
|
225
|
-
<UiFloatActionItems aria-label="
|
|
226
|
-
|
|
227
|
-
Teleport the tooltip into the top-layer panel (:to="panelEl") so it
|
|
228
|
-
is not painted underneath it. -->
|
|
229
|
-
<UiTooltip content="Edit" :to="panelEl">
|
|
436
|
+
<UiFloatActionItems aria-label="Icon actions">
|
|
437
|
+
<UiTooltip content="Top" side="top" :to="panelEl" delayDuration={0}>
|
|
230
438
|
<UiFloatActionItems type="button" aria-label="Edit">
|
|
231
439
|
<UiIcon name="edit" size="s" />
|
|
232
440
|
</UiFloatActionItems>
|
|
233
441
|
</UiTooltip>
|
|
234
|
-
<UiTooltip content="
|
|
442
|
+
<UiTooltip content="Right" side="right" :to="panelEl" delayDuration={0}>
|
|
235
443
|
<UiFloatActionItems type="button" aria-label="Copy">
|
|
236
444
|
<UiIcon name="copy" size="s" />
|
|
237
445
|
</UiFloatActionItems>
|
|
238
446
|
</UiTooltip>
|
|
447
|
+
<UiTooltip content="Bottom" side="bottom" :to="panelEl" delayDuration={0}>
|
|
448
|
+
<UiFloatActionItems type="button" aria-label="Comment">
|
|
449
|
+
<UiIcon name="message-circle" size="s" />
|
|
450
|
+
</UiFloatActionItems>
|
|
451
|
+
</UiTooltip>
|
|
452
|
+
<UiTooltip content="Left" side="left" :to="panelEl" delayDuration={0}>
|
|
453
|
+
<UiFloatActionItems type="button" aria-label="Delete">
|
|
454
|
+
<UiIcon name="trash" size="s" />
|
|
455
|
+
</UiFloatActionItems>
|
|
456
|
+
</UiTooltip>
|
|
239
457
|
</UiFloatActionItems>
|
|
240
458
|
</template>
|
|
241
459
|
</UiFloatActions>
|
|
242
460
|
</template>`;
|
|
243
461
|
|
|
244
462
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
463
|
+
* Icon-only actions where each button is named by a `UiTooltip`.
|
|
464
|
+
* Tooltips are placed on all four sides — `right`, `top`, `bottom`, `left` — via
|
|
465
|
+
* the tooltip `side` prop. Teleport each tooltip into the panel (`:to="panelEl"`)
|
|
466
|
+
* so it shares the panel's top layer instead of rendering beneath it.
|
|
249
467
|
*/
|
|
250
|
-
export const
|
|
251
|
-
|
|
468
|
+
export const IconOnlyWithTooltip: Story = {
|
|
469
|
+
name: 'Icon only with tooltip',
|
|
470
|
+
render: () => ({
|
|
252
471
|
components: { UiFloatActions, UiFloatActionItems, UiIcon, UiTooltip },
|
|
253
472
|
setup() {
|
|
254
|
-
const open = ref(
|
|
255
|
-
|
|
256
|
-
() => args?.open,
|
|
257
|
-
(value) => {
|
|
258
|
-
if (value !== undefined) open.value = value;
|
|
259
|
-
},
|
|
260
|
-
);
|
|
261
|
-
return { args, open };
|
|
473
|
+
const open = ref(false);
|
|
474
|
+
return { open };
|
|
262
475
|
},
|
|
263
476
|
template: `
|
|
264
|
-
<div class="flex min-h-64 flex-col items-center justify-center gap-
|
|
477
|
+
<div class="flex min-h-64 flex-col items-center justify-center gap-4 p-8">
|
|
478
|
+
<p class="max-w-sm text-center body-14-regular text-content-on-surface-secondary">
|
|
479
|
+
Hover or focus each icon to reveal its tooltip on a different side.
|
|
480
|
+
</p>
|
|
265
481
|
<UiFloatActions
|
|
266
482
|
v-model:open="open"
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
:offset="
|
|
270
|
-
|
|
271
|
-
:close-delay="args.closeDelay"
|
|
272
|
-
:dismiss-on-outside-click="args.dismissOnOutsideClick"
|
|
273
|
-
:dismiss-on-escape="args.dismissOnEscape"
|
|
274
|
-
:aria-label="args.ariaLabel"
|
|
483
|
+
trigger="hover"
|
|
484
|
+
placement="top"
|
|
485
|
+
:offset="10"
|
|
486
|
+
aria-label="Icon actions"
|
|
275
487
|
>
|
|
276
488
|
<template #container>
|
|
277
|
-
<
|
|
278
|
-
|
|
279
|
-
</
|
|
489
|
+
<span class="rounded-md border border-border-surface-default bg-background-surface-primary px-4 py-2 body-14-regular">
|
|
490
|
+
Icon toolbar
|
|
491
|
+
</span>
|
|
280
492
|
</template>
|
|
281
493
|
<template #action="{ panelEl }">
|
|
282
|
-
<UiFloatActionItems aria-label="
|
|
283
|
-
<UiTooltip content="
|
|
494
|
+
<UiFloatActionItems aria-label="Icon actions">
|
|
495
|
+
<UiTooltip content="Right" side="right" :to="panelEl" delayDuration={0}>
|
|
284
496
|
<UiFloatActionItems type="button" aria-label="Edit">
|
|
285
497
|
<UiIcon name="edit" size="s" />
|
|
286
498
|
</UiFloatActionItems>
|
|
287
499
|
</UiTooltip>
|
|
288
|
-
<UiTooltip content="
|
|
500
|
+
<UiTooltip content="Top" side="top" :to="panelEl" delayDuration={0}>
|
|
289
501
|
<UiFloatActionItems type="button" aria-label="Copy">
|
|
290
502
|
<UiIcon name="copy" size="s" />
|
|
291
503
|
</UiFloatActionItems>
|
|
292
504
|
</UiTooltip>
|
|
293
|
-
<UiTooltip content="
|
|
505
|
+
<UiTooltip content="Bottom" side="bottom" :to="panelEl" delayDuration={0}>
|
|
294
506
|
<UiFloatActionItems type="button" aria-label="Comment">
|
|
295
507
|
<UiIcon name="message-circle" size="s" />
|
|
296
508
|
</UiFloatActionItems>
|
|
297
509
|
</UiTooltip>
|
|
298
|
-
<UiTooltip content="
|
|
510
|
+
<UiTooltip content="Left" side="left" :to="panelEl" delayDuration={0}>
|
|
299
511
|
<UiFloatActionItems type="button" aria-label="Delete">
|
|
300
512
|
<UiIcon name="trash" size="s" />
|
|
301
513
|
</UiFloatActionItems>
|
|
@@ -307,18 +519,19 @@ export const FlatActions: Story = {
|
|
|
307
519
|
`,
|
|
308
520
|
}),
|
|
309
521
|
parameters: {
|
|
310
|
-
|
|
522
|
+
controls: { disable: true },
|
|
523
|
+
docs: { source: { code: iconOnlyWithTooltipSource } },
|
|
311
524
|
},
|
|
312
525
|
};
|
|
313
526
|
|
|
314
|
-
const
|
|
527
|
+
const buttonWithTextSource = `<script setup lang="ts">
|
|
315
528
|
import { UiFloatActions, UiFloatActionItems, UiIcon } from '@aleph-alpha/ui-library';
|
|
316
529
|
</script>
|
|
317
530
|
|
|
318
531
|
<template>
|
|
319
|
-
<UiFloatActions trigger="click" placement="bottom" :offset="10" aria-label="
|
|
532
|
+
<UiFloatActions trigger="click" placement="bottom" :offset="10" aria-label="Text actions">
|
|
320
533
|
<template #container>
|
|
321
|
-
<p>Click
|
|
534
|
+
<p>Click to toggle a labelled toolbar.</p>
|
|
322
535
|
</template>
|
|
323
536
|
<template #action>
|
|
324
537
|
<UiFloatActionItems aria-label="Text actions">
|
|
@@ -329,52 +542,40 @@ import { UiFloatActions, UiFloatActionItems, UiIcon } from '@aleph-alpha/ui-libr
|
|
|
329
542
|
<UiFloatActionItems type="button" aria-label="Copy" class="w-auto gap-1.5 px-3 label-14-medium">
|
|
330
543
|
<UiIcon name="copy" size="s" />Copy
|
|
331
544
|
</UiFloatActionItems>
|
|
545
|
+
<UiFloatActionItems type="button" aria-label="Delete" class="w-auto gap-1.5 px-3 label-14-medium">
|
|
546
|
+
<UiIcon name="trash" size="s" />Delete
|
|
547
|
+
</UiFloatActionItems>
|
|
332
548
|
</UiFloatActionItems>
|
|
333
549
|
</template>
|
|
334
550
|
</UiFloatActions>
|
|
335
551
|
</template>`;
|
|
336
552
|
|
|
337
553
|
/**
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
* for screen readers. Enter and Space also toggle the panel.
|
|
554
|
+
* Actions that pair an icon with a visible text label.
|
|
555
|
+
* A readable label makes the action self-describing, so no tooltip is required.
|
|
556
|
+
* Widen the button (`w-auto`) and add horizontal padding to fit the text.
|
|
342
557
|
*/
|
|
343
|
-
export const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
placement: 'bottom',
|
|
347
|
-
ariaLabel: 'Open text actions',
|
|
348
|
-
},
|
|
349
|
-
render: (args) => ({
|
|
558
|
+
export const ButtonWithText: Story = {
|
|
559
|
+
name: 'Button with text (no tooltip)',
|
|
560
|
+
render: () => ({
|
|
350
561
|
components: { UiFloatActions, UiFloatActionItems, UiIcon },
|
|
351
562
|
setup() {
|
|
352
|
-
const open = ref(
|
|
353
|
-
|
|
354
|
-
() => args?.open,
|
|
355
|
-
(value) => {
|
|
356
|
-
if (value !== undefined) open.value = value;
|
|
357
|
-
},
|
|
358
|
-
);
|
|
359
|
-
return { args, open };
|
|
563
|
+
const open = ref(false);
|
|
564
|
+
return { open };
|
|
360
565
|
},
|
|
361
566
|
template: `
|
|
362
567
|
<div class="flex min-h-64 flex-col items-center justify-center gap-3 p-8">
|
|
363
568
|
<UiFloatActions
|
|
364
569
|
v-model:open="open"
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
:offset="
|
|
368
|
-
|
|
369
|
-
:close-delay="args.closeDelay"
|
|
370
|
-
:dismiss-on-outside-click="args.dismissOnOutsideClick"
|
|
371
|
-
:dismiss-on-escape="args.dismissOnEscape"
|
|
372
|
-
:aria-label="args.ariaLabel"
|
|
570
|
+
trigger="hover"
|
|
571
|
+
placement="top"
|
|
572
|
+
:offset="10"
|
|
573
|
+
aria-label="Text actions"
|
|
373
574
|
>
|
|
374
575
|
<template #container>
|
|
375
|
-
<
|
|
376
|
-
|
|
377
|
-
</
|
|
576
|
+
<span class="rounded-md border border-border-surface-default bg-background-surface-primary px-4 py-2 body-14-regular">
|
|
577
|
+
Labelled toolbar
|
|
578
|
+
</span>
|
|
378
579
|
</template>
|
|
379
580
|
<template #action>
|
|
380
581
|
<UiFloatActionItems aria-label="Text actions">
|
|
@@ -384,6 +585,9 @@ export const ClickTrigger: Story = {
|
|
|
384
585
|
<UiFloatActionItems type="button" aria-label="Copy" class="w-auto gap-1.5 px-3 label-14-medium">
|
|
385
586
|
<UiIcon name="copy" size="s" />Copy
|
|
386
587
|
</UiFloatActionItems>
|
|
588
|
+
<UiFloatActionItems type="button" aria-label="Delete" class="w-auto gap-1.5 px-3 label-14-medium">
|
|
589
|
+
<UiIcon name="trash" size="s" />Delete
|
|
590
|
+
</UiFloatActionItems>
|
|
387
591
|
</UiFloatActionItems>
|
|
388
592
|
</template>
|
|
389
593
|
</UiFloatActions>
|
|
@@ -391,203 +595,210 @@ export const ClickTrigger: Story = {
|
|
|
391
595
|
`,
|
|
392
596
|
}),
|
|
393
597
|
parameters: {
|
|
394
|
-
|
|
598
|
+
controls: { disable: true },
|
|
599
|
+
docs: { source: { code: buttonWithTextSource } },
|
|
395
600
|
},
|
|
396
601
|
};
|
|
397
602
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
603
|
+
const orientationSource = `<script setup lang="ts">
|
|
604
|
+
import { UiFloatActionItems, UiIcon } from '@aleph-alpha/ui-library';
|
|
605
|
+
</script>
|
|
606
|
+
|
|
607
|
+
<template>
|
|
608
|
+
<!-- Horizontal (default): ArrowLeft / ArrowRight move between items. -->
|
|
609
|
+
<UiFloatActionItems aria-label="Horizontal actions" orientation="horizontal">
|
|
610
|
+
<UiFloatActionItems type="button" aria-label="Edit"><UiIcon name="edit" size="s" /></UiFloatActionItems>
|
|
611
|
+
<UiFloatActionItems type="button" aria-label="Copy"><UiIcon name="copy" size="s" /></UiFloatActionItems>
|
|
612
|
+
<UiFloatActionItems type="button" aria-label="Delete"><UiIcon name="trash" size="s" /></UiFloatActionItems>
|
|
613
|
+
</UiFloatActionItems>
|
|
614
|
+
|
|
615
|
+
<!-- Vertical: ArrowUp / ArrowDown move between items; the pill stacks. -->
|
|
616
|
+
<UiFloatActionItems aria-label="Vertical actions" orientation="vertical">
|
|
617
|
+
<UiFloatActionItems type="button" aria-label="Edit"><UiIcon name="edit" size="s" /></UiFloatActionItems>
|
|
618
|
+
<UiFloatActionItems type="button" aria-label="Copy"><UiIcon name="copy" size="s" /></UiFloatActionItems>
|
|
619
|
+
<UiFloatActionItems type="button" aria-label="Delete"><UiIcon name="trash" size="s" /></UiFloatActionItems>
|
|
620
|
+
</UiFloatActionItems>
|
|
621
|
+
</template>`;
|
|
416
622
|
|
|
417
623
|
/**
|
|
418
|
-
*
|
|
419
|
-
*
|
|
624
|
+
* Toolbar orientation controls both layout and roving arrow-key navigation.
|
|
625
|
+
* `horizontal` (default) stacks items in a row and maps ArrowLeft / ArrowRight;
|
|
626
|
+
* `vertical` stacks items in a column and maps ArrowUp / ArrowDown.
|
|
420
627
|
*/
|
|
421
|
-
export const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
return { args };
|
|
426
|
-
},
|
|
628
|
+
export const Orientation: Story = {
|
|
629
|
+
name: 'Action items orientation',
|
|
630
|
+
render: () => ({
|
|
631
|
+
components: { UiFloatActionItems, UiIcon },
|
|
427
632
|
template: `
|
|
428
|
-
<div class="
|
|
429
|
-
<
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
:offset="args.offset"
|
|
435
|
-
:open-delay="args.openDelay"
|
|
436
|
-
:close-delay="args.closeDelay"
|
|
437
|
-
:aria-label="placement + ' placement demo'"
|
|
438
|
-
>
|
|
439
|
-
<template #container>
|
|
440
|
-
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular capitalize">
|
|
441
|
-
{{ placement }}
|
|
442
|
-
</span>
|
|
443
|
-
</template>
|
|
444
|
-
<template #action>
|
|
445
|
-
<UiFloatActionItems :aria-label="placement + ' actions'">
|
|
446
|
-
<UiFloatActionItems type="button" aria-label="Action">
|
|
447
|
-
<UiIcon name="more-vertical" size="s" />
|
|
448
|
-
</UiFloatActionItems>
|
|
633
|
+
<div class="flex min-h-64 flex-wrap items-start justify-center gap-12 p-8">
|
|
634
|
+
<div class="flex flex-col items-center gap-3">
|
|
635
|
+
<span class="label-14-medium text-content-on-surface-secondary">Horizontal</span>
|
|
636
|
+
<UiFloatActionItems aria-label="Horizontal actions" orientation="horizontal">
|
|
637
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
638
|
+
<UiIcon name="edit" size="s" />
|
|
449
639
|
</UiFloatActionItems>
|
|
450
|
-
|
|
451
|
-
|
|
640
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
641
|
+
<UiIcon name="copy" size="s" />
|
|
642
|
+
</UiFloatActionItems>
|
|
643
|
+
<UiFloatActionItems type="button" aria-label="Delete">
|
|
644
|
+
<UiIcon name="trash" size="s" />
|
|
645
|
+
</UiFloatActionItems>
|
|
646
|
+
</UiFloatActionItems>
|
|
647
|
+
</div>
|
|
648
|
+
<div class="flex flex-col items-center gap-3">
|
|
649
|
+
<span class="label-14-medium text-content-on-surface-secondary">Vertical</span>
|
|
650
|
+
<UiFloatActionItems aria-label="Vertical actions" orientation="vertical">
|
|
651
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
652
|
+
<UiIcon name="edit" size="s" />
|
|
653
|
+
</UiFloatActionItems>
|
|
654
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
655
|
+
<UiIcon name="copy" size="s" />
|
|
656
|
+
</UiFloatActionItems>
|
|
657
|
+
<UiFloatActionItems type="button" aria-label="Delete">
|
|
658
|
+
<UiIcon name="trash" size="s" />
|
|
659
|
+
</UiFloatActionItems>
|
|
660
|
+
</UiFloatActionItems>
|
|
661
|
+
</div>
|
|
452
662
|
</div>
|
|
453
663
|
`,
|
|
454
664
|
}),
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
665
|
+
parameters: {
|
|
666
|
+
controls: { disable: true },
|
|
667
|
+
docs: { source: { code: orientationSource } },
|
|
668
|
+
},
|
|
669
|
+
play: async ({ canvasElement, step }) => {
|
|
670
|
+
// Scenario (UiFloatActionItems): orientation is announced via
|
|
671
|
+
// `aria-orientation` so assistive tech knows which Arrow keys move between
|
|
672
|
+
// items. These checks don't move focus, so the visual snapshot stays stable.
|
|
673
|
+
const canvas = within(canvasElement);
|
|
674
|
+
|
|
675
|
+
await step(
|
|
676
|
+
'screen-reader: each toolbar announces its orientation via aria-orientation (WCAG 1.3.1)',
|
|
677
|
+
async () => {
|
|
678
|
+
await expect(
|
|
679
|
+
canvas.getByRole('toolbar', { name: 'Horizontal actions' }),
|
|
680
|
+
).toHaveAttribute('aria-orientation', 'horizontal');
|
|
681
|
+
await expect(
|
|
682
|
+
canvas.getByRole('toolbar', { name: 'Vertical actions' }),
|
|
683
|
+
).toHaveAttribute('aria-orientation', 'vertical');
|
|
684
|
+
},
|
|
685
|
+
);
|
|
459
686
|
},
|
|
460
687
|
};
|
|
461
688
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
* Nest items inside a root `toolbar` container. Each icon button requires an
|
|
465
|
-
* `aria-label` because it renders without visible text.
|
|
466
|
-
*/
|
|
467
|
-
const toolbarItemTypesTemplateSource = `<script setup lang="ts">
|
|
468
|
-
import { UiFloatActions, UiFloatActionItems, UiIcon } from '@aleph-alpha/ui-library';
|
|
689
|
+
const itemTypesSource = `<script setup lang="ts">
|
|
690
|
+
import { UiFloatActionItems, UiIcon } from '@aleph-alpha/ui-library';
|
|
469
691
|
</script>
|
|
470
692
|
|
|
471
693
|
<template>
|
|
472
|
-
<
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
</UiFloatActionItems>
|
|
484
|
-
<UiFloatActionItems type="separator" />
|
|
485
|
-
<UiFloatActionItems type="group">
|
|
486
|
-
<UiFloatActionItems type="button" aria-label="Previous page">
|
|
487
|
-
<UiIcon name="chevron-left" size="s" />
|
|
488
|
-
</UiFloatActionItems>
|
|
489
|
-
<UiFloatActionItems type="text">2/2</UiFloatActionItems>
|
|
490
|
-
<UiFloatActionItems type="button" aria-label="Next page">
|
|
491
|
-
<UiIcon name="chevron-right" size="s" />
|
|
492
|
-
</UiFloatActionItems>
|
|
493
|
-
</UiFloatActionItems>
|
|
694
|
+
<UiFloatActionItems aria-label="All item types">
|
|
695
|
+
<!-- button -->
|
|
696
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
697
|
+
<UiIcon name="edit" size="s" />
|
|
698
|
+
</UiFloatActionItems>
|
|
699
|
+
<!-- separator -->
|
|
700
|
+
<UiFloatActionItems type="separator" />
|
|
701
|
+
<!-- group + text -->
|
|
702
|
+
<UiFloatActionItems type="group">
|
|
703
|
+
<UiFloatActionItems type="button" aria-label="Previous page">
|
|
704
|
+
<UiIcon name="chevron-left" size="s" />
|
|
494
705
|
</UiFloatActionItems>
|
|
495
|
-
|
|
496
|
-
|
|
706
|
+
<UiFloatActionItems type="text">2/2</UiFloatActionItems>
|
|
707
|
+
<UiFloatActionItems type="button" aria-label="Next page">
|
|
708
|
+
<UiIcon name="chevron-right" size="s" />
|
|
709
|
+
</UiFloatActionItems>
|
|
710
|
+
</UiFloatActionItems>
|
|
711
|
+
<UiFloatActionItems type="separator" />
|
|
712
|
+
<!-- input -->
|
|
713
|
+
<UiFloatActionItems type="input" aria-label="Filter value" placeholder="Filter..." />
|
|
714
|
+
</UiFloatActionItems>
|
|
497
715
|
</template>`;
|
|
498
716
|
|
|
499
|
-
|
|
717
|
+
/**
|
|
718
|
+
* All item types nested inside a root `toolbar` container:
|
|
719
|
+
* `button`, `input`, `text`, `group`, and `separator`.
|
|
720
|
+
* Icon-only `button` items require an `aria-label` because they have no visible text.
|
|
721
|
+
*/
|
|
722
|
+
export const ItemTypes: Story = {
|
|
723
|
+
name: 'Action items types',
|
|
500
724
|
render: () => ({
|
|
501
|
-
components: {
|
|
725
|
+
components: { UiFloatActionItems, UiIcon },
|
|
502
726
|
template: `
|
|
503
|
-
<div class="flex min-h-
|
|
504
|
-
<
|
|
505
|
-
<
|
|
506
|
-
<
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
<
|
|
519
|
-
<UiFloatActionItems type="group">
|
|
520
|
-
<UiFloatActionItems type="button" aria-label="Previous page">
|
|
521
|
-
<UiIcon name="chevron-left" size="s" />
|
|
522
|
-
</UiFloatActionItems>
|
|
523
|
-
<UiFloatActionItems type="text">2/2</UiFloatActionItems>
|
|
524
|
-
<UiFloatActionItems type="button" aria-label="Next page">
|
|
525
|
-
<UiIcon name="chevron-right" size="s" />
|
|
526
|
-
</UiFloatActionItems>
|
|
527
|
-
</UiFloatActionItems>
|
|
727
|
+
<div class="flex min-h-64 flex-col items-center justify-center gap-6 p-8">
|
|
728
|
+
<UiFloatActionItems aria-label="All item types">
|
|
729
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
730
|
+
<UiIcon name="edit" size="s" />
|
|
731
|
+
</UiFloatActionItems>
|
|
732
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
733
|
+
<UiIcon name="copy" size="s" />
|
|
734
|
+
</UiFloatActionItems>
|
|
735
|
+
<UiFloatActionItems type="separator" />
|
|
736
|
+
<UiFloatActionItems type="group">
|
|
737
|
+
<UiFloatActionItems type="button" aria-label="Previous page">
|
|
738
|
+
<UiIcon name="chevron-left" size="s" />
|
|
739
|
+
</UiFloatActionItems>
|
|
740
|
+
<UiFloatActionItems type="text">2/2</UiFloatActionItems>
|
|
741
|
+
<UiFloatActionItems type="button" aria-label="Next page">
|
|
742
|
+
<UiIcon name="chevron-right" size="s" />
|
|
528
743
|
</UiFloatActionItems>
|
|
529
|
-
</template>
|
|
530
|
-
</UiFloatActions>
|
|
531
|
-
|
|
532
|
-
<UiFloatActionItems aria-label="Filter actions">
|
|
533
|
-
<UiFloatActionItems
|
|
534
|
-
type="input"
|
|
535
|
-
aria-label="Filter value"
|
|
536
|
-
placeholder="Filter..."
|
|
537
|
-
/>
|
|
538
|
-
<UiFloatActionItems type="button" aria-label="Apply filter">
|
|
539
|
-
<UiIcon name="check" size="s" />
|
|
540
744
|
</UiFloatActionItems>
|
|
745
|
+
<UiFloatActionItems type="separator" />
|
|
746
|
+
<UiFloatActionItems type="input" aria-label="Filter value" placeholder="Filter..." />
|
|
541
747
|
</UiFloatActionItems>
|
|
748
|
+
|
|
749
|
+
<dl class="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 body-14-regular text-content-on-surface-secondary">
|
|
750
|
+
<dt class="label-14-medium text-content-on-surface-primary">button</dt><dd>Icon or labelled action</dd>
|
|
751
|
+
<dt class="label-14-medium text-content-on-surface-primary">separator</dt><dd>Vertical divider</dd>
|
|
752
|
+
<dt class="label-14-medium text-content-on-surface-primary">group</dt><dd>Groups related items</dd>
|
|
753
|
+
<dt class="label-14-medium text-content-on-surface-primary">text</dt><dd>Non-interactive label</dd>
|
|
754
|
+
<dt class="label-14-medium text-content-on-surface-primary">input</dt><dd>Inline text field</dd>
|
|
755
|
+
</dl>
|
|
542
756
|
</div>
|
|
543
757
|
`,
|
|
544
758
|
}),
|
|
545
759
|
parameters: {
|
|
546
760
|
controls: { disable: true },
|
|
547
|
-
docs: { source: { code:
|
|
761
|
+
docs: { source: { code: itemTypesSource } },
|
|
548
762
|
},
|
|
549
|
-
}
|
|
763
|
+
play: async ({ canvasElement, step }) => {
|
|
764
|
+
// Scenario (UiFloatActionItems): every item type is exposed with the right
|
|
765
|
+
// role and accessible name so assistive tech can describe the toolbar. These
|
|
766
|
+
// checks don't move focus or mutate state, so the snapshot stays stable.
|
|
767
|
+
const canvas = within(canvasElement);
|
|
768
|
+
const toolbar = canvas.getByRole('toolbar', { name: 'All item types' });
|
|
550
769
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
helperText:
|
|
565
|
-
'Hover or Tab to the highlighted paragraph to reveal the floating action bar. Tab into toolbar actions, then use arrow keys to move between them.',
|
|
566
|
-
anchorText:
|
|
567
|
-
'Design systems thrive when primitives stay decoupled. This pattern anchors a pill toolbar to any element without coupling the toolbar items to a specific domain model.',
|
|
568
|
-
}),
|
|
569
|
-
};
|
|
770
|
+
await step(
|
|
771
|
+
'screen-reader: the toolbar and its nested items expose roles and accessible names (WCAG 4.1.2)',
|
|
772
|
+
async () => {
|
|
773
|
+
await expect(toolbar).toBeInTheDocument();
|
|
774
|
+
await expect(canvas.getByRole('group')).toBeInTheDocument();
|
|
775
|
+
await expect(
|
|
776
|
+
canvas.getByRole('button', { name: 'Previous page' }),
|
|
777
|
+
).toBeInTheDocument();
|
|
778
|
+
await expect(
|
|
779
|
+
canvas.getByRole('textbox', { name: 'Filter value' }),
|
|
780
|
+
).toBeInTheDocument();
|
|
781
|
+
},
|
|
782
|
+
);
|
|
570
783
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
ariaLabel: 'Open card actions',
|
|
784
|
+
await step(
|
|
785
|
+
'interaction: renders each supported item type (button, group, text, input, separator)',
|
|
786
|
+
async () => {
|
|
787
|
+
await expect(canvas.getAllByRole('button')).toHaveLength(4);
|
|
788
|
+
await expect(canvas.getAllByRole('separator')).toHaveLength(2);
|
|
789
|
+
await expect(within(toolbar).getByText('2/2')).toBeInTheDocument();
|
|
790
|
+
},
|
|
791
|
+
);
|
|
580
792
|
},
|
|
581
|
-
render: createFloatRender({
|
|
582
|
-
useCardAnchor: true,
|
|
583
|
-
anchorText: 'Click anywhere on this card to reveal inline actions.',
|
|
584
|
-
}),
|
|
585
793
|
};
|
|
586
794
|
|
|
587
795
|
/**
|
|
588
|
-
* All
|
|
796
|
+
* All button states side by side for visual QA: default, hover, focus (shared
|
|
797
|
+
* `ui-focus-ring`), disabled, plus toolbar-level triggers and open / closed panels.
|
|
798
|
+
* Tab through the buttons to see the focus ring; hover to see the hover surface.
|
|
589
799
|
*/
|
|
590
800
|
export const AllStates: Story = {
|
|
801
|
+
name: 'All states with button',
|
|
591
802
|
render: () => ({
|
|
592
803
|
components: { UiFloatActions, UiFloatActionItems, UiIcon },
|
|
593
804
|
setup() {
|
|
@@ -596,17 +807,62 @@ export const AllStates: Story = {
|
|
|
596
807
|
return { openPanel, closedPanel };
|
|
597
808
|
},
|
|
598
809
|
template: `
|
|
599
|
-
<div class="flex flex-col gap-
|
|
600
|
-
<section class="flex flex-col gap-
|
|
601
|
-
<
|
|
602
|
-
|
|
603
|
-
<
|
|
604
|
-
|
|
605
|
-
|
|
810
|
+
<div class="mx-auto flex max-w-4xl flex-col gap-12 p-8">
|
|
811
|
+
<section class="flex flex-col gap-5">
|
|
812
|
+
<div class="flex flex-col gap-1">
|
|
813
|
+
<h3 class="body-16-medium text-content-on-surface-primary">Button states</h3>
|
|
814
|
+
<p class="body-14-regular text-content-on-surface-secondary">
|
|
815
|
+
Tab to a button to reveal the focus ring; hover to see the hover surface.
|
|
816
|
+
</p>
|
|
817
|
+
</div>
|
|
818
|
+
<div class="grid grid-cols-2 gap-4 sm:grid-cols-4">
|
|
819
|
+
<div class="flex flex-col items-center justify-center gap-4 rounded-lg border border-border-surface-default bg-background-surface-primary p-6">
|
|
820
|
+
<UiFloatActionItems aria-label="Default state">
|
|
821
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
822
|
+
<UiIcon name="edit" size="s" />
|
|
823
|
+
</UiFloatActionItems>
|
|
824
|
+
</UiFloatActionItems>
|
|
825
|
+
<span class="label-12-medium text-content-on-surface-secondary">Default</span>
|
|
826
|
+
</div>
|
|
827
|
+
<div class="flex flex-col items-center justify-center gap-4 rounded-lg border border-border-surface-default bg-background-surface-primary p-6">
|
|
828
|
+
<UiFloatActionItems aria-label="Hover state">
|
|
829
|
+
<UiFloatActionItems type="button" aria-label="Edit" >
|
|
830
|
+
<UiIcon name="edit" size="s" />
|
|
831
|
+
</UiFloatActionItems>
|
|
832
|
+
</UiFloatActionItems>
|
|
833
|
+
<span class="label-12-medium text-content-on-surface-secondary">Hover</span>
|
|
834
|
+
</div>
|
|
835
|
+
<div class="flex flex-col items-center justify-center gap-4 rounded-lg border border-border-surface-default bg-background-surface-primary p-6">
|
|
836
|
+
<UiFloatActionItems aria-label="Focus state">
|
|
837
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
838
|
+
<UiIcon name="edit" size="s" />
|
|
839
|
+
</UiFloatActionItems>
|
|
840
|
+
</UiFloatActionItems>
|
|
841
|
+
<span class="label-12-medium text-content-on-surface-secondary">Focus (Tab)</span>
|
|
842
|
+
</div>
|
|
843
|
+
<div class="flex flex-col items-center justify-center gap-4 rounded-lg border border-border-surface-default bg-background-surface-primary p-6">
|
|
844
|
+
<UiFloatActionItems aria-label="Disabled state">
|
|
845
|
+
<UiFloatActionItems type="button" aria-label="Edit" disabled>
|
|
846
|
+
<UiIcon name="edit" size="s" />
|
|
847
|
+
</UiFloatActionItems>
|
|
848
|
+
</UiFloatActionItems>
|
|
849
|
+
<span class="label-12-medium text-content-on-surface-secondary">Disabled</span>
|
|
850
|
+
</div>
|
|
851
|
+
</div>
|
|
852
|
+
</section>
|
|
853
|
+
|
|
854
|
+
<section class="flex flex-col gap-5">
|
|
855
|
+
<div class="flex flex-col gap-1">
|
|
856
|
+
<h3 class="body-16-medium text-content-on-surface-primary">Triggers</h3>
|
|
857
|
+
<p class="body-14-regular text-content-on-surface-secondary">
|
|
858
|
+
How the floating panel opens for each interaction mode.
|
|
859
|
+
</p>
|
|
860
|
+
</div>
|
|
861
|
+
<div class="grid gap-4 sm:grid-cols-3">
|
|
862
|
+
<div class="flex min-h-44 flex-col items-center justify-end gap-4 rounded-lg border border-border-surface-default bg-background-surface-primary p-6">
|
|
863
|
+
<UiFloatActions trigger="hover" placement="top" :offset="10" aria-label="Hover actions">
|
|
606
864
|
<template #container>
|
|
607
|
-
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular">
|
|
608
|
-
Hover or Tab
|
|
609
|
-
</span>
|
|
865
|
+
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular">Hover or Tab</span>
|
|
610
866
|
</template>
|
|
611
867
|
<template #action>
|
|
612
868
|
<UiFloatActionItems aria-label="Hover actions">
|
|
@@ -616,14 +872,12 @@ export const AllStates: Story = {
|
|
|
616
872
|
</UiFloatActionItems>
|
|
617
873
|
</template>
|
|
618
874
|
</UiFloatActions>
|
|
875
|
+
<span class="label-12-medium text-content-on-surface-secondary">Hover</span>
|
|
619
876
|
</div>
|
|
620
|
-
<div class="flex flex-col items-center gap-
|
|
621
|
-
<span class="label-14-medium text-content-on-surface-secondary">Click</span>
|
|
877
|
+
<div class="flex min-h-44 flex-col items-center justify-end gap-4 rounded-lg border border-border-surface-default bg-background-surface-primary p-6">
|
|
622
878
|
<UiFloatActions trigger="click" placement="top" :offset="10" aria-label="Click actions">
|
|
623
879
|
<template #container>
|
|
624
|
-
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular">
|
|
625
|
-
Click or Enter
|
|
626
|
-
</span>
|
|
880
|
+
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular">Click or Enter</span>
|
|
627
881
|
</template>
|
|
628
882
|
<template #action>
|
|
629
883
|
<UiFloatActionItems aria-label="Click actions">
|
|
@@ -633,14 +887,12 @@ export const AllStates: Story = {
|
|
|
633
887
|
</UiFloatActionItems>
|
|
634
888
|
</template>
|
|
635
889
|
</UiFloatActions>
|
|
890
|
+
<span class="label-12-medium text-content-on-surface-secondary">Click</span>
|
|
636
891
|
</div>
|
|
637
|
-
<div class="flex flex-col items-center gap-
|
|
638
|
-
<span class="label-14-medium text-content-on-surface-secondary">Focus</span>
|
|
892
|
+
<div class="flex min-h-44 flex-col items-center justify-end gap-4 rounded-lg border border-border-surface-default bg-background-surface-primary p-6">
|
|
639
893
|
<UiFloatActions trigger="focus" placement="top" :offset="10" aria-label="Focus actions">
|
|
640
894
|
<template #container>
|
|
641
|
-
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular">
|
|
642
|
-
Tab to focus
|
|
643
|
-
</span>
|
|
895
|
+
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular">Tab to focus</span>
|
|
644
896
|
</template>
|
|
645
897
|
<template #action>
|
|
646
898
|
<UiFloatActionItems aria-label="Focus actions">
|
|
@@ -650,48 +902,23 @@ export const AllStates: Story = {
|
|
|
650
902
|
</UiFloatActionItems>
|
|
651
903
|
</template>
|
|
652
904
|
</UiFloatActions>
|
|
905
|
+
<span class="label-12-medium text-content-on-surface-secondary">Focus</span>
|
|
653
906
|
</div>
|
|
654
907
|
</div>
|
|
655
908
|
</section>
|
|
656
909
|
|
|
657
|
-
<section class="flex flex-col gap-
|
|
658
|
-
<
|
|
659
|
-
|
|
660
|
-
<
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
trigger="manual"
|
|
664
|
-
v-model:open="openPanel"
|
|
665
|
-
:placement="placement"
|
|
666
|
-
:offset="12"
|
|
667
|
-
:aria-label="placement + ' placement'"
|
|
668
|
-
>
|
|
669
|
-
<template #container>
|
|
670
|
-
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular capitalize">
|
|
671
|
-
{{ placement }}
|
|
672
|
-
</span>
|
|
673
|
-
</template>
|
|
674
|
-
<template #action>
|
|
675
|
-
<UiFloatActionItems :aria-label="placement + ' actions'">
|
|
676
|
-
<UiFloatActionItems type="button" aria-label="Action">
|
|
677
|
-
<UiIcon name="more-vertical" size="s" />
|
|
678
|
-
</UiFloatActionItems>
|
|
679
|
-
</UiFloatActionItems>
|
|
680
|
-
</template>
|
|
681
|
-
</UiFloatActions>
|
|
910
|
+
<section class="flex flex-col gap-5">
|
|
911
|
+
<div class="flex flex-col gap-1">
|
|
912
|
+
<h3 class="body-16-medium text-content-on-surface-primary">Open vs closed</h3>
|
|
913
|
+
<p class="body-14-regular text-content-on-surface-secondary">
|
|
914
|
+
Controlled panels via <code class="label-14-regular">v-model:open</code>.
|
|
915
|
+
</p>
|
|
682
916
|
</div>
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
<section class="flex flex-col gap-4">
|
|
686
|
-
<h3 class="body-16-medium text-content-on-surface-primary">Open vs closed</h3>
|
|
687
|
-
<div class="grid gap-8 md:grid-cols-2">
|
|
688
|
-
<div class="flex flex-col items-center gap-2">
|
|
689
|
-
<span class="label-14-medium text-content-on-surface-secondary">Open</span>
|
|
917
|
+
<div class="grid gap-4 sm:grid-cols-2">
|
|
918
|
+
<div class="flex min-h-44 flex-col items-center justify-end gap-4 rounded-lg border border-border-surface-default bg-background-surface-primary p-6">
|
|
690
919
|
<UiFloatActions trigger="manual" v-model:open="openPanel" placement="top" :offset="10" aria-label="Open panel">
|
|
691
920
|
<template #container>
|
|
692
|
-
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular">
|
|
693
|
-
Panel open
|
|
694
|
-
</span>
|
|
921
|
+
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular">Panel open</span>
|
|
695
922
|
</template>
|
|
696
923
|
<template #action>
|
|
697
924
|
<UiFloatActionItems aria-label="Open panel actions">
|
|
@@ -704,14 +931,12 @@ export const AllStates: Story = {
|
|
|
704
931
|
</UiFloatActionItems>
|
|
705
932
|
</template>
|
|
706
933
|
</UiFloatActions>
|
|
934
|
+
<span class="label-12-medium text-content-on-surface-secondary">Open</span>
|
|
707
935
|
</div>
|
|
708
|
-
<div class="flex flex-col items-center gap-
|
|
709
|
-
<span class="label-14-medium text-content-on-surface-secondary">Closed</span>
|
|
936
|
+
<div class="flex min-h-44 flex-col items-center justify-end gap-4 rounded-lg border border-border-surface-default bg-background-surface-primary p-6">
|
|
710
937
|
<UiFloatActions trigger="manual" v-model:open="closedPanel" placement="top" :offset="10" aria-label="Closed panel">
|
|
711
938
|
<template #container>
|
|
712
|
-
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular">
|
|
713
|
-
Panel closed
|
|
714
|
-
</span>
|
|
939
|
+
<span class="rounded-md border border-border-surface-default px-4 py-2 body-14-regular">Panel closed</span>
|
|
715
940
|
</template>
|
|
716
941
|
<template #action>
|
|
717
942
|
<UiFloatActionItems aria-label="Closed panel actions">
|
|
@@ -721,39 +946,10 @@ export const AllStates: Story = {
|
|
|
721
946
|
</UiFloatActionItems>
|
|
722
947
|
</template>
|
|
723
948
|
</UiFloatActions>
|
|
949
|
+
<span class="label-12-medium text-content-on-surface-secondary">Closed</span>
|
|
724
950
|
</div>
|
|
725
951
|
</div>
|
|
726
952
|
</section>
|
|
727
|
-
|
|
728
|
-
<section class="flex flex-col gap-4">
|
|
729
|
-
<h3 class="body-16-medium text-content-on-surface-primary">Toolbar item types</h3>
|
|
730
|
-
<div class="flex flex-col items-center gap-6">
|
|
731
|
-
<UiFloatActionItems aria-label="Mixed actions">
|
|
732
|
-
<UiFloatActionItems type="button" aria-label="Edit">
|
|
733
|
-
<UiIcon name="edit" size="s" />
|
|
734
|
-
</UiFloatActionItems>
|
|
735
|
-
<UiFloatActionItems type="button" aria-label="Copy">
|
|
736
|
-
<UiIcon name="copy" size="s" />
|
|
737
|
-
</UiFloatActionItems>
|
|
738
|
-
<UiFloatActionItems type="separator" />
|
|
739
|
-
<UiFloatActionItems type="group">
|
|
740
|
-
<UiFloatActionItems type="button" aria-label="Previous page">
|
|
741
|
-
<UiIcon name="chevron-left" size="s" />
|
|
742
|
-
</UiFloatActionItems>
|
|
743
|
-
<UiFloatActionItems type="text">2/2</UiFloatActionItems>
|
|
744
|
-
<UiFloatActionItems type="button" aria-label="Next page">
|
|
745
|
-
<UiIcon name="chevron-right" size="s" />
|
|
746
|
-
</UiFloatActionItems>
|
|
747
|
-
</UiFloatActionItems>
|
|
748
|
-
</UiFloatActionItems>
|
|
749
|
-
<UiFloatActionItems aria-label="Filter actions">
|
|
750
|
-
<UiFloatActionItems type="input" aria-label="Filter value" placeholder="Filter..." />
|
|
751
|
-
<UiFloatActionItems type="button" aria-label="Apply filter">
|
|
752
|
-
<UiIcon name="check" size="s" />
|
|
753
|
-
</UiFloatActionItems>
|
|
754
|
-
</UiFloatActionItems>
|
|
755
|
-
</div>
|
|
756
|
-
</section>
|
|
757
953
|
</div>
|
|
758
954
|
`,
|
|
759
955
|
}),
|
|
@@ -765,9 +961,9 @@ export const AllStates: Story = {
|
|
|
765
961
|
},
|
|
766
962
|
};
|
|
767
963
|
|
|
768
|
-
const
|
|
964
|
+
const composableUsageSource = `<script setup lang="ts">
|
|
769
965
|
import { useId } from 'vue';
|
|
770
|
-
import { useAnchorFloat,
|
|
966
|
+
import { useAnchorFloat, UiFloatActionItems, UiIcon } from '@aleph-alpha/ui-library';
|
|
771
967
|
|
|
772
968
|
// Prefer UiFloatActions for the standard component API. Use useAnchorFloat when
|
|
773
969
|
// you need full control over markup, animation, or teleport targets.
|
|
@@ -792,6 +988,7 @@ const {
|
|
|
792
988
|
</script>
|
|
793
989
|
|
|
794
990
|
<template>
|
|
991
|
+
<!-- Add the shared \`ui-focus-ring\` utility to any focusable element. -->
|
|
795
992
|
<button
|
|
796
993
|
ref="referenceRef"
|
|
797
994
|
type="button"
|
|
@@ -799,6 +996,7 @@ const {
|
|
|
799
996
|
:aria-expanded="open"
|
|
800
997
|
aria-haspopup="true"
|
|
801
998
|
:aria-controls="open ? contentId : undefined"
|
|
999
|
+
class="ui-focus-ring rounded-md border border-transparent"
|
|
802
1000
|
@mouseenter="onReferenceMouseEnter"
|
|
803
1001
|
@mouseleave="onReferenceMouseLeave"
|
|
804
1002
|
@focus="onReferenceFocus"
|
|
@@ -806,8 +1004,6 @@ const {
|
|
|
806
1004
|
>
|
|
807
1005
|
Hover or Tab to reveal actions
|
|
808
1006
|
</button>
|
|
809
|
-
<!-- popover="manual" promotes the panel to the top layer and, when shown via
|
|
810
|
-
showPopover({ source }), wires the anchor → panel keyboard focus order. -->
|
|
811
1007
|
<Teleport to="body">
|
|
812
1008
|
<div
|
|
813
1009
|
v-if="open"
|
|
@@ -832,10 +1028,11 @@ const {
|
|
|
832
1028
|
/**
|
|
833
1029
|
* Headless usage with the `useAnchorFloat` composable.
|
|
834
1030
|
* Use when you need full control over markup, animation, or teleport targets
|
|
835
|
-
* beyond what
|
|
836
|
-
* the anchor yourself
|
|
1031
|
+
* beyond what `UiFloatActions` provides. Wire focus handlers and popup ARIA on
|
|
1032
|
+
* the anchor yourself, and add the shared `ui-focus-ring` utility for a consistent
|
|
1033
|
+
* keyboard focus style.
|
|
837
1034
|
*/
|
|
838
|
-
export const
|
|
1035
|
+
export const Composable: Story = {
|
|
839
1036
|
render: () => ({
|
|
840
1037
|
components: { UiFloatActionItems, UiIcon },
|
|
841
1038
|
setup() {
|
|
@@ -856,7 +1053,7 @@ export const ComposableUsage: Story = {
|
|
|
856
1053
|
:aria-expanded="open"
|
|
857
1054
|
aria-haspopup="true"
|
|
858
1055
|
:aria-controls="open ? contentId : undefined"
|
|
859
|
-
class="rounded-md border border-
|
|
1056
|
+
class="ui-focus-ring rounded-md border border-transparent bg-background-surface-primary px-6 py-10 body-14-regular"
|
|
860
1057
|
@mouseenter="onReferenceMouseEnter"
|
|
861
1058
|
@mouseleave="onReferenceMouseLeave"
|
|
862
1059
|
@focus="onReferenceFocus"
|
|
@@ -895,6 +1092,602 @@ export const ComposableUsage: Story = {
|
|
|
895
1092
|
}),
|
|
896
1093
|
parameters: {
|
|
897
1094
|
controls: { disable: true },
|
|
898
|
-
docs: { source: { code:
|
|
1095
|
+
docs: { source: { code: composableUsageSource } },
|
|
1096
|
+
},
|
|
1097
|
+
};
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Accessibility guidance for the floating trigger and its toolbar: popup
|
|
1101
|
+
* semantics on the anchor, roving arrow-key focus in the toolbar, accessible
|
|
1102
|
+
* names on every item, and the accessibility theme for contrast.
|
|
1103
|
+
*/
|
|
1104
|
+
export const Accessibility: Story = {
|
|
1105
|
+
render: () => ({
|
|
1106
|
+
components: { UiFloatActionItems, UiIcon },
|
|
1107
|
+
template: `
|
|
1108
|
+
<section class="flex flex-col gap-6 p-4">
|
|
1109
|
+
<div>
|
|
1110
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
1111
|
+
Accessibility
|
|
1112
|
+
</h2>
|
|
1113
|
+
</div>
|
|
1114
|
+
|
|
1115
|
+
<div class="flex flex-col gap-6">
|
|
1116
|
+
<div class="flex flex-col gap-2">
|
|
1117
|
+
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
1118
|
+
Requirements
|
|
1119
|
+
</h3>
|
|
1120
|
+
<ul class="body-16-regular list-disc pl-5 text-content-on-surface-primary">
|
|
1121
|
+
<li>The trigger is a focusable button exposing <code class="label-14-regular">aria-haspopup</code> and <code class="label-14-regular">aria-expanded</code>, pointing at the open panel via <code class="label-14-regular">aria-controls</code>.</li>
|
|
1122
|
+
<li>Focus or hover opens the panel; <code class="label-14-regular">Escape</code> closes it and restores focus to the trigger.</li>
|
|
1123
|
+
<li>The toolbar uses <code class="label-14-regular">role="toolbar"</code> with roving arrow-key focus — one Tab stop enters and leaves it, Arrow keys move between items.</li>
|
|
1124
|
+
<li>Every icon-only button and input item has an accessible name via <code class="label-14-regular">aria-label</code>.</li>
|
|
1125
|
+
</ul>
|
|
1126
|
+
</div>
|
|
1127
|
+
|
|
1128
|
+
<div class="flex flex-col gap-2">
|
|
1129
|
+
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
1130
|
+
Enable accessibility theme
|
|
1131
|
+
</h3>
|
|
1132
|
+
<p class="body-16-regular text-content-on-surface-primary">
|
|
1133
|
+
When accessibility is required, enable our accessibility theme. This
|
|
1134
|
+
increases contrast and ensures there are no color contrast issues.
|
|
1135
|
+
</p>
|
|
1136
|
+
</div>
|
|
1137
|
+
</div>
|
|
1138
|
+
|
|
1139
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
1140
|
+
<div class="flex flex-col gap-3">
|
|
1141
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
1142
|
+
Default
|
|
1143
|
+
</h3>
|
|
1144
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
1145
|
+
<UiFloatActionItems aria-label="Default paragraph actions">
|
|
1146
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
1147
|
+
<UiIcon name="edit" size="s" />
|
|
1148
|
+
</UiFloatActionItems>
|
|
1149
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
1150
|
+
<UiIcon name="copy" size="s" />
|
|
1151
|
+
</UiFloatActionItems>
|
|
1152
|
+
<UiFloatActionItems type="separator" />
|
|
1153
|
+
<UiFloatActionItems type="button" aria-label="Delete">
|
|
1154
|
+
<UiIcon name="trash" size="s" />
|
|
1155
|
+
</UiFloatActionItems>
|
|
1156
|
+
</UiFloatActionItems>
|
|
1157
|
+
</div>
|
|
1158
|
+
</div>
|
|
1159
|
+
|
|
1160
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
1161
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
1162
|
+
Accessible
|
|
1163
|
+
</h3>
|
|
1164
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
1165
|
+
<UiFloatActionItems aria-label="Accessible paragraph actions">
|
|
1166
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
1167
|
+
<UiIcon name="edit" size="s" />
|
|
1168
|
+
</UiFloatActionItems>
|
|
1169
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
1170
|
+
<UiIcon name="copy" size="s" />
|
|
1171
|
+
</UiFloatActionItems>
|
|
1172
|
+
<UiFloatActionItems type="separator" />
|
|
1173
|
+
<UiFloatActionItems type="button" aria-label="Delete">
|
|
1174
|
+
<UiIcon name="trash" size="s" />
|
|
1175
|
+
</UiFloatActionItems>
|
|
1176
|
+
</UiFloatActionItems>
|
|
1177
|
+
</div>
|
|
1178
|
+
</div>
|
|
1179
|
+
</div>
|
|
1180
|
+
</section>
|
|
1181
|
+
`,
|
|
1182
|
+
}),
|
|
1183
|
+
tags: ['!autodocs'],
|
|
1184
|
+
parameters: {
|
|
1185
|
+
a11y: { test: 'off' },
|
|
1186
|
+
chromatic: {
|
|
1187
|
+
disableSnapshot: true,
|
|
1188
|
+
},
|
|
1189
|
+
docs: {
|
|
1190
|
+
canvas: {
|
|
1191
|
+
sourceState: 'none',
|
|
1192
|
+
},
|
|
1193
|
+
},
|
|
1194
|
+
},
|
|
1195
|
+
};
|
|
1196
|
+
|
|
1197
|
+
/*
|
|
1198
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
1199
|
+
* Interaction & accessibility tests (play functions)
|
|
1200
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
1201
|
+
* How these tests are built and reported:
|
|
1202
|
+
*
|
|
1203
|
+
* - Each story below is a hidden, test-only story (`name: 'test - …'`,
|
|
1204
|
+
* `tags: ['!dev', '!autodocs']`). It is excluded from the sidebar and docs but
|
|
1205
|
+
* still runs in the Storybook `test-runner` on every PR, in the accessible
|
|
1206
|
+
* theme, alongside the axe audit.
|
|
1207
|
+
* - Every play opens with a `Scenario (Component): …` comment stating the user
|
|
1208
|
+
* story it verifies, then drives the UI with `userEvent` and asserts with
|
|
1209
|
+
* `expect` from `storybook/test`.
|
|
1210
|
+
* - Assertions are grouped into category-labelled `step()` calls. The prefix is
|
|
1211
|
+
* the contract for reporting — it is parsed statically into the per-story
|
|
1212
|
+
* summary table and the scenarios PDF (`pnpm report:scenarios-pdf`), so keep
|
|
1213
|
+
* it accurate. Between them, these stories cover every report column:
|
|
1214
|
+
* • `interaction:` behaviour, guards, emitted events (WCAG 4.1.2)
|
|
1215
|
+
* • `keyboard:` Tab order, Enter / Space / Arrow / Escape (WCAG 2.1.1, 2.4.3)
|
|
1216
|
+
* • `screen-reader:` accessible names, roles, ARIA state (WCAG 4.1.2)
|
|
1217
|
+
* • `zoom:` usable at 200% page zoom (WCAG 1.4.4)
|
|
1218
|
+
* • `mobile:` 320px reflow + touch-target size (WCAG 1.4.10, 2.5.8)
|
|
1219
|
+
* The Accessibility column is filled automatically by the axe audit that runs
|
|
1220
|
+
* on every story — never add an `a11y:` prefix.
|
|
1221
|
+
* - Coverage is split across stories: non-mutating `screen-reader`/`interaction`
|
|
1222
|
+
* checks are co-located on the visible `Orientation` and `ItemTypes` stories
|
|
1223
|
+
* (so their Chromatic snapshots stay valid), while focus-moving flows live in
|
|
1224
|
+
* the dedicated `test - …` stories below (Focus / Hover / Click / Toolbar /
|
|
1225
|
+
* Zoom / Mobile).
|
|
1226
|
+
* - The floating panel is teleported to `document.body`, so panel content is
|
|
1227
|
+
* queried with `within(document.body)` rather than the story canvas.
|
|
1228
|
+
* - Stories whose play moves focus, opens the panel, or rescales the layout
|
|
1229
|
+
* disable their Chromatic snapshot. Pure render/logic coverage lives in Vitest
|
|
1230
|
+
* under `__tests__/`.
|
|
1231
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
1232
|
+
*/
|
|
1233
|
+
|
|
1234
|
+
/**
|
|
1235
|
+
* A `focus` trigger opens the panel when the anchor receives keyboard focus and
|
|
1236
|
+
* exposes popup semantics; `Escape` closes it and restores focus to the anchor.
|
|
1237
|
+
* Hidden test-only story.
|
|
1238
|
+
*/
|
|
1239
|
+
export const FocusTriggerKeyboard: Story = {
|
|
1240
|
+
name: 'test - Focus trigger & escape',
|
|
1241
|
+
tags: ['!dev', '!autodocs'],
|
|
1242
|
+
render: () => ({
|
|
1243
|
+
components: { UiFloatActions, UiFloatActionItems, UiIcon },
|
|
1244
|
+
template: `
|
|
1245
|
+
<div class="flex min-h-64 items-center justify-center p-8">
|
|
1246
|
+
<UiFloatActions trigger="focus" placement="top" :offset="10" aria-label="Paragraph actions">
|
|
1247
|
+
<template #container>
|
|
1248
|
+
<span class="rounded-md border border-border-surface-default bg-background-surface-primary px-4 py-2 body-14-regular">
|
|
1249
|
+
Tab to reveal actions
|
|
1250
|
+
</span>
|
|
1251
|
+
</template>
|
|
1252
|
+
<template #action>
|
|
1253
|
+
<UiFloatActionItems aria-label="Paragraph actions">
|
|
1254
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
1255
|
+
<UiIcon name="edit" size="s" />
|
|
1256
|
+
</UiFloatActionItems>
|
|
1257
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
1258
|
+
<UiIcon name="copy" size="s" />
|
|
1259
|
+
</UiFloatActionItems>
|
|
1260
|
+
</UiFloatActionItems>
|
|
1261
|
+
</template>
|
|
1262
|
+
</UiFloatActions>
|
|
1263
|
+
</div>
|
|
1264
|
+
`,
|
|
1265
|
+
}),
|
|
1266
|
+
parameters: {
|
|
1267
|
+
// The play function moves focus and opens the teleported panel; skip the
|
|
1268
|
+
// snapshot so the focus ring and open panel don't register as a diff.
|
|
1269
|
+
chromatic: { disableSnapshot: true },
|
|
1270
|
+
docs: {
|
|
1271
|
+
description: {
|
|
1272
|
+
story:
|
|
1273
|
+
'Press `Tab` to focus the anchor and open the panel, then `Escape` to close it and restore focus.',
|
|
1274
|
+
},
|
|
1275
|
+
},
|
|
1276
|
+
},
|
|
1277
|
+
play: async ({ canvasElement, step }) => {
|
|
1278
|
+
// Scenario (UiFloatActions): a keyboard user Tabs to a `focus`-trigger
|
|
1279
|
+
// anchor, which opens the panel and exposes popup semantics (aria-haspopup /
|
|
1280
|
+
// aria-expanded / aria-controls); Escape then closes it and returns focus to
|
|
1281
|
+
// the anchor. The panel is teleported to `document.body`, so its content is
|
|
1282
|
+
// queried against the body rather than the story canvas.
|
|
1283
|
+
const canvas = within(canvasElement);
|
|
1284
|
+
const body = within(document.body);
|
|
1285
|
+
const anchor = canvas.getByRole('button', { name: 'Paragraph actions' });
|
|
1286
|
+
|
|
1287
|
+
await step(
|
|
1288
|
+
'screen-reader: the collapsed trigger exposes popup semantics (WCAG 4.1.2)',
|
|
1289
|
+
async () => {
|
|
1290
|
+
await expect(anchor).toHaveAttribute('aria-haspopup', 'true');
|
|
1291
|
+
await expect(anchor).toHaveAttribute('aria-expanded', 'false');
|
|
1292
|
+
},
|
|
1293
|
+
);
|
|
1294
|
+
|
|
1295
|
+
await step(
|
|
1296
|
+
'keyboard: focusing the trigger opens the panel and links it via aria-controls (WCAG 2.1.1 / 4.1.2)',
|
|
1297
|
+
async () => {
|
|
1298
|
+
await userEvent.tab();
|
|
1299
|
+
await expect(anchor).toHaveFocus();
|
|
1300
|
+
await waitFor(() =>
|
|
1301
|
+
expect(anchor).toHaveAttribute('aria-expanded', 'true'),
|
|
1302
|
+
);
|
|
1303
|
+
await expect(anchor).toHaveAttribute('aria-controls');
|
|
1304
|
+
await expect(
|
|
1305
|
+
await body.findByRole('toolbar', { name: 'Paragraph actions' }),
|
|
1306
|
+
).toBeInTheDocument();
|
|
1307
|
+
},
|
|
1308
|
+
);
|
|
1309
|
+
|
|
1310
|
+
await step(
|
|
1311
|
+
'keyboard: Escape closes the panel and restores focus to the trigger (WCAG 2.1.2)',
|
|
1312
|
+
async () => {
|
|
1313
|
+
await userEvent.keyboard('{Escape}');
|
|
1314
|
+
await waitFor(() =>
|
|
1315
|
+
expect(anchor).toHaveAttribute('aria-expanded', 'false'),
|
|
1316
|
+
);
|
|
1317
|
+
await expect(anchor).toHaveFocus();
|
|
1318
|
+
await waitFor(() =>
|
|
1319
|
+
expect(
|
|
1320
|
+
body.queryByRole('toolbar', { name: 'Paragraph actions' }),
|
|
1321
|
+
).not.toBeInTheDocument(),
|
|
1322
|
+
);
|
|
1323
|
+
},
|
|
1324
|
+
);
|
|
1325
|
+
},
|
|
1326
|
+
};
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* A `hover` trigger also opens on keyboard focus, so keyboard-only users reach
|
|
1330
|
+
* the same actions as pointer users. Hidden test-only story.
|
|
1331
|
+
*/
|
|
1332
|
+
export const HoverTriggerKeyboard: Story = {
|
|
1333
|
+
name: 'test - Hover trigger keyboard',
|
|
1334
|
+
tags: ['!dev', '!autodocs'],
|
|
1335
|
+
render: () => ({
|
|
1336
|
+
components: { UiFloatActions, UiFloatActionItems, UiIcon },
|
|
1337
|
+
template: `
|
|
1338
|
+
<div class="flex min-h-64 items-center justify-center p-8">
|
|
1339
|
+
<UiFloatActions trigger="hover" placement="top" :offset="10" aria-label="Text actions">
|
|
1340
|
+
<template #container>
|
|
1341
|
+
<span class="rounded-md border border-border-surface-default bg-background-surface-primary px-4 py-2 body-14-regular">
|
|
1342
|
+
Hover or Tab to reveal actions
|
|
1343
|
+
</span>
|
|
1344
|
+
</template>
|
|
1345
|
+
<template #action>
|
|
1346
|
+
<UiFloatActionItems aria-label="Text actions">
|
|
1347
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
1348
|
+
<UiIcon name="copy" size="s" />
|
|
1349
|
+
</UiFloatActionItems>
|
|
1350
|
+
</UiFloatActionItems>
|
|
1351
|
+
</template>
|
|
1352
|
+
</UiFloatActions>
|
|
1353
|
+
</div>
|
|
1354
|
+
`,
|
|
1355
|
+
}),
|
|
1356
|
+
parameters: {
|
|
1357
|
+
chromatic: { disableSnapshot: true },
|
|
1358
|
+
docs: {
|
|
1359
|
+
description: {
|
|
1360
|
+
story:
|
|
1361
|
+
'Press `Tab` to focus the hover anchor — the panel opens for keyboard users just like it does on pointer hover.',
|
|
1362
|
+
},
|
|
1363
|
+
},
|
|
1364
|
+
},
|
|
1365
|
+
play: async ({ canvasElement, step }) => {
|
|
1366
|
+
// Scenario (UiFloatActions): a `hover` trigger must also open on keyboard
|
|
1367
|
+
// focus so keyboard-only users reach the same actions as pointer users.
|
|
1368
|
+
// Tabbing to the anchor opens the teleported panel (queried on the body).
|
|
1369
|
+
const canvas = within(canvasElement);
|
|
1370
|
+
const body = within(document.body);
|
|
1371
|
+
const anchor = canvas.getByRole('button', { name: 'Text actions' });
|
|
1372
|
+
|
|
1373
|
+
await step(
|
|
1374
|
+
'keyboard: focusing a hover trigger opens the panel for keyboard users (WCAG 2.1.1)',
|
|
1375
|
+
async () => {
|
|
1376
|
+
await expect(anchor).toHaveAttribute('aria-haspopup', 'true');
|
|
1377
|
+
await userEvent.tab();
|
|
1378
|
+
await expect(anchor).toHaveFocus();
|
|
1379
|
+
await waitFor(() =>
|
|
1380
|
+
expect(anchor).toHaveAttribute('aria-expanded', 'true'),
|
|
1381
|
+
);
|
|
1382
|
+
await expect(
|
|
1383
|
+
await body.findByRole('button', { name: 'Copy' }),
|
|
1384
|
+
).toBeInTheDocument();
|
|
1385
|
+
},
|
|
1386
|
+
);
|
|
1387
|
+
},
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* A `click` trigger toggles the panel with `Enter` and `Space` (and pointer
|
|
1392
|
+
* click), flipping `aria-expanded`. Hidden test-only story.
|
|
1393
|
+
*/
|
|
1394
|
+
export const ClickTriggerKeyboard: Story = {
|
|
1395
|
+
name: 'test - Click toggle keyboard',
|
|
1396
|
+
tags: ['!dev', '!autodocs'],
|
|
1397
|
+
render: () => ({
|
|
1398
|
+
components: { UiFloatActions, UiFloatActionItems, UiIcon },
|
|
1399
|
+
template: `
|
|
1400
|
+
<div class="flex min-h-64 items-center justify-center p-8">
|
|
1401
|
+
<UiFloatActions trigger="click" placement="top" :offset="10" aria-label="Open actions">
|
|
1402
|
+
<template #container>
|
|
1403
|
+
<span class="rounded-md border border-border-surface-default bg-background-surface-primary px-4 py-2 body-14-regular">
|
|
1404
|
+
Click or press Enter / Space
|
|
1405
|
+
</span>
|
|
1406
|
+
</template>
|
|
1407
|
+
<template #action>
|
|
1408
|
+
<UiFloatActionItems aria-label="Open actions">
|
|
1409
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
1410
|
+
<UiIcon name="edit" size="s" />
|
|
1411
|
+
</UiFloatActionItems>
|
|
1412
|
+
</UiFloatActionItems>
|
|
1413
|
+
</template>
|
|
1414
|
+
</UiFloatActions>
|
|
1415
|
+
</div>
|
|
1416
|
+
`,
|
|
1417
|
+
}),
|
|
1418
|
+
parameters: {
|
|
1419
|
+
chromatic: { disableSnapshot: true },
|
|
1420
|
+
docs: {
|
|
1421
|
+
description: {
|
|
1422
|
+
story:
|
|
1423
|
+
'Focus the anchor, then press `Enter` to open and `Space` to close the panel.',
|
|
1424
|
+
},
|
|
1425
|
+
},
|
|
1426
|
+
},
|
|
1427
|
+
play: async ({ canvasElement, step }) => {
|
|
1428
|
+
// Scenario (UiFloatActions): a `click` trigger toggles from the keyboard —
|
|
1429
|
+
// focus alone must not open it, Enter opens the panel and Space closes it,
|
|
1430
|
+
// flipping aria-expanded each time.
|
|
1431
|
+
const canvas = within(canvasElement);
|
|
1432
|
+
const body = within(document.body);
|
|
1433
|
+
const anchor = canvas.getByRole('button', { name: 'Open actions' });
|
|
1434
|
+
|
|
1435
|
+
await step(
|
|
1436
|
+
'keyboard: Enter opens the click-trigger panel (WCAG 2.1.1 / 4.1.2)',
|
|
1437
|
+
async () => {
|
|
1438
|
+
await userEvent.tab();
|
|
1439
|
+
await expect(anchor).toHaveFocus();
|
|
1440
|
+
// Focus alone must not open a click trigger.
|
|
1441
|
+
await expect(anchor).toHaveAttribute('aria-expanded', 'false');
|
|
1442
|
+
await userEvent.keyboard('{Enter}');
|
|
1443
|
+
await waitFor(() =>
|
|
1444
|
+
expect(anchor).toHaveAttribute('aria-expanded', 'true'),
|
|
1445
|
+
);
|
|
1446
|
+
await expect(
|
|
1447
|
+
await body.findByRole('button', { name: 'Edit' }),
|
|
1448
|
+
).toBeInTheDocument();
|
|
1449
|
+
},
|
|
1450
|
+
);
|
|
1451
|
+
|
|
1452
|
+
await step(
|
|
1453
|
+
'keyboard: Space closes the click-trigger panel (WCAG 2.1.1)',
|
|
1454
|
+
async () => {
|
|
1455
|
+
await userEvent.keyboard(' ');
|
|
1456
|
+
await waitFor(() =>
|
|
1457
|
+
expect(anchor).toHaveAttribute('aria-expanded', 'false'),
|
|
1458
|
+
);
|
|
1459
|
+
await waitFor(() =>
|
|
1460
|
+
expect(
|
|
1461
|
+
body.queryByRole('button', { name: 'Edit' }),
|
|
1462
|
+
).not.toBeInTheDocument(),
|
|
1463
|
+
);
|
|
1464
|
+
},
|
|
1465
|
+
);
|
|
1466
|
+
},
|
|
1467
|
+
};
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* The toolbar follows the WAI-ARIA APG pattern: `role="toolbar"` with roving
|
|
1471
|
+
* arrow-key focus, accessibly named items, and `click` events from buttons.
|
|
1472
|
+
* Hidden test-only story.
|
|
1473
|
+
*/
|
|
1474
|
+
export const ToolbarKeyboard: Story = {
|
|
1475
|
+
name: 'test - Toolbar keyboard & items',
|
|
1476
|
+
tags: ['!dev', '!autodocs'],
|
|
1477
|
+
render: () => ({
|
|
1478
|
+
components: { UiFloatActionItems, UiIcon },
|
|
1479
|
+
setup() {
|
|
1480
|
+
return { onItemClick };
|
|
1481
|
+
},
|
|
1482
|
+
template: `
|
|
1483
|
+
<div class="flex min-h-48 items-center justify-center p-8">
|
|
1484
|
+
<UiFloatActionItems aria-label="Paragraph actions">
|
|
1485
|
+
<UiFloatActionItems type="button" aria-label="Edit" @click="onItemClick">
|
|
1486
|
+
<UiIcon name="edit" size="s" />
|
|
1487
|
+
</UiFloatActionItems>
|
|
1488
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
1489
|
+
<UiIcon name="copy" size="s" />
|
|
1490
|
+
</UiFloatActionItems>
|
|
1491
|
+
<UiFloatActionItems type="separator" />
|
|
1492
|
+
<UiFloatActionItems type="input" aria-label="Filter value" placeholder="Filter..." />
|
|
1493
|
+
</UiFloatActionItems>
|
|
1494
|
+
</div>
|
|
1495
|
+
`,
|
|
1496
|
+
}),
|
|
1497
|
+
parameters: {
|
|
1498
|
+
chromatic: { disableSnapshot: true },
|
|
1499
|
+
docs: {
|
|
1500
|
+
description: {
|
|
1501
|
+
story:
|
|
1502
|
+
'Tab once to enter the toolbar, then use the Arrow keys to move roving focus between items.',
|
|
1503
|
+
},
|
|
1504
|
+
},
|
|
1505
|
+
},
|
|
1506
|
+
play: async ({ canvasElement, step }) => {
|
|
1507
|
+
// Scenario (UiFloatActionItems): the toolbar follows the WAI-ARIA APG
|
|
1508
|
+
// pattern — a single Tab stop enters it, Arrow keys move roving focus
|
|
1509
|
+
// between items, every item is accessibly named, and activating a button
|
|
1510
|
+
// emits its click event (asserted via the module-level `onItemClick` spy).
|
|
1511
|
+
onItemClick.mockClear();
|
|
1512
|
+
const canvas = within(canvasElement);
|
|
1513
|
+
const toolbar = canvas.getByRole('toolbar', { name: 'Paragraph actions' });
|
|
1514
|
+
const edit = canvas.getByRole('button', { name: 'Edit' });
|
|
1515
|
+
const copy = canvas.getByRole('button', { name: 'Copy' });
|
|
1516
|
+
const filter = canvas.getByRole('textbox', { name: 'Filter value' });
|
|
1517
|
+
|
|
1518
|
+
await step(
|
|
1519
|
+
'screen-reader: the toolbar and its items expose roles and accessible names (WCAG 4.1.2)',
|
|
1520
|
+
async () => {
|
|
1521
|
+
await expect(toolbar).toHaveAttribute('aria-orientation', 'horizontal');
|
|
1522
|
+
await expect(edit).toBeInTheDocument();
|
|
1523
|
+
await expect(filter).toHaveAttribute('placeholder', 'Filter...');
|
|
1524
|
+
},
|
|
1525
|
+
);
|
|
1526
|
+
|
|
1527
|
+
await step(
|
|
1528
|
+
'keyboard: the toolbar is a single Tab stop and Arrow keys move roving focus (WCAG 2.1.1)',
|
|
1529
|
+
async () => {
|
|
1530
|
+
await userEvent.tab();
|
|
1531
|
+
await expect(edit).toHaveFocus();
|
|
1532
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
1533
|
+
await expect(copy).toHaveFocus();
|
|
1534
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
1535
|
+
await expect(filter).toHaveFocus();
|
|
1536
|
+
},
|
|
1537
|
+
);
|
|
1538
|
+
|
|
1539
|
+
await step(
|
|
1540
|
+
'interaction: activating a button item emits its click event',
|
|
1541
|
+
async () => {
|
|
1542
|
+
await userEvent.click(edit);
|
|
1543
|
+
await expect(onItemClick).toHaveBeenCalledTimes(1);
|
|
1544
|
+
},
|
|
1545
|
+
);
|
|
1546
|
+
},
|
|
1547
|
+
};
|
|
1548
|
+
|
|
1549
|
+
/**
|
|
1550
|
+
* Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
|
|
1551
|
+
* try 400% reflow (WCAG 1.4.10); the toolbar must stay visible and operable.
|
|
1552
|
+
* Hidden test-only story.
|
|
1553
|
+
*/
|
|
1554
|
+
export const ZoomMagnification: Story = {
|
|
1555
|
+
name: 'test - Zoom magnification',
|
|
1556
|
+
tags: ['!dev', '!autodocs'],
|
|
1557
|
+
globals: { zoom: '200' },
|
|
1558
|
+
render: () => ({
|
|
1559
|
+
components: { UiFloatActionItems, UiIcon },
|
|
1560
|
+
setup() {
|
|
1561
|
+
return { onItemClick };
|
|
1562
|
+
},
|
|
1563
|
+
template: `
|
|
1564
|
+
<div class="flex min-h-48 items-center justify-center p-8">
|
|
1565
|
+
<UiFloatActionItems aria-label="Paragraph actions">
|
|
1566
|
+
<UiFloatActionItems type="button" aria-label="Edit" @click="onItemClick">
|
|
1567
|
+
<UiIcon name="edit" size="s" />
|
|
1568
|
+
</UiFloatActionItems>
|
|
1569
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
1570
|
+
<UiIcon name="copy" size="s" />
|
|
1571
|
+
</UiFloatActionItems>
|
|
1572
|
+
<UiFloatActionItems type="button" aria-label="Delete">
|
|
1573
|
+
<UiIcon name="trash" size="s" />
|
|
1574
|
+
</UiFloatActionItems>
|
|
1575
|
+
</UiFloatActionItems>
|
|
1576
|
+
</div>
|
|
1577
|
+
`,
|
|
1578
|
+
}),
|
|
1579
|
+
parameters: {
|
|
1580
|
+
// Zoom changes the layout scale; the accessible-reflow Chromatic mode
|
|
1581
|
+
// already covers magnified snapshots, so skip this one.
|
|
1582
|
+
chromatic: { disableSnapshot: true },
|
|
1583
|
+
docs: {
|
|
1584
|
+
description: {
|
|
1585
|
+
story:
|
|
1586
|
+
'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
|
|
1587
|
+
},
|
|
1588
|
+
},
|
|
1589
|
+
},
|
|
1590
|
+
play: async ({ canvasElement, step }) => {
|
|
1591
|
+
// Scenario (UiFloatActionItems): at 200% page zoom the toolbar stays visible,
|
|
1592
|
+
// keeps its accessible names, and remains operable.
|
|
1593
|
+
onItemClick.mockClear();
|
|
1594
|
+
const canvas = within(canvasElement);
|
|
1595
|
+
const edit = canvas.getByRole('button', { name: 'Edit' });
|
|
1596
|
+
|
|
1597
|
+
await step(
|
|
1598
|
+
'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
|
|
1599
|
+
async () => {
|
|
1600
|
+
await expect(document.documentElement.style.zoom).toBe('200%');
|
|
1601
|
+
},
|
|
1602
|
+
);
|
|
1603
|
+
|
|
1604
|
+
await step(
|
|
1605
|
+
'zoom: the toolbar and its buttons stay visible with their accessible names',
|
|
1606
|
+
async () => {
|
|
1607
|
+
await expect(
|
|
1608
|
+
canvas.getByRole('toolbar', { name: 'Paragraph actions' }),
|
|
1609
|
+
).toBeVisible();
|
|
1610
|
+
await expect(edit).toBeVisible();
|
|
1611
|
+
await expect(edit).toHaveAccessibleName('Edit');
|
|
1612
|
+
},
|
|
1613
|
+
);
|
|
1614
|
+
|
|
1615
|
+
await step('zoom: remains operable when magnified', async () => {
|
|
1616
|
+
await userEvent.click(edit);
|
|
1617
|
+
await expect(onItemClick).toHaveBeenCalledTimes(1);
|
|
1618
|
+
});
|
|
1619
|
+
},
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
/**
|
|
1623
|
+
* Rendered at the 320px mobile reflow breakpoint. The toolbar stays labelled,
|
|
1624
|
+
* keyboard operable via roving focus, and its buttons meet the minimum
|
|
1625
|
+
* touch-target size. Hidden test-only story.
|
|
1626
|
+
*/
|
|
1627
|
+
export const MobileBreakpoint: Story = {
|
|
1628
|
+
name: 'test - Mobile breakpoint',
|
|
1629
|
+
tags: ['!dev', '!autodocs'],
|
|
1630
|
+
globals: { mediaBreakpoint: 'reflow' },
|
|
1631
|
+
render: () => ({
|
|
1632
|
+
components: { UiFloatActionItems, UiIcon },
|
|
1633
|
+
template: `
|
|
1634
|
+
<div class="flex min-h-48 items-center justify-center p-8">
|
|
1635
|
+
<UiFloatActionItems aria-label="Paragraph actions">
|
|
1636
|
+
<UiFloatActionItems type="button" aria-label="Edit">
|
|
1637
|
+
<UiIcon name="edit" size="s" />
|
|
1638
|
+
</UiFloatActionItems>
|
|
1639
|
+
<UiFloatActionItems type="button" aria-label="Copy">
|
|
1640
|
+
<UiIcon name="copy" size="s" />
|
|
1641
|
+
</UiFloatActionItems>
|
|
1642
|
+
</UiFloatActionItems>
|
|
1643
|
+
</div>
|
|
1644
|
+
`,
|
|
1645
|
+
}),
|
|
1646
|
+
parameters: {
|
|
1647
|
+
// Reflow snapshots are already covered by the accessible-reflow Chromatic
|
|
1648
|
+
// mode, and the play moves focus, so skip this snapshot.
|
|
1649
|
+
chromatic: { disableSnapshot: true },
|
|
1650
|
+
docs: {
|
|
1651
|
+
description: {
|
|
1652
|
+
story:
|
|
1653
|
+
'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
|
|
1654
|
+
},
|
|
1655
|
+
},
|
|
1656
|
+
},
|
|
1657
|
+
play: async ({ canvasElement, step }) => {
|
|
1658
|
+
// Scenario (UiFloatActionItems): at the 320px mobile breakpoint the toolbar
|
|
1659
|
+
// stays labelled, keyboard operable (roving focus), and its buttons meet the
|
|
1660
|
+
// minimum touch-target size.
|
|
1661
|
+
const canvas = within(canvasElement);
|
|
1662
|
+
const toolbar = canvas.getByRole('toolbar', { name: 'Paragraph actions' });
|
|
1663
|
+
const edit = canvas.getByRole('button', { name: 'Edit' });
|
|
1664
|
+
const copy = canvas.getByRole('button', { name: 'Copy' });
|
|
1665
|
+
|
|
1666
|
+
await step(
|
|
1667
|
+
'mobile: exposes a labelled toolbar and named items at the 320px breakpoint (WCAG 4.1.2)',
|
|
1668
|
+
async () => {
|
|
1669
|
+
await expect(toolbar).toBeVisible();
|
|
1670
|
+
await expect(edit).toHaveAccessibleName('Edit');
|
|
1671
|
+
},
|
|
1672
|
+
);
|
|
1673
|
+
|
|
1674
|
+
await step(
|
|
1675
|
+
'mobile: stays keyboard operable — Tab enters the toolbar and Arrow keys move roving focus (WCAG 2.1.1)',
|
|
1676
|
+
async () => {
|
|
1677
|
+
await userEvent.tab();
|
|
1678
|
+
await expect(edit).toHaveFocus();
|
|
1679
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
1680
|
+
await expect(copy).toHaveFocus();
|
|
1681
|
+
},
|
|
1682
|
+
);
|
|
1683
|
+
|
|
1684
|
+
await step(
|
|
1685
|
+
'mobile: the toolbar buttons meet the minimum touch-target size (WCAG 2.5.8)',
|
|
1686
|
+
async () => {
|
|
1687
|
+
const { width, height } = edit.getBoundingClientRect();
|
|
1688
|
+
await expect(width).toBeGreaterThanOrEqual(24);
|
|
1689
|
+
await expect(height).toBeGreaterThanOrEqual(24);
|
|
1690
|
+
},
|
|
1691
|
+
);
|
|
899
1692
|
},
|
|
900
1693
|
};
|