@thekestongroup/ui 0.11.1 → 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 +10 -0
- package/dist/components/CardSelect/CardSelect.vue.d.ts +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts +1 -1
- package/dist/components/Footer/Footer.vue.d.ts +66 -0
- package/dist/components/Footer/footer.d.ts +6 -0
- package/dist/components/Footer/links.d.ts +8 -0
- package/dist/components/FormField/FormField.vue.d.ts +1 -1
- package/dist/components/Input/Input.vue.d.ts +1 -1
- package/dist/components/InputCode/InputCode.vue.d.ts +1 -1
- package/dist/components/InputDate/InputDate.vue.d.ts +1 -1
- package/dist/components/InputNumber/InputNumber.vue.d.ts +1 -1
- package/dist/components/InputPassword/InputPassword.vue.d.ts +1 -1
- package/dist/components/InputRichText/InputRichText.vue.d.ts +1 -1
- package/dist/components/InputTextArea/InputTextArea.vue.d.ts +1 -1
- package/dist/components/RadioGroup/RadioGroup.vue.d.ts +1 -1
- package/dist/components/Select/Select.vue.d.ts +1 -1
- package/dist/i18n/en.d.ts +9 -0
- package/dist/index.d.ts +6 -0
- package/dist/keston-ui.js +1052 -798
- 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 +13 -0
- package/src/components/AppShell/AppShell.vue +21 -4
- package/src/components/Avatar/Avatar.vue +6 -3
- package/src/components/Card/Card.stories.ts +1 -1
- package/src/components/Checklist/Checklist.stories.ts +1 -1
- package/src/components/Footer/Footer.stories.ts +82 -0
- package/src/components/Footer/Footer.vue +123 -0
- package/src/components/Footer/footer.test.ts +41 -0
- package/src/components/Footer/footer.ts +15 -0
- package/src/components/Footer/links.ts +19 -0
- package/src/components/Input/Input.vue +1 -0
- package/src/components/StatTile/StatTile.stories.ts +1 -1
- package/src/examples/AppPages.stories.ts +1 -1
- package/src/examples/SchoolPages.stories.ts +2 -2
- package/src/i18n/en.ts +7 -0
- package/src/index.ts +6 -0
- package/src/lib/parseDate.ts +1 -1
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
|
+
]
|
|
@@ -60,6 +60,19 @@ type Story = StoryObj<typeof meta>;
|
|
|
60
60
|
*/
|
|
61
61
|
export const Default: Story = {};
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* footer: the Keston Group footer under the page, with this app's name, version and build. On a short page
|
|
65
|
+
* it sits at the bottom of the screen; on a long one it follows the content (scroll down).
|
|
66
|
+
*/
|
|
67
|
+
export const WithFooter: Story = {
|
|
68
|
+
args: { footer: { appName: "Keston Admissions", version: "2.3.0", build: "a1b2c3d", since: 2024 } },
|
|
69
|
+
};
|
|
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
|
+
|
|
63
76
|
/** titleTo: the app's name in the header links to its dashboard (`to` for `linkComponent`, or an href). */
|
|
64
77
|
export const TitleLink: Story = {
|
|
65
78
|
args: { titleTo: "#dashboard" },
|
|
@@ -4,7 +4,9 @@ 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'
|
|
9
|
+
import Footer, { type FooterProps } from '../Footer/Footer.vue'
|
|
8
10
|
import Header, { type HeaderProps, type HeaderUser, type HeaderUserAction } from '../Header/Header.vue'
|
|
9
11
|
import Sidebar, { type SidebarItem, type SidebarProps } from '../Sidebar/Sidebar.vue'
|
|
10
12
|
import Slideover from '../Slideover/Slideover.vue'
|
|
@@ -28,6 +30,10 @@ import Slideover from '../Slideover/Slideover.vue'
|
|
|
28
30
|
* The account menu (top right) is the Header's: pass `user` and listen for
|
|
29
31
|
* account-settings, switch-account, log-out (and sign-in when signed out).
|
|
30
32
|
*
|
|
33
|
+
* The footer: pass `footer` (the Footer's props, e.g. `{ appName, version }`) to put the
|
|
34
|
+
* Keston Group footer at the bottom of the page, under the content. It sits at the bottom of the
|
|
35
|
+
* screen on short pages and after the content on long ones.
|
|
36
|
+
*
|
|
31
37
|
* Slots: default (the page), header-leading, header-middle, header-trailing,
|
|
32
38
|
* account, account-menu and organisation (passed to Header), sidebar-header and sidebar-footer (passed to Sidebar;
|
|
33
39
|
* sidebar-header is only shown on wide screens, as the Slideover has its own
|
|
@@ -50,6 +56,10 @@ export interface AppShellProps {
|
|
|
50
56
|
sections?: SidebarProps['sections']
|
|
51
57
|
/** Wide screens: show the header's menu button, which collapses the sidebar to icons. */
|
|
52
58
|
collapsible?: boolean
|
|
59
|
+
/** Show the Keston Group footer under the page. The Footer's props: `{ appName, version, … }`. Without it there is no footer. */
|
|
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
|
|
53
63
|
/** Component used for sidebar items with `to`, and the title link, e.g. RouterLink. */
|
|
54
64
|
linkComponent?: SidebarProps['linkComponent']
|
|
55
65
|
/** Other Header props, e.g. `{ ui: { title: '…' } }`. */
|
|
@@ -164,7 +174,10 @@ const sidebarId = `${uid}-sidebar`
|
|
|
164
174
|
<slot name="header-leading" />
|
|
165
175
|
</template>
|
|
166
176
|
<slot name="header-middle" />
|
|
167
|
-
<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>
|
|
168
181
|
<template v-if="$slots.account" #account><slot name="account" /></template>
|
|
169
182
|
<template v-if="$slots['account-menu']" #account-menu="slotProps"><slot name="account-menu" v-bind="slotProps" /></template>
|
|
170
183
|
<template v-if="$slots.organisation" #organisation="slotProps"><slot name="organisation" v-bind="slotProps" /></template>
|
|
@@ -220,9 +233,13 @@ const sidebarId = `${uid}-sidebar`
|
|
|
220
233
|
</template>
|
|
221
234
|
</Slideover>
|
|
222
235
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
236
|
+
<!-- The page, and under it the footer: the page grows, so the footer is at the bottom of a short page. -->
|
|
237
|
+
<div class="flex min-w-0 flex-1 flex-col">
|
|
238
|
+
<main :id="mainId" tabindex="-1" :class="cn('min-w-0 flex-1 outline-none', ui?.main)">
|
|
239
|
+
<slot />
|
|
240
|
+
</main>
|
|
241
|
+
<Footer v-if="footer" v-bind="{ linkComponent, ...footer }" />
|
|
242
|
+
</div>
|
|
226
243
|
</div>
|
|
227
244
|
</div>
|
|
228
245
|
</TooltipProvider>
|
|
@@ -59,6 +59,9 @@ const sizes: Record<NonNullable<AvatarProps['size']>, string> = {
|
|
|
59
59
|
xl: 'size-16 text-xl'
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
// Pixel size of each `sizes` entry, so the browser can reserve the space before the image loads.
|
|
63
|
+
const pixels: Record<NonNullable<AvatarProps['size']>, number> = { xs: 20, sm: 28, md: 36, lg: 48, xl: 64 }
|
|
64
|
+
|
|
62
65
|
const circle = 'relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-primary font-bold text-white select-none'
|
|
63
66
|
</script>
|
|
64
67
|
|
|
@@ -74,7 +77,7 @@ const circle = 'relative inline-flex shrink-0 items-center justify-center overfl
|
|
|
74
77
|
props.class
|
|
75
78
|
)"
|
|
76
79
|
>
|
|
77
|
-
<img v-if="showImage" :src="user.avatar" alt="" class="size-full object-cover" @error="failed = true">
|
|
80
|
+
<img v-if="showImage" :src="user.avatar" :width="pixels[size]" :height="pixels[size]" loading="lazy" decoding="async" alt="" class="size-full object-cover" @error="failed = true">
|
|
78
81
|
<span v-else aria-hidden="true">{{ initials }}</span>
|
|
79
82
|
</button>
|
|
80
83
|
|
|
@@ -85,7 +88,7 @@ const circle = 'relative inline-flex shrink-0 items-center justify-center overfl
|
|
|
85
88
|
</p>
|
|
86
89
|
<div class="flex items-center gap-3 px-4 py-3">
|
|
87
90
|
<span :class="cn(circle, sizes.lg)" aria-hidden="true">
|
|
88
|
-
<img v-if="showImage" :src="user.avatar" alt="" class="size-full object-cover">
|
|
91
|
+
<img v-if="showImage" :src="user.avatar" :width="pixels.lg" :height="pixels.lg" loading="lazy" decoding="async" alt="" class="size-full object-cover">
|
|
89
92
|
<template v-else>{{ initials }}</template>
|
|
90
93
|
</span>
|
|
91
94
|
<div class="flex min-w-0 flex-col">
|
|
@@ -112,7 +115,7 @@ const circle = 'relative inline-flex shrink-0 items-center justify-center overfl
|
|
|
112
115
|
:aria-hidden="decorative || undefined"
|
|
113
116
|
:class="cn(circle, sizes[size], props.class)"
|
|
114
117
|
>
|
|
115
|
-
<img v-if="showImage" :src="user.avatar" alt="" class="size-full object-cover" @error="failed = true">
|
|
118
|
+
<img v-if="showImage" :src="user.avatar" :width="pixels[size]" :height="pixels[size]" loading="lazy" decoding="async" alt="" class="size-full object-cover" @error="failed = true">
|
|
116
119
|
<span v-else aria-hidden="true">{{ initials }}</span>
|
|
117
120
|
</span>
|
|
118
121
|
</template>
|
|
@@ -78,7 +78,7 @@ export const Stats: Story = {
|
|
|
78
78
|
render: () => ({
|
|
79
79
|
components: { Card, Badge },
|
|
80
80
|
template: `
|
|
81
|
-
<div class="grid grid-cols-1 gap-
|
|
81
|
+
<div class="grid grid-cols-1 gap-6 sm:grid-cols-3">
|
|
82
82
|
<Card v-for="stat in [['Open applications', '48'], ['Interviews this week', '9'], ['Offers accepted', '31']]" :key="stat[0]" padding="sm" :ui="{ body: 'gap-1' }">
|
|
83
83
|
<span class="text-sm text-black/65">{{ stat[0] }}</span>
|
|
84
84
|
<span class="text-2xl font-bold">{{ stat[1] }}</span>
|
|
@@ -58,7 +58,7 @@ export const FollowingAForm: Story = {
|
|
|
58
58
|
template: `
|
|
59
59
|
<!-- Laid out by the space it has (container query), not the window. -->
|
|
60
60
|
<div class="@container max-w-160">
|
|
61
|
-
<div class="grid grid-cols-1 items-start gap-
|
|
61
|
+
<div class="grid grid-cols-1 items-start gap-6 @lg:grid-cols-[minmax(0,1fr)_14rem]">
|
|
62
62
|
<Card title="Documents">
|
|
63
63
|
<Checkbox v-model="form.address" label="Proof of address received" />
|
|
64
64
|
<Checkbox v-model="form.report" label="School report received" />
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
2
|
+
import Footer from './Footer.vue'
|
|
3
|
+
import { kestonGroupLinks } from './links'
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Components/Layout/Footer',
|
|
7
|
+
component: Footer,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
parameters: { layout: 'fullscreen' },
|
|
10
|
+
args: {
|
|
11
|
+
appName: 'Keston Admin',
|
|
12
|
+
version: '1.4.2',
|
|
13
|
+
build: 'a1b2c3d',
|
|
14
|
+
},
|
|
15
|
+
} satisfies Meta<typeof Footer>
|
|
16
|
+
|
|
17
|
+
export default meta
|
|
18
|
+
type Story = StoryObj<typeof meta>
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Playground: use the controls below. Help & support and the legal links on the left; the app's name, version and build,
|
|
22
|
+
* and the copyright, on the right. Narrow the preview to see it stack.
|
|
23
|
+
*/
|
|
24
|
+
export const Default: Story = {}
|
|
25
|
+
|
|
26
|
+
/** No build: only the version (e.g. a local run, where there is no CI build). */
|
|
27
|
+
export const NoBuild: Story = {
|
|
28
|
+
args: { build: undefined },
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `since` shows a range of years. */
|
|
32
|
+
export const SinceYear: Story = {
|
|
33
|
+
args: { since: 2024 },
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** `moreLinks`: more links after the standard ones, e.g. Contact us. */
|
|
37
|
+
export const WithMoreLinks: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
moreLinks: [{ label: 'Contact us', href: 'https://example.com/contact' }],
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** `kestonGroupLinks` as `moreLinks`, to point people at the other Keston apps. */
|
|
44
|
+
export const WithGroupLinks: Story = {
|
|
45
|
+
args: { moreLinks: kestonGroupLinks },
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** `links` replaces the standard links altogether, e.g. for an app with its own help and policies. Rarely needed: prefer `moreLinks`. */
|
|
49
|
+
export const CustomLinks: Story = {
|
|
50
|
+
args: {
|
|
51
|
+
links: [
|
|
52
|
+
{ label: 'Help & support', href: '#help', newTab: false },
|
|
53
|
+
{ label: 'Privacy Policy', href: '#privacy', newTab: false },
|
|
54
|
+
{ label: 'Terms of use', href: '#terms', newTab: false },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** No app name, version or build (e.g. a public page): just the links and the copyright. */
|
|
60
|
+
export const NoVersion: Story = {
|
|
61
|
+
args: { appName: undefined, version: undefined, build: undefined },
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The slot `end`, after the copyright: here a stand-in for a language switcher. */
|
|
65
|
+
export const WithEndSlot: Story = {
|
|
66
|
+
render: (args) => ({
|
|
67
|
+
components: { Footer },
|
|
68
|
+
setup: () => ({ args }),
|
|
69
|
+
template: `
|
|
70
|
+
<Footer v-bind="args">
|
|
71
|
+
<template #end><button type="button" class="underline underline-offset-2">English</button></template>
|
|
72
|
+
</Footer>`,
|
|
73
|
+
}),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Phone-sized: the links, then the version and copyright, stacked. */
|
|
77
|
+
export const Mobile: Story = {
|
|
78
|
+
globals: { viewport: { value: 'mobile1', isRotated: false } },
|
|
79
|
+
args: {
|
|
80
|
+
moreLinks: [{ label: 'Contact us', href: 'https://example.com/contact' }],
|
|
81
|
+
},
|
|
82
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useI18n } from 'vue-i18n'
|
|
3
|
+
import { computed, type Component, type HTMLAttributes } from 'vue'
|
|
4
|
+
import { cn } from '../../lib/cn'
|
|
5
|
+
import Link from '../Link/Link.vue'
|
|
6
|
+
import { bareVersion, displayVersion, yearRange } from './footer'
|
|
7
|
+
import { kestonFooterLinks } from './links'
|
|
8
|
+
|
|
9
|
+
export interface FooterLink {
|
|
10
|
+
label: string
|
|
11
|
+
/** A plain link. */
|
|
12
|
+
href?: string
|
|
13
|
+
/** Link through `linkComponent` (e.g. RouterLink), which receives `to`. */
|
|
14
|
+
to?: unknown
|
|
15
|
+
/** Open in a new tab. Default true for `href` links (they leave the app), false for `to`. */
|
|
16
|
+
newTab?: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The bottom of an app's page: on the left Help & support and the legal links (Privacy Policy, Terms & Conditions), and
|
|
21
|
+
* on the right the app's name, version and build (so a bug report can say exactly which build) with
|
|
22
|
+
* the copyright. The same in every Keston app; pass the app's `version` and `build`.
|
|
23
|
+
*
|
|
24
|
+
* Without `links` it shows the Keston Group's footer links (`kestonFooterLinks`). Add to them rather than
|
|
25
|
+
* replacing them with `moreLinks` (e.g. Contact us, or `kestonGroupLinks` to point at the other Keston
|
|
26
|
+
* apps), which follow, after a divider. The version comes from the app's package.json and the build
|
|
27
|
+
* from its CI: in Vite, put them in with `define` (see the spec).
|
|
28
|
+
*
|
|
29
|
+
* Slots: nav (instead of the whole link list), end (after the copyright, e.g. a language switcher).
|
|
30
|
+
*/
|
|
31
|
+
export interface FooterProps {
|
|
32
|
+
/** The links on the left. Default: `kestonFooterLinks` (Help & support, Privacy Policy, Terms & Conditions). */
|
|
33
|
+
links?: FooterLink[]
|
|
34
|
+
/** More links after a divider, e.g. Contact us, or `kestonGroupLinks` to point at the other Keston apps. */
|
|
35
|
+
moreLinks?: FooterLink[]
|
|
36
|
+
/** Component used for links with `to`, e.g. RouterLink. */
|
|
37
|
+
linkComponent?: string | Component
|
|
38
|
+
/** The app's name, shown before its version. */
|
|
39
|
+
appName?: string
|
|
40
|
+
/** The app's version, e.g. "1.4.2" or "v1.4.2". */
|
|
41
|
+
version?: string
|
|
42
|
+
/** The build, e.g. a commit "a1b2c3d" or a CI run number, shown after the version so a bug report can name the exact build. */
|
|
43
|
+
build?: string
|
|
44
|
+
/** Who owns the copyright. */
|
|
45
|
+
holder?: string
|
|
46
|
+
/** The current year. Default: this year, from the device's clock. */
|
|
47
|
+
year?: number
|
|
48
|
+
/** The first year, to show a range such as 2024–2026. */
|
|
49
|
+
since?: number
|
|
50
|
+
class?: HTMLAttributes['class']
|
|
51
|
+
/** Extra classes for the parts. */
|
|
52
|
+
ui?: {
|
|
53
|
+
links?: HTMLAttributes['class']
|
|
54
|
+
meta?: HTMLAttributes['class']
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const { t } = useI18n()
|
|
59
|
+
const props = withDefaults(defineProps<FooterProps>(), {
|
|
60
|
+
links: () => kestonFooterLinks,
|
|
61
|
+
moreLinks: () => [],
|
|
62
|
+
linkComponent: undefined,
|
|
63
|
+
holder: 'The Keston Group'
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
defineSlots<{
|
|
67
|
+
nav?(): unknown
|
|
68
|
+
end?(): unknown
|
|
69
|
+
}>()
|
|
70
|
+
|
|
71
|
+
const years = computed(() => yearRange(props.year ?? new Date().getFullYear(), props.since))
|
|
72
|
+
const shownVersion = computed(() => displayVersion(props.version))
|
|
73
|
+
const versionLabel = computed(() => (props.version ? t('ui.footer.version', { version: bareVersion(props.version) }) : ''))
|
|
74
|
+
const buildLabel = computed(() => (props.build ? t('ui.footer.build', { build: props.build }) : ''))
|
|
75
|
+
|
|
76
|
+
// Links that leave the app open in a new tab, so people don't lose their place.
|
|
77
|
+
function linkAttrs(link: FooterLink) {
|
|
78
|
+
return link.to !== undefined
|
|
79
|
+
? { as: props.linkComponent as never, to: link.to, newTab: link.newTab ?? false }
|
|
80
|
+
: { href: link.href, newTab: link.newTab ?? true }
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<template>
|
|
85
|
+
<footer
|
|
86
|
+
:class="cn(
|
|
87
|
+
'flex shrink-0 flex-col gap-3 border-t border-black/15 bg-white px-4 py-4 text-sm text-black/65 sm:flex-row sm:items-center sm:justify-between sm:px-6',
|
|
88
|
+
props.class
|
|
89
|
+
)"
|
|
90
|
+
>
|
|
91
|
+
<nav :aria-label="t('ui.footer.label')" :class="cn('min-w-0', ui?.links)">
|
|
92
|
+
<slot name="nav">
|
|
93
|
+
<ul class="flex flex-wrap items-center gap-x-4 gap-y-1">
|
|
94
|
+
<li v-for="link in links" :key="link.label">
|
|
95
|
+
<Link v-bind="linkAttrs(link)" :icon="false">{{ link.label }}</Link>
|
|
96
|
+
</li>
|
|
97
|
+
<li v-if="moreLinks.length" class="hidden h-4 w-px bg-black/15 sm:block" aria-hidden="true"></li>
|
|
98
|
+
<li v-for="link in moreLinks" :key="link.label">
|
|
99
|
+
<Link v-bind="linkAttrs(link)" :icon="false">{{ link.label }}</Link>
|
|
100
|
+
</li>
|
|
101
|
+
</ul>
|
|
102
|
+
</slot>
|
|
103
|
+
</nav>
|
|
104
|
+
|
|
105
|
+
<div :class="cn('flex flex-wrap items-center gap-x-3 gap-y-1 sm:justify-end', ui?.meta)">
|
|
106
|
+
<p v-if="appName || version || build" class="flex flex-wrap items-baseline gap-x-1.5">
|
|
107
|
+
<span v-if="appName" class="font-bold text-black/80">{{ appName }}</span>
|
|
108
|
+
<!-- Shows as "v1.4.2" but reads as "Version 1.4.2". -->
|
|
109
|
+
<span v-if="version">
|
|
110
|
+
<span class="sr-only">{{ versionLabel }}</span>
|
|
111
|
+
<span aria-hidden="true">{{ shownVersion }}</span>
|
|
112
|
+
</span>
|
|
113
|
+
<!-- Shows as "a1b2c3d" in monospace but reads as "Build a1b2c3d". -->
|
|
114
|
+
<span v-if="build" :title="buildLabel">
|
|
115
|
+
<span class="sr-only">{{ buildLabel }}</span>
|
|
116
|
+
<span class="font-mono text-xs text-black/55" aria-hidden="true">{{ build }}</span>
|
|
117
|
+
</span>
|
|
118
|
+
</p>
|
|
119
|
+
<p>{{ t('ui.footer.copyright', { years, holder }) }}</p>
|
|
120
|
+
<slot name="end" />
|
|
121
|
+
</div>
|
|
122
|
+
</footer>
|
|
123
|
+
</template>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { bareVersion, displayVersion, yearRange } from './footer'
|
|
3
|
+
import { kestonFooterLinks, kestonGroupLinks } from './links'
|
|
4
|
+
|
|
5
|
+
describe('yearRange', () => {
|
|
6
|
+
it('shows a range from an earlier year, and a single year otherwise', () => {
|
|
7
|
+
expect(yearRange(2026, 2024)).toBe('2024–2026')
|
|
8
|
+
expect(yearRange(2026, 2026)).toBe('2026')
|
|
9
|
+
expect(yearRange(2026)).toBe('2026')
|
|
10
|
+
expect(yearRange(2026, 2030)).toBe('2026')
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
describe('version', () => {
|
|
15
|
+
it('shows a v in front, once', () => {
|
|
16
|
+
expect(displayVersion('1.4.2')).toBe('v1.4.2')
|
|
17
|
+
expect(displayVersion('v1.4.2')).toBe('v1.4.2')
|
|
18
|
+
expect(displayVersion('V1.4.2')).toBe('v1.4.2')
|
|
19
|
+
expect(displayVersion(undefined)).toBe('')
|
|
20
|
+
expect(displayVersion('')).toBe('')
|
|
21
|
+
})
|
|
22
|
+
it('gives the plain number for screen readers', () => {
|
|
23
|
+
expect(bareVersion('v1.4.2')).toBe('1.4.2')
|
|
24
|
+
expect(bareVersion('1.4.2')).toBe('1.4.2')
|
|
25
|
+
expect(bareVersion(undefined)).toBe('')
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
describe('kestonFooterLinks', () => {
|
|
30
|
+
it('are Help & support, Privacy Policy and Terms & Conditions, on secure thekestongroup.com addresses', () => {
|
|
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:\/\/thekestongroup\.com\/(help|privacy|terms)$/)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
describe('kestonGroupLinks', () => {
|
|
37
|
+
it('are all secure addresses on keston.co', () => {
|
|
38
|
+
expect(kestonGroupLinks.length).toBeGreaterThan(0)
|
|
39
|
+
for (const link of kestonGroupLinks) expect(link.href).toMatch(/^https:\/\/[a-z]+\.keston\.co\/?$/)
|
|
40
|
+
})
|
|
41
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** "2024–2026" when `since` is before `year`, otherwise just the year. */
|
|
2
|
+
export function yearRange(year: number, since?: number): string {
|
|
3
|
+
return since && since < year ? `${since}–${year}` : String(year)
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** "1.4.2" and "v1.4.2" both show as "v1.4.2". Empty for no version. */
|
|
7
|
+
export function displayVersion(version?: string): string {
|
|
8
|
+
if (!version) return ''
|
|
9
|
+
return /^v/i.test(version) ? `v${version.slice(1)}` : `v${version}`
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The version without a leading "v", for the screen reader's "Version 1.4.2". */
|
|
13
|
+
export function bareVersion(version?: string): string {
|
|
14
|
+
return version ? version.replace(/^v/i, '') : ''
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FooterLink } from './Footer.vue'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The links every Keston app shows on the left of its footer: help first, then the legal pages.
|
|
5
|
+
* Apps can pass their own `links`, or add to these with `moreLinks`.
|
|
6
|
+
*/
|
|
7
|
+
export const kestonFooterLinks: FooterLink[] = [
|
|
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
|
+
]
|
|
12
|
+
|
|
13
|
+
/** Links to the rest of the Keston Group. Not shown by default: pass them as `moreLinks` where an app should offer them. */
|
|
14
|
+
export const kestonGroupLinks: FooterLink[] = [
|
|
15
|
+
{ label: 'Keston ID', href: 'https://id.keston.co' },
|
|
16
|
+
{ label: 'Admin', href: 'https://admin.keston.co' },
|
|
17
|
+
{ label: 'Work', href: 'https://work.keston.co' },
|
|
18
|
+
{ label: 'Design system', href: 'https://ui.keston.co' }
|
|
19
|
+
]
|
|
@@ -42,7 +42,7 @@ export const Grid: Story = {
|
|
|
42
42
|
components: { StatTile },
|
|
43
43
|
setup: () => ({ Users, FileText, CalendarCheck, UserX }),
|
|
44
44
|
template: `
|
|
45
|
-
<div class="grid grid-cols-1 gap-
|
|
45
|
+
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-4">
|
|
46
46
|
<StatTile label="Students on roll" value="1,204" :icon="Users" change="+38" change-label="since September" trend="up" />
|
|
47
47
|
<StatTile label="Open applications" value="48" :icon="FileText" change="+12%" change-label="on last year" trend="up" />
|
|
48
48
|
<StatTile label="Attendance" value="95.8%" :icon="CalendarCheck" change="0.0 pts" change-label="on last week" trend="flat" href="#attendance" />
|
|
@@ -100,7 +100,7 @@ const pageTemplate = `
|
|
|
100
100
|
</template>
|
|
101
101
|
</PageHeader>
|
|
102
102
|
|
|
103
|
-
<div class="grid grid-cols-1 gap-
|
|
103
|
+
<div class="grid grid-cols-1 gap-6 sm:grid-cols-3">
|
|
104
104
|
<StatTile v-for="stat in stats" :key="stat.label" v-bind="stat" />
|
|
105
105
|
</div>
|
|
106
106
|
|
|
@@ -196,7 +196,7 @@ export const StudentRecord: Story = {
|
|
|
196
196
|
<div class="grid grid-cols-1 items-start gap-6 @4xl:grid-cols-[minmax(0,1fr)_20rem]">
|
|
197
197
|
<div class="flex flex-col gap-6">
|
|
198
198
|
<!-- This term at a glance -->
|
|
199
|
-
<div class="grid grid-cols-1 gap-
|
|
199
|
+
<div class="grid grid-cols-1 gap-6 @lg:grid-cols-3">
|
|
200
200
|
<StatTile label="Attendance" value="96.4%" change="+1.2%" change-label="on last term" trend="up">
|
|
201
201
|
<template #footer>
|
|
202
202
|
<span class="flex items-center gap-1 text-xs text-black/65">
|
|
@@ -414,7 +414,7 @@ export const ApplicationReview: Story = {
|
|
|
414
414
|
<div class="flex flex-col gap-6 p-4 sm:p-6">
|
|
415
415
|
<PageHeader title="Applications" description="Applications for entry in 2027. Newest first." />
|
|
416
416
|
|
|
417
|
-
<div class="grid grid-cols-1 gap-
|
|
417
|
+
<div class="grid grid-cols-1 gap-6 sm:grid-cols-3">
|
|
418
418
|
<StatTile v-for="stat in stats" :key="stat.label" v-bind="stat" />
|
|
419
419
|
</div>
|
|
420
420
|
|
package/src/i18n/en.ts
CHANGED
|
@@ -42,6 +42,13 @@ export const en = {
|
|
|
42
42
|
},
|
|
43
43
|
changeIndicator: { changed: 'Changed from {from} to {to}' },
|
|
44
44
|
chip: { remove: 'Remove' },
|
|
45
|
+
appLauncher: { label: 'Keston apps' },
|
|
46
|
+
footer: {
|
|
47
|
+
label: 'Help and legal',
|
|
48
|
+
version: 'Version {version}',
|
|
49
|
+
build: 'Build {build}',
|
|
50
|
+
copyright: '© {years} {holder}'
|
|
51
|
+
},
|
|
45
52
|
formField: { about: 'About {label}' },
|
|
46
53
|
header: {
|
|
47
54
|
menu: 'Menu',
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,12 @@ 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'
|
|
20
|
+
export { default as Footer } from './components/Footer/Footer.vue'
|
|
21
|
+
export type { FooterLink, FooterProps } from './components/Footer/Footer.vue'
|
|
22
|
+
export { kestonFooterLinks, kestonGroupLinks } from './components/Footer/links'
|
|
17
23
|
|
|
18
24
|
// Element
|
|
19
25
|
export { default as Avatar } from './components/Avatar/Avatar.vue'
|