@thekestongroup/ui 0.12.0 → 0.13.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.
- package/dist/components/AppLauncher/AppLauncher.vue.d.ts +33 -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 +1 -1
- 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 +989 -894
- package/package.json +1 -1
- package/src/components/AppLauncher/AppLauncher.stories.ts +32 -0
- package/src/components/AppLauncher/AppLauncher.vue +91 -0
- package/src/components/AppLauncher/apps.ts +10 -0
- package/src/components/AppShell/AppShell.stories.ts +5 -0
- package/src/components/AppShell/AppShell.vue +7 -1
- package/src/components/Footer/footer.test.ts +2 -2
- package/src/components/Footer/links.ts +3 -3
- 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", description: "Who is in when", href: "#a" },
|
|
29
|
+
{ id: "b", label: "Reports", href: "#b" },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
/** A few words on what the app is for. */
|
|
27
|
+
description?: string
|
|
28
|
+
href: string
|
|
29
|
+
/** An icon component, or the name of one of the Keston app icons (id, admin, work, utilities, design). */
|
|
30
|
+
icon?: Component | string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The grid button in the header that opens a panel of the Keston Group's apps, so people can move between
|
|
35
|
+
* them. The same in every app: it lists `kestonApps` and marks the one you are in with `current`. In an app
|
|
36
|
+
* built on AppShell, pass `launcher` to AppShell instead of using this directly.
|
|
37
|
+
*
|
|
38
|
+
* Apps open in the same tab, as moving between Keston apps is moving on, not a side trip (the footer's
|
|
39
|
+
* links are the opposite: they open in a new tab).
|
|
40
|
+
*/
|
|
41
|
+
export interface AppLauncherProps {
|
|
42
|
+
/** The apps to list. Default: `kestonApps`. */
|
|
43
|
+
apps?: AppLauncherApp[]
|
|
44
|
+
/** The `id` of the app you are in, shown as the current page. */
|
|
45
|
+
current?: string
|
|
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 })
|
|
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: 'end' }" :ui="{ content: 'w-80 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 class="grid grid-cols-2 gap-1">
|
|
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 h-full flex-col items-start gap-2 rounded-lg p-3 text-sm 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-9 items-center justify-center rounded-lg bg-black/5 text-black">
|
|
79
|
+
<component :is="iconOf(app)" class="size-5" aria-hidden="true" />
|
|
80
|
+
</span>
|
|
81
|
+
<span class="min-w-0">
|
|
82
|
+
<span class="block font-bold text-black">{{ app.label }}</span>
|
|
83
|
+
<span v-if="app.description" class="block text-xs text-black/65">{{ app.description }}</span>
|
|
84
|
+
</span>
|
|
85
|
+
</a>
|
|
86
|
+
</li>
|
|
87
|
+
</ul>
|
|
88
|
+
</nav>
|
|
89
|
+
</template>
|
|
90
|
+
</Popover>
|
|
91
|
+
</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', description: 'Your account and sign-in', href: 'https://id.keston.co', icon: 'id' },
|
|
6
|
+
{ id: 'admin', label: 'Admin', description: 'Manage people and access', href: 'https://admin.keston.co', icon: 'admin' },
|
|
7
|
+
{ id: 'work', label: 'Work', description: 'Day-to-day work', href: 'https://work.keston.co', icon: 'work' },
|
|
8
|
+
{ id: 'utilities', label: 'Utilities', description: 'Small tools that run on your device', href: 'https://utilities.keston.co', icon: 'utilities' },
|
|
9
|
+
{ id: 'design', label: 'Design system', description: 'Keston UI', 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) in the header. `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: '…' } }`. */
|
|
@@ -171,7 +174,10 @@ const sidebarId = `${uid}-sidebar`
|
|
|
171
174
|
<slot name="header-leading" />
|
|
172
175
|
</template>
|
|
173
176
|
<slot name="header-middle" />
|
|
174
|
-
<template v-if="$slots['header-trailing']" #trailing
|
|
177
|
+
<template v-if="$slots['header-trailing'] || launcher" #trailing>
|
|
178
|
+
<slot name="header-trailing" />
|
|
179
|
+
<AppLauncher v-if="launcher" v-bind="launcher === true ? {} : launcher" />
|
|
180
|
+
</template>
|
|
175
181
|
<template v-if="$slots.account" #account><slot name="account" /></template>
|
|
176
182
|
<template v-if="$slots['account-menu']" #account-menu="slotProps"><slot name="account-menu" v-bind="slotProps" /></template>
|
|
177
183
|
<template v-if="$slots.organisation" #organisation="slotProps"><slot name="organisation" v-bind="slotProps" /></template>
|
|
@@ -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. */
|
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'
|