@thekestongroup/ui 0.12.0 → 0.14.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/dist/components/AppLauncher/AppLauncher.vue.d.ts +34 -0
- package/dist/components/AppLauncher/apps.d.ts +3 -0
- package/dist/components/AppShell/AppShell.vue.d.ts +3 -0
- package/dist/components/Header/Header.vue.d.ts +3 -2
- package/dist/components/Slideover/Slideover.vue.d.ts +1 -1
- package/dist/i18n/en.d.ts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/keston-ui.js +997 -899
- package/package.json +1 -1
- package/src/components/AppLauncher/AppLauncher.stories.ts +32 -0
- package/src/components/AppLauncher/AppLauncher.vue +88 -0
- package/src/components/AppLauncher/apps.ts +10 -0
- package/src/components/AppShell/AppShell.stories.ts +5 -0
- package/src/components/AppShell/AppShell.vue +9 -2
- package/src/components/Footer/footer.test.ts +2 -2
- package/src/components/Footer/links.ts +3 -3
- package/src/components/Header/Header.vue +4 -1
- package/src/i18n/en.ts +1 -0
- package/src/index.ts +3 -0
package/package.json
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import { userEvent, within } from "storybook/test";
|
|
3
|
+
import AppLauncher from "./AppLauncher.vue";
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: "Components/Navigation/AppLauncher",
|
|
7
|
+
component: AppLauncher,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
decorators: [() => ({ template: '<div class="flex min-h-96 justify-end p-4"><story /></div>' })],
|
|
10
|
+
} satisfies Meta<typeof AppLauncher>;
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
type Story = StoryObj<typeof meta>;
|
|
14
|
+
|
|
15
|
+
export const Default: Story = {};
|
|
16
|
+
|
|
17
|
+
/** Open, with the app you are in marked. */
|
|
18
|
+
export const Open: Story = {
|
|
19
|
+
args: { current: "admin" },
|
|
20
|
+
play: async ({ canvasElement }) => {
|
|
21
|
+
await userEvent.click(within(canvasElement).getByRole("button", { name: "Keston apps" }));
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const CustomApps: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
apps: [
|
|
28
|
+
{ id: "a", label: "Rota", href: "#a" },
|
|
29
|
+
{ id: "b", label: "Reports", href: "#b" },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { BriefcaseBusiness, IdCard, Palette, ShieldCheck, Wrench, AppWindow, type LucideIcon } from '@lucide/vue'
|
|
3
|
+
|
|
4
|
+
const builtInIcons: Record<string, LucideIcon> = {
|
|
5
|
+
id: IdCard,
|
|
6
|
+
admin: ShieldCheck,
|
|
7
|
+
work: BriefcaseBusiness,
|
|
8
|
+
utilities: Wrench,
|
|
9
|
+
design: Palette
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import { useI18n } from 'vue-i18n'
|
|
15
|
+
import { LayoutGrid } from '@lucide/vue'
|
|
16
|
+
import type { Component, HTMLAttributes } from 'vue'
|
|
17
|
+
import { cn } from '../../lib/cn'
|
|
18
|
+
import Button from '../Button/Button.vue'
|
|
19
|
+
import Popover from '../Popover/Popover.vue'
|
|
20
|
+
import { kestonApps } from './apps'
|
|
21
|
+
|
|
22
|
+
export interface AppLauncherApp {
|
|
23
|
+
/** Matches `current` to mark the app you are in. */
|
|
24
|
+
id: string
|
|
25
|
+
label: string
|
|
26
|
+
href: string
|
|
27
|
+
/** An icon component, or the name of one of the Keston app icons (id, admin, work, utilities, design). */
|
|
28
|
+
icon?: Component | string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The grid button in the header that opens a panel of the Keston Group's apps, so people can move between
|
|
33
|
+
* them. The same in every app: it lists `kestonApps` and marks the one you are in with `current`. In an app
|
|
34
|
+
* built on AppShell, pass `launcher` to AppShell instead of using this directly.
|
|
35
|
+
*
|
|
36
|
+
* Apps open in the same tab, as moving between Keston apps is moving on, not a side trip (the footer's
|
|
37
|
+
* links are the opposite: they open in a new tab).
|
|
38
|
+
*/
|
|
39
|
+
export interface AppLauncherProps {
|
|
40
|
+
/** The apps to list. Default: `kestonApps`. */
|
|
41
|
+
apps?: AppLauncherApp[]
|
|
42
|
+
/** The `id` of the app you are in, shown as the current page. */
|
|
43
|
+
current?: string
|
|
44
|
+
/** Which edge of the button the panel lines up with: `start` when the button is at the left of the header (AppShell), `end` when at the right. Default `end`. */
|
|
45
|
+
align?: 'start' | 'end'
|
|
46
|
+
/** Name of the button for screen readers. Default "Keston apps". */
|
|
47
|
+
label?: string
|
|
48
|
+
class?: HTMLAttributes['class']
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const { t } = useI18n()
|
|
52
|
+
const props = withDefaults(defineProps<AppLauncherProps>(), { apps: () => kestonApps, align: 'end' })
|
|
53
|
+
|
|
54
|
+
function iconOf(app: AppLauncherApp): Component {
|
|
55
|
+
if (typeof app.icon === 'string') return builtInIcons[app.icon] ?? AppWindow
|
|
56
|
+
return app.icon ?? AppWindow
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<Popover :content="{ align }" :ui="{ content: 'w-64 p-2' }">
|
|
62
|
+
<Button variant="ghost" square :aria-label="label ?? t('ui.appLauncher.label')" :class="props.class">
|
|
63
|
+
<LayoutGrid />
|
|
64
|
+
</Button>
|
|
65
|
+
<template #content="{ close }">
|
|
66
|
+
<nav :aria-label="label ?? t('ui.appLauncher.label')">
|
|
67
|
+
<ul>
|
|
68
|
+
<li v-for="app in apps" :key="app.id">
|
|
69
|
+
<a
|
|
70
|
+
:href="app.href"
|
|
71
|
+
:aria-current="app.id === current ? 'page' : undefined"
|
|
72
|
+
:class="cn(
|
|
73
|
+
'flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-bold text-black outline-none hover:bg-black/5 focus-visible:outline-2 focus-visible:outline-focus',
|
|
74
|
+
app.id === current && 'bg-black/5'
|
|
75
|
+
)"
|
|
76
|
+
@click="close()"
|
|
77
|
+
>
|
|
78
|
+
<span class="flex size-8 shrink-0 items-center justify-center rounded-lg bg-black/5">
|
|
79
|
+
<component :is="iconOf(app)" class="size-5" aria-hidden="true" />
|
|
80
|
+
</span>
|
|
81
|
+
<span class="min-w-0 truncate">{{ app.label }}</span>
|
|
82
|
+
</a>
|
|
83
|
+
</li>
|
|
84
|
+
</ul>
|
|
85
|
+
</nav>
|
|
86
|
+
</template>
|
|
87
|
+
</Popover>
|
|
88
|
+
</template>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AppLauncherApp } from './AppLauncher.vue'
|
|
2
|
+
|
|
3
|
+
/** The Keston Group's apps, as the launcher lists them by default. Apps can pass their own `apps`. */
|
|
4
|
+
export const kestonApps: AppLauncherApp[] = [
|
|
5
|
+
{ id: 'id', label: 'Keston ID', href: 'https://id.keston.co', icon: 'id' },
|
|
6
|
+
{ id: 'admin', label: 'Admin', href: 'https://admin.keston.co', icon: 'admin' },
|
|
7
|
+
{ id: 'work', label: 'Work', href: 'https://work.keston.co', icon: 'work' },
|
|
8
|
+
{ id: 'utilities', label: 'Utilities', href: 'https://utilities.keston.co', icon: 'utilities' },
|
|
9
|
+
{ id: 'design', label: 'Design system', href: 'https://ui.keston.co', icon: 'design' }
|
|
10
|
+
]
|
|
@@ -68,6 +68,11 @@ export const WithFooter: Story = {
|
|
|
68
68
|
args: { footer: { appName: "Keston Admissions", version: "2.3.0", build: "a1b2c3d", since: 2024 } },
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
+
/** The Keston app launcher: a grid button in the header for moving between the Keston apps. */
|
|
72
|
+
export const WithLauncher: Story = {
|
|
73
|
+
args: { launcher: { current: "admin" } },
|
|
74
|
+
};
|
|
75
|
+
|
|
71
76
|
/** titleTo: the app's name in the header links to its dashboard (`to` for `linkComponent`, or an href). */
|
|
72
77
|
export const TitleLink: Story = {
|
|
73
78
|
args: { titleTo: "#dashboard" },
|
|
@@ -4,6 +4,7 @@ import { onBeforeUnmount, onMounted, useId, type HTMLAttributes } from 'vue'
|
|
|
4
4
|
import { Menu } from '@lucide/vue'
|
|
5
5
|
import { TooltipProvider } from 'reka-ui'
|
|
6
6
|
import { cn } from '../../lib/cn'
|
|
7
|
+
import AppLauncher, { type AppLauncherProps } from '../AppLauncher/AppLauncher.vue'
|
|
7
8
|
import Button from '../Button/Button.vue'
|
|
8
9
|
import Footer, { type FooterProps } from '../Footer/Footer.vue'
|
|
9
10
|
import Header, { type HeaderProps, type HeaderUser, type HeaderUserAction } from '../Header/Header.vue'
|
|
@@ -57,6 +58,8 @@ export interface AppShellProps {
|
|
|
57
58
|
collapsible?: boolean
|
|
58
59
|
/** Show the Keston Group footer under the page. The Footer's props: `{ appName, version, … }`. Without it there is no footer. */
|
|
59
60
|
footer?: FooterProps
|
|
61
|
+
/** Show the app launcher (a grid button for moving between Keston apps) at the left of the header, before the menu button. `true` for the defaults, or the AppLauncher's props: `{ current: 'admin' }`. */
|
|
62
|
+
launcher?: boolean | AppLauncherProps
|
|
60
63
|
/** Component used for sidebar items with `to`, and the title link, e.g. RouterLink. */
|
|
61
64
|
linkComponent?: SidebarProps['linkComponent']
|
|
62
65
|
/** Other Header props, e.g. `{ ui: { title: '…' } }`. */
|
|
@@ -146,13 +149,17 @@ const sidebarId = `${uid}-sidebar`
|
|
|
146
149
|
:user="user"
|
|
147
150
|
:user-actions="userActions"
|
|
148
151
|
:sign-in="signIn"
|
|
149
|
-
:ui="{ ...header?.ui, menu: cn('lg:hidden', header?.ui?.menu) }"
|
|
152
|
+
:ui="{ ...header?.ui, menu: cn('lg:hidden', launcher && 'ml-0', header?.ui?.menu) }"
|
|
150
153
|
@menu="menuOpen = true"
|
|
151
154
|
@account-settings="emit('account-settings')"
|
|
152
155
|
@switch-account="emit('switch-account')"
|
|
153
156
|
@log-out="emit('log-out')"
|
|
154
157
|
@sign-in="emit('sign-in')"
|
|
155
158
|
>
|
|
159
|
+
<!-- First in the header, to the left of the menu / collapse button. -->
|
|
160
|
+
<template v-if="launcher" #start>
|
|
161
|
+
<AppLauncher align="start" v-bind="launcher === true ? {} : launcher" class="-ml-2.5" />
|
|
162
|
+
</template>
|
|
156
163
|
<template #leading>
|
|
157
164
|
<!-- Wide screens: in place of the menu button (same look and spot),
|
|
158
165
|
collapses the sidebar beside the page to icons and back. -->
|
|
@@ -163,7 +170,7 @@ const sidebarId = `${uid}-sidebar`
|
|
|
163
170
|
:aria-label="collapsed ? t('ui.appShell.expandSidebar') : t('ui.appShell.collapseSidebar')"
|
|
164
171
|
:aria-expanded="!collapsed"
|
|
165
172
|
:aria-controls="sidebarId"
|
|
166
|
-
class="-ml-2.5
|
|
173
|
+
:class="cn('max-lg:hidden', launcher ? 'ml-0' : '-ml-2.5')"
|
|
167
174
|
@click="collapsed = !collapsed"
|
|
168
175
|
>
|
|
169
176
|
<Menu />
|
|
@@ -27,9 +27,9 @@ describe('version', () => {
|
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
describe('kestonFooterLinks', () => {
|
|
30
|
-
it('are Help & support, Privacy Policy and Terms & Conditions, on secure
|
|
30
|
+
it('are Help & support, Privacy Policy and Terms & Conditions, on secure thekestongroup.com addresses', () => {
|
|
31
31
|
expect(kestonFooterLinks.map((l) => l.label)).toEqual(['Help & support', 'Privacy Policy', 'Terms & Conditions'])
|
|
32
|
-
for (const link of kestonFooterLinks) expect(link.href).toMatch(/^https:\/\/
|
|
32
|
+
for (const link of kestonFooterLinks) expect(link.href).toMatch(/^https:\/\/thekestongroup\.com\/(help|privacy|terms)$/)
|
|
33
33
|
})
|
|
34
34
|
})
|
|
35
35
|
|
|
@@ -5,9 +5,9 @@ import type { FooterLink } from './Footer.vue'
|
|
|
5
5
|
* Apps can pass their own `links`, or add to these with `moreLinks`.
|
|
6
6
|
*/
|
|
7
7
|
export const kestonFooterLinks: FooterLink[] = [
|
|
8
|
-
{ label: 'Help & support', href: 'https://
|
|
9
|
-
{ label: 'Privacy Policy', href: 'https://
|
|
10
|
-
{ label: 'Terms & Conditions', href: 'https://
|
|
8
|
+
{ label: 'Help & support', href: 'https://thekestongroup.com/help' },
|
|
9
|
+
{ label: 'Privacy Policy', href: 'https://thekestongroup.com/privacy' },
|
|
10
|
+
{ label: 'Terms & Conditions', href: 'https://thekestongroup.com/terms' }
|
|
11
11
|
]
|
|
12
12
|
|
|
13
13
|
/** Links to the rest of the Keston Group. Not shown by default: pass them as `moreLinks` where an app should offer them. */
|
|
@@ -26,7 +26,7 @@ export type HeaderUserAction = 'account-settings' | 'switch-account' | 'log-out'
|
|
|
26
26
|
* the right (Account settings, Switch account, Log out). Each part can be
|
|
27
27
|
* overridden with a slot.
|
|
28
28
|
*
|
|
29
|
-
* Slots: leading (before the title, e.g. a logo), title, default (the middle,
|
|
29
|
+
* Slots: start (the very first thing, before the menu button, e.g. the app launcher; give it a `-ml-2.5` button to line up with the padding), leading (before the title, e.g. a logo), title, default (the middle,
|
|
30
30
|
* fills the space between title and trailing), trailing (actions before the
|
|
31
31
|
* account menu), account (replaces the account menu, or the Sign in button),
|
|
32
32
|
* account-menu (extra content in the account menu, above Switch account /
|
|
@@ -104,6 +104,7 @@ const emit = defineEmits<{
|
|
|
104
104
|
}>()
|
|
105
105
|
|
|
106
106
|
defineSlots<{
|
|
107
|
+
start?(): unknown
|
|
107
108
|
leading?(): unknown
|
|
108
109
|
title?(): unknown
|
|
109
110
|
default?(): unknown
|
|
@@ -156,6 +157,8 @@ function runAction(action: HeaderUserAction, close: () => void) {
|
|
|
156
157
|
props.class
|
|
157
158
|
)"
|
|
158
159
|
>
|
|
160
|
+
<slot name="start" />
|
|
161
|
+
|
|
159
162
|
<!-- A ghost icon Button; the negative margin lines its icon up with the
|
|
160
163
|
header's padding, as the × does in Slideover. -->
|
|
161
164
|
<Button
|
package/src/i18n/en.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -14,6 +14,9 @@ export { default as PageHeader } from './components/PageHeader/PageHeader.vue'
|
|
|
14
14
|
export type { PageHeaderAction, PageHeaderProps } from './components/PageHeader/PageHeader.vue'
|
|
15
15
|
export { default as SettingsRow } from './components/SettingsRow/SettingsRow.vue'
|
|
16
16
|
export type { SettingsRowProps } from './components/SettingsRow/SettingsRow.vue'
|
|
17
|
+
export { default as AppLauncher } from './components/AppLauncher/AppLauncher.vue'
|
|
18
|
+
export type { AppLauncherApp, AppLauncherProps } from './components/AppLauncher/AppLauncher.vue'
|
|
19
|
+
export { kestonApps } from './components/AppLauncher/apps'
|
|
17
20
|
export { default as Footer } from './components/Footer/Footer.vue'
|
|
18
21
|
export type { FooterLink, FooterProps } from './components/Footer/Footer.vue'
|
|
19
22
|
export { kestonFooterLinks, kestonGroupLinks } from './components/Footer/links'
|