@aleph-alpha/ui-library 2.0.0 → 2.2.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 +0 -19
- package/config.js +65 -81
- package/dist/system/components/UiSnackbar/UiSnackbar.vue.d.ts +5 -0
- package/dist/system/components/UiSnackbar/index.d.ts +3 -0
- package/dist/system/components/UiSnackbar/types.d.ts +96 -0
- package/dist/system/components/core/sonner/Sonner.vue.d.ts +3 -0
- package/dist/system/components/core/sonner/index.d.ts +1 -0
- package/dist/system/components/index.d.ts +1 -1
- package/dist/system/index.d.ts +3 -4
- package/dist/system/lib.js +20658 -19240
- package/dist/system/patterns/UiSidebar/UiSidebarGroupLabel.vue.d.ts +6 -6
- package/dist/system/patterns/UiSidebar/activeIndicator.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/index.d.ts +1 -3
- package/dist/system/patterns/UiSidebar/types.d.ts +1 -95
- package/docs/public-docs/foundations.md +48 -38
- package/hover-mix.d.ts +8 -11
- package/hover-mix.js +7 -15
- package/package.json +6 -4
- package/src/components/UiAccordion/UiAccordion.stories.ts +2 -2
- package/src/components/UiAlert/UiAlert.stories.ts +4 -4
- package/src/components/UiAvatar/UiAvatar.stories.ts +2 -2
- package/src/components/UiButton/UiButton.stories.ts +1 -1
- package/src/components/UiCalendar/UiCalendar.stories.ts +1 -24
- package/src/components/UiCalendar/UiCalendar.vue +16 -0
- package/src/components/UiCard/UiCard.stories.ts +4 -4
- package/src/components/UiChip/UiChip.vue +1 -1
- package/src/components/UiDrawer/UiDrawer.stories.ts +6 -6
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +4 -4
- package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +70 -3
- package/src/components/UiEmpty/UiEmpty.stories.ts +1 -0
- package/src/components/UiFileItem/UiFileItem.vue +1 -1
- package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +4 -1
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +2 -2
- package/src/components/UiIcon/UiIcon.stories.ts +90 -18
- package/src/components/UiInput/UiInput.stories.ts +2 -2
- package/src/components/UiKbd/UiKbd.stories.ts +10 -10
- package/src/components/UiLabel/UiLabel.stories.ts +2 -2
- package/src/components/UiListbox/UiListbox.stories.ts +14 -14
- package/src/components/UiListbox/UiListbox.vue +16 -0
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +24 -13
- package/src/components/UiPopover/UiPopover.stories.ts +6 -6
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +22 -22
- package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +11 -22
- package/src/components/UiRangeCalendar/UiRangeCalendar.vue +16 -0
- package/src/components/UiSelect/UiSelectItem.vue +1 -1
- package/src/components/UiSeparator/UiSeparator.stories.ts +8 -8
- package/src/components/UiSheet/UiSheet.stories.ts +12 -12
- package/src/components/UiSkeleton/UiSkeleton.stories.ts +20 -20
- package/src/components/UiSlider/UiSlider.stories.ts +6 -6
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +508 -0
- package/src/components/UiSnackbar/UiSnackbar.vue +286 -0
- package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +17 -0
- package/src/components/UiSnackbar/index.ts +4 -0
- package/src/components/UiSnackbar/types.ts +97 -0
- package/src/components/UiSwitch/UiSwitch.stories.ts +4 -4
- package/src/components/UiSwitch/__tests__/UiSwitch.test.ts +9 -2
- package/src/components/UiTable/__tests__/UiTableRow.test.ts +10 -0
- package/src/components/UiTabs/UiTabs.stories.ts +2 -2
- package/src/components/UiTabs/__tests__/UiTabs.test.ts +25 -0
- package/src/components/UiTagsInput/UiTagsInput.stories.ts +2 -0
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +9 -0
- package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +18 -0
- package/src/components/UiTooltip/UiTooltip.stories.ts +7 -7
- package/src/components/core/alert/index.ts +3 -2
- package/src/components/core/button/index.ts +5 -6
- package/src/components/core/calendar/CalendarGrid.vue +1 -1
- package/src/components/core/card/Card.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuCheckboxItem.vue +14 -13
- package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuRadioItem.vue +23 -13
- package/src/components/core/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
- package/src/components/core/listbox/ListboxItem.vue +1 -1
- package/src/components/core/popover/PopoverContent.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendarGrid.vue +1 -1
- package/src/components/core/select/SelectItem.vue +1 -1
- package/src/components/core/sidebar/SidebarGroupAction.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuAction.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuSubButton.vue +2 -2
- package/src/components/core/sidebar/SidebarTrigger.vue +4 -4
- package/src/components/core/sidebar/index.ts +4 -3
- package/src/components/core/sonner/Sonner.vue +43 -0
- package/src/components/core/sonner/index.ts +1 -0
- package/src/components/core/switch/Switch.vue +2 -2
- package/src/components/core/table/TableRow.vue +1 -1
- package/src/components/core/tabs/TabsList.vue +1 -1
- package/src/components/core/tabs/TabsTrigger.vue +1 -1
- package/src/components/core/toggle/index.ts +1 -1
- package/src/components/core/toggle-group/index.ts +1 -1
- package/src/components/index.ts +1 -1
- package/src/directives/vHover.stories.ts +1 -1
- package/src/index.ts +3 -0
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +15 -15
- package/src/patterns/UiDataTable/UiDataTableColumnHeader.vue +1 -1
- package/src/patterns/UiDataTable/UiDataTablePagination.vue +3 -3
- package/src/patterns/UiDataTable/UiDataTableToolbar.vue +1 -1
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +14 -0
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +4 -4
- package/src/patterns/UiDatePicker/UiDatePicker.vue +2 -0
- package/src/patterns/UiSidebar/UiSidebar.stories.ts +27 -258
- package/src/patterns/UiSidebar/UiSidebarGroup.stories.ts +6 -8
- package/src/patterns/UiSidebar/UiSidebarGroupLabel.stories.ts +15 -10
- package/src/patterns/UiSidebar/UiSidebarGroupLabel.vue +20 -7
- package/src/patterns/UiSidebar/UiSidebarHeader.vue +0 -1
- package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +29 -40
- package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +9 -6
- package/src/patterns/UiSidebar/UiSidebarMenuItem.stories.ts +11 -13
- package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +8 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverMenu.stories.ts +6 -8
- package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.stories.ts +6 -7
- package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +9 -7
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.stories.ts +3 -3
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +11 -12
- package/src/patterns/UiSidebar/UiSidebarTrigger.vue +1 -1
- package/src/patterns/UiSidebar/activeIndicator.ts +1 -2
- package/src/patterns/UiSidebar/index.ts +0 -5
- package/src/patterns/UiSidebar/types.ts +1 -111
- package/src/theme/Background.stories.ts +5 -5
- package/src/theme/Border.stories.ts +3 -3
- package/src/theme/Extended.stories.ts +6 -6
- package/src/theme/Flex.stories.ts +10 -10
- package/src/theme/Grid.stories.ts +10 -10
- package/src/theme/HoverLayer.stories.ts +215 -0
- package/src/theme/Overlay.stories.ts +2 -2
- package/src/theme/Shadow.stories.ts +1 -1
- package/src/theme/Theme.stories.ts +4 -4
- package/src/theme/Typography.stories.ts +21 -21
- package/tokens.json +4835 -1369
- package/dist/system/components/UiIconButton/UiIconButton.vue.d.ts +0 -25
- package/dist/system/components/UiIconButton/index.d.ts +0 -7
- package/dist/system/components/UiIconButton/types.d.ts +0 -67
- package/dist/system/patterns/UiSidebar/UiSidebarChatHistory.vue.d.ts +0 -20
- package/dist/system/patterns/UiSidebar/UiSidebarChatHistoryItem.vue.d.ts +0 -34
- package/src/components/UiIconButton/UiIconButton.stories.ts +0 -470
- package/src/components/UiIconButton/UiIconButton.vue +0 -76
- package/src/components/UiIconButton/__tests__/UiIconButton.test.ts +0 -105
- package/src/components/UiIconButton/index.ts +0 -13
- package/src/components/UiIconButton/types.ts +0 -87
- package/src/patterns/UiSidebar/UiSidebarChatHistory.stories.ts +0 -104
- package/src/patterns/UiSidebar/UiSidebarChatHistory.vue +0 -43
- package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.stories.ts +0 -204
- package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.vue +0 -269
- package/src/patterns/UiSidebar/__tests__/UiSidebarChatHistory.test.ts +0 -35
- package/src/patterns/UiSidebar/__tests__/UiSidebarChatHistoryItem.test.ts +0 -49
- package/src/theme/BackgroundHover.stories.ts +0 -182
- package/src/theme/ContentHover.stories.ts +0 -171
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import 'vue-sonner/style.css';
|
|
3
|
+
import { Toaster as ShadcnSonner } from '@/components/core/sonner';
|
|
4
|
+
import type { UiSnackbarProps } from './types';
|
|
5
|
+
|
|
6
|
+
defineOptions({
|
|
7
|
+
name: 'UiSnackbar',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<UiSnackbarProps>(), {
|
|
11
|
+
containerAriaLabel: 'Notifications',
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<ShadcnSonner v-bind="props" />
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<style scoped>
|
|
20
|
+
/*
|
|
21
|
+
* Snackbar visual variants per Figma "Spark Design System / Snackbar".
|
|
22
|
+
*
|
|
23
|
+
* Tokens follow Figma exactly. They resolve at `:root`/`html.dark` via
|
|
24
|
+
* `@aleph-alpha/config-css`'s Spark preset (wired in via `defineUiLibraryConfig`),
|
|
25
|
+
* so light/dark switching cascades for free.
|
|
26
|
+
*
|
|
27
|
+
* `:global()` is required because the toast list is portalled outside
|
|
28
|
+
* the component's scope (rooted at document level via `position: fixed`),
|
|
29
|
+
* so scoped selectors can't reach the rendered DOM. Sonner's
|
|
30
|
+
* `toastOptions.classes` API exposes only a few slots (no per-type×state
|
|
31
|
+
* combinations, no state pseudos), which is why the per-variant colour,
|
|
32
|
+
* action-button and close-button state rules below have to be selector-based.
|
|
33
|
+
*
|
|
34
|
+
* Hierarchy mapping:
|
|
35
|
+
* - "High" -> `richColors: true` (vivid background)
|
|
36
|
+
* - "Low" -> `richColors: false` (muted/soft background)
|
|
37
|
+
*
|
|
38
|
+
* State mapping (per Figma "Default / Hover / Focused"):
|
|
39
|
+
* - Default -> no pseudo-class
|
|
40
|
+
* - Hover -> :hover
|
|
41
|
+
* - Focused -> :focus-visible
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/* Container shape (all variants) — Figma: padding L L L XL, gap M, banner-and-snackbars shadow */
|
|
45
|
+
:global([data-sonner-toaster] [data-sonner-toast][data-styled='true']) {
|
|
46
|
+
padding: var(--spacing-l) var(--spacing-l) var(--spacing-l) var(--spacing-xl);
|
|
47
|
+
gap: var(--spacing-m);
|
|
48
|
+
/* No Spark token at exactly 4.075px; matches Figma export literally */
|
|
49
|
+
border-radius: 4.075px;
|
|
50
|
+
box-shadow: var(--shadow-banner-and-snackbars);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* Matrix overrides (used by the AllVariants Storybook story).
|
|
55
|
+
*
|
|
56
|
+
* Each cell mounts a real `<UiSnackbar />` and dispatches one toast on
|
|
57
|
+
* mount. The toast list anchors `<ol>` with `position: fixed` (default
|
|
58
|
+
* bottom-right) and individual toasts with `position: absolute`. Inside
|
|
59
|
+
* `.snackbar-matrix` we want them inline within the grid cell, so reset
|
|
60
|
+
* the layout to normal flow.
|
|
61
|
+
*/
|
|
62
|
+
:global(.snackbar-matrix [data-sonner-toaster]) {
|
|
63
|
+
position: relative !important;
|
|
64
|
+
inset: auto !important;
|
|
65
|
+
width: 100%;
|
|
66
|
+
transform: none !important;
|
|
67
|
+
}
|
|
68
|
+
:global(.snackbar-matrix [data-sonner-toast]) {
|
|
69
|
+
position: relative !important;
|
|
70
|
+
transform: none !important;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Close button: Figma renders the X inline at the right end, after the
|
|
74
|
+
action button. The default markup floats it as a circular badge in a
|
|
75
|
+
corner via `position: absolute` + transform. Override to inline. */
|
|
76
|
+
:global(
|
|
77
|
+
[data-sonner-toaster]
|
|
78
|
+
[data-sonner-toast][data-styled='true']
|
|
79
|
+
[data-close-button]
|
|
80
|
+
) {
|
|
81
|
+
position: static;
|
|
82
|
+
order: 999;
|
|
83
|
+
width: var(--spacing-xxl);
|
|
84
|
+
height: var(--spacing-xxl);
|
|
85
|
+
padding: 0;
|
|
86
|
+
border: none;
|
|
87
|
+
/* Figma: 4px (no exact Spark token; --radius-sm is 2px in this preset) */
|
|
88
|
+
border-radius: 4px;
|
|
89
|
+
background: transparent;
|
|
90
|
+
color: inherit;
|
|
91
|
+
transform: none;
|
|
92
|
+
}
|
|
93
|
+
:global(
|
|
94
|
+
[data-sonner-toaster]
|
|
95
|
+
[data-sonner-toast][data-styled='true']
|
|
96
|
+
[data-close-button]:hover
|
|
97
|
+
) {
|
|
98
|
+
/* No DS token for this hover overlay — keep literal */
|
|
99
|
+
background: rgba(255, 255, 255, 0.1);
|
|
100
|
+
}
|
|
101
|
+
:global(
|
|
102
|
+
[data-sonner-toaster]
|
|
103
|
+
[data-sonner-toast][data-styled='true']
|
|
104
|
+
[data-close-button]:focus-visible
|
|
105
|
+
) {
|
|
106
|
+
outline: 2px solid var(--core-border-focus);
|
|
107
|
+
outline-offset: 2px;
|
|
108
|
+
box-shadow: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* HIGH hierarchy (richColors=true) */
|
|
112
|
+
/* Error High */
|
|
113
|
+
:global(
|
|
114
|
+
[data-sonner-toaster]
|
|
115
|
+
[data-sonner-toast][data-rich-colors='true'][data-type='error']
|
|
116
|
+
) {
|
|
117
|
+
background: var(--semantic-bg-error);
|
|
118
|
+
border: 1px solid var(--semantic-border-error);
|
|
119
|
+
color: var(--semantic-content-error);
|
|
120
|
+
}
|
|
121
|
+
:global(
|
|
122
|
+
[data-sonner-toaster]
|
|
123
|
+
[data-sonner-toast][data-rich-colors='true'][data-type='error']
|
|
124
|
+
[data-button]
|
|
125
|
+
) {
|
|
126
|
+
background: var(--semantic-bg-error-action);
|
|
127
|
+
color: var(--semantic-content-error);
|
|
128
|
+
}
|
|
129
|
+
:global(
|
|
130
|
+
[data-sonner-toaster]
|
|
131
|
+
[data-sonner-toast][data-rich-colors='true'][data-type='error']
|
|
132
|
+
[data-button]:hover
|
|
133
|
+
) {
|
|
134
|
+
background: var(--semantic-bg-error-action-hover);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* Info High */
|
|
138
|
+
:global(
|
|
139
|
+
[data-sonner-toaster]
|
|
140
|
+
[data-sonner-toast][data-rich-colors='true'][data-type='info']
|
|
141
|
+
) {
|
|
142
|
+
background: var(--semantic-bg-info);
|
|
143
|
+
border: 1px solid var(--semantic-border-info);
|
|
144
|
+
color: var(--semantic-content-info);
|
|
145
|
+
}
|
|
146
|
+
:global(
|
|
147
|
+
[data-sonner-toaster]
|
|
148
|
+
[data-sonner-toast][data-rich-colors='true'][data-type='info']
|
|
149
|
+
[data-button]
|
|
150
|
+
) {
|
|
151
|
+
background: var(--semantic-bg-info-action);
|
|
152
|
+
color: var(--semantic-content-info);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* Warning High */
|
|
156
|
+
:global(
|
|
157
|
+
[data-sonner-toaster]
|
|
158
|
+
[data-sonner-toast][data-rich-colors='true'][data-type='warning']
|
|
159
|
+
) {
|
|
160
|
+
background: var(--semantic-bg-warning);
|
|
161
|
+
border: 1px solid var(--semantic-border-warning);
|
|
162
|
+
color: var(--semantic-content-warning);
|
|
163
|
+
}
|
|
164
|
+
:global(
|
|
165
|
+
[data-sonner-toaster]
|
|
166
|
+
[data-sonner-toast][data-rich-colors='true'][data-type='warning']
|
|
167
|
+
[data-button]
|
|
168
|
+
) {
|
|
169
|
+
background: var(--semantic-bg-warning-action);
|
|
170
|
+
color: var(--semantic-content-warning);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* Success High */
|
|
174
|
+
:global(
|
|
175
|
+
[data-sonner-toaster]
|
|
176
|
+
[data-sonner-toast][data-rich-colors='true'][data-type='success']
|
|
177
|
+
) {
|
|
178
|
+
background: var(--semantic-bg-success);
|
|
179
|
+
border: 1px solid var(--semantic-border-success);
|
|
180
|
+
color: var(--semantic-content-success);
|
|
181
|
+
}
|
|
182
|
+
:global(
|
|
183
|
+
[data-sonner-toaster]
|
|
184
|
+
[data-sonner-toast][data-rich-colors='true'][data-type='success']
|
|
185
|
+
[data-button]
|
|
186
|
+
) {
|
|
187
|
+
background: var(--semantic-bg-success-action);
|
|
188
|
+
color: var(--semantic-content-success);
|
|
189
|
+
}
|
|
190
|
+
:global(
|
|
191
|
+
[data-sonner-toaster]
|
|
192
|
+
[data-sonner-toast][data-rich-colors='true'][data-type='success']
|
|
193
|
+
[data-button]:hover
|
|
194
|
+
) {
|
|
195
|
+
background: var(--semantic-bg-success-action-hover);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* LOW hierarchy (richColors=false) */
|
|
199
|
+
/* Error Low */
|
|
200
|
+
:global(
|
|
201
|
+
[data-sonner-toaster]
|
|
202
|
+
[data-sonner-toast]:not([data-rich-colors='true'])[data-type='error']
|
|
203
|
+
) {
|
|
204
|
+
background: var(--semantic-bg-error-soft);
|
|
205
|
+
border: 1px solid var(--semantic-border-error-soft);
|
|
206
|
+
color: var(--semantic-content-error-soft);
|
|
207
|
+
}
|
|
208
|
+
:global(
|
|
209
|
+
[data-sonner-toaster]
|
|
210
|
+
[data-sonner-toast]:not([data-rich-colors='true'])[data-type='error']
|
|
211
|
+
[data-button]
|
|
212
|
+
) {
|
|
213
|
+
background: var(--semantic-bg-error-soft-action);
|
|
214
|
+
color: var(--semantic-content-error-soft);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* Info Low */
|
|
218
|
+
:global(
|
|
219
|
+
[data-sonner-toaster]
|
|
220
|
+
[data-sonner-toast]:not([data-rich-colors='true'])[data-type='info']
|
|
221
|
+
) {
|
|
222
|
+
background: var(--semantic-bg-info-soft);
|
|
223
|
+
border: 1px solid var(--semantic-border-info-soft);
|
|
224
|
+
color: var(--semantic-content-info-soft);
|
|
225
|
+
}
|
|
226
|
+
:global(
|
|
227
|
+
[data-sonner-toaster]
|
|
228
|
+
[data-sonner-toast]:not([data-rich-colors='true'])[data-type='info']
|
|
229
|
+
[data-button]
|
|
230
|
+
) {
|
|
231
|
+
background: var(--semantic-bg-info-soft-action);
|
|
232
|
+
color: var(--semantic-content-info-soft);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* Warning Low */
|
|
236
|
+
:global(
|
|
237
|
+
[data-sonner-toaster]
|
|
238
|
+
[data-sonner-toast]:not([data-rich-colors='true'])[data-type='warning']
|
|
239
|
+
) {
|
|
240
|
+
background: var(--semantic-bg-warning-soft);
|
|
241
|
+
border: 1px solid var(--semantic-border-warning-soft);
|
|
242
|
+
color: var(--semantic-content-warning-soft);
|
|
243
|
+
}
|
|
244
|
+
:global(
|
|
245
|
+
[data-sonner-toaster]
|
|
246
|
+
[data-sonner-toast]:not([data-rich-colors='true'])[data-type='warning']
|
|
247
|
+
[data-button]
|
|
248
|
+
) {
|
|
249
|
+
background: var(--semantic-bg-warning-soft-action);
|
|
250
|
+
color: var(--semantic-content-warning-soft);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/* Success Low */
|
|
254
|
+
:global(
|
|
255
|
+
[data-sonner-toaster]
|
|
256
|
+
[data-sonner-toast]:not([data-rich-colors='true'])[data-type='success']
|
|
257
|
+
) {
|
|
258
|
+
background: var(--semantic-bg-success-soft);
|
|
259
|
+
border: 1px solid var(--semantic-border-success-soft);
|
|
260
|
+
color: var(--semantic-content-success-soft);
|
|
261
|
+
}
|
|
262
|
+
:global(
|
|
263
|
+
[data-sonner-toaster]
|
|
264
|
+
[data-sonner-toast]:not([data-rich-colors='true'])[data-type='success']
|
|
265
|
+
[data-button]
|
|
266
|
+
) {
|
|
267
|
+
background: var(--semantic-bg-success-soft-action);
|
|
268
|
+
color: var(--semantic-content-success-soft);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/* Focus state on action button (Figma "Focused") */
|
|
272
|
+
:global([data-sonner-toaster] [data-sonner-toast] [data-button]:focus-visible) {
|
|
273
|
+
outline: 2px solid var(--core-border-focus);
|
|
274
|
+
outline-offset: 2px;
|
|
275
|
+
box-shadow: none;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Hover state for Low hierarchy action button (Figma shows ~80% opacity) */
|
|
279
|
+
:global(
|
|
280
|
+
[data-sonner-toaster]
|
|
281
|
+
[data-sonner-toast]:not([data-rich-colors='true'])
|
|
282
|
+
[data-button]:hover
|
|
283
|
+
) {
|
|
284
|
+
opacity: 0.8;
|
|
285
|
+
}
|
|
286
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { render } from '@testing-library/vue';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import UiSnackbar from '../UiSnackbar.vue';
|
|
4
|
+
|
|
5
|
+
describe('UiSnackbar', () => {
|
|
6
|
+
test('applies the wrapper default containerAriaLabel', () => {
|
|
7
|
+
const { getByLabelText } = render(UiSnackbar);
|
|
8
|
+
expect(getByLabelText(/Notifications/i)).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('forwards a custom containerAriaLabel', () => {
|
|
12
|
+
const { getByLabelText } = render(UiSnackbar, {
|
|
13
|
+
props: { containerAriaLabel: 'App messages' },
|
|
14
|
+
});
|
|
15
|
+
expect(getByLabelText(/App messages/i)).toBeInTheDocument();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ToasterProps } from 'vue-sonner';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Toast notification container (Sonner). Place once near the app root,
|
|
5
|
+
* then call `toast()` (or `toast.success()`, `toast.error()`, etc.) from
|
|
6
|
+
* anywhere to display a non-blocking notification.
|
|
7
|
+
* @category Feedback
|
|
8
|
+
* @useCases success confirmation, error notice, undo action, async progress, background updates
|
|
9
|
+
* @keywords snackbar, toast, sonner, notification, alert, message, banner, undo
|
|
10
|
+
* @related UiAlert, UiAlertDialog
|
|
11
|
+
*/
|
|
12
|
+
export type UiSnackbarProps = {
|
|
13
|
+
/**
|
|
14
|
+
* Where toasts appear on screen.
|
|
15
|
+
* @default 'bottom-right'
|
|
16
|
+
*/
|
|
17
|
+
position?: ToasterProps['position'];
|
|
18
|
+
/**
|
|
19
|
+
* Color theme for toasts.
|
|
20
|
+
* @default 'light'
|
|
21
|
+
*/
|
|
22
|
+
theme?: ToasterProps['theme'];
|
|
23
|
+
/** Mirror the body color scheme so toasts contrast against it. */
|
|
24
|
+
invert?: ToasterProps['invert'];
|
|
25
|
+
/**
|
|
26
|
+
* Apply colored backgrounds for `success`, `error`, `info`, and `warning` toasts.
|
|
27
|
+
*
|
|
28
|
+
* Accessibility: color must not be the only signal of toast type
|
|
29
|
+
* (WCAG 1.4.1 Use of Color). Always pair with a descriptive message
|
|
30
|
+
* and/or icon so the meaning is conveyed to users who cannot perceive
|
|
31
|
+
* the color difference.
|
|
32
|
+
*/
|
|
33
|
+
richColors?: ToasterProps['richColors'];
|
|
34
|
+
/** Show all stacked toasts expanded by default instead of collapsed. */
|
|
35
|
+
expand?: ToasterProps['expand'];
|
|
36
|
+
/**
|
|
37
|
+
* Show a close (X) button on every toast.
|
|
38
|
+
*
|
|
39
|
+
* Accessibility: recommended whenever toasts have non-trivial
|
|
40
|
+
* `duration` values or contain actions, so keyboard and screen
|
|
41
|
+
* reader users can dismiss them on their own terms. The close
|
|
42
|
+
* button has an accessible name of `'Close toast'` by default;
|
|
43
|
+
* customise via `toastOptions.closeButtonAriaLabel`.
|
|
44
|
+
*/
|
|
45
|
+
closeButton?: ToasterProps['closeButton'];
|
|
46
|
+
/** Position of the close button within each toast. */
|
|
47
|
+
closeButtonPosition?: ToasterProps['closeButtonPosition'];
|
|
48
|
+
/**
|
|
49
|
+
* Default duration in milliseconds before a toast auto-dismisses.
|
|
50
|
+
* Pass `Infinity` to keep toasts open until dismissed.
|
|
51
|
+
*
|
|
52
|
+
* Accessibility: very short durations can violate WCAG 2.2.1
|
|
53
|
+
* (Timing Adjustable). For toasts that carry critical information
|
|
54
|
+
* or actions (e.g. an Undo button), prefer longer durations or
|
|
55
|
+
* `Infinity` combined with `closeButton: true` so users with
|
|
56
|
+
* cognitive or motor impairments have time to read and respond.
|
|
57
|
+
*/
|
|
58
|
+
duration?: ToasterProps['duration'];
|
|
59
|
+
/** Pixel gap between stacked toasts. */
|
|
60
|
+
gap?: ToasterProps['gap'];
|
|
61
|
+
/**
|
|
62
|
+
* Maximum number of toasts visible at the same time.
|
|
63
|
+
* @default 3
|
|
64
|
+
*/
|
|
65
|
+
visibleToasts?: ToasterProps['visibleToasts'];
|
|
66
|
+
/** Offset from the viewport edges. Accepts a string, number, or per-side object. */
|
|
67
|
+
offset?: ToasterProps['offset'];
|
|
68
|
+
/** Offset used on mobile viewports. */
|
|
69
|
+
mobileOffset?: ToasterProps['mobileOffset'];
|
|
70
|
+
/** Document writing direction. */
|
|
71
|
+
dir?: ToasterProps['dir'];
|
|
72
|
+
/**
|
|
73
|
+
* Keyboard combination that focuses the toast region.
|
|
74
|
+
* Provides a keyboard escape hatch (WCAG 2.1.1 Keyboard) so users
|
|
75
|
+
* can reach toasts without a pointing device. Document the chosen
|
|
76
|
+
* combination in your app's keyboard-shortcuts help.
|
|
77
|
+
* @default ['altKey', 'KeyT']
|
|
78
|
+
*/
|
|
79
|
+
hotkey?: ToasterProps['hotkey'];
|
|
80
|
+
/** Directions in which a toast can be dismissed by swipe. */
|
|
81
|
+
swipeDirections?: ToasterProps['swipeDirections'];
|
|
82
|
+
/** Custom icons used for each toast type. */
|
|
83
|
+
icons?: ToasterProps['icons'];
|
|
84
|
+
/** Default options applied to every toast. */
|
|
85
|
+
toastOptions?: ToasterProps['toastOptions'];
|
|
86
|
+
/**
|
|
87
|
+
* Accessible label announced to screen readers for the live region wrapping all toasts.
|
|
88
|
+
*
|
|
89
|
+
* The default `'Notifications'` is sufficient for most apps. Override only
|
|
90
|
+
* when you need a localized label or when multiple Toaster instances exist
|
|
91
|
+
* on the same page and need to be distinguishable to assistive technology.
|
|
92
|
+
* @default 'Notifications'
|
|
93
|
+
*/
|
|
94
|
+
containerAriaLabel?: ToasterProps['containerAriaLabel'];
|
|
95
|
+
/** Identifier when rendering more than one Toaster instance. */
|
|
96
|
+
id?: ToasterProps['id'];
|
|
97
|
+
};
|
|
@@ -39,7 +39,7 @@ const enabled = ref(false)
|
|
|
39
39
|
</script>
|
|
40
40
|
|
|
41
41
|
<template>
|
|
42
|
-
<div class="flex items-center
|
|
42
|
+
<div class="flex items-center gap-x-2">
|
|
43
43
|
<UiSwitch id="airplane-mode" v-model="enabled" name="airplane-mode" />
|
|
44
44
|
<label for="airplane-mode" class="text-sm font-medium">Airplane Mode</label>
|
|
45
45
|
</div>
|
|
@@ -62,7 +62,7 @@ export const Default: Story = {
|
|
|
62
62
|
return { args, enabled };
|
|
63
63
|
},
|
|
64
64
|
template: `
|
|
65
|
-
<div class="flex items-center
|
|
65
|
+
<div class="flex items-center gap-x-2">
|
|
66
66
|
<UiSwitch id="airplane-mode" v-model="enabled" name="airplane-mode" :disabled="args.disabled" />
|
|
67
67
|
<label for="airplane-mode" class="text-sm font-medium">Airplane Mode</label>
|
|
68
68
|
</div>
|
|
@@ -82,7 +82,7 @@ import { UiSwitch } from '@aleph-alpha/ui-library'
|
|
|
82
82
|
</script>
|
|
83
83
|
|
|
84
84
|
<template>
|
|
85
|
-
<div class="flex items-center
|
|
85
|
+
<div class="flex items-center gap-x-2">
|
|
86
86
|
<UiSwitch id="airplane-mode" name="airplane-mode" disabled />
|
|
87
87
|
<label for="airplane-mode" class="text-sm font-medium text-muted-foreground">Airplane Mode</label>
|
|
88
88
|
</div>
|
|
@@ -108,7 +108,7 @@ export const Disabled: Story = {
|
|
|
108
108
|
return { args, enabled };
|
|
109
109
|
},
|
|
110
110
|
template: `
|
|
111
|
-
<div class="flex items-center
|
|
111
|
+
<div class="flex items-center gap-x-2">
|
|
112
112
|
<UiSwitch id="airplane-mode" v-model="enabled" name="airplane-mode" :disabled="args.disabled" />
|
|
113
113
|
<label for="airplane-mode" class="text-sm font-medium text-muted-foreground">Airplane Mode</label>
|
|
114
114
|
</div>
|
|
@@ -12,10 +12,17 @@ describe('UiSwitch', () => {
|
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
test('renders with initial checked state', () => {
|
|
15
|
-
const { getByRole } = render(UiSwitch, {
|
|
15
|
+
const { container, getByRole } = render(UiSwitch, {
|
|
16
16
|
props: { modelValue: true },
|
|
17
17
|
});
|
|
18
|
-
|
|
18
|
+
const switchEl = getByRole('switch');
|
|
19
|
+
const thumb = container.querySelector('[data-slot="switch-thumb"]');
|
|
20
|
+
|
|
21
|
+
expect(switchEl).toHaveAttribute('aria-checked', 'true');
|
|
22
|
+
expect(switchEl).toHaveClass(
|
|
23
|
+
'data-[state=checked]:bg-background-accent-default',
|
|
24
|
+
);
|
|
25
|
+
expect(thumb).toHaveClass('data-[state=checked]:bg-background-accent-soft');
|
|
19
26
|
});
|
|
20
27
|
|
|
21
28
|
test('emits update:modelValue true when toggled from off', async () => {
|
|
@@ -13,6 +13,16 @@ describe('UiTableRow', () => {
|
|
|
13
13
|
expect(getByRole('row')).toHaveClass('hover:bg-muted');
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
+
test('uses muted-subtle hover fill by default', () => {
|
|
17
|
+
const { getByRole } = render(UiTableRow, {
|
|
18
|
+
slots: { default: '<td>Cell</td>' },
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
expect(getByRole('row')).toHaveClass(
|
|
22
|
+
'hover:bg-background-surface-muted-subtle',
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
16
26
|
test('applies data-state="selected" when selected prop is true', () => {
|
|
17
27
|
const { getByRole } = render(UiTableRow, {
|
|
18
28
|
props: { selected: true },
|
|
@@ -382,7 +382,7 @@ function goToDetails() {
|
|
|
382
382
|
</script>
|
|
383
383
|
|
|
384
384
|
<template>
|
|
385
|
-
<div class="
|
|
385
|
+
<div class="gap-y-4">
|
|
386
386
|
<div class="flex items-center gap-4">
|
|
387
387
|
<p class="text-sm">Current tab: <strong>{{ activeTab }}</strong></p>
|
|
388
388
|
<button
|
|
@@ -433,7 +433,7 @@ export const Controlled: Story = {
|
|
|
433
433
|
return { activeTab, goToDetails };
|
|
434
434
|
},
|
|
435
435
|
template: `
|
|
436
|
-
<div class="
|
|
436
|
+
<div class="gap-y-4">
|
|
437
437
|
<div class="flex items-center gap-4">
|
|
438
438
|
<p class="text-sm">Current tab: <strong>{{ activeTab }}</strong></p>
|
|
439
439
|
<button
|
|
@@ -125,4 +125,29 @@ describe('UiTabs', () => {
|
|
|
125
125
|
const tabsRoot = container.querySelector('[data-slot="tabs"]');
|
|
126
126
|
expect(tabsRoot).toHaveClass('custom-tabs-class');
|
|
127
127
|
});
|
|
128
|
+
|
|
129
|
+
test('uses muted-subtle list background and secondary tab states', () => {
|
|
130
|
+
const { container, getByRole } = render({
|
|
131
|
+
components: { UiTabs, UiTabsList, UiTabsTrigger, UiTabsContent },
|
|
132
|
+
template: `
|
|
133
|
+
<UiTabs default-value="tab1">
|
|
134
|
+
<UiTabsList>
|
|
135
|
+
<UiTabsTrigger value="tab1">Tab 1</UiTabsTrigger>
|
|
136
|
+
<UiTabsTrigger value="tab2">Tab 2</UiTabsTrigger>
|
|
137
|
+
</UiTabsList>
|
|
138
|
+
<UiTabsContent value="tab1">Content 1</UiTabsContent>
|
|
139
|
+
<UiTabsContent value="tab2">Content 2</UiTabsContent>
|
|
140
|
+
</UiTabs>
|
|
141
|
+
`,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const tabsList = container.querySelector('[data-slot="tabs-list"]');
|
|
145
|
+
const tab = getByRole('tab', { name: 'Tab 1' });
|
|
146
|
+
|
|
147
|
+
expect(tabsList).toHaveClass('bg-background-surface-muted-subtle');
|
|
148
|
+
expect(tab).toHaveClass('hover:bg-background-surface-secondary');
|
|
149
|
+
expect(tab).toHaveClass(
|
|
150
|
+
'data-[state=active]:bg-background-surface-secondary',
|
|
151
|
+
);
|
|
152
|
+
});
|
|
128
153
|
});
|
|
@@ -401,6 +401,7 @@ watch(searchTerm, (value) => {
|
|
|
401
401
|
v-model="selectedFrameworks"
|
|
402
402
|
highlight-on-hover
|
|
403
403
|
multiple
|
|
404
|
+
class="rounded-none border-0 bg-transparent shadow-none"
|
|
404
405
|
>
|
|
405
406
|
<UiPopoverAnchor class="inline-flex w-[300px]">
|
|
406
407
|
<UiTagsInput v-slot="{ modelValue: tags }" v-model="selectedFrameworks" class="w-full">
|
|
@@ -506,6 +507,7 @@ export const WithListbox: Story = {
|
|
|
506
507
|
v-model="selectedFrameworks"
|
|
507
508
|
highlight-on-hover
|
|
508
509
|
multiple
|
|
510
|
+
class="rounded-none border-0 bg-transparent shadow-none"
|
|
509
511
|
>
|
|
510
512
|
<UiPopoverAnchor class="inline-flex w-[300px]">
|
|
511
513
|
<UiTagsInput v-slot="{ modelValue: tags }" v-model="selectedFrameworks" class="w-full">
|
|
@@ -25,6 +25,15 @@ describe('UiToggle', () => {
|
|
|
25
25
|
expect(getByRole('button')).toHaveAttribute('data-state', 'off');
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
test('uses muted-subtle hover fill', () => {
|
|
29
|
+
const { getByRole } = render(UiToggle, {
|
|
30
|
+
slots: { default: 'Toggle' },
|
|
31
|
+
});
|
|
32
|
+
expect(getByRole('button')).toHaveClass(
|
|
33
|
+
'hover:bg-background-surface-muted-subtle',
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
28
37
|
test('is disabled when disabled prop is true', () => {
|
|
29
38
|
const { getByRole } = render(UiToggle, {
|
|
30
39
|
props: { disabled: true },
|
|
@@ -374,6 +374,24 @@ describe('UiToggleGroup', () => {
|
|
|
374
374
|
expect(item).toBeInTheDocument();
|
|
375
375
|
});
|
|
376
376
|
|
|
377
|
+
test('items use muted-subtle hover fill', () => {
|
|
378
|
+
const { container } = render(UiToggleGroup, {
|
|
379
|
+
props: { type: 'single' },
|
|
380
|
+
slots: {
|
|
381
|
+
default: {
|
|
382
|
+
components: { UiToggleGroupItem },
|
|
383
|
+
template:
|
|
384
|
+
'<UiToggleGroupItem value="test">Test</UiToggleGroupItem>',
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
global: {
|
|
388
|
+
components: { UiToggleGroupItem },
|
|
389
|
+
},
|
|
390
|
+
});
|
|
391
|
+
const item = container.querySelector('[data-slot="toggle-group-item"]');
|
|
392
|
+
expect(item).toHaveClass('hover:bg-background-surface-muted-subtle');
|
|
393
|
+
});
|
|
394
|
+
|
|
377
395
|
test('renders multiple items within group', () => {
|
|
378
396
|
const { container } = render(UiToggleGroup, {
|
|
379
397
|
props: { type: 'multiple' },
|
|
@@ -112,10 +112,10 @@ export const Default: Story = {
|
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
|
-
* Tooltip with an icon
|
|
115
|
+
* Tooltip with an icon-only `UiButton`.
|
|
116
116
|
*/
|
|
117
117
|
|
|
118
|
-
const
|
|
118
|
+
const withIconTriggerTemplateSource = `<script setup lang="ts">
|
|
119
119
|
import { UiTooltip } from '@aleph-alpha/ui-library'
|
|
120
120
|
import { UiButton } from '@aleph-alpha/ui-library'
|
|
121
121
|
import { UiIcon } from '@aleph-alpha/ui-library'
|
|
@@ -129,7 +129,7 @@ import { UiIcon } from '@aleph-alpha/ui-library'
|
|
|
129
129
|
</UiTooltip>
|
|
130
130
|
</template>`;
|
|
131
131
|
|
|
132
|
-
const
|
|
132
|
+
const withIconTriggerTemplate = `
|
|
133
133
|
<div class="flex justify-center p-8">
|
|
134
134
|
<UiTooltip content="More information" side="top" align="center" :delay-duration="500">
|
|
135
135
|
<UiButton size="icon" variant="ghost" aria-label="Information">
|
|
@@ -140,20 +140,20 @@ const withIconButtonTemplate = `
|
|
|
140
140
|
`;
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
* Tooltip with an icon
|
|
143
|
+
* Tooltip with an icon-only `UiButton` trigger.
|
|
144
144
|
*/
|
|
145
|
-
export const
|
|
145
|
+
export const WithIconTrigger: Story = {
|
|
146
146
|
parameters: {
|
|
147
147
|
docs: {
|
|
148
148
|
source: {
|
|
149
149
|
type: 'code',
|
|
150
|
-
code:
|
|
150
|
+
code: withIconTriggerTemplateSource,
|
|
151
151
|
},
|
|
152
152
|
},
|
|
153
153
|
},
|
|
154
154
|
render: () => ({
|
|
155
155
|
components: { UiTooltip, UiButton, UiIcon },
|
|
156
|
-
template:
|
|
156
|
+
template: withIconTriggerTemplate,
|
|
157
157
|
}),
|
|
158
158
|
};
|
|
159
159
|
|
|
@@ -10,9 +10,10 @@ export const alertVariants = cva(
|
|
|
10
10
|
{
|
|
11
11
|
variants: {
|
|
12
12
|
variant: {
|
|
13
|
-
default:
|
|
13
|
+
default:
|
|
14
|
+
'bg-background-surface-secondary text-content-on-surface-primary',
|
|
14
15
|
destructive:
|
|
15
|
-
'text-destructive bg-background-surface-
|
|
16
|
+
'text-destructive bg-background-surface-secondary [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90',
|
|
16
17
|
},
|
|
17
18
|
},
|
|
18
19
|
defaultVariants: {
|
|
@@ -9,15 +9,14 @@ export const buttonVariants = cva(
|
|
|
9
9
|
variants: {
|
|
10
10
|
variant: {
|
|
11
11
|
default:
|
|
12
|
-
'bg-background-button-primary-button text-content-on-button-primary-button hover
|
|
12
|
+
'bg-background-button-primary-button text-content-on-button-primary-button hover-layer hover-layer-subtle',
|
|
13
13
|
destructive:
|
|
14
|
-
'bg-background-button-danger-button text-content-on-button-danger-button hover
|
|
14
|
+
'bg-background-button-danger-button text-content-on-button-danger-button hover-layer hover-layer-default focus-visible:border-transparent focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40',
|
|
15
15
|
outline:
|
|
16
|
-
'border border-input bg-transparent text-foreground hover:bg-background-surface-
|
|
16
|
+
'border border-input bg-transparent text-foreground hover:bg-background-surface-muted-subtle',
|
|
17
17
|
secondary:
|
|
18
|
-
'bg-background-button-secondary-button text-content-on-button-secondary-button hover
|
|
19
|
-
ghost:
|
|
20
|
-
'text-foreground hover:bg-background-surface-primary-hover-default hover:border-border-button-outlined',
|
|
18
|
+
'bg-background-button-secondary-button text-content-on-button-secondary-button hover-layer hover-layer-default',
|
|
19
|
+
ghost: 'text-foreground hover:bg-background-surface-muted-subtle',
|
|
21
20
|
link: 'text-link overlay-link-hover-subtle',
|
|
22
21
|
},
|
|
23
22
|
size: {
|