@thekestongroup/ui 0.1.3 → 0.2.1

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.
@@ -1,8 +1,29 @@
1
+ import { ToastAddOptions } from 'reka-ui';
2
+ export type ToastStatus = 'success' | 'warning' | 'error' | 'info' | 'plain';
3
+ export interface ToastNotification {
4
+ id: string;
5
+ title: string;
6
+ description: string;
7
+ status: ToastStatus;
8
+ at: number;
9
+ read: boolean;
10
+ }
11
+ export declare const toastNotifications: import('vue').Reactive<ToastNotification[]>;
12
+ declare function add(options: ToastAddOptions): string;
13
+ declare function update(id: string, options: Partial<ToastAddOptions>): void;
1
14
  export declare const toast: {
2
- add: <T extends any = any>(options: import('reka-ui').ToastAddOptions<T>) => string;
3
- update: <T extends any = any>(id: string, updates: import('reka-ui').ToastUpdateOptions<T> | ((prevToast: import('reka-ui').ToastObject<T>) => import('reka-ui').ToastUpdateOptions<T>)) => void;
15
+ add: typeof add;
16
+ update: typeof update;
4
17
  close: (id?: string) => void;
5
18
  promise: <Value, T extends any = any>(promise: Promise<Value>, options: import('reka-ui').ToastPromiseOptions<Value, T>) => Promise<Value>;
19
+ success: (options: ToastAddOptions) => string;
20
+ warning: (options: ToastAddOptions) => string;
21
+ error: (options: ToastAddOptions) => string;
22
+ info: (options: ToastAddOptions) => string;
23
+ plain: (options: ToastAddOptions) => string;
6
24
  };
25
+ export declare function markNotificationsRead(): void;
26
+ export declare function clearNotifications(): void;
27
+ export declare function removeNotification(id: string): void;
7
28
  export declare const toastManager: import('reka-ui').GlobalToastManager<any>;
8
29
  export type { ToastObject, ToastAddOptions, ToastUpdateOptions, ToastPromiseOptions, } from 'reka-ui';
@@ -0,0 +1,5 @@
1
+ export interface AppLink {
2
+ name: string;
3
+ href: string;
4
+ description?: string;
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thekestongroup/ui",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "description": "Keston UI — Vue 3 + Reka UI + Tailwind CSS component library",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -32,6 +32,7 @@
32
32
  "vue": "^3.5.0"
33
33
  },
34
34
  "devDependencies": {
35
+ "@lucide/vue": "^1.61.0",
35
36
  "@tailwindcss/vite": "^4.3.3",
36
37
  "@types/node": "^24.13.3",
37
38
  "@vitejs/plugin-vue": "^6.0.10",
@@ -0,0 +1,63 @@
1
+ <script setup lang="ts">
2
+ import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from 'reka-ui'
3
+ import type { AppLink } from '../lib/types'
4
+
5
+ withDefaults(
6
+ defineProps<{
7
+ apps: AppLink[]
8
+ current?: string
9
+ }>(),
10
+ {
11
+ current: '',
12
+ },
13
+ )
14
+
15
+ function initial(name: string) {
16
+ return name.trim().charAt(0).toUpperCase() || '?'
17
+ }
18
+ </script>
19
+
20
+ <template>
21
+ <PopoverRoot>
22
+ <PopoverTrigger as-child>
23
+ <button
24
+ type="button"
25
+ aria-label="Open app launcher"
26
+ class="inline-flex h-9 w-9 items-center justify-center rounded-md text-neutral-600 outline-none transition-colors hover:bg-neutral-100 focus-visible:ring-2 focus-visible:ring-blue-500"
27
+ >
28
+ <svg class="h-5 w-5" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
29
+ <path d="M4 4h4v4H4zM10 4h4v4h-4zM16 4h4v4h-4zM4 10h4v4H4zM10 10h4v4h-4zM16 10h4v4h-4zM4 16h4v4H4zM10 16h4v4h-4zM16 16h4v4h-4z" />
30
+ </svg>
31
+ </button>
32
+ </PopoverTrigger>
33
+ <PopoverPortal>
34
+ <PopoverContent
35
+ align="start"
36
+ :side-offset="8"
37
+ class="z-50 w-72 rounded-lg border border-neutral-200 bg-white p-2 shadow-lg outline-none"
38
+ >
39
+ <p class="px-2 py-1 text-xs font-semibold uppercase tracking-wide text-neutral-400">
40
+ Keston apps
41
+ </p>
42
+ <div class="mt-1 grid grid-cols-3 gap-1">
43
+ <a
44
+ v-for="app in apps"
45
+ :key="app.href"
46
+ :href="app.href"
47
+ :aria-current="app.name === current ? 'page' : undefined"
48
+ class="flex flex-col items-center gap-1.5 rounded-md p-2 text-center transition-colors hover:bg-neutral-100"
49
+ :class="app.name === current ? 'bg-neutral-50' : ''"
50
+ >
51
+ <span
52
+ class="flex h-9 w-9 items-center justify-center rounded-md text-sm font-semibold text-white"
53
+ :class="app.name === current ? 'bg-blue-600' : 'bg-neutral-900'"
54
+ >
55
+ {{ initial(app.name) }}
56
+ </span>
57
+ <span class="text-xs text-neutral-700">{{ app.name }}</span>
58
+ </a>
59
+ </div>
60
+ </PopoverContent>
61
+ </PopoverPortal>
62
+ </PopoverRoot>
63
+ </template>
@@ -0,0 +1,51 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import { cn } from '../lib/cn'
4
+
5
+ type Size = 'sm' | 'md' | 'lg'
6
+
7
+ const props = withDefaults(
8
+ defineProps<{
9
+ name?: string
10
+ email?: string
11
+ src?: string
12
+ size?: Size
13
+ class?: string
14
+ }>(),
15
+ {
16
+ name: '',
17
+ email: '',
18
+ src: '',
19
+ size: 'md',
20
+ },
21
+ )
22
+
23
+ const sizeClasses: Record<Size, string> = {
24
+ sm: 'h-8 w-8 text-xs',
25
+ md: 'h-9 w-9 text-sm',
26
+ lg: 'h-12 w-12 text-base',
27
+ }
28
+
29
+ const initials = computed(() => {
30
+ const source = (props.name || props.email || '').trim()
31
+ if (!source) return '?'
32
+ const parts = source.split(/\s+/).filter(Boolean)
33
+ if (parts.length >= 2) return (parts[0][0] + parts[1][0]).toUpperCase()
34
+ return parts[0].slice(0, 2).toUpperCase()
35
+ })
36
+ </script>
37
+
38
+ <template>
39
+ <span
40
+ :class="
41
+ cn(
42
+ 'inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-neutral-900 font-medium text-white',
43
+ sizeClasses[props.size],
44
+ props.class,
45
+ )
46
+ "
47
+ >
48
+ <img v-if="props.src" :src="props.src" alt="" class="h-full w-full object-cover" />
49
+ <span v-else>{{ initials }}</span>
50
+ </span>
51
+ </template>
@@ -0,0 +1,115 @@
1
+ <script setup lang="ts">
2
+ import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from 'reka-ui'
3
+ import { computed } from 'vue'
4
+ import {
5
+ clearNotifications,
6
+ markNotificationsRead,
7
+ removeNotification,
8
+ toastNotifications,
9
+ } from '../lib/toast'
10
+
11
+ const unread = computed(() => toastNotifications.filter((n) => !n.read).length)
12
+
13
+ function onOpen(open: boolean) {
14
+ if (open) markNotificationsRead()
15
+ }
16
+
17
+ function relativeTime(ts: number) {
18
+ const seconds = Math.max(0, Math.floor((Date.now() - ts) / 1000))
19
+ if (seconds < 60) return 'just now'
20
+ const minutes = Math.floor(seconds / 60)
21
+ if (minutes < 60) return `${minutes}m ago`
22
+ const hours = Math.floor(minutes / 60)
23
+ if (hours < 24) return `${hours}h ago`
24
+ return `${Math.floor(hours / 24)}d ago`
25
+ }
26
+
27
+ const statusDot: Record<string, string> = {
28
+ success: 'bg-green-500',
29
+ warning: 'bg-yellow-500',
30
+ error: 'bg-red-500',
31
+ info: 'bg-blue-500',
32
+ plain: 'bg-neutral-400',
33
+ }
34
+ </script>
35
+
36
+ <template>
37
+ <PopoverRoot @update:open="onOpen">
38
+ <PopoverTrigger as-child>
39
+ <button
40
+ type="button"
41
+ aria-label="Notifications"
42
+ class="relative inline-flex h-9 w-9 items-center justify-center rounded-md text-neutral-600 outline-none transition-colors hover:bg-neutral-100 focus-visible:ring-2 focus-visible:ring-blue-500"
43
+ >
44
+ <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.8" aria-hidden="true">
45
+ <path
46
+ stroke-linecap="round"
47
+ stroke-linejoin="round"
48
+ d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"
49
+ />
50
+ </svg>
51
+ <span
52
+ v-if="unread"
53
+ class="absolute right-1 top-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-red-600 px-1 text-[10px] font-semibold leading-none text-white"
54
+ >
55
+ {{ unread > 9 ? '9+' : unread }}
56
+ </span>
57
+ </button>
58
+ </PopoverTrigger>
59
+ <PopoverPortal>
60
+ <PopoverContent
61
+ align="end"
62
+ :side-offset="8"
63
+ class="z-50 w-80 rounded-lg border border-neutral-200 bg-white p-0 shadow-lg outline-none"
64
+ >
65
+ <div class="flex items-center justify-between border-b border-neutral-100 px-3 py-2">
66
+ <p class="text-sm font-semibold">Notifications</p>
67
+ <button
68
+ v-if="toastNotifications.length"
69
+ type="button"
70
+ class="rounded px-2 py-1 text-xs text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900"
71
+ @click="clearNotifications"
72
+ >
73
+ Clear all
74
+ </button>
75
+ </div>
76
+
77
+ <p v-if="toastNotifications.length === 0" class="px-3 py-6 text-center text-sm text-neutral-400">
78
+ No notifications yet.
79
+ </p>
80
+
81
+ <ul v-else class="max-h-80 divide-y divide-neutral-100 overflow-y-auto">
82
+ <li
83
+ v-for="item in toastNotifications"
84
+ :key="item.id"
85
+ class="group flex items-start gap-2 px-3 py-2.5"
86
+ >
87
+ <span
88
+ class="mt-1.5 h-2 w-2 shrink-0 rounded-full"
89
+ :class="statusDot[item.status] || statusDot.plain"
90
+ />
91
+ <div class="min-w-0 flex-1">
92
+ <p class="truncate text-sm font-medium text-neutral-900">
93
+ {{ item.title || 'Notification' }}
94
+ </p>
95
+ <p v-if="item.description" class="mt-0.5 text-xs text-neutral-500">
96
+ {{ item.description }}
97
+ </p>
98
+ <p class="mt-0.5 text-xs text-neutral-400">{{ relativeTime(item.at) }}</p>
99
+ </div>
100
+ <button
101
+ type="button"
102
+ aria-label="Dismiss notification"
103
+ class="mt-0.5 shrink-0 rounded p-1 text-neutral-300 opacity-0 transition-opacity hover:bg-neutral-100 hover:text-neutral-600 group-hover:opacity-100"
104
+ @click="removeNotification(item.id)"
105
+ >
106
+ <svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
107
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
108
+ </svg>
109
+ </button>
110
+ </li>
111
+ </ul>
112
+ </PopoverContent>
113
+ </PopoverPortal>
114
+ </PopoverRoot>
115
+ </template>
@@ -0,0 +1,113 @@
1
+ <script setup lang="ts">
2
+ import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from 'reka-ui'
3
+ import Avatar from './Avatar.vue'
4
+
5
+ const props = withDefaults(
6
+ defineProps<{
7
+ name?: string
8
+ email?: string
9
+ orgName?: string
10
+ avatarSrc?: string
11
+ accountSettingsUrl?: string
12
+ differentAccountUrl?: string
13
+ settingsLabel?: string
14
+ }>(),
15
+ {
16
+ name: '',
17
+ email: '',
18
+ orgName: '',
19
+ avatarSrc: '',
20
+ accountSettingsUrl: '',
21
+ differentAccountUrl: '',
22
+ settingsLabel: 'Account settings at Keston ID',
23
+ },
24
+ )
25
+
26
+ const emit = defineEmits<{
27
+ (e: 'signOut'): void
28
+ }>()
29
+ </script>
30
+
31
+ <template>
32
+ <PopoverRoot>
33
+ <PopoverTrigger as-child>
34
+ <button
35
+ type="button"
36
+ aria-label="Account menu"
37
+ class="rounded-full outline-none ring-offset-2 transition hover:opacity-90 focus-visible:ring-2 focus-visible:ring-blue-500"
38
+ >
39
+ <Avatar :name="props.name" :email="props.email" :src="props.avatarSrc" size="md" />
40
+ </button>
41
+ </PopoverTrigger>
42
+ <PopoverPortal>
43
+ <PopoverContent
44
+ align="end"
45
+ :side-offset="8"
46
+ class="z-50 w-80 rounded-lg border border-neutral-200 bg-white p-0 shadow-lg outline-none"
47
+ >
48
+ <div class="flex items-center justify-between gap-3 px-3 py-2.5">
49
+ <div class="min-w-0">
50
+ <p class="text-[11px] uppercase tracking-wide text-neutral-400">Signed in to</p>
51
+ <p class="truncate text-sm font-semibold text-neutral-900">
52
+ {{ props.orgName || 'Keston' }}
53
+ </p>
54
+ </div>
55
+ <button
56
+ type="button"
57
+ class="shrink-0 rounded-md px-2 py-1 text-xs font-medium text-neutral-600 hover:bg-neutral-100 hover:text-neutral-900"
58
+ @click="emit('signOut')"
59
+ >
60
+ Sign out
61
+ </button>
62
+ </div>
63
+
64
+ <div class="h-px bg-neutral-100" />
65
+
66
+ <div class="flex items-center gap-3 px-3 py-3">
67
+ <Avatar :name="props.name" :email="props.email" :src="props.avatarSrc" size="lg" />
68
+ <div class="min-w-0">
69
+ <p class="truncate text-sm font-semibold text-neutral-900">
70
+ {{ props.name || 'Signed in' }}
71
+ </p>
72
+ <p class="truncate text-xs text-neutral-500">{{ props.email }}</p>
73
+ </div>
74
+ </div>
75
+
76
+ <div class="h-px bg-neutral-100" />
77
+
78
+ <div class="p-1">
79
+ <a
80
+ v-if="props.accountSettingsUrl"
81
+ :href="props.accountSettingsUrl"
82
+ class="flex items-center gap-2 rounded-md px-2 py-2 text-sm text-neutral-700 hover:bg-neutral-100"
83
+ >
84
+ <svg class="h-4 w-4 text-neutral-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.8" aria-hidden="true">
85
+ <path
86
+ stroke-linecap="round"
87
+ stroke-linejoin="round"
88
+ d="M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"
89
+ />
90
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
91
+ </svg>
92
+ <span class="truncate">{{ props.settingsLabel }}</span>
93
+ </a>
94
+
95
+ <a
96
+ v-if="props.differentAccountUrl"
97
+ :href="props.differentAccountUrl"
98
+ class="flex items-center gap-2 rounded-md px-2 py-2 text-sm text-neutral-700 hover:bg-neutral-100"
99
+ >
100
+ <svg class="h-4 w-4 text-neutral-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.8" aria-hidden="true">
101
+ <path
102
+ stroke-linecap="round"
103
+ stroke-linejoin="round"
104
+ d="M16 21v-2a4 4 0 00-4-4H6a4 4 0 00-4 4v2M9 7a4 4 0 108 0 4 4 0 00-8 0zM19 8v6M22 11h-6"
105
+ />
106
+ </svg>
107
+ <span class="truncate">Use a different account</span>
108
+ </a>
109
+ </div>
110
+ </PopoverContent>
111
+ </PopoverPortal>
112
+ </PopoverRoot>
113
+ </template>
@@ -0,0 +1,158 @@
1
+ <script setup lang="ts">
2
+ import { CircleCheck, CircleX, Info, TriangleAlert } from '@lucide/vue'
3
+ import {
4
+ ToastAction,
5
+ ToastClose,
6
+ ToastDescription,
7
+ ToastRoot,
8
+ ToastTitle,
9
+ } from 'reka-ui'
10
+ import type { ToastObject } from 'reka-ui'
11
+ import type { Component } from 'vue'
12
+ import { computed } from 'vue'
13
+ import { cn } from '../lib/cn'
14
+ import CloseButton from './CloseButton.vue'
15
+
16
+ const props = defineProps<{
17
+ toast: ToastObject
18
+ }>()
19
+
20
+ type ToastVariant = 'success' | 'warning' | 'error' | 'info' | 'plain'
21
+
22
+ interface VariantStyle {
23
+ icon?: Component
24
+ root: string
25
+ iconClass: string
26
+ title: string
27
+ description: string
28
+ action: string
29
+ close: string
30
+ bar: string
31
+ }
32
+
33
+ const variants: Record<ToastVariant, VariantStyle> = {
34
+ success: {
35
+ icon: CircleCheck,
36
+ root: 'border-green-200 bg-green-50',
37
+ iconClass: 'text-green-600',
38
+ title: 'text-green-900',
39
+ description: 'text-green-700',
40
+ action: 'bg-green-100 text-green-900 hover:bg-green-200',
41
+ close: 'text-green-600 hover:text-green-800',
42
+ bar: 'bg-green-500',
43
+ },
44
+ warning: {
45
+ icon: TriangleAlert,
46
+ root: 'border-yellow-200 bg-yellow-50',
47
+ iconClass: 'text-yellow-600',
48
+ title: 'text-yellow-900',
49
+ description: 'text-yellow-700',
50
+ action: 'bg-yellow-100 text-yellow-900 hover:bg-yellow-200',
51
+ close: 'text-yellow-600 hover:text-yellow-800',
52
+ bar: 'bg-yellow-500',
53
+ },
54
+ error: {
55
+ icon: CircleX,
56
+ root: 'border-red-200 bg-red-50',
57
+ iconClass: 'text-red-600',
58
+ title: 'text-red-900',
59
+ description: 'text-red-700',
60
+ action: 'bg-red-100 text-red-900 hover:bg-red-200',
61
+ close: 'text-red-600 hover:text-red-800',
62
+ bar: 'bg-red-500',
63
+ },
64
+ info: {
65
+ icon: Info,
66
+ root: 'border-blue-200 bg-blue-50',
67
+ iconClass: 'text-blue-600',
68
+ title: 'text-blue-900',
69
+ description: 'text-blue-700',
70
+ action: 'bg-blue-100 text-blue-900 hover:bg-blue-200',
71
+ close: 'text-blue-600 hover:text-blue-800',
72
+ bar: 'bg-blue-500',
73
+ },
74
+ plain: {
75
+ root: 'border-neutral-200 bg-white',
76
+ iconClass: '',
77
+ title: 'text-neutral-900',
78
+ description: 'text-neutral-500',
79
+ action: 'bg-neutral-100 text-neutral-900 hover:bg-neutral-200',
80
+ close: 'text-neutral-400 hover:text-neutral-600',
81
+ bar: 'bg-neutral-400',
82
+ },
83
+ }
84
+
85
+ function variantFor(status?: string): ToastVariant {
86
+ if (
87
+ status === 'success' ||
88
+ status === 'warning' ||
89
+ status === 'error' ||
90
+ status === 'info'
91
+ ) {
92
+ return status
93
+ }
94
+ return 'plain'
95
+ }
96
+
97
+ function progressRatio(remaining: number, duration: number) {
98
+ if (!Number.isFinite(duration) || duration <= 0) return 0
99
+ return Math.min(Math.max(remaining / duration, 0), 1)
100
+ }
101
+
102
+ const variant = computed(() => variantFor(props.toast.status))
103
+ const style = computed(() => variants[variant.value])
104
+ </script>
105
+
106
+ <template>
107
+ <ToastRoot
108
+ :toast="toast"
109
+ :class="
110
+ cn(
111
+ 'kui-toast pointer-events-auto flex items-start gap-3 rounded-lg border p-4 shadow-lg',
112
+ style.root,
113
+ )
114
+ "
115
+ v-slot="{ remaining, duration }"
116
+ >
117
+ <component
118
+ :is="style.icon"
119
+ v-if="style.icon"
120
+ :class="cn('h-5 w-5 shrink-0', style.iconClass)"
121
+ aria-hidden="true"
122
+ />
123
+ <div class="flex min-w-0 flex-1 flex-col gap-1">
124
+ <ToastTitle :class="cn('text-sm font-semibold', style.title)" />
125
+ <ToastDescription :class="cn('text-sm', style.description)" />
126
+ <ToastAction
127
+ :class="
128
+ cn(
129
+ 'mt-1 inline-flex h-8 items-center justify-center gap-2 self-start rounded-md px-3 text-xs font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2',
130
+ style.action,
131
+ )
132
+ "
133
+ />
134
+ </div>
135
+ <ToastClose
136
+ aria-label="Close"
137
+ :class="
138
+ cn(
139
+ 'shrink-0 rounded-sm outline-none transition-colors focus-visible:ring-2 focus-visible:ring-blue-500',
140
+ style.close,
141
+ )
142
+ "
143
+ >
144
+ <CloseButton />
145
+ </ToastClose>
146
+ <div
147
+ v-if="Number.isFinite(duration) && duration > 0"
148
+ aria-hidden="true"
149
+ class="pointer-events-none absolute inset-x-0 bottom-0 h-1 overflow-hidden rounded-b-lg bg-black/5"
150
+ >
151
+ <div
152
+ class="h-full w-full origin-left will-change-transform"
153
+ :class="style.bar"
154
+ :style="{ transform: `scaleX(${progressRatio(remaining, duration)})` }"
155
+ />
156
+ </div>
157
+ </ToastRoot>
158
+ </template>
@@ -1,53 +1,26 @@
1
1
  <script setup lang="ts">
2
- import {
3
- ToastAction,
4
- ToastClose,
5
- ToastDescription,
6
- ToastRoot,
7
- ToastTitle,
8
- ToastViewport,
9
- useToastManager,
10
- } from 'reka-ui'
11
- import CloseButton from './CloseButton.vue'
2
+ import { ToastViewport, useToastManager } from 'reka-ui'
3
+ import ToastItem from './ToastItem.vue'
12
4
 
13
5
  const { toasts } = useToastManager()
14
6
  </script>
15
7
 
16
8
  <template>
17
9
  <ToastViewport
18
- class="kui-toast-viewport fixed bottom-0 right-0 z-[100] w-full max-w-sm p-4 outline-none sm:bottom-4 sm:right-4"
10
+ class="kui-toast-viewport fixed left-0 top-0 z-[100] w-full max-w-sm p-4 outline-none sm:left-4 sm:top-4"
19
11
  >
20
- <ToastRoot
21
- v-for="toast in toasts"
22
- :key="toast.id"
23
- :toast="toast"
24
- class="kui-toast pointer-events-auto flex items-start gap-3 rounded-lg border border-neutral-200 bg-white p-4 shadow-lg"
25
- >
26
- <div class="flex min-w-0 flex-1 flex-col gap-1">
27
- <ToastTitle class="text-sm font-semibold text-neutral-900" />
28
- <ToastDescription class="text-sm text-neutral-500" />
29
- <ToastAction
30
- class="mt-1 inline-flex h-8 items-center justify-center gap-2 self-start rounded-md bg-neutral-100 px-3 text-xs font-medium text-neutral-900 outline-none transition-colors hover:bg-neutral-200 focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2"
31
- />
32
- </div>
33
- <ToastClose
34
- aria-label="Close"
35
- class="shrink-0 rounded-sm text-neutral-400 outline-none transition-colors hover:text-neutral-600 focus-visible:ring-2 focus-visible:ring-blue-500"
36
- >
37
- <CloseButton />
38
- </ToastClose>
39
- </ToastRoot>
12
+ <ToastItem v-for="toast in toasts" :key="toast.id" :toast="toast" />
40
13
  </ToastViewport>
41
14
  </template>
42
15
 
43
16
  <style>
44
17
  .kui-toast {
45
18
  position: absolute;
46
- bottom: 0;
47
- right: 0;
19
+ top: 0;
20
+ left: 0;
48
21
  width: 100%;
49
22
  height: var(--reka-toast-frontmost-height);
50
- transform: translateY(calc(var(--reka-toast-index) * -12px))
23
+ transform: translateY(calc(var(--reka-toast-index) * 12px))
51
24
  scale(calc(1 - var(--reka-toast-index) * 0.05));
52
25
  z-index: calc(1000 - var(--reka-toast-index));
53
26
  transition:
@@ -57,21 +30,21 @@ const { toasts } = useToastManager()
57
30
  transition-delay: 100ms;
58
31
  }
59
32
 
60
- /* Invisible hit-area that covers the gap above each toast, so the cursor
33
+ /* Invisible hit-area that covers the gap below each toast, so the cursor
61
34
  moving between toasts doesn't leave the viewport and collapse the stack. */
62
35
  .kui-toast::after {
63
36
  content: '';
64
37
  position: absolute;
65
38
  left: 0;
66
39
  right: 0;
67
- bottom: 100%;
40
+ top: 100%;
68
41
  height: 12px;
69
42
  }
70
43
 
71
44
  .kui-toast-viewport[data-expanded] .kui-toast {
72
45
  height: var(--reka-toast-height);
73
46
  transform: translateY(
74
- calc(var(--reka-toast-offset-y) * -1 - var(--reka-toast-index) * 12px)
47
+ calc(var(--reka-toast-offset-y) + var(--reka-toast-index) * 12px)
75
48
  );
76
49
  transition-delay: 0ms;
77
50
  }
@@ -100,7 +73,7 @@ const { toasts } = useToastManager()
100
73
 
101
74
  @keyframes kui-toast-in {
102
75
  from {
103
- translate: 100% 0;
76
+ translate: -100% 0;
104
77
  opacity: 0;
105
78
  }
106
79
  to {
@@ -110,7 +83,7 @@ const { toasts } = useToastManager()
110
83
  }
111
84
  @keyframes kui-toast-out {
112
85
  to {
113
- translate: 100% 0;
86
+ translate: -100% 0;
114
87
  opacity: 0;
115
88
  }
116
89
  }
@@ -119,7 +92,7 @@ const { toasts } = useToastManager()
119
92
  transform: translateX(var(--reka-toast-swipe-end-x));
120
93
  }
121
94
  to {
122
- transform: translateX(calc(100% + 1rem));
95
+ transform: translateX(calc(-100% - 1rem));
123
96
  }
124
97
  }
125
98