@thekestongroup/ui 0.11.1 → 0.12.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/AppShell/AppShell.vue.d.ts +7 -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/Header/Header.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/components/Slideover/Slideover.vue.d.ts +1 -1
- package/dist/i18n/en.d.ts +6 -0
- package/dist/index.d.ts +3 -0
- package/dist/keston-ui.js +687 -528
- package/package.json +1 -1
- package/src/components/AppShell/AppShell.stories.ts +8 -0
- package/src/components/AppShell/AppShell.vue +14 -3
- 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 +6 -0
- package/src/index.ts +3 -0
- package/src/lib/parseDate.ts +1 -1
package/package.json
CHANGED
|
@@ -60,6 +60,14 @@ 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
|
+
|
|
63
71
|
/** titleTo: the app's name in the header links to its dashboard (`to` for `linkComponent`, or an href). */
|
|
64
72
|
export const TitleLink: Story = {
|
|
65
73
|
args: { titleTo: "#dashboard" },
|
|
@@ -5,6 +5,7 @@ import { Menu } from '@lucide/vue'
|
|
|
5
5
|
import { TooltipProvider } from 'reka-ui'
|
|
6
6
|
import { cn } from '../../lib/cn'
|
|
7
7
|
import Button from '../Button/Button.vue'
|
|
8
|
+
import Footer, { type FooterProps } from '../Footer/Footer.vue'
|
|
8
9
|
import Header, { type HeaderProps, type HeaderUser, type HeaderUserAction } from '../Header/Header.vue'
|
|
9
10
|
import Sidebar, { type SidebarItem, type SidebarProps } from '../Sidebar/Sidebar.vue'
|
|
10
11
|
import Slideover from '../Slideover/Slideover.vue'
|
|
@@ -28,6 +29,10 @@ import Slideover from '../Slideover/Slideover.vue'
|
|
|
28
29
|
* The account menu (top right) is the Header's: pass `user` and listen for
|
|
29
30
|
* account-settings, switch-account, log-out (and sign-in when signed out).
|
|
30
31
|
*
|
|
32
|
+
* The footer: pass `footer` (the Footer's props, e.g. `{ appName, version }`) to put the
|
|
33
|
+
* Keston Group footer at the bottom of the page, under the content. It sits at the bottom of the
|
|
34
|
+
* screen on short pages and after the content on long ones.
|
|
35
|
+
*
|
|
31
36
|
* Slots: default (the page), header-leading, header-middle, header-trailing,
|
|
32
37
|
* account, account-menu and organisation (passed to Header), sidebar-header and sidebar-footer (passed to Sidebar;
|
|
33
38
|
* sidebar-header is only shown on wide screens, as the Slideover has its own
|
|
@@ -50,6 +55,8 @@ export interface AppShellProps {
|
|
|
50
55
|
sections?: SidebarProps['sections']
|
|
51
56
|
/** Wide screens: show the header's menu button, which collapses the sidebar to icons. */
|
|
52
57
|
collapsible?: boolean
|
|
58
|
+
/** Show the Keston Group footer under the page. The Footer's props: `{ appName, version, … }`. Without it there is no footer. */
|
|
59
|
+
footer?: FooterProps
|
|
53
60
|
/** Component used for sidebar items with `to`, and the title link, e.g. RouterLink. */
|
|
54
61
|
linkComponent?: SidebarProps['linkComponent']
|
|
55
62
|
/** Other Header props, e.g. `{ ui: { title: '…' } }`. */
|
|
@@ -220,9 +227,13 @@ const sidebarId = `${uid}-sidebar`
|
|
|
220
227
|
</template>
|
|
221
228
|
</Slideover>
|
|
222
229
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
230
|
+
<!-- The page, and under it the footer: the page grows, so the footer is at the bottom of a short page. -->
|
|
231
|
+
<div class="flex min-w-0 flex-1 flex-col">
|
|
232
|
+
<main :id="mainId" tabindex="-1" :class="cn('min-w-0 flex-1 outline-none', ui?.main)">
|
|
233
|
+
<slot />
|
|
234
|
+
</main>
|
|
235
|
+
<Footer v-if="footer" v-bind="{ linkComponent, ...footer }" />
|
|
236
|
+
</div>
|
|
226
237
|
</div>
|
|
227
238
|
</div>
|
|
228
239
|
</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 keston.co 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:\/\/keston\.co\//)
|
|
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://keston.co/help' },
|
|
9
|
+
{ label: 'Privacy Policy', href: 'https://keston.co/privacy' },
|
|
10
|
+
{ label: 'Terms & Conditions', href: 'https://keston.co/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,12 @@ export const en = {
|
|
|
42
42
|
},
|
|
43
43
|
changeIndicator: { changed: 'Changed from {from} to {to}' },
|
|
44
44
|
chip: { remove: 'Remove' },
|
|
45
|
+
footer: {
|
|
46
|
+
label: 'Help and legal',
|
|
47
|
+
version: 'Version {version}',
|
|
48
|
+
build: 'Build {build}',
|
|
49
|
+
copyright: '© {years} {holder}'
|
|
50
|
+
},
|
|
45
51
|
formField: { about: 'About {label}' },
|
|
46
52
|
header: {
|
|
47
53
|
menu: 'Menu',
|
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 Footer } from './components/Footer/Footer.vue'
|
|
18
|
+
export type { FooterLink, FooterProps } from './components/Footer/Footer.vue'
|
|
19
|
+
export { kestonFooterLinks, kestonGroupLinks } from './components/Footer/links'
|
|
17
20
|
|
|
18
21
|
// Element
|
|
19
22
|
export { default as Avatar } from './components/Avatar/Avatar.vue'
|
package/src/lib/parseDate.ts
CHANGED
|
@@ -183,7 +183,7 @@ type Start =
|
|
|
183
183
|
function pick(candidates: (CalendarDate | undefined)[], today: CalendarDate, prefer: DatePreference) {
|
|
184
184
|
const dates = candidates.filter((d): d is CalendarDate => !!d).sort((a, b) => a.compare(b))
|
|
185
185
|
if (prefer === 'future') return dates.find((d) => d.compare(today) >= 0)
|
|
186
|
-
if (prefer === 'past') return
|
|
186
|
+
if (prefer === 'past') return dates.findLast((d) => d.compare(today) <= 0)
|
|
187
187
|
// nearest; ties go to the future
|
|
188
188
|
return dates.reduce<CalendarDate | undefined>((best, d) => {
|
|
189
189
|
if (!best) return d
|