@thekestongroup/ui 0.2.1 → 0.4.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 +98 -31
- 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/EmptyState/EmptyState.vue.d.ts +55 -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 +91 -25
- package/dist/keston-ui.js +5030 -14786
- 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 +57 -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 +221 -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/EmptyState/EmptyState.stories.ts +99 -0
- package/src/components/EmptyState/EmptyState.vue +87 -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 +186 -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 +212 -0
- package/src/components/Table/Table.vue +223 -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 +116 -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,73 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import Link, { type LinkProps } from "./Link.vue";
|
|
3
|
+
|
|
4
|
+
type LinkStoryArgs = LinkProps & { text: string };
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Components/Navigation/Link",
|
|
8
|
+
component: Link,
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
argTypes: {
|
|
11
|
+
text: { control: "text", table: { category: "Content" } },
|
|
12
|
+
},
|
|
13
|
+
args: { href: "#", text: "Privacy policy", newTab: false, icon: true },
|
|
14
|
+
render: (args) => ({
|
|
15
|
+
components: { Link },
|
|
16
|
+
setup: () => ({ args }),
|
|
17
|
+
template: `<p class="text-sm text-black"><Link :href="args.href" :new-tab="args.newTab" :icon="args.icon">{{ args.text }}</Link></p>`,
|
|
18
|
+
}),
|
|
19
|
+
} satisfies Meta<LinkStoryArgs>;
|
|
20
|
+
|
|
21
|
+
export default meta;
|
|
22
|
+
type Story = StoryObj<typeof meta>;
|
|
23
|
+
|
|
24
|
+
/** Playground: use the controls below. */
|
|
25
|
+
export const Default: Story = {};
|
|
26
|
+
|
|
27
|
+
/** Opens in a new tab: the small external-page icon shows it, and screen readers hear "(opens in a new tab)". */
|
|
28
|
+
export const NewTab: Story = { args: { newTab: true } };
|
|
29
|
+
|
|
30
|
+
/** Opens in a new tab without the icon (`:icon="false"`). Screen readers still hear "(opens in a new tab)". */
|
|
31
|
+
export const NewTabWithoutIcon: Story = { args: { newTab: true, icon: false } };
|
|
32
|
+
|
|
33
|
+
/** In a sentence it takes the text's size and colour. */
|
|
34
|
+
export const InASentence: Story = {
|
|
35
|
+
render: () => ({
|
|
36
|
+
components: { Link },
|
|
37
|
+
template: `
|
|
38
|
+
<p class="max-w-100 text-xs text-black/65">
|
|
39
|
+
Make sure you trust Keston Admissions: read its
|
|
40
|
+
<Link href="#" new-tab>privacy policy</Link> and <Link href="#" new-tab>terms</Link>.
|
|
41
|
+
You can remove its access at any time in your <Link href="#">Keston account</Link>.
|
|
42
|
+
</p>`,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** A row of footer links, muted until hovered. */
|
|
47
|
+
export const Footer: Story = {
|
|
48
|
+
render: () => ({
|
|
49
|
+
components: { Link },
|
|
50
|
+
template: `
|
|
51
|
+
<nav aria-label="Legal and help" class="flex items-center gap-2 text-xs text-black/65">
|
|
52
|
+
<Link href="#" new-tab>Privacy</Link>
|
|
53
|
+
<span aria-hidden="true">·</span>
|
|
54
|
+
<Link href="#" new-tab>Terms</Link>
|
|
55
|
+
<span aria-hidden="true">·</span>
|
|
56
|
+
<Link href="#" new-tab>Help</Link>
|
|
57
|
+
</nav>`,
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Larger text: the icon grows with it. */
|
|
62
|
+
export const Sizes: Story = {
|
|
63
|
+
render: () => ({
|
|
64
|
+
components: { Link },
|
|
65
|
+
template: `
|
|
66
|
+
<div class="flex flex-col gap-2 text-black">
|
|
67
|
+
<p class="text-xs"><Link href="#" new-tab>Extra small</Link></p>
|
|
68
|
+
<p class="text-sm"><Link href="#" new-tab>Small</Link></p>
|
|
69
|
+
<p class="text-base"><Link href="#" new-tab>Base</Link></p>
|
|
70
|
+
<p class="text-xl"><Link href="#" new-tab>Extra large</Link></p>
|
|
71
|
+
</div>`,
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue'
|
|
3
|
+
import { Primitive, type PrimitiveProps } from 'reka-ui'
|
|
4
|
+
import { ExternalLink } from '@lucide/vue'
|
|
5
|
+
import { cn } from '../../lib/cn'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A text link: underlined, in the colour and size of the text around it, so
|
|
9
|
+
* it fits in a sentence, a footer or a tooltip alike. With `newTab` it opens
|
|
10
|
+
* in a new tab and shows a small external-page icon (and tells screen
|
|
11
|
+
* readers it opens in a new tab).
|
|
12
|
+
*
|
|
13
|
+
* For a router, pass its link component as `as`, e.g.
|
|
14
|
+
* `<Link :as="RouterLink" to="/help">`.
|
|
15
|
+
*/
|
|
16
|
+
export interface LinkProps {
|
|
17
|
+
href?: string
|
|
18
|
+
/** Open in a new tab, with the external-page icon. Use it for pages outside the current flow (policies, help) so people don't lose their place. */
|
|
19
|
+
newTab?: boolean
|
|
20
|
+
/** With `newTab`, show the external-page icon. Turn it off where it would clutter, e.g. a row of footer links. Screen readers still hear "(opens in a new tab)". */
|
|
21
|
+
icon?: boolean
|
|
22
|
+
/** Element or component to render, e.g. RouterLink. */
|
|
23
|
+
as?: PrimitiveProps['as']
|
|
24
|
+
class?: HTMLAttributes['class']
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const props = withDefaults(defineProps<LinkProps>(), {
|
|
28
|
+
as: 'a',
|
|
29
|
+
icon: true
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// Underlined in the text's own colour; hovering darkens it to black and
|
|
33
|
+
// thickens the line. Keyboard focus gets the usual focus ring.
|
|
34
|
+
const base = [
|
|
35
|
+
'cursor-pointer rounded-xs underline underline-offset-2 transition-colors',
|
|
36
|
+
'hover:text-black hover:decoration-2',
|
|
37
|
+
'outline-2 outline-offset-2 outline-transparent focus-visible:outline-focus'
|
|
38
|
+
]
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<Primitive
|
|
43
|
+
:as="as"
|
|
44
|
+
:href="href"
|
|
45
|
+
:target="newTab ? '_blank' : undefined"
|
|
46
|
+
:rel="newTab ? 'noopener noreferrer' : undefined"
|
|
47
|
+
:class="cn(base, props.class)"
|
|
48
|
+
>
|
|
49
|
+
<slot />
|
|
50
|
+
<template v-if="newTab">
|
|
51
|
+
<!-- Sized to the text (em), sitting on its baseline, after a thin gap. -->
|
|
52
|
+
<ExternalLink v-if="icon" class="ms-0.5 inline size-[0.9em] align-[-0.1em]" aria-hidden="true" />
|
|
53
|
+
<span class="sr-only"> (opens in a new tab)</span>
|
|
54
|
+
</template>
|
|
55
|
+
</Primitive>
|
|
56
|
+
</template>
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import { h, ref } from "vue";
|
|
3
|
+
import Button from "../Button/Button.vue";
|
|
4
|
+
import Header from "../Header/Header.vue";
|
|
5
|
+
import Notification from "./Notification.vue";
|
|
6
|
+
import NotificationPane from "./NotificationPane.vue";
|
|
7
|
+
import Toaster from "./Toaster.vue";
|
|
8
|
+
import { createNotifications, type NotificationInput } from "./notifications";
|
|
9
|
+
import { passwordExpiry, sampleNotifications } from "./notification.samples";
|
|
10
|
+
|
|
11
|
+
// Cards and rows on the page background, at a toast's width. Header stories
|
|
12
|
+
// use their own (full width), so this is per story rather than in meta.
|
|
13
|
+
const narrow = () => ({ template: '<div class="bg-background p-6"><div class="max-w-sm"><story /></div></div>' });
|
|
14
|
+
|
|
15
|
+
const meta = {
|
|
16
|
+
title: "Components/Overlay/Notification",
|
|
17
|
+
component: Notification,
|
|
18
|
+
tags: ["autodocs"],
|
|
19
|
+
parameters: { backgrounds: { disable: true } },
|
|
20
|
+
argTypes: {
|
|
21
|
+
type: { options: ["info", "success", "warning", "error"], control: { type: "inline-radio" } },
|
|
22
|
+
appearance: { options: ["card", "row"], control: { type: "inline-radio" } },
|
|
23
|
+
description: { control: "text" },
|
|
24
|
+
},
|
|
25
|
+
args: {
|
|
26
|
+
type: "warning",
|
|
27
|
+
title: "Password Expiry",
|
|
28
|
+
description: passwordExpiry.description,
|
|
29
|
+
action: passwordExpiry.action,
|
|
30
|
+
appearance: "card",
|
|
31
|
+
dismissible: true,
|
|
32
|
+
},
|
|
33
|
+
} satisfies Meta<typeof Notification>;
|
|
34
|
+
|
|
35
|
+
export default meta;
|
|
36
|
+
type Story = StoryObj<typeof meta>;
|
|
37
|
+
|
|
38
|
+
/** One notification. The description is a render function, so "7 days" can be bold. */
|
|
39
|
+
export const Default: Story = { decorators: [narrow] };
|
|
40
|
+
|
|
41
|
+
/** Each type: its icon and colour. Screen readers hear the type before the title ("Warning: …"). */
|
|
42
|
+
export const Types: Story = {
|
|
43
|
+
decorators: [narrow],
|
|
44
|
+
render: () => ({
|
|
45
|
+
components: { Notification },
|
|
46
|
+
template: `
|
|
47
|
+
<div class="flex flex-col gap-3">
|
|
48
|
+
<Notification type="info" title="New application" description="Amelia Clarke applied for Year 7." />
|
|
49
|
+
<Notification type="success" title="Timetable published" description="Staff and students can now see it." />
|
|
50
|
+
<Notification type="warning" title="Password Expiry" description="Your password expires in 7 days." :action="{ label: 'Change password' }" />
|
|
51
|
+
<Notification type="error" title="Census upload failed" description="The file has 3 errors." :action="{ label: 'View errors' }" />
|
|
52
|
+
</div>`,
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* compact: one line, for quick confirmations. The action (e.g. Undo) sits on
|
|
58
|
+
* the right, before the ×. As a toast it's the same width as the others,
|
|
59
|
+
* just shorter; with an action it stays 10 seconds.
|
|
60
|
+
*/
|
|
61
|
+
export const Compact: Story = {
|
|
62
|
+
decorators: [narrow],
|
|
63
|
+
render: () => ({
|
|
64
|
+
components: { Notification },
|
|
65
|
+
template: `
|
|
66
|
+
<div class="flex flex-col gap-3">
|
|
67
|
+
<Notification compact type="success" title="Student disabled" :action="{ label: 'Undo' }" />
|
|
68
|
+
<Notification compact type="success" title="Changes saved" />
|
|
69
|
+
<Notification compact type="info" title="Link copied" :dismissible="false" />
|
|
70
|
+
<Notification compact type="error" title="Couldn't save" :action="{ label: 'Retry' }" />
|
|
71
|
+
</div>`,
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** The row appearance, as in the pane: the time, and a dot when unread. */
|
|
76
|
+
export const Rows: Story = {
|
|
77
|
+
decorators: [narrow],
|
|
78
|
+
render: () => ({
|
|
79
|
+
components: { Notification },
|
|
80
|
+
setup: () => ({ items: createNotifications(sampleNotifications()).items }),
|
|
81
|
+
template: `
|
|
82
|
+
<ul class="rounded border border-black/15 bg-white">
|
|
83
|
+
<li v-for="item in items" :key="item.id" class="border-b border-black/15 last:border-b-0">
|
|
84
|
+
<Notification appearance="row" v-bind="item" :created-at="item.createdAt" :unread="!item.read" />
|
|
85
|
+
</li>
|
|
86
|
+
</ul>`,
|
|
87
|
+
}),
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The bell in the Header. Open it to see past notifications: × removes one,
|
|
92
|
+
* Clear all removes them all, and closing it marks them read.
|
|
93
|
+
*/
|
|
94
|
+
export const Pane: Story = {
|
|
95
|
+
parameters: { layout: "fullscreen" },
|
|
96
|
+
decorators: [() => ({ template: '<div class="min-h-dvh bg-background"><story /></div>' })],
|
|
97
|
+
render: () => ({
|
|
98
|
+
components: { Header, NotificationPane },
|
|
99
|
+
setup: () => ({ notifications: createNotifications(sampleNotifications()) }),
|
|
100
|
+
template: `
|
|
101
|
+
<Header title="Keston School Admin" :user="{ name: 'Ben Smith', email: 'ben.smith@keston.school' }">
|
|
102
|
+
<template #trailing><NotificationPane :notifications="notifications" /></template>
|
|
103
|
+
</Header>`,
|
|
104
|
+
}),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** Nothing to show. */
|
|
108
|
+
export const PaneEmpty: Story = {
|
|
109
|
+
...Pane,
|
|
110
|
+
render: () => ({
|
|
111
|
+
components: { Header, NotificationPane },
|
|
112
|
+
setup: () => ({ notifications: createNotifications(), open: ref(true) }),
|
|
113
|
+
template: `
|
|
114
|
+
<Header title="Keston School Admin">
|
|
115
|
+
<template #trailing><NotificationPane v-model:open="open" :notifications="notifications" /></template>
|
|
116
|
+
</Header>`,
|
|
117
|
+
}),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Try notifications: each button calls notify(). They slide up from the
|
|
122
|
+
* bottom right, pushing the others up, and go into the pane. Past 320px tall
|
|
123
|
+
* the older ones collapse into a stack; hover the toasts (or press F8) to
|
|
124
|
+
* spread them out. If there are more than fit on the screen, "+N more" at
|
|
125
|
+
* the end opens the pane (try Error, then Five at once, twice).
|
|
126
|
+
* Info and success close after 6 seconds; ones with an action, and errors,
|
|
127
|
+
* stay until closed. Hover to pause. Swipe right to close. F8 jumps to them.
|
|
128
|
+
*/
|
|
129
|
+
export const Playground: Story = {
|
|
130
|
+
parameters: { layout: "fullscreen" },
|
|
131
|
+
decorators: [() => ({ template: '<div class="min-h-dvh bg-background"><story /></div>' })],
|
|
132
|
+
render: () => ({
|
|
133
|
+
components: { Button, Header, NotificationPane, Toaster },
|
|
134
|
+
setup() {
|
|
135
|
+
const notifications = createNotifications(sampleNotifications());
|
|
136
|
+
const samples: Record<string, NotificationInput> = {
|
|
137
|
+
info: { type: "info", title: "New application", description: "Noah Patel applied for Year 9." },
|
|
138
|
+
success: { type: "success", title: "Changes saved", description: "Term dates for 2027–28 are updated." },
|
|
139
|
+
warning: passwordExpiry,
|
|
140
|
+
error: {
|
|
141
|
+
type: "error",
|
|
142
|
+
title: "Couldn't send the newsletter",
|
|
143
|
+
description: () => ["The mail server didn't respond. ", h("b", "Nothing was sent"), "."],
|
|
144
|
+
action: { label: "Try again" },
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
let n = 0;
|
|
148
|
+
const burst = () =>
|
|
149
|
+
["Year 7", "Year 8", "Year 9", "Year 10", "Year 11"].forEach((year, i) =>
|
|
150
|
+
setTimeout(() => notifications.notify({ type: "success", title: `${year} reports sent`, description: `${28 + i} reports emailed to parents.` }), i * 150),
|
|
151
|
+
);
|
|
152
|
+
const quiet = () => notifications.notify({ title: `Background sync ${++n} finished` }, { toast: false });
|
|
153
|
+
const disable = () => {
|
|
154
|
+
const id = notifications.notify({
|
|
155
|
+
type: "success",
|
|
156
|
+
title: "Student disabled",
|
|
157
|
+
compact: true,
|
|
158
|
+
action: {
|
|
159
|
+
label: "Undo",
|
|
160
|
+
onSelect: () => {
|
|
161
|
+
notifications.dismiss(id);
|
|
162
|
+
notifications.notify({ type: "info", title: "Student enabled again", compact: true });
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
return { notifications, samples, burst, quiet, disable };
|
|
168
|
+
},
|
|
169
|
+
template: `
|
|
170
|
+
<Header title="Keston School Admin" :user="{ name: 'Ben Smith', email: 'ben.smith@keston.school' }">
|
|
171
|
+
<template #trailing><NotificationPane :notifications="notifications" /></template>
|
|
172
|
+
</Header>
|
|
173
|
+
<div class="flex flex-col gap-4 p-6">
|
|
174
|
+
<p class="max-w-prose text-sm text-black/65">Each button sends a notification. It pops up as a toast and is added to the bell.</p>
|
|
175
|
+
<div class="flex flex-wrap gap-2">
|
|
176
|
+
<Button @click="notifications.notify(samples.info)">Info</Button>
|
|
177
|
+
<Button @click="notifications.notify(samples.success)">Success</Button>
|
|
178
|
+
<Button @click="notifications.notify(samples.warning)">Warning (Password Expiry)</Button>
|
|
179
|
+
<Button @click="notifications.notify(samples.error)">Error</Button>
|
|
180
|
+
<Button @click="burst">Five at once</Button>
|
|
181
|
+
<Button @click="disable">Compact with Undo</Button>
|
|
182
|
+
<Button @click="quiet">Pane only (no toast)</Button>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
<Toaster :notifications="notifications" />`,
|
|
186
|
+
}),
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/** Toasts can also sit top right, under the Header. */
|
|
190
|
+
export const ToasterTopRight: Story = {
|
|
191
|
+
...Playground,
|
|
192
|
+
render: (args, context) => {
|
|
193
|
+
const story = (Playground.render as (a: typeof args, c: typeof context) => { template: string })(args, context);
|
|
194
|
+
return { ...story, template: story.template.replace("<Toaster ", '<Toaster position="top-right" ') };
|
|
195
|
+
},
|
|
196
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, useId, type HTMLAttributes } from 'vue'
|
|
3
|
+
import { CircleCheck, CircleX, Info, TriangleAlert, X } from '@lucide/vue'
|
|
4
|
+
import { cn } from '../../lib/cn'
|
|
5
|
+
import Button from '../Button/Button.vue'
|
|
6
|
+
import RelativeTime from '../RelativeTime/RelativeTime.vue'
|
|
7
|
+
import { type NotificationAction, type NotificationInput, type NotificationType } from './notifications'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* One notification: an icon for its type, a title, a description, an
|
|
11
|
+
* optional action button, and a close ×.
|
|
12
|
+
*
|
|
13
|
+
* - appearance "card" (default): a white panel with a border. On a page, or
|
|
14
|
+
* as a toast (Toaster adds the shadow).
|
|
15
|
+
* - appearance "row": no border, for lists, e.g. NotificationPane. Shows the
|
|
16
|
+
* time, and a dot when unread.
|
|
17
|
+
*
|
|
18
|
+
* The description can be formatted with a render function, e.g.
|
|
19
|
+
* `() => ['Your password expires in ', h('b', '7 days'), '.']`, or the
|
|
20
|
+
* default slot.
|
|
21
|
+
*/
|
|
22
|
+
export interface NotificationProps {
|
|
23
|
+
type?: NotificationType
|
|
24
|
+
title: string
|
|
25
|
+
description?: NotificationInput['description']
|
|
26
|
+
action?: NotificationAction
|
|
27
|
+
/** When it happened. Shown in the row appearance, e.g. "2 hours ago", with the exact time on hover. */
|
|
28
|
+
createdAt?: Date
|
|
29
|
+
/** Row appearance: show the unread dot. */
|
|
30
|
+
unread?: boolean
|
|
31
|
+
appearance?: 'card' | 'row'
|
|
32
|
+
/**
|
|
33
|
+
* Card appearance: one line, for quick confirmations, e.g. "✓ Student
|
|
34
|
+
* disabled [Undo] ×". The title only (no description); the action sits on
|
|
35
|
+
* the right, before the ×.
|
|
36
|
+
*/
|
|
37
|
+
compact?: boolean
|
|
38
|
+
/** Show the close ×. */
|
|
39
|
+
dismissible?: boolean
|
|
40
|
+
/** The ×'s accessible name. Default "Dismiss: {title}". */
|
|
41
|
+
dismissLabel?: string
|
|
42
|
+
/** What "now" is for the relative time. Default the live time. */
|
|
43
|
+
now?: Date
|
|
44
|
+
class?: HTMLAttributes['class']
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const props = withDefaults(defineProps<NotificationProps>(), {
|
|
48
|
+
type: 'info',
|
|
49
|
+
appearance: 'card',
|
|
50
|
+
dismissible: true
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const emit = defineEmits<{ dismiss: []; action: [] }>()
|
|
54
|
+
|
|
55
|
+
defineSlots<{
|
|
56
|
+
default?(): unknown
|
|
57
|
+
actions?(): unknown
|
|
58
|
+
}>()
|
|
59
|
+
|
|
60
|
+
const titleId = `${useId()}-title`
|
|
61
|
+
|
|
62
|
+
const types = {
|
|
63
|
+
info: { icon: Info, colour: 'text-blue', word: 'Information' },
|
|
64
|
+
success: { icon: CircleCheck, colour: 'text-green', word: 'Success' },
|
|
65
|
+
warning: { icon: TriangleAlert, colour: 'text-yellow', word: 'Warning' },
|
|
66
|
+
error: { icon: CircleX, colour: 'text-red', word: 'Error' }
|
|
67
|
+
} as const
|
|
68
|
+
|
|
69
|
+
// A string, or a render function (for bold text, links).
|
|
70
|
+
const Description = () => (typeof props.description === 'function' ? props.description() : props.description)
|
|
71
|
+
|
|
72
|
+
// Compact only changes the card; in a list (row) it reads like the others.
|
|
73
|
+
const oneLine = computed(() => props.compact && props.appearance === 'card')
|
|
74
|
+
|
|
75
|
+
function runAction() {
|
|
76
|
+
props.action?.onSelect?.()
|
|
77
|
+
emit('action')
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<template>
|
|
82
|
+
<div
|
|
83
|
+
:aria-labelledby="titleId"
|
|
84
|
+
role="group"
|
|
85
|
+
:class="
|
|
86
|
+
cn(
|
|
87
|
+
'relative flex text-sm text-black',
|
|
88
|
+
oneLine ? 'items-center gap-3' : 'gap-3',
|
|
89
|
+
appearance === 'row' ? 'px-4 py-3' : 'rounded border border-black/15 bg-white',
|
|
90
|
+
appearance === 'card' && (oneLine ? cn('py-1.5 pl-5', dismissible ? 'pr-1.5' : 'pr-4') : 'py-4 pr-4 pl-5'),
|
|
91
|
+
appearance === 'row' && unread && 'bg-blue/5',
|
|
92
|
+
props.class
|
|
93
|
+
)
|
|
94
|
+
"
|
|
95
|
+
>
|
|
96
|
+
<component :is="types[type].icon" :class="cn('size-4 shrink-0', !oneLine && 'mt-0.5', types[type].colour)" aria-hidden="true" />
|
|
97
|
+
|
|
98
|
+
<div :class="cn('flex min-w-0 flex-1', oneLine ? 'items-center gap-3' : 'flex-col gap-1')">
|
|
99
|
+
<p :id="titleId" :class="cn('font-bold', oneLine && 'min-w-0 flex-1 py-1')">
|
|
100
|
+
<span class="sr-only">{{ types[type].word }}: </span>{{ title }}
|
|
101
|
+
</p>
|
|
102
|
+
|
|
103
|
+
<div v-if="!oneLine && (description || $slots.default)" class="text-black/65 [&_a]:font-bold [&_a]:text-primary [&_a]:underline [&_b]:font-bold [&_b]:text-black [&_strong]:font-bold [&_strong]:text-black">
|
|
104
|
+
<slot><Description /></slot>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<p v-if="appearance === 'row' && (createdAt || unread)" class="flex items-center gap-1.5 text-xs text-black/65">
|
|
108
|
+
<span v-if="unread" class="size-2 shrink-0 rounded-full bg-primary" aria-hidden="true" />
|
|
109
|
+
<span v-if="unread" class="sr-only">Unread, </span>
|
|
110
|
+
<RelativeTime v-if="createdAt" :date="createdAt" :now="now" />
|
|
111
|
+
</p>
|
|
112
|
+
|
|
113
|
+
<div v-if="action || $slots.actions" :class="cn('flex gap-2', oneLine ? 'shrink-0' : 'mt-2 flex-wrap')">
|
|
114
|
+
<slot name="actions">
|
|
115
|
+
<Button v-if="action?.href" size="sm" as-child @click="runAction">
|
|
116
|
+
<a :href="action.href">{{ action.label }}</a>
|
|
117
|
+
</Button>
|
|
118
|
+
<Button v-else-if="action" size="sm" @click="runAction">{{ action.label }}</Button>
|
|
119
|
+
</slot>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<Button
|
|
124
|
+
v-if="dismissible"
|
|
125
|
+
variant="ghost"
|
|
126
|
+
size="sm"
|
|
127
|
+
square
|
|
128
|
+
:class="cn('shrink-0', !oneLine && '-mt-1 -mr-1.5')"
|
|
129
|
+
data-dismiss
|
|
130
|
+
:aria-label="dismissLabel ?? `Dismiss: ${title}`"
|
|
131
|
+
@click="emit('dismiss')"
|
|
132
|
+
>
|
|
133
|
+
<X />
|
|
134
|
+
</Button>
|
|
135
|
+
</div>
|
|
136
|
+
</template>
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, ref, useId, watch, type HTMLAttributes } from 'vue'
|
|
3
|
+
import { Bell, BellOff } from '@lucide/vue'
|
|
4
|
+
import { cn } from '../../lib/cn'
|
|
5
|
+
import Button from '../Button/Button.vue'
|
|
6
|
+
import EmptyState from '../EmptyState/EmptyState.vue'
|
|
7
|
+
import Popover from '../Popover/Popover.vue'
|
|
8
|
+
import Notification from './Notification.vue'
|
|
9
|
+
import { useNotifications, type Notifications } from './notifications'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The bell in the Header, with a count of unread notifications, that opens
|
|
13
|
+
* a panel of past notifications: newest first, each with a × to remove it,
|
|
14
|
+
* and Clear all. Put it in the Header's `trailing` slot (AppShell's
|
|
15
|
+
* `header-trailing`).
|
|
16
|
+
*
|
|
17
|
+
* Opening it shows what's unread (a dot on each); closing it marks them all
|
|
18
|
+
* read.
|
|
19
|
+
*/
|
|
20
|
+
export interface NotificationPaneProps {
|
|
21
|
+
/** The list to show. Default the shared one from `useNotifications()`. */
|
|
22
|
+
notifications?: Notifications
|
|
23
|
+
/** Panel heading, and the bell's name. */
|
|
24
|
+
label?: string
|
|
25
|
+
/** Shown when there are none. */
|
|
26
|
+
emptyText?: string
|
|
27
|
+
ui?: { content?: HTMLAttributes['class']; trigger?: HTMLAttributes['class'] }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(defineProps<NotificationPaneProps>(), {
|
|
31
|
+
label: 'Notifications',
|
|
32
|
+
emptyText: "You're all caught up."
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const open = defineModel<boolean>('open', { default: false })
|
|
36
|
+
|
|
37
|
+
const store = computed(() => props.notifications ?? useNotifications())
|
|
38
|
+
const items = computed(() => store.value.items)
|
|
39
|
+
const unread = computed(() => store.value.unreadCount.value)
|
|
40
|
+
// The name uses the same text as the badge ("99+"), so voice control users
|
|
41
|
+
// can say what they see.
|
|
42
|
+
const countText = computed(() => (unread.value > 99 ? '99+' : String(unread.value)))
|
|
43
|
+
const triggerLabel = computed(() => (unread.value ? `${props.label}, ${countText.value} unread` : props.label))
|
|
44
|
+
|
|
45
|
+
const headingId = `${useId()}-heading`
|
|
46
|
+
const heading = ref<HTMLElement>()
|
|
47
|
+
const list = ref<HTMLElement>()
|
|
48
|
+
|
|
49
|
+
// Tell the list, so the Toaster puts toasts away while the pane shows them.
|
|
50
|
+
watch(open, (isOpen) => store.value.setPaneOpen(isOpen), { immediate: true })
|
|
51
|
+
|
|
52
|
+
// Open when something else asks, e.g. the Toaster's "+3 more", and move
|
|
53
|
+
// focus into the pane (the button pressed is gone with the toasts).
|
|
54
|
+
watch(
|
|
55
|
+
() => store.value.paneRequests,
|
|
56
|
+
async () => {
|
|
57
|
+
open.value = true
|
|
58
|
+
await nextTick()
|
|
59
|
+
requestAnimationFrame(() => requestAnimationFrame(() => heading.value?.focus()))
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
// Mark everything read when the panel closes, so the dots show while open.
|
|
64
|
+
watch(open, (isOpen, wasOpen) => {
|
|
65
|
+
if (!isOpen && wasOpen) store.value.markAllRead()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
// Clear all fades the list out first, then clears it when the fade ends and
|
|
69
|
+
// eases the pane's height down to the empty state's. `emptied` plays the
|
|
70
|
+
// empty state's arrival, only when the last one was just removed here, not
|
|
71
|
+
// every time the pane opens empty.
|
|
72
|
+
const pane = ref<HTMLElement>()
|
|
73
|
+
const clearing = ref(false)
|
|
74
|
+
const emptied = ref(false)
|
|
75
|
+
|
|
76
|
+
const reducedMotion = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
77
|
+
|
|
78
|
+
// Closing mid-fade unmounts the list before its animation ends, so finish
|
|
79
|
+
// the clear now.
|
|
80
|
+
watch(open, (isOpen) => {
|
|
81
|
+
if (isOpen) emptied.value = false
|
|
82
|
+
else if (clearing.value) finishClear()
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
// After removing one, focus moves to the × of the one that took its place
|
|
86
|
+
// (or the one before), so keyboard users keep their place. With none left,
|
|
87
|
+
// focus goes to the heading.
|
|
88
|
+
async function dismiss(id: string, index: number) {
|
|
89
|
+
store.value.dismiss(id)
|
|
90
|
+
if (!items.value.length) emptied.value = true
|
|
91
|
+
await nextTick()
|
|
92
|
+
const buttons = list.value?.querySelectorAll<HTMLElement>('[data-dismiss]') ?? []
|
|
93
|
+
const next = buttons[Math.min(index, buttons.length - 1)]
|
|
94
|
+
;(next ?? heading.value)?.focus()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function clearAll() {
|
|
98
|
+
if (clearing.value) return
|
|
99
|
+
// With reduced motion there's no fade (and so no animationend): clear now.
|
|
100
|
+
if (reducedMotion()) finishClear()
|
|
101
|
+
else clearing.value = true
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function finishClear() {
|
|
105
|
+
const from = pane.value?.offsetHeight
|
|
106
|
+
clearing.value = false
|
|
107
|
+
store.value.clear()
|
|
108
|
+
emptied.value = true
|
|
109
|
+
await nextTick()
|
|
110
|
+
heading.value?.focus()
|
|
111
|
+
// The height is only known once the empty state is in, so animate from the
|
|
112
|
+
// old height to the new one (Tailwind's 300ms ease-out, as `empty-in`).
|
|
113
|
+
const to = pane.value?.offsetHeight
|
|
114
|
+
if (pane.value && from && to && from !== to && !reducedMotion()) {
|
|
115
|
+
pane.value.animate(
|
|
116
|
+
[
|
|
117
|
+
{ height: `${from}px`, overflow: 'hidden' },
|
|
118
|
+
{ height: `${to}px`, overflow: 'hidden' }
|
|
119
|
+
],
|
|
120
|
+
{ duration: 300, easing: 'cubic-bezier(0, 0, 0.2, 1)' }
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<template>
|
|
127
|
+
<Popover
|
|
128
|
+
v-model:open="open"
|
|
129
|
+
:content="{ align: 'end', collisionPadding: 8 }"
|
|
130
|
+
:ui="{ content: cn('flex max-h-(--reka-popover-content-available-height) w-96 overflow-clip max-w-[calc(100vw-1rem)] flex-col', ui?.content) }"
|
|
131
|
+
>
|
|
132
|
+
<Button variant="ghost" square :aria-label="triggerLabel" :class="cn('relative overflow-visible', ui?.trigger)">
|
|
133
|
+
<Bell />
|
|
134
|
+
<span
|
|
135
|
+
v-if="unread"
|
|
136
|
+
class="absolute top-1 left-1/2 ml-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-red px-1 text-xs leading-none font-bold text-white ring-2 ring-white"
|
|
137
|
+
aria-hidden="true"
|
|
138
|
+
>
|
|
139
|
+
{{ countText }}
|
|
140
|
+
</span>
|
|
141
|
+
</Button>
|
|
142
|
+
|
|
143
|
+
<template #content="{ close }">
|
|
144
|
+
<section ref="pane" :aria-labelledby="headingId" class="flex min-h-0 flex-col">
|
|
145
|
+
<div class="flex h-11 shrink-0 items-center justify-between gap-2 border-b border-black/15 pr-2 pl-4">
|
|
146
|
+
<h2 :id="headingId" ref="heading" tabindex="-1" class="font-bold outline-none">{{ label }}</h2>
|
|
147
|
+
<Button v-if="items.length" variant="ghost" size="sm" :disabled="clearing" @click="clearAll">
|
|
148
|
+
Clear all
|
|
149
|
+
</Button>
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
<!-- inert while fading, so nothing in it can be clicked or focused on its way out. -->
|
|
153
|
+
<ul
|
|
154
|
+
v-if="items.length"
|
|
155
|
+
ref="list"
|
|
156
|
+
:inert="clearing"
|
|
157
|
+
:class="cn('min-h-0 overflow-y-auto overscroll-contain [scrollbar-width:thin]', clearing && 'animate-fade-out')"
|
|
158
|
+
@animationend.self="clearing && finishClear()"
|
|
159
|
+
>
|
|
160
|
+
<li v-for="(item, index) in items" :key="item.id" class="border-b border-black/15 last:border-b-0">
|
|
161
|
+
<Notification
|
|
162
|
+
appearance="row"
|
|
163
|
+
:type="item.type"
|
|
164
|
+
:title="item.title"
|
|
165
|
+
:description="item.description"
|
|
166
|
+
:action="item.action"
|
|
167
|
+
:created-at="item.createdAt"
|
|
168
|
+
:unread="!item.read"
|
|
169
|
+
@dismiss="dismiss(item.id, index)"
|
|
170
|
+
@action="close()"
|
|
171
|
+
/>
|
|
172
|
+
</li>
|
|
173
|
+
</ul>
|
|
174
|
+
|
|
175
|
+
<EmptyState
|
|
176
|
+
v-else
|
|
177
|
+
size="sm"
|
|
178
|
+
:icon="BellOff"
|
|
179
|
+
:description="emptyText"
|
|
180
|
+
:class="cn(emptied && 'motion-safe:animate-empty-in')"
|
|
181
|
+
:ui="{ icon: cn('origin-top', emptied && 'motion-safe:animate-bell-wobble') }"
|
|
182
|
+
/>
|
|
183
|
+
</section>
|
|
184
|
+
</template>
|
|
185
|
+
</Popover>
|
|
186
|
+
</template>
|