@aleph-alpha/ui-library 2.11.0 → 2.12.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 +8 -2
- package/config.js +85 -73
- package/dist/system/components/UiAutocomplete/types.d.ts +0 -1
- package/dist/system/components/UiDialog/UiDialogDescription.vue.d.ts +2 -1
- package/dist/system/components/UiDialog/UiDialogFooter.vue.d.ts +1 -2
- package/dist/system/components/UiDialog/UiDialogHeader.vue.d.ts +1 -2
- package/dist/system/components/UiDialog/UiDialogTitle.vue.d.ts +2 -1
- package/dist/system/components/UiDialog/types.d.ts +10 -4
- package/dist/system/components/UiDropdownMenu/UiDropdownMenuSub.vue.d.ts +3 -1
- package/dist/system/components/UiField/UiFieldError.vue.d.ts +8 -1
- package/dist/system/components/UiInput/UiInput.vue.d.ts +16 -1
- package/dist/system/components/UiStepper/UiStepperDescription.vue.d.ts +3 -1
- package/dist/system/components/UiStepper/UiStepperIndicator.vue.d.ts +3 -1
- package/dist/system/components/UiStepper/UiStepperItem.vue.d.ts +3 -1
- package/dist/system/components/UiTagsInput/types.d.ts +1 -2
- package/dist/system/components/core/accordion/AccordionItem.vue.d.ts +3 -1
- package/dist/system/components/core/calendar/CalendarHeading.vue.d.ts +2 -2
- package/dist/system/components/core/dropdown-menu/DropdownMenuSub.vue.d.ts +3 -1
- package/dist/system/components/core/range-calendar/RangeCalendarHeading.vue.d.ts +2 -2
- package/dist/system/components/core/stepper/StepperDescription.vue.d.ts +3 -1
- package/dist/system/components/core/stepper/StepperIndicator.vue.d.ts +3 -1
- package/dist/system/components/core/stepper/StepperItem.vue.d.ts +3 -1
- package/dist/system/index.d.ts +2 -1
- package/dist/system/lib/utils.d.ts +6 -0
- package/dist/system/lib.js +15498 -15548
- package/dist/system/patterns/UiSidebar/UiSidebarContent.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarFooter.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarGroupContent.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarInset.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarMenu.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarMenuItem.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarProvider.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarRail.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/__tests__/sidebar-test-helpers.d.ts +9 -9
- package/dist/system/patterns/UiSidebar/types.d.ts +8 -16
- package/dist/system/story-sidebar-icons.json +10 -0
- package/package.json +5 -2
- package/src/@types/shims-vue.d.ts +1 -1
- package/src/__tests__/test-utils.ts +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogAction.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogCancel.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogContent.vue +4 -1
- package/src/components/UiAlertDialog/UiAlertDialogDescription.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogTitle.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogTrigger.vue +1 -1
- package/src/components/UiAutocomplete/types.ts +0 -1
- package/src/components/UiBadge/UiBadge.vue +1 -1
- package/src/components/UiBadge/constants.ts +1 -1
- package/src/components/UiBadge/types.ts +1 -1
- package/src/components/UiButton/UiButton.stories.ts +286 -198
- package/src/components/UiButton/mcp-docs.json +49 -0
- package/src/components/UiCalendar/UiCalendar.vue +2 -5
- package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +4 -2
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +176 -2
- package/src/components/UiCheckbox/mcp-docs.json +36 -0
- package/src/components/UiChip/types.ts +1 -1
- package/src/components/UiDialog/UiDialogFooter.vue +0 -3
- package/src/components/UiDialog/UiDialogHeader.vue +0 -3
- package/src/components/UiDialog/types.ts +10 -4
- package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +1 -1
- package/src/components/UiField/UiField.stories.ts +265 -3
- package/src/components/UiField/UiField.vue +9 -2
- package/src/components/UiField/UiFieldError.vue +3 -3
- package/src/components/UiField/mcp-docs.json +72 -0
- package/src/components/UiFileItem/UiFileItem.stories.ts +11 -11
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +1 -1
- package/src/components/UiIcon/UiIcon.vue +3 -2
- package/src/components/UiInput/UiInput.vue +19 -3
- package/src/components/UiInput/mcp-docs.json +51 -0
- package/src/components/UiItem/UiItem.stories.ts +118 -2
- package/src/components/UiItem/__tests__/UiItem.test.ts +3 -5
- package/src/components/UiItem/mcp-docs.json +25 -0
- package/src/components/UiLabel/UiLabel.vue +1 -1
- package/src/components/UiListbox/UiListbox.vue +3 -6
- package/src/components/UiListbox/UiListboxFilter.vue +1 -1
- package/src/components/UiListbox/UiListboxItem.vue +1 -1
- package/src/components/UiProgress/UiProgress.vue +1 -1
- package/src/components/UiRadioGroup/UiRadioGroup.vue +1 -1
- package/src/components/UiRadioGroup/UiRadioGroupItem.vue +2 -2
- package/src/components/UiRadioGroup/__tests__/UiRadioGroup.test.ts +2 -2
- package/src/components/UiRangeCalendar/UiRangeCalendar.vue +2 -5
- package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +9 -6
- package/src/components/UiSelect/UiSelectContent.vue +2 -4
- package/src/components/UiSwitch/UiSwitch.vue +1 -1
- package/src/components/UiTagsInput/UiTagsInput.vue +1 -1
- package/src/components/UiTagsInput/UiTagsInputInput.vue +1 -1
- package/src/components/UiTagsInput/UiTagsInputItem.vue +1 -1
- package/src/components/UiTagsInput/types.ts +1 -4
- package/src/components/UiTooltip/UiTooltip.stories.ts +0 -8
- package/src/components/core/accordion/AccordionItem.vue +1 -1
- package/src/components/core/alert-dialog/AlertDialogContent.vue +1 -1
- package/src/components/core/badge/Badge.vue +2 -5
- package/src/components/core/calendar/CalendarHeading.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuSub.vue +1 -1
- package/src/components/core/item/index.ts +1 -1
- package/src/components/core/listbox/Listbox.vue +2 -5
- package/src/components/core/listbox/ListboxContent.vue +2 -5
- package/src/components/core/listbox/ListboxFilter.vue +2 -5
- package/src/components/core/listbox/ListboxGroup.vue +2 -5
- package/src/components/core/listbox/ListboxGroupLabel.vue +2 -5
- package/src/components/core/listbox/ListboxItem.vue +2 -5
- package/src/components/core/listbox/ListboxItemIndicator.vue +2 -5
- package/src/components/core/range-calendar/RangeCalendarHeading.vue +1 -1
- package/src/components/core/sidebar/SidebarContent.vue +4 -5
- package/src/components/core/sidebar/SidebarFooter.vue +4 -5
- package/src/components/core/sidebar/SidebarGroup.vue +4 -5
- package/src/components/core/sidebar/SidebarHeader.vue +4 -5
- package/src/components/core/sidebar/SidebarMenu.vue +4 -5
- package/src/components/core/sidebar/SidebarMenuAction.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuButtonChild.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuSkeleton.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuSubButton.vue +1 -1
- package/src/components/core/sidebar/SidebarSeparator.vue +4 -5
- package/src/components/core/stepper/StepperDescription.vue +1 -1
- package/src/components/core/stepper/StepperIndicator.vue +1 -1
- package/src/components/core/stepper/StepperItem.vue +1 -1
- package/src/components/core/tags-input/TagsInput.vue +2 -5
- package/src/components/core/tags-input/TagsInputInput.vue +2 -5
- package/src/components/core/tags-input/TagsInputItem.vue +2 -5
- package/src/components/core/tags-input/TagsInputItemDelete.vue +2 -5
- package/src/components/core/tags-input/TagsInputItemText.vue +2 -5
- package/src/components/core/toggle/Toggle.vue +1 -1
- package/src/index.ts +30 -5
- package/src/lib/useDrag.ts +1 -0
- package/src/lib/utils.ts +12 -0
- package/src/patterns/UiDataTable/UiDataTable.mock.ts +13 -4
- package/src/patterns/UiDataTable/UiDataTable.vue +1 -0
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +11 -2
- package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +28 -39
- package/src/patterns/UiSidebar/UiSidebarContent.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarFooter.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarGroup.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarHeader.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarInset.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarMenu.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarMenuItem.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarMenuSub.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverMenu.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarProvider.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarRail.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarSub.vue +4 -5
- package/src/patterns/UiSidebar/__tests__/UiSidebar.test.ts +21 -17
- package/src/patterns/UiSidebar/__tests__/UiSidebarMenuButton.test.ts +12 -10
- package/src/patterns/UiSidebar/types.ts +8 -8
- package/src/theme/Typography.stories.ts +3 -2
|
@@ -17,10 +17,12 @@ const MailIcon = {
|
|
|
17
17
|
template: '<UiIcon name="mail" :size="16" />',
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
const designStoryLink = '/?path=/docs/components-uibutton--design-notes';
|
|
21
|
+
const accessibilityStoryLink =
|
|
22
|
+
'/?path=/docs/components-uibutton--accessibility';
|
|
23
|
+
|
|
20
24
|
/**
|
|
21
|
-
*
|
|
22
|
-
* Use the `variant` and `size` props for emphasis and density, slot in icons, or use `as-child` to render an `<a>` for link-style navigation.
|
|
23
|
-
* For icon-only buttons, use `UiButton` with an icon child and an `aria-label`.
|
|
25
|
+
* Buttons are used to initiate actions within an application. Their labels clearly describe the action they trigger.
|
|
24
26
|
*/
|
|
25
27
|
const meta: Meta<typeof UiButton> = {
|
|
26
28
|
title: 'Components/UiButton',
|
|
@@ -77,6 +79,22 @@ const meta: Meta<typeof UiButton> = {
|
|
|
77
79
|
disabled: false,
|
|
78
80
|
loading: false,
|
|
79
81
|
},
|
|
82
|
+
parameters: {
|
|
83
|
+
docs: {
|
|
84
|
+
links: [
|
|
85
|
+
{
|
|
86
|
+
label: 'Designer docs',
|
|
87
|
+
href: designStoryLink,
|
|
88
|
+
icon: 'palette',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
label: 'Accessibility',
|
|
92
|
+
href: accessibilityStoryLink,
|
|
93
|
+
icon: 'accessibility',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
80
98
|
};
|
|
81
99
|
|
|
82
100
|
export default meta;
|
|
@@ -111,6 +129,184 @@ export const Default: Story = {
|
|
|
111
129
|
},
|
|
112
130
|
};
|
|
113
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Design guidance for choosing button variants by action priority.
|
|
134
|
+
*/
|
|
135
|
+
export const DesignNotes: Story = {
|
|
136
|
+
render: () => ({
|
|
137
|
+
components: { UiButton },
|
|
138
|
+
template: `
|
|
139
|
+
<section class="flex flex-col gap-8 p-4 bg-surface-secondary">
|
|
140
|
+
<div>
|
|
141
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">Usage</h2>
|
|
142
|
+
<p class="body-16-regular mt-2 text-content-on-surface-primary">
|
|
143
|
+
To help users clearly understand primary, secondary, and other types of
|
|
144
|
+
buttons, make sure to consider the action. Use the guidelines below to
|
|
145
|
+
determine the correct button to use.
|
|
146
|
+
</p>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<div class="grid gap-x-12 gap-y-6 md:grid-cols-[160px_1fr]">
|
|
150
|
+
<div>
|
|
151
|
+
<UiButton>Primary</UiButton>
|
|
152
|
+
</div>
|
|
153
|
+
<p class="label-16-regular text-content-on-surface-primary">
|
|
154
|
+
Reserved for the main call to action on a page. Only one primary button
|
|
155
|
+
should be used per screen (excluding application headers, modal dialogs,
|
|
156
|
+
or side panels).
|
|
157
|
+
</p>
|
|
158
|
+
|
|
159
|
+
<div>
|
|
160
|
+
<UiButton variant="secondary">Secondary</UiButton>
|
|
161
|
+
</div>
|
|
162
|
+
<p class="label-16-regular text-content-on-surface-primary">
|
|
163
|
+
Use for less prominent but still important actions.
|
|
164
|
+
</p>
|
|
165
|
+
|
|
166
|
+
<div>
|
|
167
|
+
<UiButton variant="outline">Outlined</UiButton>
|
|
168
|
+
</div>
|
|
169
|
+
<p class="label-16-regular text-content-on-surface-primary">
|
|
170
|
+
For less prominent or independent actions. These buttons can be used
|
|
171
|
+
alone or paired with a primary button when multiple actions are present.
|
|
172
|
+
They are also suitable for subtasks where the primary button performs
|
|
173
|
+
the main action.
|
|
174
|
+
</p>
|
|
175
|
+
|
|
176
|
+
<div>
|
|
177
|
+
<UiButton variant="ghost">Ghost</UiButton>
|
|
178
|
+
</div>
|
|
179
|
+
<p class="label-16-regular text-content-on-surface-primary">
|
|
180
|
+
For subtle actions with little emphasis, or for use with a primary
|
|
181
|
+
button in a button row (for example, dialogs: "Cancel" next to a primary
|
|
182
|
+
"Submit").
|
|
183
|
+
</p>
|
|
184
|
+
|
|
185
|
+
<div>
|
|
186
|
+
<UiButton variant="destructive">Destructive</UiButton>
|
|
187
|
+
</div>
|
|
188
|
+
<p class="label-16-regular text-content-on-surface-primary">
|
|
189
|
+
For critical actions, like deleting or removing.
|
|
190
|
+
</p>
|
|
191
|
+
|
|
192
|
+
<div>
|
|
193
|
+
<UiButton variant="link">Link</UiButton>
|
|
194
|
+
</div>
|
|
195
|
+
<p class="label-16-regular text-content-on-surface-primary">
|
|
196
|
+
For when a link is required.
|
|
197
|
+
</p>
|
|
198
|
+
</div>
|
|
199
|
+
</section>
|
|
200
|
+
`,
|
|
201
|
+
}),
|
|
202
|
+
parameters: {
|
|
203
|
+
chromatic: {
|
|
204
|
+
disableSnapshot: true,
|
|
205
|
+
},
|
|
206
|
+
docs: {
|
|
207
|
+
canvas: {
|
|
208
|
+
sourceState: 'none',
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Accessibility guidance for button labels, icon-only buttons, and contrast.
|
|
216
|
+
*/
|
|
217
|
+
export const Accessibility: Story = {
|
|
218
|
+
render: () => ({
|
|
219
|
+
components: { UiButton },
|
|
220
|
+
template: `
|
|
221
|
+
<section class="flex flex-col gap-6 p-4">
|
|
222
|
+
<div>
|
|
223
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
224
|
+
Accessibility
|
|
225
|
+
</h2>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
<div class="flex flex-col gap-6">
|
|
229
|
+
<div class="flex flex-col gap-2">
|
|
230
|
+
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
231
|
+
Make sure button labels are unique and descriptive
|
|
232
|
+
</h3>
|
|
233
|
+
<p class="body-16-regular text-content-on-surface-primary">
|
|
234
|
+
Labels like "Click Here" and "Read More" don't provide context. In
|
|
235
|
+
addition, some screen reader users also navigate through a list of all
|
|
236
|
+
the buttons on a page or screen. Therefore, all button labels should
|
|
237
|
+
provide an indication of what will happen if activated.
|
|
238
|
+
</p>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<div class="flex flex-col gap-2">
|
|
242
|
+
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
243
|
+
Icon-only buttons should be used carefully and only after checking for accessibility
|
|
244
|
+
</h3>
|
|
245
|
+
<p class="body-16-regular text-content-on-surface-primary">
|
|
246
|
+
The meaning of the icon must be visually self-evident (easily and
|
|
247
|
+
universally understood). In addition, a programmatically associated
|
|
248
|
+
semantic label (such as an aria-label attribute) should be added so it
|
|
249
|
+
can be read by screen readers. If you're in any doubt that an
|
|
250
|
+
icon-only button will be understood, use accompanying text in your
|
|
251
|
+
button label.
|
|
252
|
+
<br />
|
|
253
|
+
WCAG 2.2:
|
|
254
|
+
<a
|
|
255
|
+
href="https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html"
|
|
256
|
+
target="_blank"
|
|
257
|
+
rel="noopener noreferrer"
|
|
258
|
+
class="text-content-link-default underline"
|
|
259
|
+
>
|
|
260
|
+
1.3.1 Info and Relationships
|
|
261
|
+
</a>
|
|
262
|
+
</p>
|
|
263
|
+
</div>
|
|
264
|
+
|
|
265
|
+
<div class="flex flex-col gap-2">
|
|
266
|
+
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
267
|
+
Enable accessibility theme
|
|
268
|
+
</h3>
|
|
269
|
+
<p class="body-16-regular text-content-on-surface-primary">
|
|
270
|
+
When accessibility is required, enable our accessibility theme. This
|
|
271
|
+
increases contrast and makes sure there are no color contrast issues.
|
|
272
|
+
</p>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
|
|
276
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
277
|
+
<div class="flex flex-col gap-3">
|
|
278
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
279
|
+
Default
|
|
280
|
+
</h3>
|
|
281
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
282
|
+
<UiButton>Submit</UiButton>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
287
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
288
|
+
Accessible
|
|
289
|
+
</h3>
|
|
290
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
291
|
+
<UiButton>Submit</UiButton>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
</section>
|
|
296
|
+
`,
|
|
297
|
+
}),
|
|
298
|
+
parameters: {
|
|
299
|
+
chromatic: {
|
|
300
|
+
disableSnapshot: true,
|
|
301
|
+
},
|
|
302
|
+
docs: {
|
|
303
|
+
canvas: {
|
|
304
|
+
sourceState: 'none',
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
|
|
114
310
|
const outlineTemplateSource = `<script setup lang="ts">
|
|
115
311
|
import { UiButton } from '@aleph-alpha/ui-library'
|
|
116
312
|
</script>
|
|
@@ -241,25 +437,51 @@ import { UiButton } from '@aleph-alpha/ui-library'
|
|
|
241
437
|
</script>
|
|
242
438
|
|
|
243
439
|
<template>
|
|
244
|
-
<div class="
|
|
245
|
-
<UiButton size="sm"
|
|
246
|
-
<UiButton
|
|
247
|
-
<UiButton size="lg"
|
|
440
|
+
<div class="grid gap-4 md:grid-cols-3">
|
|
441
|
+
<UiButton size="sm">Primary</UiButton>
|
|
442
|
+
<UiButton>Primary</UiButton>
|
|
443
|
+
<UiButton size="lg">Primary</UiButton>
|
|
248
444
|
</div>
|
|
249
445
|
</template>`;
|
|
250
446
|
|
|
251
447
|
/**
|
|
252
|
-
* Button
|
|
448
|
+
* Button size guidance.
|
|
253
449
|
*/
|
|
254
450
|
export const Sizes: Story = {
|
|
255
451
|
render: () => ({
|
|
256
452
|
components: { UiButton },
|
|
257
453
|
template: `
|
|
258
|
-
<
|
|
259
|
-
<
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
454
|
+
<section class="flex flex-col gap-6 rounded-lg bg-background-surface-primary p-4">
|
|
455
|
+
<div>
|
|
456
|
+
<h2 class="heading-s text-content-on-surface-primary">Sizes</h2>
|
|
457
|
+
<p class="body-14-regular mt-2 text-content-on-surface-primary">
|
|
458
|
+
Buttons come in three sizes: small, default and large. Buttons should match in size.
|
|
459
|
+
</p>
|
|
460
|
+
</div>
|
|
461
|
+
|
|
462
|
+
<div class="grid gap-4 md:grid-cols-3">
|
|
463
|
+
<div class="flex flex-col gap-3">
|
|
464
|
+
<h3 class="label-14-medium text-center text-content-on-surface-primary">Small</h3>
|
|
465
|
+
<div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
|
|
466
|
+
<UiButton size="sm">Primary</UiButton>
|
|
467
|
+
</div>
|
|
468
|
+
</div>
|
|
469
|
+
|
|
470
|
+
<div class="flex flex-col gap-3">
|
|
471
|
+
<h3 class="label-14-medium text-center text-content-on-surface-primary">Default</h3>
|
|
472
|
+
<div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
|
|
473
|
+
<UiButton>Primary</UiButton>
|
|
474
|
+
</div>
|
|
475
|
+
</div>
|
|
476
|
+
|
|
477
|
+
<div class="flex flex-col gap-3">
|
|
478
|
+
<h3 class="label-14-medium text-center text-content-on-surface-primary">Large</h3>
|
|
479
|
+
<div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
|
|
480
|
+
<UiButton size="lg">Primary</UiButton>
|
|
481
|
+
</div>
|
|
482
|
+
</div>
|
|
483
|
+
</div>
|
|
484
|
+
</section>
|
|
263
485
|
`,
|
|
264
486
|
}),
|
|
265
487
|
parameters: {
|
|
@@ -271,41 +493,13 @@ export const Sizes: Story = {
|
|
|
271
493
|
},
|
|
272
494
|
};
|
|
273
495
|
|
|
274
|
-
const
|
|
496
|
+
const iconUsageTemplateSource = `<script setup lang="ts">
|
|
275
497
|
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
276
498
|
|
|
277
499
|
const ChevronLeftIcon = {
|
|
278
500
|
components: { UiIcon },
|
|
279
501
|
template: '<UiIcon name="chevron-left" :size="16" />',
|
|
280
502
|
}
|
|
281
|
-
</script>
|
|
282
|
-
|
|
283
|
-
<template>
|
|
284
|
-
<UiButton :start-icon="ChevronLeftIcon">Back</UiButton>
|
|
285
|
-
</template>`;
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Use the `startIcon` prop to add an icon before the button text.
|
|
289
|
-
*/
|
|
290
|
-
export const WithStartIcon: Story = {
|
|
291
|
-
render: () => ({
|
|
292
|
-
components: { UiButton },
|
|
293
|
-
setup() {
|
|
294
|
-
return { ChevronLeftIcon };
|
|
295
|
-
},
|
|
296
|
-
template: `<UiButton :start-icon="ChevronLeftIcon">Back</UiButton>`,
|
|
297
|
-
}),
|
|
298
|
-
parameters: {
|
|
299
|
-
docs: {
|
|
300
|
-
source: {
|
|
301
|
-
code: withStartIconTemplateSource,
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
const withEndIconTemplateSource = `<script setup lang="ts">
|
|
308
|
-
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
309
503
|
|
|
310
504
|
const ChevronRightIcon = {
|
|
311
505
|
components: { UiIcon },
|
|
@@ -314,64 +508,68 @@ const ChevronRightIcon = {
|
|
|
314
508
|
</script>
|
|
315
509
|
|
|
316
510
|
<template>
|
|
317
|
-
<
|
|
511
|
+
<div class="grid gap-4 md:grid-cols-3">
|
|
512
|
+
<UiButton :end-icon="ChevronRightIcon">Primary</UiButton>
|
|
513
|
+
<UiButton :start-icon="ChevronLeftIcon">Primary</UiButton>
|
|
514
|
+
<UiButton size="icon-sm" aria-label="Go back">
|
|
515
|
+
<UiIcon name="chevron-left" :size="16" />
|
|
516
|
+
</UiButton>
|
|
517
|
+
</div>
|
|
318
518
|
</template>`;
|
|
319
519
|
|
|
320
520
|
/**
|
|
321
|
-
*
|
|
521
|
+
* Guidance for placing icons in buttons.
|
|
322
522
|
*/
|
|
323
|
-
export const
|
|
523
|
+
export const IconUsage: Story = {
|
|
324
524
|
render: () => ({
|
|
325
|
-
components: { UiButton },
|
|
525
|
+
components: { UiButton, UiIcon },
|
|
326
526
|
setup() {
|
|
327
|
-
return { ChevronRightIcon };
|
|
328
|
-
},
|
|
329
|
-
template: `<UiButton :end-icon="ChevronRightIcon">Next</UiButton>`,
|
|
330
|
-
}),
|
|
331
|
-
parameters: {
|
|
332
|
-
docs: {
|
|
333
|
-
source: {
|
|
334
|
-
code: withEndIconTemplateSource,
|
|
335
|
-
},
|
|
527
|
+
return { ChevronLeftIcon, ChevronRightIcon };
|
|
336
528
|
},
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
components: { UiIcon },
|
|
350
|
-
template: '<UiIcon name="chevron-right" :size="16" />',
|
|
351
|
-
}
|
|
352
|
-
</script>
|
|
353
|
-
|
|
354
|
-
<template>
|
|
355
|
-
<UiButton :start-icon="MailIcon" :end-icon="ChevronRightIcon">
|
|
356
|
-
Login with Email
|
|
357
|
-
</UiButton>
|
|
358
|
-
</template>`;
|
|
529
|
+
template: `
|
|
530
|
+
<section class="flex flex-col gap-6 rounded-lg bg-background-surface-primary p-4">
|
|
531
|
+
<div>
|
|
532
|
+
<h2 class="heading-s text-content-on-surface-primary">Icon usage</h2>
|
|
533
|
+
<p class="body-14-regular mt-2 text-content-on-surface-primary">
|
|
534
|
+
There are three options for placing icons within buttons. Use only one icon per button.
|
|
535
|
+
</p>
|
|
536
|
+
<p class="body-14-regular mt-6 text-content-on-surface-primary">
|
|
537
|
+
Icon-only buttons can only be used when the user's action is very clear and doesn't need
|
|
538
|
+
explanatory text. Examples include down and next arrows.
|
|
539
|
+
</p>
|
|
540
|
+
</div>
|
|
359
541
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
542
|
+
<div class="grid gap-4 md:grid-cols-3">
|
|
543
|
+
<div class="flex flex-col gap-3">
|
|
544
|
+
<h3 class="label-14-medium text-center text-content-on-surface-primary">Icon right</h3>
|
|
545
|
+
<div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
|
|
546
|
+
<UiButton :end-icon="ChevronRightIcon">Primary</UiButton>
|
|
547
|
+
</div>
|
|
548
|
+
</div>
|
|
549
|
+
|
|
550
|
+
<div class="flex flex-col gap-3">
|
|
551
|
+
<h3 class="label-14-medium text-center text-content-on-surface-primary">Icon left</h3>
|
|
552
|
+
<div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
|
|
553
|
+
<UiButton :start-icon="ChevronLeftIcon">Primary</UiButton>
|
|
554
|
+
</div>
|
|
555
|
+
</div>
|
|
556
|
+
|
|
557
|
+
<div class="flex flex-col gap-3">
|
|
558
|
+
<h3 class="label-14-medium text-center text-content-on-surface-primary">Icon only</h3>
|
|
559
|
+
<div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
|
|
560
|
+
<UiButton size="icon-sm" aria-label="Go back">
|
|
561
|
+
<UiIcon name="chevron-left" :size="16" />
|
|
562
|
+
</UiButton>
|
|
563
|
+
</div>
|
|
564
|
+
</div>
|
|
565
|
+
</div>
|
|
566
|
+
</section>
|
|
567
|
+
`,
|
|
370
568
|
}),
|
|
371
569
|
parameters: {
|
|
372
570
|
docs: {
|
|
373
571
|
source: {
|
|
374
|
-
code:
|
|
572
|
+
code: iconUsageTemplateSource,
|
|
375
573
|
},
|
|
376
574
|
},
|
|
377
575
|
},
|
|
@@ -451,39 +649,6 @@ export const LoadingWithBothIcons: Story = {
|
|
|
451
649
|
},
|
|
452
650
|
};
|
|
453
651
|
|
|
454
|
-
const withIconSlotTemplateSource = `<script setup lang="ts">
|
|
455
|
-
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
456
|
-
</script>
|
|
457
|
-
|
|
458
|
-
<template>
|
|
459
|
-
<UiButton variant="outline" size="sm">
|
|
460
|
-
<UiIcon name="git-branch" :size="16" />
|
|
461
|
-
New Branch
|
|
462
|
-
</UiButton>
|
|
463
|
-
</template>`;
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* For maximum flexibility, you can use slots to render custom icon content.
|
|
467
|
-
*/
|
|
468
|
-
export const WithIconSlot: Story = {
|
|
469
|
-
render: () => ({
|
|
470
|
-
components: { UiButton, UiIcon },
|
|
471
|
-
template: `
|
|
472
|
-
<UiButton variant="outline" size="sm">
|
|
473
|
-
<UiIcon name="git-branch" :size="16" />
|
|
474
|
-
New Branch
|
|
475
|
-
</UiButton>
|
|
476
|
-
`,
|
|
477
|
-
}),
|
|
478
|
-
parameters: {
|
|
479
|
-
docs: {
|
|
480
|
-
source: {
|
|
481
|
-
code: withIconSlotTemplateSource,
|
|
482
|
-
},
|
|
483
|
-
},
|
|
484
|
-
},
|
|
485
|
-
};
|
|
486
|
-
|
|
487
652
|
const asChildTemplateSource = `<script setup lang="ts">
|
|
488
653
|
import { UiButton } from '@aleph-alpha/ui-library'
|
|
489
654
|
</script>
|
|
@@ -616,83 +781,6 @@ export const DisabledHoverBleed: Story = {
|
|
|
616
781
|
},
|
|
617
782
|
};
|
|
618
783
|
|
|
619
|
-
const iconSizesTemplateSource = `<script setup lang="ts">
|
|
620
|
-
import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
|
|
621
|
-
</script>
|
|
622
|
-
|
|
623
|
-
<template>
|
|
624
|
-
<div class="flex flex-wrap items-end gap-6">
|
|
625
|
-
<div class="flex flex-col items-center gap-2">
|
|
626
|
-
<span class="label-12-medium text-muted-foreground">icon-sm-no-padding</span>
|
|
627
|
-
<UiButton variant="outline" size="icon-sm-no-padding" aria-label="Close">
|
|
628
|
-
<UiIcon name="x" />
|
|
629
|
-
</UiButton>
|
|
630
|
-
</div>
|
|
631
|
-
<div class="flex flex-col items-center gap-2">
|
|
632
|
-
<span class="label-12-medium text-muted-foreground">icon-sm</span>
|
|
633
|
-
<UiButton variant="outline" size="icon-sm" aria-label="Close">
|
|
634
|
-
<UiIcon name="x" />
|
|
635
|
-
</UiButton>
|
|
636
|
-
</div>
|
|
637
|
-
<div class="flex flex-col items-center gap-2">
|
|
638
|
-
<span class="label-12-medium text-muted-foreground">icon</span>
|
|
639
|
-
<UiButton variant="outline" size="icon" aria-label="Close">
|
|
640
|
-
<UiIcon name="x" />
|
|
641
|
-
</UiButton>
|
|
642
|
-
</div>
|
|
643
|
-
<div class="flex flex-col items-center gap-2">
|
|
644
|
-
<span class="label-12-medium text-muted-foreground">icon-lg</span>
|
|
645
|
-
<UiButton variant="outline" size="icon-lg" aria-label="Close">
|
|
646
|
-
<UiIcon name="x" />
|
|
647
|
-
</UiButton>
|
|
648
|
-
</div>
|
|
649
|
-
</div>
|
|
650
|
-
</template>`;
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* Icon-only button sizes — render a single icon as the slot content and always pass an `aria-label`.
|
|
654
|
-
*/
|
|
655
|
-
export const IconSizes: Story = {
|
|
656
|
-
render: () => ({
|
|
657
|
-
components: { UiButton, UiIcon },
|
|
658
|
-
template: `
|
|
659
|
-
<div class="flex flex-wrap items-end gap-6">
|
|
660
|
-
<div class="flex flex-col items-center gap-2">
|
|
661
|
-
<span class="label-12-medium text-muted-foreground">icon-sm-no-padding</span>
|
|
662
|
-
<UiButton variant="outline" size="icon-sm-no-padding" aria-label="Close">
|
|
663
|
-
<UiIcon name="x" />
|
|
664
|
-
</UiButton>
|
|
665
|
-
</div>
|
|
666
|
-
<div class="flex flex-col items-center gap-2">
|
|
667
|
-
<span class="label-12-medium text-muted-foreground">icon-sm</span>
|
|
668
|
-
<UiButton variant="outline" size="icon-sm" aria-label="Close">
|
|
669
|
-
<UiIcon name="x" />
|
|
670
|
-
</UiButton>
|
|
671
|
-
</div>
|
|
672
|
-
<div class="flex flex-col items-center gap-2">
|
|
673
|
-
<span class="label-12-medium text-muted-foreground">icon</span>
|
|
674
|
-
<UiButton variant="outline" size="icon" aria-label="Close">
|
|
675
|
-
<UiIcon name="x" />
|
|
676
|
-
</UiButton>
|
|
677
|
-
</div>
|
|
678
|
-
<div class="flex flex-col items-center gap-2">
|
|
679
|
-
<span class="label-12-medium text-muted-foreground">icon-lg</span>
|
|
680
|
-
<UiButton variant="outline" size="icon-lg" aria-label="Close">
|
|
681
|
-
<UiIcon name="x" />
|
|
682
|
-
</UiButton>
|
|
683
|
-
</div>
|
|
684
|
-
</div>
|
|
685
|
-
`,
|
|
686
|
-
}),
|
|
687
|
-
parameters: {
|
|
688
|
-
docs: {
|
|
689
|
-
source: {
|
|
690
|
-
code: iconSizesTemplateSource,
|
|
691
|
-
},
|
|
692
|
-
},
|
|
693
|
-
},
|
|
694
|
-
};
|
|
695
|
-
|
|
696
784
|
type MatrixVariant =
|
|
697
785
|
| 'default'
|
|
698
786
|
| 'secondary'
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"designNotes": {
|
|
3
|
+
"title": "Usage",
|
|
4
|
+
"summary": "To help users clearly understand primary, secondary, and other types of buttons, make sure to consider the action. Use the guidelines below to determine the correct button to use.",
|
|
5
|
+
"sections": [
|
|
6
|
+
{
|
|
7
|
+
"title": "Primary",
|
|
8
|
+
"content": "Reserved for the main call to action on a page. Only one primary button should be used per screen, excluding application headers, modal dialogs, or side panels."
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"title": "Secondary",
|
|
12
|
+
"content": "Use for less prominent but still important actions."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"title": "Outlined",
|
|
16
|
+
"content": "For less prominent or independent actions. These buttons can be used alone or paired with a primary button when multiple actions are present. They are also suitable for subtasks where the primary button performs the main action."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"title": "Ghost",
|
|
20
|
+
"content": "For subtle actions with little emphasis, or for use with a primary button in a button row, such as Cancel next to Submit."
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"title": "Destructive",
|
|
24
|
+
"content": "For critical actions, like deleting or removing."
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"title": "Link",
|
|
28
|
+
"content": "For when a link is required."
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"accessibility": {
|
|
33
|
+
"title": "Accessibility",
|
|
34
|
+
"sections": [
|
|
35
|
+
{
|
|
36
|
+
"title": "Make sure button labels are unique and descriptive",
|
|
37
|
+
"content": "Labels like Click Here and Read More do not provide context. Some screen reader users navigate through a list of all buttons on a page or screen, so all button labels should indicate what will happen when activated."
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"title": "Icon-only buttons should be used carefully",
|
|
41
|
+
"content": "The meaning of the icon must be visually self-evident and universally understood. Add a semantic label such as aria-label so it can be read by screen readers. If there is doubt that an icon-only button will be understood, use accompanying text in the button label."
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"title": "Enable accessibility theme",
|
|
45
|
+
"content": "When accessibility is required, enable the accessibility theme. This increases contrast and makes sure there are no color contrast issues."
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, useAttrs } from 'vue';
|
|
3
3
|
import { Calendar as ShadcnCalendar } from '@/components/core/calendar';
|
|
4
|
-
import { cn } from '@/lib/utils';
|
|
4
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
5
5
|
import type { UiCalendarProps } from './types';
|
|
6
6
|
|
|
7
7
|
defineOptions({
|
|
@@ -28,10 +28,7 @@ const model = defineModel<UiCalendarProps['modelValue']>();
|
|
|
28
28
|
const placeholder = defineModel<UiCalendarProps['placeholder']>('placeholder');
|
|
29
29
|
|
|
30
30
|
const attrs = useAttrs();
|
|
31
|
-
const forwardedAttrs = computed(() =>
|
|
32
|
-
const { class: _class, ...rest } = attrs;
|
|
33
|
-
return rest;
|
|
34
|
-
});
|
|
31
|
+
const forwardedAttrs = computed(() => omitClass(attrs));
|
|
35
32
|
</script>
|
|
36
33
|
|
|
37
34
|
<template>
|
|
@@ -25,9 +25,11 @@ describe('UiCalendar', () => {
|
|
|
25
25
|
(cell) => !cell.querySelector('button')?.hasAttribute('data-disabled'),
|
|
26
26
|
);
|
|
27
27
|
const button = clickableCell?.querySelector('button');
|
|
28
|
-
|
|
28
|
+
if (!button) {
|
|
29
|
+
throw new Error('Expected an enabled date button');
|
|
30
|
+
}
|
|
29
31
|
|
|
30
|
-
await userEvent.click(button
|
|
32
|
+
await userEvent.click(button);
|
|
31
33
|
expect(emitted('update:modelValue')).toHaveLength(1);
|
|
32
34
|
});
|
|
33
35
|
|