@thekestongroup/ui 0.2.1 → 0.3.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/README.md +90 -32
- package/dist/components/Age/Age.vue.d.ts +19 -0
- package/dist/components/AppShell/AppShell.vue.d.ts +108 -0
- package/dist/components/Avatar/Avatar.vue.d.ts +34 -0
- package/dist/components/AvatarGroup/AvatarGroup.vue.d.ts +25 -0
- package/dist/components/Badge/Badge.vue.d.ts +41 -0
- package/dist/components/Breadcrumb/Breadcrumb.vue.d.ts +39 -0
- package/dist/components/Button/Button.vue.d.ts +69 -0
- package/dist/components/Calendar/Calendar.vue.d.ts +34 -0
- package/dist/components/Card/Card.vue.d.ts +56 -0
- package/dist/components/Checkbox/Checkbox.vue.d.ts +40 -0
- package/dist/components/Checklist/Checklist.vue.d.ts +18 -0
- package/dist/components/Chip/Chip.vue.d.ts +44 -0
- package/dist/components/Divider/Divider.vue.d.ts +36 -0
- package/dist/components/{ToastItem.vue.d.ts → FormField/FieldMessage.vue.d.ts} +10 -2
- package/dist/components/FormField/FormField.vue.d.ts +61 -0
- package/dist/components/Header/Header.vue.d.ts +104 -0
- package/dist/components/InfoTip/InfoTip.vue.d.ts +20 -0
- package/dist/components/Input/Input.vue.d.ts +56 -0
- package/dist/components/InputCode/InputCode.vue.d.ts +53 -0
- package/dist/components/InputDate/InputDate.vue.d.ts +49 -0
- package/dist/components/InputNumber/InputNumber.vue.d.ts +44 -0
- package/dist/components/InputPassword/InputPassword.vue.d.ts +51 -0
- package/dist/components/InputRichText/InputRichText.vue.d.ts +44 -0
- package/dist/components/Link/Link.vue.d.ts +39 -0
- package/dist/components/Notification/Notification.vue.d.ts +62 -0
- package/dist/components/Notification/NotificationPane.vue.d.ts +38 -0
- package/dist/components/Notification/Toaster.vue.d.ts +51 -0
- package/dist/components/Notification/notification.samples.d.ts +3 -0
- package/dist/components/Notification/notifications.d.ts +115 -0
- package/dist/components/PageHeader/PageHeader.vue.d.ts +43 -0
- package/dist/components/Popover/Popover.vue.d.ts +83 -0
- package/dist/components/Popover/popover.d.ts +16 -0
- package/dist/components/Progress/Progress.vue.d.ts +26 -0
- package/dist/components/RadioGroup/RadioGroup.vue.d.ts +45 -0
- package/dist/components/RelativeTime/RelativeTime.vue.d.ts +22 -0
- package/dist/components/Select/Select.vue.d.ts +110 -0
- package/dist/components/Sidebar/Sidebar.vue.d.ts +106 -0
- package/dist/components/Sidebar/sidebar.d.ts +10 -0
- package/dist/components/Slideover/Slideover.vue.d.ts +125 -0
- package/dist/components/Spinner/Spinner.vue.d.ts +30 -0
- package/dist/components/StatTile/StatTile.vue.d.ts +46 -0
- package/dist/components/SummaryList/SummaryList.vue.d.ts +62 -0
- package/dist/components/Switch/Switch.vue.d.ts +39 -0
- package/dist/components/Table/Table.vue.d.ts +82 -0
- package/dist/components/Table/table.d.ts +36 -0
- package/dist/components/Tooltip/Tooltip.vue.d.ts +46 -0
- package/dist/index.d.ts +89 -25
- package/dist/keston-ui.js +4963 -14785
- package/dist/lib/cn.d.ts +4 -0
- package/dist/lib/dates.d.ts +27 -0
- package/dist/lib/initials.d.ts +2 -0
- package/dist/lib/parseDate.d.ts +44 -0
- package/dist/lib/useNow.d.ts +3 -0
- package/package.json +53 -24
- package/src/components/.gitkeep +0 -0
- package/src/components/Age/Age.stories.ts +24 -0
- package/src/components/Age/Age.vue +56 -0
- package/src/components/AppShell/AppShell.stories.ts +124 -0
- package/src/components/AppShell/AppShell.vue +212 -0
- package/src/components/Avatar/Avatar.stories.ts +56 -0
- package/src/components/Avatar/Avatar.vue +118 -0
- package/src/components/AvatarGroup/AvatarGroup.stories.ts +47 -0
- package/src/components/AvatarGroup/AvatarGroup.vue +97 -0
- package/src/components/Badge/Badge.stories.ts +92 -0
- package/src/components/Badge/Badge.vue +67 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.ts +58 -0
- package/src/components/Breadcrumb/Breadcrumb.vue +109 -0
- package/src/components/Button/Button.mdx +79 -0
- package/src/components/Button/Button.stories.ts +207 -0
- package/src/components/Button/Button.vue +266 -0
- package/src/components/Calendar/Calendar.stories.ts +51 -0
- package/src/components/Calendar/Calendar.vue +364 -0
- package/src/components/Card/Card.stories.ts +109 -0
- package/src/components/Card/Card.vue +115 -0
- package/src/components/Checkbox/Checkbox.stories.ts +102 -0
- package/src/components/Checkbox/Checkbox.vue +102 -0
- package/src/components/Checklist/Checklist.stories.ts +67 -0
- package/src/components/Checklist/Checklist.vue +38 -0
- package/src/components/Chip/Chip.stories.ts +71 -0
- package/src/components/Chip/Chip.vue +86 -0
- package/src/components/Divider/Divider.stories.ts +57 -0
- package/src/components/Divider/Divider.vue +58 -0
- package/src/components/FormField/FieldMessage.vue +81 -0
- package/src/components/FormField/FormField.stories.ts +55 -0
- package/src/components/FormField/FormField.vue +160 -0
- package/src/components/Header/Header.stories.ts +168 -0
- package/src/components/Header/Header.vue +232 -0
- package/src/components/InfoTip/InfoTip.stories.ts +63 -0
- package/src/components/InfoTip/InfoTip.vue +50 -0
- package/src/components/Input/Input.stories.ts +206 -0
- package/src/components/Input/Input.vue +90 -0
- package/src/components/InputCode/InputCode.stories.ts +85 -0
- package/src/components/InputCode/InputCode.vue +145 -0
- package/src/components/InputDate/InputDate.stories.ts +58 -0
- package/src/components/InputDate/InputDate.vue +258 -0
- package/src/components/InputNumber/InputNumber.stories.ts +63 -0
- package/src/components/InputNumber/InputNumber.vue +109 -0
- package/src/components/InputPassword/InputPassword.stories.ts +105 -0
- package/src/components/InputPassword/InputPassword.vue +132 -0
- package/src/components/InputRichText/InputRichText.stories.ts +100 -0
- package/src/components/InputRichText/InputRichText.vue +194 -0
- package/src/components/Link/Link.stories.ts +73 -0
- package/src/components/Link/Link.vue +56 -0
- package/src/components/Notification/Notification.stories.ts +196 -0
- package/src/components/Notification/Notification.vue +136 -0
- package/src/components/Notification/NotificationPane.vue +187 -0
- package/src/components/Notification/Toaster.vue +446 -0
- package/src/components/Notification/notification.samples.ts +45 -0
- package/src/components/Notification/notifications.test.ts +99 -0
- package/src/components/Notification/notifications.ts +172 -0
- package/src/components/PageHeader/PageHeader.stories.ts +79 -0
- package/src/components/PageHeader/PageHeader.vue +66 -0
- package/src/components/Popover/Popover.stories.ts +135 -0
- package/src/components/Popover/Popover.vue +192 -0
- package/src/components/Popover/popover.ts +20 -0
- package/src/components/Progress/Progress.stories.ts +74 -0
- package/src/components/Progress/Progress.vue +75 -0
- package/src/components/RadioGroup/RadioGroup.stories.ts +90 -0
- package/src/components/RadioGroup/RadioGroup.vue +132 -0
- package/src/components/RelativeTime/RelativeTime.stories.ts +74 -0
- package/src/components/RelativeTime/RelativeTime.vue +51 -0
- package/src/components/Select/Select.mdx +202 -0
- package/src/components/Select/Select.stories.ts +223 -0
- package/src/components/Select/Select.vue +630 -0
- package/src/components/Sidebar/Sidebar.stories.ts +192 -0
- package/src/components/Sidebar/Sidebar.vue +382 -0
- package/src/components/Sidebar/sidebar.ts +20 -0
- package/src/components/Slideover/Slideover.stories.ts +225 -0
- package/src/components/Slideover/Slideover.vue +365 -0
- package/src/components/Spinner/Spinner.stories.ts +79 -0
- package/src/components/Spinner/Spinner.vue +97 -0
- package/src/components/StatTile/StatTile.stories.ts +75 -0
- package/src/components/StatTile/StatTile.vue +89 -0
- package/src/components/SummaryList/SummaryList.stories.ts +103 -0
- package/src/components/SummaryList/SummaryList.vue +127 -0
- package/src/components/Switch/Switch.stories.ts +100 -0
- package/src/components/Switch/Switch.vue +96 -0
- package/src/components/Table/Table.stories.ts +206 -0
- package/src/components/Table/Table.vue +220 -0
- package/src/components/Table/table.test.ts +65 -0
- package/src/components/Table/table.ts +70 -0
- package/src/components/Tooltip/Tooltip.stories.ts +57 -0
- package/src/components/Tooltip/Tooltip.vue +86 -0
- package/src/examples/AppPages.stories.ts +500 -0
- package/src/examples/FormLayout.stories.ts +185 -0
- package/src/examples/KestonIdPages.stories.ts +415 -0
- package/src/examples/SchoolPages.stories.ts +665 -0
- package/src/index.ts +114 -36
- package/src/lib/cn.ts +4 -0
- package/src/lib/dates.test.ts +68 -0
- package/src/lib/dates.ts +86 -0
- package/src/lib/initials.ts +8 -0
- package/src/lib/parseDate.test.ts +331 -0
- package/src/lib/parseDate.ts +561 -0
- package/src/lib/useNow.ts +20 -0
- package/src/styles/theme.css +101 -0
- package/dist/components/AppLauncher.vue.d.ts +0 -10
- package/dist/components/Avatar.vue.d.ts +0 -16
- package/dist/components/Button.vue.d.ts +0 -27
- package/dist/components/Checkbox.vue.d.ts +0 -18
- package/dist/components/CloseButton.vue.d.ts +0 -6
- package/dist/components/Dialog.vue.d.ts +0 -23
- package/dist/components/Drawer.vue.d.ts +0 -34
- package/dist/components/DropdownMenu.vue.d.ts +0 -21
- package/dist/components/DropdownMenuItem.vue.d.ts +0 -19
- package/dist/components/DropdownMenuSeparator.vue.d.ts +0 -6
- package/dist/components/Input.vue.d.ts +0 -14
- package/dist/components/Label.vue.d.ts +0 -16
- package/dist/components/NotificationsMenu.vue.d.ts +0 -3
- package/dist/components/Popover.vue.d.ts +0 -23
- package/dist/components/ProfileSwitcher.vue.d.ts +0 -24
- package/dist/components/Select.vue.d.ts +0 -28
- package/dist/components/Separator.vue.d.ts +0 -11
- package/dist/components/ToastRenderer.vue.d.ts +0 -3
- package/dist/components/Toaster.vue.d.ts +0 -3
- package/dist/components/Tooltip.vue.d.ts +0 -23
- package/dist/components/TopBar.vue.d.ts +0 -34
- package/dist/favicon-old.svg +0 -1
- package/dist/favicon.svg +0 -1
- package/dist/keston-ui.cjs +0 -15
- package/dist/lib/toast.d.ts +0 -29
- package/dist/lib/types.d.ts +0 -5
- package/src/components/AppLauncher.vue +0 -63
- package/src/components/Avatar.vue +0 -51
- package/src/components/Button.vue +0 -54
- package/src/components/Checkbox.vue +0 -47
- package/src/components/CloseButton.vue +0 -24
- package/src/components/Dialog.vue +0 -65
- package/src/components/Drawer.vue +0 -202
- package/src/components/DropdownMenu.vue +0 -41
- package/src/components/DropdownMenuItem.vue +0 -28
- package/src/components/DropdownMenuSeparator.vue +0 -12
- package/src/components/Input.vue +0 -21
- package/src/components/Label.vue +0 -15
- package/src/components/NotificationsMenu.vue +0 -115
- package/src/components/Popover.vue +0 -46
- package/src/components/ProfileSwitcher.vue +0 -113
- package/src/components/Select.vue +0 -97
- package/src/components/Separator.vue +0 -30
- package/src/components/ToastItem.vue +0 -158
- package/src/components/ToastRenderer.vue +0 -113
- package/src/components/Toaster.vue +0 -11
- package/src/components/Tooltip.vue +0 -48
- package/src/components/TopBar.vue +0 -52
- package/src/lib/toast.ts +0 -95
- package/src/lib/types.ts +0 -5
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import Avatar from "./Avatar.vue";
|
|
3
|
+
|
|
4
|
+
const ben = {
|
|
5
|
+
name: "Ben Blissett",
|
|
6
|
+
role: "Head of Year 9",
|
|
7
|
+
email: "ben.blissett@keston.school",
|
|
8
|
+
organisation: "The Keston School",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
title: "Components/Element/Avatar",
|
|
13
|
+
component: Avatar,
|
|
14
|
+
tags: ["autodocs"],
|
|
15
|
+
argTypes: {
|
|
16
|
+
size: { options: ["xs", "sm", "md", "lg", "xl"], control: { type: "inline-radio" } },
|
|
17
|
+
},
|
|
18
|
+
args: { user: ben, size: "md", profile: false, decorative: false },
|
|
19
|
+
} satisfies Meta<typeof Avatar>;
|
|
20
|
+
|
|
21
|
+
export default meta;
|
|
22
|
+
type Story = StoryObj<typeof meta>;
|
|
23
|
+
|
|
24
|
+
/** Initials on primary when there's no picture. */
|
|
25
|
+
export const Default: Story = {};
|
|
26
|
+
|
|
27
|
+
/** Hover (or press, or Enter) for a small profile: name, role, email, organisation. */
|
|
28
|
+
export const WithProfile: Story = { args: { profile: true } };
|
|
29
|
+
|
|
30
|
+
/** All five sizes: 20, 28, 36, 48 and 64px. */
|
|
31
|
+
export const Sizes: Story = {
|
|
32
|
+
render: (args) => ({
|
|
33
|
+
components: { Avatar },
|
|
34
|
+
setup: () => ({ args }),
|
|
35
|
+
template: `
|
|
36
|
+
<div class="flex items-end gap-3">
|
|
37
|
+
<Avatar v-for="size in ['xs', 'sm', 'md', 'lg', 'xl']" :key="size" v-bind="args" :size="size" />
|
|
38
|
+
</div>`,
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** A picture, and a broken picture that falls back to initials. */
|
|
43
|
+
export const Pictures: Story = {
|
|
44
|
+
render: () => ({
|
|
45
|
+
components: { Avatar },
|
|
46
|
+
setup: () => ({
|
|
47
|
+
withPicture: { ...ben, avatar: "https://i.pravatar.cc/128?img=12" },
|
|
48
|
+
broken: { ...ben, name: "Zara Khan", avatar: "https://example.invalid/missing.png" },
|
|
49
|
+
}),
|
|
50
|
+
template: `
|
|
51
|
+
<div class="flex items-center gap-3">
|
|
52
|
+
<Avatar :user="withPicture" size="lg" profile />
|
|
53
|
+
<Avatar :user="broken" size="lg" profile />
|
|
54
|
+
</div>`,
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, watch, type HTMLAttributes } from 'vue'
|
|
3
|
+
import { cn } from '../../lib/cn'
|
|
4
|
+
import { initials as toInitials } from '../../lib/initials'
|
|
5
|
+
import Popover from '../Popover/Popover.vue'
|
|
6
|
+
|
|
7
|
+
export interface AvatarUser {
|
|
8
|
+
name: string
|
|
9
|
+
/** Picture URL. Initials are shown without one, or if it fails to load. */
|
|
10
|
+
avatar?: string
|
|
11
|
+
/** Job or role, e.g. "Head of Year 9". Shown in the profile. */
|
|
12
|
+
role?: string
|
|
13
|
+
email?: string
|
|
14
|
+
/** Organisation or school, shown in the profile. */
|
|
15
|
+
organisation?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A person's picture, or their initials on a primary circle. With `profile`,
|
|
20
|
+
* it becomes a button that shows a small profile card (name, role, email,
|
|
21
|
+
* organisation) on hover, and on click, tap or Enter, so it works on touch
|
|
22
|
+
* screens and from the keyboard.
|
|
23
|
+
*
|
|
24
|
+
* Several people overlapping: use AvatarGroup.
|
|
25
|
+
*/
|
|
26
|
+
export interface AvatarProps {
|
|
27
|
+
user: AvatarUser
|
|
28
|
+
/** 20 / 28 / 36 / 48 / 64px. */
|
|
29
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
30
|
+
/** Show a profile card on hover / press. Makes the avatar a button. */
|
|
31
|
+
profile?: boolean
|
|
32
|
+
/** Hidden from screen readers, when the name is already said nearby (e.g. in a labelled button). */
|
|
33
|
+
decorative?: boolean
|
|
34
|
+
class?: HTMLAttributes['class']
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const props = withDefaults(defineProps<AvatarProps>(), {
|
|
38
|
+
size: 'md'
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const initials = computed(() => toInitials(props.user.name))
|
|
42
|
+
|
|
43
|
+
// A picture that fails to load falls back to initials.
|
|
44
|
+
const failed = ref(false)
|
|
45
|
+
watch(() => props.user.avatar, () => (failed.value = false))
|
|
46
|
+
const showImage = computed(() => !!props.user.avatar && !failed.value)
|
|
47
|
+
|
|
48
|
+
// The button's name. When it shows initials, they're its visible text, so the
|
|
49
|
+
// name starts with them (voice control: "click BS"), as in Header.
|
|
50
|
+
const buttonLabel = computed(() =>
|
|
51
|
+
showImage.value || !initials.value ? props.user.name : `${initials.value}, ${props.user.name}`
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
const sizes: Record<NonNullable<AvatarProps['size']>, string> = {
|
|
55
|
+
xs: 'size-5 text-xs',
|
|
56
|
+
sm: 'size-7 text-xs',
|
|
57
|
+
md: 'size-9 text-sm',
|
|
58
|
+
lg: 'size-12 text-base',
|
|
59
|
+
xl: 'size-16 text-xl'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const circle = 'relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-primary font-bold text-white select-none'
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<template>
|
|
66
|
+
<Popover v-if="profile" mode="hover" :open-delay="300" :close-delay="150" :content="{ side: 'bottom', align: 'start', sideOffset: 6 }" :ui="{ content: 'w-64' }">
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
:aria-label="buttonLabel"
|
|
70
|
+
:class="cn(
|
|
71
|
+
circle,
|
|
72
|
+
sizes[size],
|
|
73
|
+
'cursor-pointer outline-2 outline-offset-1 outline-transparent transition focus-visible:outline-focus',
|
|
74
|
+
props.class
|
|
75
|
+
)"
|
|
76
|
+
>
|
|
77
|
+
<img v-if="showImage" :src="user.avatar" alt="" class="size-full object-cover" @error="failed = true">
|
|
78
|
+
<span v-else aria-hidden="true">{{ initials }}</span>
|
|
79
|
+
</button>
|
|
80
|
+
|
|
81
|
+
<template #content>
|
|
82
|
+
<div class="flex flex-col">
|
|
83
|
+
<p v-if="user.organisation" class="truncate px-4 pt-3 text-xs font-bold text-black/65 uppercase">
|
|
84
|
+
{{ user.organisation }}
|
|
85
|
+
</p>
|
|
86
|
+
<div class="flex items-center gap-3 px-4 py-3">
|
|
87
|
+
<span :class="cn(circle, sizes.lg)" aria-hidden="true">
|
|
88
|
+
<img v-if="showImage" :src="user.avatar" alt="" class="size-full object-cover">
|
|
89
|
+
<template v-else>{{ initials }}</template>
|
|
90
|
+
</span>
|
|
91
|
+
<div class="flex min-w-0 flex-col">
|
|
92
|
+
<span class="truncate font-bold">{{ user.name }}</span>
|
|
93
|
+
<span v-if="user.role" class="truncate text-sm text-black/65">{{ user.role }}</span>
|
|
94
|
+
<a
|
|
95
|
+
v-if="user.email"
|
|
96
|
+
:href="`mailto:${user.email}`"
|
|
97
|
+
class="truncate rounded-sm text-sm text-black/65 underline-offset-2 hover:text-black hover:underline outline-2 outline-offset-1 outline-transparent focus-visible:outline-focus"
|
|
98
|
+
>
|
|
99
|
+
{{ user.email }}
|
|
100
|
+
</a>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</template>
|
|
105
|
+
</Popover>
|
|
106
|
+
|
|
107
|
+
<!-- No profile: an image named after the person (or hidden, if decorative). -->
|
|
108
|
+
<span
|
|
109
|
+
v-else
|
|
110
|
+
:role="decorative ? undefined : 'img'"
|
|
111
|
+
:aria-label="decorative ? undefined : user.name"
|
|
112
|
+
:aria-hidden="decorative || undefined"
|
|
113
|
+
:class="cn(circle, sizes[size], props.class)"
|
|
114
|
+
>
|
|
115
|
+
<img v-if="showImage" :src="user.avatar" alt="" class="size-full object-cover" @error="failed = true">
|
|
116
|
+
<span v-else aria-hidden="true">{{ initials }}</span>
|
|
117
|
+
</span>
|
|
118
|
+
</template>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import AvatarGroup from "./AvatarGroup.vue";
|
|
3
|
+
|
|
4
|
+
const org = "The Keston School";
|
|
5
|
+
const staff = [
|
|
6
|
+
{ name: "Ben Blissett", role: "Head of Year 9", email: "ben.blissett@keston.school", organisation: org },
|
|
7
|
+
{ name: "Zara Khan", role: "English teacher", email: "zara.khan@keston.school", organisation: org },
|
|
8
|
+
{ name: "Oscar Hughes", role: "Maths teacher", email: "oscar.hughes@keston.school", organisation: org },
|
|
9
|
+
{ name: "Freya Lewis", role: "Science teacher", email: "freya.lewis@keston.school", organisation: org },
|
|
10
|
+
{ name: "Ethan Price", role: "Teaching assistant", email: "ethan.price@keston.school", organisation: org },
|
|
11
|
+
{ name: "Isla Ahmed", role: "SENCo", email: "isla.ahmed@keston.school", organisation: org },
|
|
12
|
+
{ name: "Leo Wright", role: "Head of Science", email: "leo.wright@keston.school", organisation: org },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const meta = {
|
|
16
|
+
title: "Components/Element/AvatarGroup",
|
|
17
|
+
component: AvatarGroup,
|
|
18
|
+
tags: ["autodocs"],
|
|
19
|
+
argTypes: {
|
|
20
|
+
size: { options: ["xs", "sm", "md", "lg", "xl"], control: { type: "inline-radio" } },
|
|
21
|
+
},
|
|
22
|
+
args: { users: staff, size: "md", max: 4, profile: true },
|
|
23
|
+
} satisfies Meta<typeof AvatarGroup>;
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
26
|
+
type Story = StoryObj<typeof meta>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Overlapping avatars. Hover (or press) one for its profile; it comes to the
|
|
30
|
+
* front. "+3" lists everyone not shown.
|
|
31
|
+
*/
|
|
32
|
+
export const Default: Story = {};
|
|
33
|
+
|
|
34
|
+
/** Few enough to show everyone: no "+N". (One extra is shown rather than "+1".) */
|
|
35
|
+
export const Small: Story = { args: { users: staff.slice(0, 5) } };
|
|
36
|
+
|
|
37
|
+
/** Every size. */
|
|
38
|
+
export const Sizes: Story = {
|
|
39
|
+
render: (args) => ({
|
|
40
|
+
components: { AvatarGroup },
|
|
41
|
+
setup: () => ({ args }),
|
|
42
|
+
template: `
|
|
43
|
+
<div class="flex flex-col gap-4">
|
|
44
|
+
<AvatarGroup v-for="size in ['xs', 'sm', 'md', 'lg', 'xl']" :key="size" v-bind="args" :size="size" />
|
|
45
|
+
</div>`,
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, type HTMLAttributes } from 'vue'
|
|
3
|
+
import { cn } from '../../lib/cn'
|
|
4
|
+
import Avatar, { type AvatarProps, type AvatarUser } from '../Avatar/Avatar.vue'
|
|
5
|
+
import Popover from '../Popover/Popover.vue'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Several people as overlapping avatars, e.g. a class's teachers or who's
|
|
9
|
+
* been sent a message. Each shows its profile on hover (or press). Past
|
|
10
|
+
* `max`, the rest are a "+N" circle that lists them.
|
|
11
|
+
*/
|
|
12
|
+
export interface AvatarGroupProps {
|
|
13
|
+
users: AvatarUser[]
|
|
14
|
+
size?: AvatarProps['size']
|
|
15
|
+
/** Avatars shown before "+N". */
|
|
16
|
+
max?: number
|
|
17
|
+
/** Profile card on each avatar. */
|
|
18
|
+
profile?: boolean
|
|
19
|
+
/** Name of the group for screen readers. Default "{n} people". */
|
|
20
|
+
label?: string
|
|
21
|
+
class?: HTMLAttributes['class']
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(defineProps<AvatarGroupProps>(), {
|
|
25
|
+
size: 'md',
|
|
26
|
+
max: 4,
|
|
27
|
+
profile: true
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// Show all of them if only one would be hidden: "+1" saves no space.
|
|
31
|
+
const shown = computed(() => (props.users.length <= props.max + 1 ? props.users : props.users.slice(0, props.max)))
|
|
32
|
+
const hidden = computed(() => props.users.slice(shown.value.length))
|
|
33
|
+
|
|
34
|
+
// Each avatar after the first overlaps the one before, by as much as it can
|
|
35
|
+
// without its ring reaching the initials in the middle (about 15–20%).
|
|
36
|
+
const overlaps: Record<NonNullable<AvatarProps['size']>, string> = {
|
|
37
|
+
xs: '-ml-0.5',
|
|
38
|
+
sm: '-ml-1',
|
|
39
|
+
md: '-ml-1.5',
|
|
40
|
+
lg: '-ml-2',
|
|
41
|
+
xl: '-ml-3'
|
|
42
|
+
}
|
|
43
|
+
// The white ring that keeps overlapping circles apart: thinner on the smallest.
|
|
44
|
+
const rings: Record<NonNullable<AvatarProps['size']>, string> = {
|
|
45
|
+
xs: 'ring-1',
|
|
46
|
+
sm: 'ring-2',
|
|
47
|
+
md: 'ring-2',
|
|
48
|
+
lg: 'ring-2',
|
|
49
|
+
xl: 'ring-2'
|
|
50
|
+
}
|
|
51
|
+
const counterSizes: Record<NonNullable<AvatarProps['size']>, string> = {
|
|
52
|
+
xs: 'size-5 text-xs',
|
|
53
|
+
sm: 'size-7 text-xs',
|
|
54
|
+
md: 'size-9 text-xs',
|
|
55
|
+
lg: 'size-12 text-sm',
|
|
56
|
+
xl: 'size-16 text-base'
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<div role="group" :aria-label="label ?? `${users.length} ${users.length === 1 ? 'person' : 'people'}`" :class="cn('flex items-center', props.class)">
|
|
62
|
+
<!-- A white ring keeps overlapping circles apart; the one pointed at or
|
|
63
|
+
focused comes to the front, so its ring and focus outline show. -->
|
|
64
|
+
<span
|
|
65
|
+
v-for="(user, i) in shown"
|
|
66
|
+
:key="`${user.name}-${i}`"
|
|
67
|
+
:class="cn('relative flex rounded-full ring-white hover:z-10 focus-within:z-10', rings[size], i > 0 && overlaps[size])"
|
|
68
|
+
>
|
|
69
|
+
<Avatar :user="user" :size="size" :profile="profile" />
|
|
70
|
+
</span>
|
|
71
|
+
|
|
72
|
+
<span v-if="hidden.length" :class="cn('relative flex rounded-full ring-white hover:z-10 focus-within:z-10', rings[size], overlaps[size])">
|
|
73
|
+
<Popover mode="hover" :open-delay="300" :close-delay="150" :content="{ side: 'bottom', align: 'start', sideOffset: 6 }" :ui="{ content: 'w-56' }">
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
:aria-label="`${hidden.length} more: ${hidden.map((u) => u.name).join(', ')}`"
|
|
77
|
+
:class="cn(
|
|
78
|
+
'inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full bg-surface font-bold text-black select-none',
|
|
79
|
+
'outline-2 outline-offset-1 outline-transparent transition focus-visible:outline-focus',
|
|
80
|
+
counterSizes[size]
|
|
81
|
+
)"
|
|
82
|
+
>
|
|
83
|
+
<span aria-hidden="true">+{{ hidden.length }}</span>
|
|
84
|
+
</button>
|
|
85
|
+
<template #content>
|
|
86
|
+
<ul class="flex max-h-72 flex-col gap-2 overflow-y-auto p-3 text-sm [scrollbar-width:thin]">
|
|
87
|
+
<li v-for="(user, i) in hidden" :key="`${user.name}-${i}`" class="flex items-center gap-2">
|
|
88
|
+
<Avatar :user="user" size="xs" decorative />
|
|
89
|
+
<span class="min-w-0 truncate">{{ user.name }}</span>
|
|
90
|
+
<span v-if="user.role" class="ml-auto shrink-0 truncate text-xs text-black/65">{{ user.role }}</span>
|
|
91
|
+
</li>
|
|
92
|
+
</ul>
|
|
93
|
+
</template>
|
|
94
|
+
</Popover>
|
|
95
|
+
</span>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import { CircleAlert, CircleCheck, Clock, Info, Sparkles, Users } from "@lucide/vue";
|
|
3
|
+
import Badge from "./Badge.vue";
|
|
4
|
+
|
|
5
|
+
const colors = ["basic", "primary", "green", "blue", "yellow", "red"] as const;
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: "Components/Element/Badge",
|
|
9
|
+
component: Badge,
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
argTypes: {
|
|
12
|
+
color: { options: colors, control: { type: "inline-radio" } },
|
|
13
|
+
size: { options: ["sm", "md", "lg"], control: { type: "inline-radio" } },
|
|
14
|
+
},
|
|
15
|
+
args: { color: "basic", size: "md" },
|
|
16
|
+
render: (args) => ({
|
|
17
|
+
components: { Badge },
|
|
18
|
+
setup: () => ({ args }),
|
|
19
|
+
template: `<Badge v-bind="args">Year 9</Badge>`,
|
|
20
|
+
}),
|
|
21
|
+
} satisfies Meta<typeof Badge>;
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
type Story = StoryObj<typeof meta>;
|
|
25
|
+
|
|
26
|
+
/** Playground: use the controls below. */
|
|
27
|
+
export const Default: Story = {};
|
|
28
|
+
|
|
29
|
+
/** Each colour, with the kind of status it suits. */
|
|
30
|
+
export const Colors: Story = {
|
|
31
|
+
render: (args) => ({
|
|
32
|
+
components: { Badge },
|
|
33
|
+
setup: () => ({
|
|
34
|
+
args,
|
|
35
|
+
examples: [
|
|
36
|
+
{ color: "basic", text: "Year 9" },
|
|
37
|
+
{ color: "primary", text: "New" },
|
|
38
|
+
{ color: "green", text: "Paid" },
|
|
39
|
+
{ color: "blue", text: "In progress" },
|
|
40
|
+
{ color: "yellow", text: "Due soon" },
|
|
41
|
+
{ color: "red", text: "Overdue" },
|
|
42
|
+
],
|
|
43
|
+
}),
|
|
44
|
+
template: `
|
|
45
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
46
|
+
<Badge v-for="e in examples" :key="e.color" v-bind="args" :color="e.color">{{ e.text }}</Badge>
|
|
47
|
+
</div>`,
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const Sizes: Story = {
|
|
52
|
+
render: (args) => ({
|
|
53
|
+
components: { Badge },
|
|
54
|
+
setup: () => ({ args }),
|
|
55
|
+
template: `
|
|
56
|
+
<div class="flex items-center gap-2">
|
|
57
|
+
<Badge v-bind="args" size="sm">Small</Badge>
|
|
58
|
+
<Badge v-bind="args" size="md">Medium</Badge>
|
|
59
|
+
<Badge v-bind="args" size="lg">Large</Badge>
|
|
60
|
+
</div>`,
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** An icon in the leading slot. */
|
|
65
|
+
export const WithIcon: Story = {
|
|
66
|
+
render: (args) => ({
|
|
67
|
+
components: { Badge, CircleAlert, CircleCheck, Clock, Info, Sparkles, Users },
|
|
68
|
+
setup: () => ({ args }),
|
|
69
|
+
template: `
|
|
70
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
71
|
+
<Badge v-bind="args" color="basic"><template #leading><Users /></template>28 students</Badge>
|
|
72
|
+
<Badge v-bind="args" color="primary"><template #leading><Sparkles /></template>New</Badge>
|
|
73
|
+
<Badge v-bind="args" color="green"><template #leading><CircleCheck /></template>Paid</Badge>
|
|
74
|
+
<Badge v-bind="args" color="blue"><template #leading><Info /></template>In progress</Badge>
|
|
75
|
+
<Badge v-bind="args" color="yellow"><template #leading><Clock /></template>Due soon</Badge>
|
|
76
|
+
<Badge v-bind="args" color="red"><template #leading><CircleAlert /></template>Overdue</Badge>
|
|
77
|
+
</div>`,
|
|
78
|
+
}),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/** Next to text, e.g. in a heading or a table cell. */
|
|
82
|
+
export const InContext: Story = {
|
|
83
|
+
render: (args) => ({
|
|
84
|
+
components: { Badge },
|
|
85
|
+
setup: () => ({ args }),
|
|
86
|
+
template: `
|
|
87
|
+
<div class="flex flex-col gap-3 text-sm">
|
|
88
|
+
<h2 class="flex items-center gap-2 text-lg">Ben Smith <Badge v-bind="args" color="green">Enrolled</Badge></h2>
|
|
89
|
+
<p class="flex items-center gap-2">Spring term invoice <Badge v-bind="args" color="red" size="sm">Overdue</Badge></p>
|
|
90
|
+
</div>`,
|
|
91
|
+
}),
|
|
92
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue'
|
|
3
|
+
import { cn } from '../../lib/cn'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A small label for a status, count or category, e.g. "Active", "3", "Year 9".
|
|
7
|
+
* Not interactive: for something people can press, use a Button.
|
|
8
|
+
*
|
|
9
|
+
* Slots: default (the text), leading and trailing (e.g. an icon).
|
|
10
|
+
*/
|
|
11
|
+
export interface BadgeProps {
|
|
12
|
+
/**
|
|
13
|
+
* Colour, by meaning:
|
|
14
|
+
* - basic: neutral information, e.g. a category or count
|
|
15
|
+
* - primary: emphasis, e.g. "New"
|
|
16
|
+
* - green: positive / done, e.g. "Paid"
|
|
17
|
+
* - blue: informational, e.g. "In progress"
|
|
18
|
+
* - yellow: needs attention, e.g. "Due soon"
|
|
19
|
+
* - red: a problem, e.g. "Overdue"
|
|
20
|
+
*
|
|
21
|
+
* Colour alone doesn't carry meaning for everyone, so the text should say
|
|
22
|
+
* it too.
|
|
23
|
+
*/
|
|
24
|
+
color?: 'basic' | 'primary' | 'red' | 'green' | 'blue' | 'yellow'
|
|
25
|
+
size?: 'sm' | 'md' | 'lg'
|
|
26
|
+
class?: HTMLAttributes['class']
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const props = withDefaults(defineProps<BadgeProps>(), {
|
|
30
|
+
color: 'basic',
|
|
31
|
+
size: 'md'
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
defineSlots<{
|
|
35
|
+
default?(): unknown
|
|
36
|
+
leading?(): unknown
|
|
37
|
+
trailing?(): unknown
|
|
38
|
+
}>()
|
|
39
|
+
|
|
40
|
+
// The same border and colours as Button's variants (basic white, the rest
|
|
41
|
+
// solid with white text, except yellow, which needs black text to be readable).
|
|
42
|
+
const base = 'inline-flex shrink-0 items-center whitespace-nowrap rounded-full border border-black/15 font-bold'
|
|
43
|
+
|
|
44
|
+
const colors: Record<NonNullable<BadgeProps['color']>, string> = {
|
|
45
|
+
basic: 'bg-white text-black',
|
|
46
|
+
primary: 'bg-primary text-white',
|
|
47
|
+
red: 'bg-red text-white',
|
|
48
|
+
green: 'bg-green text-white',
|
|
49
|
+
blue: 'bg-blue text-white',
|
|
50
|
+
yellow: 'bg-yellow text-black'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Heights 20 / 24 / 28px, including the border.
|
|
54
|
+
const sizes: Record<NonNullable<BadgeProps['size']>, string> = {
|
|
55
|
+
sm: 'h-5 px-1.5 text-xs gap-1 [&_svg]:size-3',
|
|
56
|
+
md: 'h-6 px-2 text-xs gap-1 [&_svg]:size-3.5',
|
|
57
|
+
lg: 'h-7 px-2.5 text-sm gap-1.5 [&_svg]:size-4'
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<template>
|
|
62
|
+
<span :class="cn(base, colors[color], sizes[size], props.class)">
|
|
63
|
+
<slot name="leading" />
|
|
64
|
+
<slot />
|
|
65
|
+
<slot name="trailing" />
|
|
66
|
+
</span>
|
|
67
|
+
</template>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import { House, School } from "@lucide/vue";
|
|
3
|
+
import Breadcrumb from "./Breadcrumb.vue";
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: "Components/Navigation/Breadcrumb",
|
|
7
|
+
component: Breadcrumb,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
args: {
|
|
10
|
+
items: [
|
|
11
|
+
{ label: "School", href: "#" },
|
|
12
|
+
{ label: "School Structure", href: "#" },
|
|
13
|
+
{ label: "New School Year Setup" },
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
} satisfies Meta<typeof Breadcrumb>;
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
/** Earlier steps link back; the last is the current page. */
|
|
22
|
+
export const Default: Story = {};
|
|
23
|
+
|
|
24
|
+
/** Steps that aren't pages themselves (here "School", a group in the sidebar) are plain text. */
|
|
25
|
+
export const WithGroups: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
items: [
|
|
28
|
+
{ label: "School", icon: School },
|
|
29
|
+
{ label: "School Structure", href: "#" },
|
|
30
|
+
{ label: "New School Year Setup" },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** An icon on the first step, e.g. home. */
|
|
36
|
+
export const WithIcon: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
items: [
|
|
39
|
+
{ label: "Home", icon: House, href: "#" },
|
|
40
|
+
{ label: "Students", href: "#" },
|
|
41
|
+
{ label: "Year 9", href: "#" },
|
|
42
|
+
{ label: "Ben Blissett" },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** Long steps are cut off with … at 240px (full text on hover), and the trail wraps on narrow screens. */
|
|
48
|
+
export const LongNames: Story = {
|
|
49
|
+
decorators: [() => ({ template: '<div class="max-w-80"><story /></div>' })],
|
|
50
|
+
args: {
|
|
51
|
+
items: [
|
|
52
|
+
{ label: "School", href: "#" },
|
|
53
|
+
{ label: "School Structure and Organisation Settings", href: "#" },
|
|
54
|
+
{ label: "Academic Years", href: "#" },
|
|
55
|
+
{ label: "New School Year Setup for September 2027" },
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Component, HTMLAttributes } from 'vue'
|
|
3
|
+
import { ChevronRight } from '@lucide/vue'
|
|
4
|
+
import { cn } from '../../lib/cn'
|
|
5
|
+
|
|
6
|
+
export interface BreadcrumbItem {
|
|
7
|
+
label: string
|
|
8
|
+
/** A Lucide (or any) icon component, shown before the label. */
|
|
9
|
+
icon?: Component
|
|
10
|
+
/** Link with a plain <a href>. */
|
|
11
|
+
href?: string
|
|
12
|
+
/** Link through `linkComponent` (e.g. RouterLink), which receives `to`. */
|
|
13
|
+
to?: unknown
|
|
14
|
+
/** Called when the step is chosen (for steps that aren't links). */
|
|
15
|
+
onSelect?: (event: MouseEvent) => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Where the current page is: its parents, then the page itself, e.g.
|
|
20
|
+
* School › School Structure › New School Year Setup. Earlier steps with a
|
|
21
|
+
* `href`, `to` or `onSelect` are links back; steps without are plain text
|
|
22
|
+
* (e.g. a group that isn't a page itself). The last step is the current page.
|
|
23
|
+
*
|
|
24
|
+
* SidebarItems fit, so it can follow a nested Sidebar:
|
|
25
|
+
* `<Breadcrumb :items="sidebarTrail(items, sections)" />`.
|
|
26
|
+
*/
|
|
27
|
+
export interface BreadcrumbProps {
|
|
28
|
+
items: BreadcrumbItem[]
|
|
29
|
+
/** Accessible name of the navigation landmark. */
|
|
30
|
+
label?: string
|
|
31
|
+
/** Component used for steps with `to`, e.g. RouterLink or NuxtLink. */
|
|
32
|
+
linkComponent?: string | Component
|
|
33
|
+
class?: HTMLAttributes['class']
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const props = withDefaults(defineProps<BreadcrumbProps>(), {
|
|
37
|
+
label: 'Breadcrumb',
|
|
38
|
+
linkComponent: 'a'
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits<{
|
|
42
|
+
/** A step before the current page was chosen. */
|
|
43
|
+
select: [item: BreadcrumbItem, event: MouseEvent]
|
|
44
|
+
}>()
|
|
45
|
+
|
|
46
|
+
// Steps that lead somewhere are links (or buttons, for onSelect); the rest,
|
|
47
|
+
// and the current page, are text.
|
|
48
|
+
function tagFor(item: BreadcrumbItem) {
|
|
49
|
+
if (item.to !== undefined) return props.linkComponent
|
|
50
|
+
if (item.href) return 'a'
|
|
51
|
+
if (item.onSelect) return 'button'
|
|
52
|
+
return undefined
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function attrsFor(item: BreadcrumbItem) {
|
|
56
|
+
if (item.to !== undefined) return { to: item.to }
|
|
57
|
+
if (item.href) return { href: item.href }
|
|
58
|
+
return { type: 'button' }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function select(item: BreadcrumbItem, event: MouseEvent) {
|
|
62
|
+
item.onSelect?.(event)
|
|
63
|
+
emit('select', item, event)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Every step: one line, cut off with … past 240px (full text on hover).
|
|
67
|
+
const step = 'inline-flex max-w-60 min-w-0 items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:shrink-0'
|
|
68
|
+
|
|
69
|
+
const link = [
|
|
70
|
+
'cursor-pointer rounded-sm text-black/65 underline-offset-2 transition',
|
|
71
|
+
'hover:text-black hover:underline',
|
|
72
|
+
'outline-2 outline-offset-1 outline-transparent focus-visible:outline-focus'
|
|
73
|
+
]
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<nav :aria-label="label" :class="cn('min-w-0 text-sm', props.class)">
|
|
78
|
+
<ol class="flex flex-wrap items-center gap-x-1.5 gap-y-1">
|
|
79
|
+
<li v-for="(item, i) in items" :key="`${item.label}-${i}`" class="flex min-w-0 items-center gap-1.5">
|
|
80
|
+
<!-- The current page. -->
|
|
81
|
+
<span v-if="i === items.length - 1" aria-current="page" :title="item.label" :class="cn(step, 'text-black')">
|
|
82
|
+
<component :is="item.icon" v-if="item.icon" aria-hidden="true" />
|
|
83
|
+
<span class="truncate">{{ item.label }}</span>
|
|
84
|
+
</span>
|
|
85
|
+
|
|
86
|
+
<!-- A step back that leads somewhere. -->
|
|
87
|
+
<component
|
|
88
|
+
:is="tagFor(item)"
|
|
89
|
+
v-else-if="tagFor(item)"
|
|
90
|
+
v-bind="attrsFor(item)"
|
|
91
|
+
:title="item.label"
|
|
92
|
+
:class="cn(step, link)"
|
|
93
|
+
@click="select(item, $event)"
|
|
94
|
+
>
|
|
95
|
+
<component :is="item.icon" v-if="item.icon" aria-hidden="true" />
|
|
96
|
+
<span class="truncate">{{ item.label }}</span>
|
|
97
|
+
</component>
|
|
98
|
+
|
|
99
|
+
<!-- A step that isn't a page itself, e.g. a group. -->
|
|
100
|
+
<span v-else :title="item.label" :class="cn(step, 'text-black/65')">
|
|
101
|
+
<component :is="item.icon" v-if="item.icon" aria-hidden="true" />
|
|
102
|
+
<span class="truncate">{{ item.label }}</span>
|
|
103
|
+
</span>
|
|
104
|
+
|
|
105
|
+
<ChevronRight v-if="i < items.length - 1" aria-hidden="true" class="size-3.5 shrink-0 text-black/40" />
|
|
106
|
+
</li>
|
|
107
|
+
</ol>
|
|
108
|
+
</nav>
|
|
109
|
+
</template>
|