@thekestongroup/ui 0.14.0 → 0.16.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/ActionList/ActionList.vue.d.ts +63 -0
- package/dist/components/Alert/Alert.vue.d.ts +55 -0
- package/dist/components/AvatarGroup/AvatarGroup.vue.d.ts +1 -1
- package/dist/components/BarChart/BarChart.vue.d.ts +37 -0
- package/dist/components/BarChart/ChartData.vue.d.ts +20 -0
- package/dist/components/Button/Button.vue.d.ts +1 -1
- package/dist/components/Collapsible/Collapsible.vue.d.ts +48 -0
- package/dist/components/FileUpload/FileUpload.vue.d.ts +55 -0
- package/dist/components/Footer/Footer.vue.d.ts +11 -1
- package/dist/components/Header/Header.vue.d.ts +1 -1
- package/dist/components/LineChart/LineChart.vue.d.ts +37 -0
- package/dist/components/Notification/Notification.vue.d.ts +2 -2
- package/dist/components/Popover/popover.d.ts +3 -2
- package/dist/components/Progress/Progress.vue.d.ts +14 -1
- package/dist/components/Slideover/Slideover.vue.d.ts +7 -5
- package/dist/components/Spinner/Spinner.vue.d.ts +2 -2
- package/dist/components/ThemeSwitcher/ThemeSwitcher.vue.d.ts +18 -0
- package/dist/i18n/en.d.ts +27 -0
- package/dist/index.d.ts +17 -0
- package/dist/keston-ui.js +4369 -3509
- package/dist/lib/chart.d.ts +32 -0
- package/dist/lib/theme.d.ts +23 -0
- package/package.json +8 -3
- package/src/components/ActionList/ActionList.stories.ts +59 -0
- package/src/components/ActionList/ActionList.vue +116 -0
- package/src/components/Alert/Alert.stories.ts +65 -0
- package/src/components/Alert/Alert.vue +110 -0
- package/src/components/AppLauncher/AppLauncher.vue +3 -3
- package/src/components/AppShell/AppShell.stories.ts +2 -2
- package/src/components/AppShell/AppShell.vue +2 -2
- package/src/components/Avatar/Avatar.vue +3 -3
- package/src/components/AvatarGroup/AvatarGroup.vue +4 -4
- package/src/components/Badge/Badge.vue +2 -2
- package/src/components/BarChart/BarChart.stories.ts +62 -0
- package/src/components/BarChart/BarChart.vue +153 -0
- package/src/components/BarChart/ChartData.vue +64 -0
- package/src/components/Breadcrumb/Breadcrumb.vue +5 -5
- package/src/components/Button/Button.stories.ts +1 -1
- package/src/components/Button/Button.vue +12 -9
- package/src/components/Calendar/Calendar.stories.ts +2 -2
- package/src/components/Calendar/Calendar.vue +11 -10
- package/src/components/Card/Card.stories.ts +5 -5
- package/src/components/Card/Card.vue +3 -3
- package/src/components/CardSelect/CardSelect.vue +10 -7
- package/src/components/ChangeIndicator/ChangeIndicator.vue +2 -2
- package/src/components/Checkbox/Checkbox.vue +5 -5
- package/src/components/CheckboxGroup/CheckboxGroup.stories.ts +1 -1
- package/src/components/CheckboxGroup/CheckboxGroup.vue +2 -2
- package/src/components/Checklist/Checklist.vue +3 -3
- package/src/components/Chip/Chip.stories.ts +1 -1
- package/src/components/Chip/Chip.vue +2 -2
- package/src/components/Collapsible/Collapsible.stories.ts +32 -0
- package/src/components/Collapsible/Collapsible.vue +68 -0
- package/src/components/Divider/Divider.vue +4 -4
- package/src/components/EmptyState/EmptyState.vue +3 -3
- package/src/components/FileUpload/FileUpload.stories.ts +38 -0
- package/src/components/FileUpload/FileUpload.vue +150 -0
- package/src/components/Footer/Footer.stories.ts +10 -2
- package/src/components/Footer/Footer.vue +26 -8
- package/src/components/FormField/FieldMessage.vue +3 -3
- package/src/components/FormField/FormField.stories.ts +1 -1
- package/src/components/FormField/FormField.vue +8 -3
- package/src/components/Header/Header.stories.ts +28 -8
- package/src/components/Header/Header.vue +6 -6
- package/src/components/InfoTip/InfoTip.stories.ts +1 -1
- package/src/components/InfoTip/InfoTip.vue +1 -1
- package/src/components/Input/Input.vue +1 -1
- package/src/components/InputCode/InputCode.stories.ts +1 -1
- package/src/components/InputCode/InputCode.vue +4 -4
- package/src/components/InputDate/InputDate.stories.ts +1 -1
- package/src/components/InputDate/InputDate.vue +5 -5
- package/src/components/InputNumber/InputNumber.stories.ts +1 -1
- package/src/components/InputNumber/InputNumber.vue +6 -6
- package/src/components/InputPassword/InputPassword.vue +4 -4
- package/src/components/InputRichText/InputRichText.stories.ts +1 -1
- package/src/components/InputRichText/InputRichText.vue +3 -3
- package/src/components/InputTextArea/InputTextArea.vue +1 -1
- package/src/components/LineChart/LineChart.stories.ts +47 -0
- package/src/components/LineChart/LineChart.vue +173 -0
- package/src/components/Link/Link.stories.ts +4 -4
- package/src/components/Link/Link.vue +1 -1
- package/src/components/Menu/Menu.vue +6 -5
- package/src/components/Notification/Notification.stories.ts +3 -3
- package/src/components/Notification/Notification.vue +9 -9
- package/src/components/Notification/NotificationPane.vue +3 -3
- package/src/components/Notification/Toaster.vue +1 -1
- package/src/components/PageHeader/PageHeader.vue +2 -2
- package/src/components/Popover/Popover.stories.ts +2 -2
- package/src/components/Popover/popover.ts +4 -3
- package/src/components/Progress/Progress.stories.ts +18 -0
- package/src/components/Progress/Progress.vue +58 -1
- package/src/components/RadioGroup/RadioGroup.vue +7 -7
- package/src/components/RelativeTime/RelativeTime.stories.ts +1 -1
- package/src/components/Select/Select.stories.ts +1 -1
- package/src/components/Select/Select.vue +26 -20
- package/src/components/SettingsRow/SettingsRow.vue +1 -1
- package/src/components/Sidebar/Sidebar.stories.ts +2 -2
- package/src/components/Sidebar/Sidebar.vue +9 -9
- package/src/components/Slideover/Slideover.stories.ts +5 -5
- package/src/components/Slideover/Slideover.vue +111 -35
- package/src/components/Spinner/Spinner.stories.ts +7 -7
- package/src/components/Spinner/Spinner.vue +1 -1
- package/src/components/StatTile/StatTile.stories.ts +2 -2
- package/src/components/StatTile/StatTile.vue +6 -6
- package/src/components/Steps/Steps.vue +2 -2
- package/src/components/SummaryList/SummaryList.vue +8 -8
- package/src/components/Switch/Switch.vue +3 -3
- package/src/components/Table/Table.vue +12 -12
- package/src/components/Tabs/Tabs.vue +4 -4
- package/src/components/ThemeSwitcher/ThemeSwitcher.stories.ts +22 -0
- package/src/components/ThemeSwitcher/ThemeSwitcher.vue +48 -0
- package/src/components/Tooltip/Tooltip.stories.ts +1 -1
- package/src/components/Tooltip/Tooltip.vue +1 -1
- package/src/components/UnsavedChangesBar/UnsavedChangesBar.stories.ts +1 -1
- package/src/components/UnsavedChangesBar/UnsavedChangesBar.vue +1 -1
- package/src/examples/AppPages.stories.ts +3 -3
- package/src/examples/FormLayout.stories.ts +3 -3
- package/src/examples/KestonIdPages.stories.ts +18 -18
- package/src/examples/SchoolPages.stories.ts +5 -5
- package/src/i18n/en.ts +16 -4
- package/src/index.ts +17 -0
- package/src/lib/chart.ts +47 -0
- package/src/lib/theme.ts +75 -0
- package/src/styles/theme.css +117 -5
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
2
|
+
import Collapsible from './Collapsible.vue'
|
|
3
|
+
import Input from '../Input/Input.vue'
|
|
4
|
+
import Switch from '../Switch/Switch.vue'
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/Element/Collapsible',
|
|
8
|
+
component: Collapsible,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
args: { title: 'Advanced options', defaultOpen: false, divided: false, disabled: false },
|
|
11
|
+
render: (args) => ({
|
|
12
|
+
components: { Collapsible, Input, Switch },
|
|
13
|
+
setup: () => ({ args }),
|
|
14
|
+
template: `
|
|
15
|
+
<div class="max-w-xl">
|
|
16
|
+
<Collapsible v-bind="args">
|
|
17
|
+
<Input label="Issuer name" helper="Shown in people's authenticator apps." />
|
|
18
|
+
<Switch label="Include backup codes" />
|
|
19
|
+
</Collapsible>
|
|
20
|
+
</div>`,
|
|
21
|
+
}),
|
|
22
|
+
} satisfies Meta<typeof Collapsible>
|
|
23
|
+
|
|
24
|
+
export default meta
|
|
25
|
+
type Story = StoryObj<typeof meta>
|
|
26
|
+
|
|
27
|
+
export const Default: Story = {}
|
|
28
|
+
|
|
29
|
+
export const Open: Story = { args: { defaultOpen: true } }
|
|
30
|
+
|
|
31
|
+
/** At the end of a form, with a line above it. */
|
|
32
|
+
export const Divided: Story = { args: { divided: true, title: 'Customise rules' } }
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue'
|
|
3
|
+
import { CollapsibleContent, CollapsibleRoot, CollapsibleTrigger } from 'reka-ui'
|
|
4
|
+
import { ChevronRight } from '@lucide/vue'
|
|
5
|
+
import { cn } from '../../lib/cn'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A section that opens and closes: "Advanced options", "Customise rules",
|
|
9
|
+
* "How does this work?". The title row is a button; the content shows under
|
|
10
|
+
* it. Closed by default; use `defaultOpen` or `v-model:open`.
|
|
11
|
+
*
|
|
12
|
+
* Built on Reka UI's Collapsible, so the button says whether it's open
|
|
13
|
+
* (aria-expanded) and points at what it opens (aria-controls).
|
|
14
|
+
*
|
|
15
|
+
* Slots: default (the content), title (replaces the title text).
|
|
16
|
+
*/
|
|
17
|
+
export interface CollapsibleProps {
|
|
18
|
+
/** The title row's text, e.g. "Advanced options". */
|
|
19
|
+
title?: string
|
|
20
|
+
/** Start open (when not using v-model:open). */
|
|
21
|
+
defaultOpen?: boolean
|
|
22
|
+
/** A line between it and what's above, e.g. at the end of a Card's fields. */
|
|
23
|
+
divided?: boolean
|
|
24
|
+
disabled?: boolean
|
|
25
|
+
class?: HTMLAttributes['class']
|
|
26
|
+
/** Extra classes for the parts. */
|
|
27
|
+
ui?: {
|
|
28
|
+
trigger?: HTMLAttributes['class']
|
|
29
|
+
content?: HTMLAttributes['class']
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const props = defineProps<CollapsibleProps>()
|
|
34
|
+
const open = defineModel<boolean | undefined>('open', { default: undefined })
|
|
35
|
+
|
|
36
|
+
defineSlots<{
|
|
37
|
+
default?(): unknown
|
|
38
|
+
title?(): unknown
|
|
39
|
+
}>()
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<CollapsibleRoot
|
|
44
|
+
v-model:open="open"
|
|
45
|
+
:default-open="defaultOpen"
|
|
46
|
+
:disabled="disabled"
|
|
47
|
+
:class="cn('flex flex-col', divided && 'border-t border-ink/10', props.class)"
|
|
48
|
+
>
|
|
49
|
+
<!-- The row: a chevron that turns to point down when open, then the title. -->
|
|
50
|
+
<CollapsibleTrigger
|
|
51
|
+
:class="cn(
|
|
52
|
+
'group/collapsible -mx-2 flex items-center gap-2 rounded px-2 py-3 text-left text-sm font-bold text-ink transition-colors',
|
|
53
|
+
'cursor-pointer not-disabled:hover:bg-hover not-disabled:active:bg-pressed disabled:cursor-not-allowed disabled:opacity-40',
|
|
54
|
+
'outline-2 -outline-offset-2 outline-transparent focus-visible:outline-focus',
|
|
55
|
+
ui?.trigger
|
|
56
|
+
)"
|
|
57
|
+
>
|
|
58
|
+
<ChevronRight
|
|
59
|
+
class="size-4 shrink-0 text-ink/65 transition-transform duration-150 group-data-[state=open]/collapsible:rotate-90 motion-reduce:transition-none"
|
|
60
|
+
aria-hidden="true"
|
|
61
|
+
/>
|
|
62
|
+
<slot name="title">{{ title }}</slot>
|
|
63
|
+
</CollapsibleTrigger>
|
|
64
|
+
<CollapsibleContent :class="cn('flex flex-col gap-4 pb-3', ui?.content)">
|
|
65
|
+
<slot />
|
|
66
|
+
</CollapsibleContent>
|
|
67
|
+
</CollapsibleRoot>
|
|
68
|
+
</template>
|
|
@@ -38,11 +38,11 @@ defineSlots<{ default?(): unknown }>()
|
|
|
38
38
|
v-if="orientation === 'horizontal' && (label || $slots.default)"
|
|
39
39
|
:role="decorative ? 'presentation' : 'separator'"
|
|
40
40
|
:aria-label="decorative ? undefined : label"
|
|
41
|
-
:class="cn('flex w-full items-center gap-3 text-xs text-
|
|
41
|
+
:class="cn('flex w-full items-center gap-3 text-xs text-ink/65', props.class)"
|
|
42
42
|
>
|
|
43
|
-
<span aria-hidden="true" class="h-px flex-1 bg-
|
|
43
|
+
<span aria-hidden="true" class="h-px flex-1 bg-ink/10" />
|
|
44
44
|
<span class="shrink-0"><slot>{{ label }}</slot></span>
|
|
45
|
-
<span aria-hidden="true" class="h-px flex-1 bg-
|
|
45
|
+
<span aria-hidden="true" class="h-px flex-1 bg-ink/10" />
|
|
46
46
|
</div>
|
|
47
47
|
|
|
48
48
|
<Separator
|
|
@@ -50,7 +50,7 @@ defineSlots<{ default?(): unknown }>()
|
|
|
50
50
|
:orientation="orientation"
|
|
51
51
|
:decorative="decorative"
|
|
52
52
|
:class="cn(
|
|
53
|
-
'shrink-0 bg-
|
|
53
|
+
'shrink-0 bg-ink/10',
|
|
54
54
|
orientation === 'horizontal' ? 'h-px w-full' : 'w-px self-stretch',
|
|
55
55
|
props.class
|
|
56
56
|
)"
|
|
@@ -59,21 +59,21 @@ const sizes = {
|
|
|
59
59
|
|
|
60
60
|
<template>
|
|
61
61
|
<div :class="cn('flex flex-col items-center text-center', sizes[size].root, props.class)">
|
|
62
|
-
<div v-if="icon" :class="cn('flex text-
|
|
62
|
+
<div v-if="icon" :class="cn('flex text-ink/45', size === 'md' && 'mb-1', ui?.icon)" aria-hidden="true">
|
|
63
63
|
<component :is="icon" :class="sizes[size].icon" />
|
|
64
64
|
</div>
|
|
65
65
|
|
|
66
66
|
<component
|
|
67
67
|
:is="headingLevel ? `h${headingLevel}` : 'p'"
|
|
68
68
|
v-if="$slots.title || title"
|
|
69
|
-
:class="cn('font-bold text-
|
|
69
|
+
:class="cn('font-bold text-ink', sizes[size].title, ui?.title)"
|
|
70
70
|
>
|
|
71
71
|
<slot name="title">{{ title }}</slot>
|
|
72
72
|
</component>
|
|
73
73
|
|
|
74
74
|
<p
|
|
75
75
|
v-if="$slots.description || description"
|
|
76
|
-
:class="cn('max-w-sm text-
|
|
76
|
+
:class="cn('max-w-sm text-ink/65', sizes[size].description, ui?.description)"
|
|
77
77
|
>
|
|
78
78
|
<slot name="description">{{ description }}</slot>
|
|
79
79
|
</p>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import FileUpload from './FileUpload.vue'
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Components/Form/FileUpload',
|
|
7
|
+
component: FileUpload,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
args: { drop: false, multiple: false, disabled: false, accept: undefined },
|
|
10
|
+
} satisfies Meta<typeof FileUpload>
|
|
11
|
+
|
|
12
|
+
export default meta
|
|
13
|
+
type Story = StoryObj<typeof meta>
|
|
14
|
+
|
|
15
|
+
/** Just the button, e.g. "Upload a photo" beside an avatar. */
|
|
16
|
+
export const Default: Story = {}
|
|
17
|
+
|
|
18
|
+
/** With a drop area: drag files onto it, or press the button. */
|
|
19
|
+
export const Drop: Story = {
|
|
20
|
+
args: { drop: true },
|
|
21
|
+
render: (args) => ({
|
|
22
|
+
components: { FileUpload },
|
|
23
|
+
setup: () => ({ args, names: ref<string[]>([]) }),
|
|
24
|
+
template: `
|
|
25
|
+
<div class="max-w-xl">
|
|
26
|
+
<FileUpload v-bind="args" @select="names = $event.map(f => f.name)">
|
|
27
|
+
<p v-if="names.length" class="text-sm font-bold">{{ names.join(', ') }}</p>
|
|
28
|
+
</FileUpload>
|
|
29
|
+
</div>`,
|
|
30
|
+
}),
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Several files, of one type. Dropped files of other types are ignored, as in the picker. */
|
|
34
|
+
export const MultiplePdfs: Story = { args: { drop: true, multiple: true, accept: 'application/pdf,.pdf' } }
|
|
35
|
+
|
|
36
|
+
export const CustomLabel: Story = { args: { label: 'Import a CSV', accept: '.csv,text/csv' } }
|
|
37
|
+
|
|
38
|
+
export const Disabled: Story = { args: { drop: true, disabled: true } }
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, type HTMLAttributes } from 'vue'
|
|
3
|
+
import { useI18n } from 'vue-i18n'
|
|
4
|
+
import { FileUp, Upload } from '@lucide/vue'
|
|
5
|
+
import { cn } from '../../lib/cn'
|
|
6
|
+
import Button, { type ButtonProps } from '../Button/Button.vue'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Choosing files to upload: a Button that opens the device's file picker
|
|
10
|
+
* and, with `drop`, a dashed area around it that files can be dragged onto.
|
|
11
|
+
* Emits `select` with the chosen files (only ones `accept` allows; just the
|
|
12
|
+
* first unless `multiple`). It doesn't upload anything itself.
|
|
13
|
+
*
|
|
14
|
+
* The button is always there, so it works by keyboard, on touch screens and
|
|
15
|
+
* with screen readers; dropping is a shortcut for mouse users.
|
|
16
|
+
*
|
|
17
|
+
* Slots: default (in the drop area above the button, e.g. the chosen file's
|
|
18
|
+
* name; replaces the description), leading (the button's icon).
|
|
19
|
+
*/
|
|
20
|
+
export interface FileUploadProps {
|
|
21
|
+
/** The button's text. Default "Choose a file" (or "Choose files" with `multiple`). */
|
|
22
|
+
label?: string
|
|
23
|
+
/** File types to allow, as for `<input accept>`: ".csv,text/csv", "image/*". */
|
|
24
|
+
accept?: string
|
|
25
|
+
multiple?: boolean
|
|
26
|
+
/** Show a drop area around the button. */
|
|
27
|
+
drop?: boolean
|
|
28
|
+
/** Text in the drop area. Default "Drop a file here, or choose one." */
|
|
29
|
+
description?: string
|
|
30
|
+
disabled?: boolean
|
|
31
|
+
/** The button's look; default basic. */
|
|
32
|
+
variant?: ButtonProps['variant']
|
|
33
|
+
size?: ButtonProps['size']
|
|
34
|
+
/** Button status, e.g. `loading` while the chosen file uploads. */
|
|
35
|
+
status?: ButtonProps['status']
|
|
36
|
+
/** Text beside the spinner while `status` is loading, e.g. "Uploading…". */
|
|
37
|
+
loadingText?: string
|
|
38
|
+
class?: HTMLAttributes['class']
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const { t } = useI18n()
|
|
42
|
+
const props = withDefaults(defineProps<FileUploadProps>(), {
|
|
43
|
+
variant: 'basic',
|
|
44
|
+
size: 'md',
|
|
45
|
+
status: 'idle'
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const emit = defineEmits<{
|
|
49
|
+
/** Files were chosen or dropped. */
|
|
50
|
+
select: [files: File[]]
|
|
51
|
+
}>()
|
|
52
|
+
|
|
53
|
+
defineSlots<{
|
|
54
|
+
default?(): unknown
|
|
55
|
+
leading?(): unknown
|
|
56
|
+
}>()
|
|
57
|
+
|
|
58
|
+
const input = ref<HTMLInputElement>()
|
|
59
|
+
|
|
60
|
+
const buttonLabel = computed(() => props.label ?? (props.multiple ? t('ui.fileUpload.chooseFiles') : t('ui.fileUpload.chooseFile')))
|
|
61
|
+
const dropText = computed(() => props.description ?? (props.multiple ? t('ui.fileUpload.dropFiles') : t('ui.fileUpload.dropFile')))
|
|
62
|
+
|
|
63
|
+
// The same check the file picker does, for dropped files: an extension
|
|
64
|
+
// (".csv"), an exact type ("text/csv") or a family ("image/*").
|
|
65
|
+
function allowed(file: File) {
|
|
66
|
+
if (!props.accept) return true
|
|
67
|
+
const name = file.name.toLowerCase()
|
|
68
|
+
const type = file.type.toLowerCase()
|
|
69
|
+
return props.accept.split(',').some((raw) => {
|
|
70
|
+
const rule = raw.trim().toLowerCase()
|
|
71
|
+
if (!rule) return false
|
|
72
|
+
if (rule.startsWith('.')) return name.endsWith(rule)
|
|
73
|
+
if (rule.endsWith('/*')) return type.startsWith(rule.slice(0, -1))
|
|
74
|
+
return type === rule
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function choose(list: FileList | null | undefined) {
|
|
79
|
+
const files = Array.from(list ?? []).filter(allowed)
|
|
80
|
+
if (!files.length) return
|
|
81
|
+
emit('select', props.multiple ? files : files.slice(0, 1))
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function open() {
|
|
85
|
+
if (!props.disabled) input.value?.click()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function onPick(event: Event) {
|
|
89
|
+
const target = event.target as HTMLInputElement
|
|
90
|
+
choose(target.files)
|
|
91
|
+
// Clear it, so choosing the same file again still counts.
|
|
92
|
+
target.value = ''
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Dragging over the area. A counter, not a flag: dragenter / dragleave fire
|
|
96
|
+
// for every child the pointer crosses.
|
|
97
|
+
const over = ref(0)
|
|
98
|
+
const dragging = computed(() => over.value > 0)
|
|
99
|
+
|
|
100
|
+
function onDragEnter() {
|
|
101
|
+
if (!props.disabled) over.value++
|
|
102
|
+
}
|
|
103
|
+
function onDragLeave() {
|
|
104
|
+
over.value = Math.max(0, over.value - 1)
|
|
105
|
+
}
|
|
106
|
+
function onDrop(event: DragEvent) {
|
|
107
|
+
over.value = 0
|
|
108
|
+
if (!props.disabled) choose(event.dataTransfer?.files)
|
|
109
|
+
}
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<template>
|
|
113
|
+
<!-- One root: the drop area, or just a wrapper round the button. The real
|
|
114
|
+
file input sits inside it, hidden: the Button opens it. -->
|
|
115
|
+
<div
|
|
116
|
+
:data-disabled="disabled || undefined"
|
|
117
|
+
:class="cn(
|
|
118
|
+
drop
|
|
119
|
+
? ['flex flex-col items-center gap-3 rounded-lg border-2 border-dashed p-8 text-center transition-colors', dragging ? 'border-primary bg-primary/5' : 'border-ink/25', disabled && 'opacity-40']
|
|
120
|
+
: 'inline-flex',
|
|
121
|
+
props.class
|
|
122
|
+
)"
|
|
123
|
+
@dragenter.prevent="drop && onDragEnter()"
|
|
124
|
+
@dragover.prevent
|
|
125
|
+
@dragleave="drop && onDragLeave()"
|
|
126
|
+
@drop.prevent="drop && onDrop($event)"
|
|
127
|
+
>
|
|
128
|
+
<template v-if="drop">
|
|
129
|
+
<FileUp class="size-8 text-primary-fg" aria-hidden="true" />
|
|
130
|
+
<slot>
|
|
131
|
+
<p class="text-sm text-ink/65">{{ dropText }}</p>
|
|
132
|
+
</slot>
|
|
133
|
+
</template>
|
|
134
|
+
<Button :variant="variant" :size="size" :status="status" :loading-text="loadingText" :disabled="disabled" @click="open">
|
|
135
|
+
<template #leading><slot name="leading"><Upload /></slot></template>
|
|
136
|
+
{{ buttonLabel }}
|
|
137
|
+
</Button>
|
|
138
|
+
<input
|
|
139
|
+
ref="input"
|
|
140
|
+
type="file"
|
|
141
|
+
class="sr-only"
|
|
142
|
+
tabindex="-1"
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
:accept="accept"
|
|
145
|
+
:multiple="multiple"
|
|
146
|
+
:disabled="disabled"
|
|
147
|
+
@change="onPick"
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
</template>
|
|
@@ -57,18 +57,26 @@ export const CustomLinks: Story = {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/** No app name, version or build (e.g. a public page): just the links and the copyright. */
|
|
60
|
+
/**
|
|
61
|
+
* Without the Appearance dropdown (`themeSwitcher: false`). The Language
|
|
62
|
+
* dropdown shows by itself once the app has more than one language.
|
|
63
|
+
*/
|
|
64
|
+
export const NoSwitchers: Story = {
|
|
65
|
+
args: { themeSwitcher: false, languageSwitcher: false },
|
|
66
|
+
}
|
|
67
|
+
|
|
60
68
|
export const NoVersion: Story = {
|
|
61
69
|
args: { appName: undefined, version: undefined, build: undefined },
|
|
62
70
|
}
|
|
63
71
|
|
|
64
|
-
/** The slot `end`, after the copyright
|
|
72
|
+
/** The slot `end`, after the copyright, e.g. a link to the status page. */
|
|
65
73
|
export const WithEndSlot: Story = {
|
|
66
74
|
render: (args) => ({
|
|
67
75
|
components: { Footer },
|
|
68
76
|
setup: () => ({ args }),
|
|
69
77
|
template: `
|
|
70
78
|
<Footer v-bind="args">
|
|
71
|
-
<template #end><
|
|
79
|
+
<template #end><a href="https://example.com/status" class="underline underline-offset-2">Status</a></template>
|
|
72
80
|
</Footer>`,
|
|
73
81
|
}),
|
|
74
82
|
}
|
|
@@ -3,6 +3,8 @@ import { useI18n } from 'vue-i18n'
|
|
|
3
3
|
import { computed, type Component, type HTMLAttributes } from 'vue'
|
|
4
4
|
import { cn } from '../../lib/cn'
|
|
5
5
|
import Link from '../Link/Link.vue'
|
|
6
|
+
import LanguageSwitcher from '../LanguageSwitcher/LanguageSwitcher.vue'
|
|
7
|
+
import ThemeSwitcher from '../ThemeSwitcher/ThemeSwitcher.vue'
|
|
6
8
|
import { bareVersion, displayVersion, yearRange } from './footer'
|
|
7
9
|
import { kestonFooterLinks } from './links'
|
|
8
10
|
|
|
@@ -26,7 +28,11 @@ export interface FooterLink {
|
|
|
26
28
|
* apps), which follow, after a divider. The version comes from the app's package.json and the build
|
|
27
29
|
* from its CI: in Vite, put them in with `define` (see the spec).
|
|
28
30
|
*
|
|
29
|
-
*
|
|
31
|
+
* On the right too: a Language dropdown (when the app has more than one
|
|
32
|
+
* language) and an Appearance dropdown (Light / Dark / Match device). Turn
|
|
33
|
+
* either off with `languageSwitcher` / `themeSwitcher`.
|
|
34
|
+
*
|
|
35
|
+
* Slots: nav (instead of the whole link list), end (after the copyright).
|
|
30
36
|
*/
|
|
31
37
|
export interface FooterProps {
|
|
32
38
|
/** The links on the left. Default: `kestonFooterLinks` (Help & support, Privacy Policy, Terms & Conditions). */
|
|
@@ -47,6 +53,10 @@ export interface FooterProps {
|
|
|
47
53
|
year?: number
|
|
48
54
|
/** The first year, to show a range such as 2024–2026. */
|
|
49
55
|
since?: number
|
|
56
|
+
/** Show the Language dropdown. Default true; it only shows when the app has more than one language. */
|
|
57
|
+
languageSwitcher?: boolean
|
|
58
|
+
/** Show the Appearance dropdown (Light / Dark / Match device). Default true. */
|
|
59
|
+
themeSwitcher?: boolean
|
|
50
60
|
class?: HTMLAttributes['class']
|
|
51
61
|
/** Extra classes for the parts. */
|
|
52
62
|
ui?: {
|
|
@@ -55,12 +65,15 @@ export interface FooterProps {
|
|
|
55
65
|
}
|
|
56
66
|
}
|
|
57
67
|
|
|
58
|
-
const { t } = useI18n()
|
|
68
|
+
const { t, availableLocales } = useI18n()
|
|
69
|
+
const showLanguages = computed(() => props.languageSwitcher && availableLocales.length > 1)
|
|
59
70
|
const props = withDefaults(defineProps<FooterProps>(), {
|
|
60
71
|
links: () => kestonFooterLinks,
|
|
61
72
|
moreLinks: () => [],
|
|
62
73
|
linkComponent: undefined,
|
|
63
|
-
holder: 'The Keston Group'
|
|
74
|
+
holder: 'The Keston Group',
|
|
75
|
+
languageSwitcher: true,
|
|
76
|
+
themeSwitcher: true
|
|
64
77
|
})
|
|
65
78
|
|
|
66
79
|
defineSlots<{
|
|
@@ -84,7 +97,7 @@ function linkAttrs(link: FooterLink) {
|
|
|
84
97
|
<template>
|
|
85
98
|
<footer
|
|
86
99
|
:class="cn(
|
|
87
|
-
'flex shrink-0 flex-col gap-3 border-t border-
|
|
100
|
+
'flex shrink-0 flex-col gap-3 border-t border-ink/10 bg-surface px-4 py-4 text-sm text-ink/65 sm:flex-row sm:items-center sm:justify-between sm:px-6',
|
|
88
101
|
props.class
|
|
89
102
|
)"
|
|
90
103
|
>
|
|
@@ -94,7 +107,7 @@ function linkAttrs(link: FooterLink) {
|
|
|
94
107
|
<li v-for="link in links" :key="link.label">
|
|
95
108
|
<Link v-bind="linkAttrs(link)" :icon="false">{{ link.label }}</Link>
|
|
96
109
|
</li>
|
|
97
|
-
<li v-if="moreLinks.length" class="hidden h-4 w-px bg-
|
|
110
|
+
<li v-if="moreLinks.length" class="hidden h-4 w-px bg-ink/10 sm:block" aria-hidden="true"></li>
|
|
98
111
|
<li v-for="link in moreLinks" :key="link.label">
|
|
99
112
|
<Link v-bind="linkAttrs(link)" :icon="false">{{ link.label }}</Link>
|
|
100
113
|
</li>
|
|
@@ -102,9 +115,14 @@ function linkAttrs(link: FooterLink) {
|
|
|
102
115
|
</slot>
|
|
103
116
|
</nav>
|
|
104
117
|
|
|
105
|
-
<div :class="cn('flex flex-wrap items-center gap-x-3 gap-y-
|
|
118
|
+
<div :class="cn('flex flex-wrap items-center gap-x-3 gap-y-2 sm:justify-end', ui?.meta)">
|
|
119
|
+
<!-- Language and appearance: compact dropdowns, labelled for screen readers. -->
|
|
120
|
+
<div v-if="showLanguages || themeSwitcher" class="flex flex-wrap items-center gap-2">
|
|
121
|
+
<LanguageSwitcher v-if="showLanguages" hide-label class="w-44" />
|
|
122
|
+
<ThemeSwitcher v-if="themeSwitcher" hide-label class="w-44" />
|
|
123
|
+
</div>
|
|
106
124
|
<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-
|
|
125
|
+
<span v-if="appName" class="font-bold text-ink/80">{{ appName }}</span>
|
|
108
126
|
<!-- Shows as "v1.4.2" but reads as "Version 1.4.2". -->
|
|
109
127
|
<span v-if="version">
|
|
110
128
|
<span class="sr-only">{{ versionLabel }}</span>
|
|
@@ -113,7 +131,7 @@ function linkAttrs(link: FooterLink) {
|
|
|
113
131
|
<!-- Shows as "a1b2c3d" in monospace but reads as "Build a1b2c3d". -->
|
|
114
132
|
<span v-if="build" :title="buildLabel">
|
|
115
133
|
<span class="sr-only">{{ buildLabel }}</span>
|
|
116
|
-
<span class="font-mono text-xs text-
|
|
134
|
+
<span class="font-mono text-xs text-ink/55" aria-hidden="true">{{ build }}</span>
|
|
117
135
|
</span>
|
|
118
136
|
</p>
|
|
119
137
|
<p>{{ t('ui.footer.copyright', { years, holder }) }}</p>
|
|
@@ -34,9 +34,9 @@ watch(
|
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
const colour: Record<FieldStatus, string> = {
|
|
37
|
-
error: 'text-red',
|
|
38
|
-
success: 'text-green',
|
|
39
|
-
loading: 'text-
|
|
37
|
+
error: 'text-red-fg',
|
|
38
|
+
success: 'text-green-fg',
|
|
39
|
+
loading: 'text-ink/65'
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const icon = { error: CircleAlert, success: CircleCheck } as const
|
|
@@ -32,7 +32,7 @@ const meta = {
|
|
|
32
32
|
:disabled="args.disabled"
|
|
33
33
|
:aria-invalid="invalid"
|
|
34
34
|
:aria-describedby="describedBy"
|
|
35
|
-
class="min-h-5 min-w-0 flex-1 resize-y bg-transparent outline-none placeholder:text-
|
|
35
|
+
class="min-h-5 min-w-0 flex-1 resize-y bg-transparent outline-none placeholder:text-ink/55 disabled:cursor-not-allowed"
|
|
36
36
|
/>
|
|
37
37
|
</template>
|
|
38
38
|
</FormField>`,
|
|
@@ -105,9 +105,14 @@ function focusUnlabelable() {
|
|
|
105
105
|
//
|
|
106
106
|
// Text is 16px on touch screens: iPhone zooms the page into any field with
|
|
107
107
|
// smaller text when it's tapped. 16px stops that without blocking pinch-zoom.
|
|
108
|
+
//
|
|
109
|
+
// Text sits 12px from the sides. An icon at either end sits 10px from the
|
|
110
|
+
// edge instead, the same as above and below it (16px icon in a 20px line,
|
|
111
|
+
// plus 8px padding), so it looks evenly placed.
|
|
108
112
|
const box = [
|
|
109
113
|
'flex items-center gap-2 px-3 py-2 text-sm pointer-coarse:text-base [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:opacity-70',
|
|
110
|
-
'
|
|
114
|
+
'[&>svg:first-child]:-ml-0.5 [&>svg:last-child]:-mr-0.5',
|
|
115
|
+
'bg-surface text-ink border border-ink/45 rounded shadow-xs cursor-text transition',
|
|
111
116
|
'outline-2 outline-offset-1 outline-transparent forced-colors:not-has-focus-visible:outline-0',
|
|
112
117
|
'has-focus-visible:outline-focus',
|
|
113
118
|
// A control can mark itself data-pointer-focus to hide the ring while it
|
|
@@ -124,7 +129,7 @@ const statusBorder: Record<FormFieldStatus, string> = {
|
|
|
124
129
|
</script>
|
|
125
130
|
|
|
126
131
|
<template>
|
|
127
|
-
<div :class="cn('flex flex-col gap-1.5 text-
|
|
132
|
+
<div :class="cn('flex flex-col gap-1.5 text-ink', props.class)">
|
|
128
133
|
<!-- Label row and box in a grid, so label-trailing can come after the
|
|
129
134
|
box in the page (and the Tab order) but show at the end of the label row. -->
|
|
130
135
|
<div :class="cn('grid grid-cols-[minmax(0,1fr)_auto]', !hideLabel && 'gap-y-1.5', $slots['label-trailing'] && 'gap-x-3')">
|
|
@@ -138,7 +143,7 @@ const statusBorder: Record<FormFieldStatus, string> = {
|
|
|
138
143
|
</div>
|
|
139
144
|
|
|
140
145
|
<!-- Behind the ?: hidden, but still the control's description. -->
|
|
141
|
-
<p v-if="helper" :id="helperId" :hidden="helperPlacement === 'icon'" class="text-xs text-
|
|
146
|
+
<p v-if="helper" :id="helperId" :hidden="helperPlacement === 'icon'" class="text-xs text-ink/65">
|
|
142
147
|
{{ helper }}
|
|
143
148
|
</p>
|
|
144
149
|
</div>
|
|
@@ -3,6 +3,7 @@ import { Bell, Building2, ChevronRight } from "@lucide/vue";
|
|
|
3
3
|
import { ref } from "vue";
|
|
4
4
|
import Button from "../Button/Button.vue";
|
|
5
5
|
import Header, { type HeaderUser } from "./Header.vue";
|
|
6
|
+
import ThemeSwitcher from "../ThemeSwitcher/ThemeSwitcher.vue";
|
|
6
7
|
|
|
7
8
|
const user: HeaderUser = {
|
|
8
9
|
name: "Ben Smith",
|
|
@@ -41,7 +42,7 @@ const meta = {
|
|
|
41
42
|
<Button variant="ghost" square aria-label="Notifications"><Bell /></Button>
|
|
42
43
|
</template>
|
|
43
44
|
</Header>
|
|
44
|
-
<p class="p-4 text-sm text-
|
|
45
|
+
<p class="p-4 text-sm text-ink/65">Last event: {{ last || "none" }}</p>
|
|
45
46
|
</div>`,
|
|
46
47
|
}),
|
|
47
48
|
} satisfies Meta<typeof Header>;
|
|
@@ -80,8 +81,8 @@ export const CustomUserMenu: Story = {
|
|
|
80
81
|
template: `
|
|
81
82
|
<Header v-bind="args">
|
|
82
83
|
<template #account-menu="{ close }">
|
|
83
|
-
<div class="flex flex-col gap-1 border-t border-
|
|
84
|
-
<p class="px-3 pt-1 text-xs font-bold text-
|
|
84
|
+
<div class="flex flex-col gap-1 border-t border-ink/10 p-2">
|
|
85
|
+
<p class="px-3 pt-1 text-xs font-bold text-ink/65 uppercase">Switch school</p>
|
|
85
86
|
<Button variant="ghost" class="w-full justify-start px-3" @click="close">
|
|
86
87
|
<template #leading><Building2 /></template>Keston Prep
|
|
87
88
|
</Button>
|
|
@@ -94,6 +95,25 @@ export const CustomUserMenu: Story = {
|
|
|
94
95
|
}),
|
|
95
96
|
};
|
|
96
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Light / Dark / Match device in the account menu: ThemeSwitcher in the
|
|
100
|
+
* account-menu slot, in a row with the menu's divider and padding.
|
|
101
|
+
*/
|
|
102
|
+
export const WithThemeSwitcher: Story = {
|
|
103
|
+
render: (args) => ({
|
|
104
|
+
components: { Header, ThemeSwitcher },
|
|
105
|
+
setup: () => ({ args }),
|
|
106
|
+
template: `
|
|
107
|
+
<Header v-bind="args">
|
|
108
|
+
<template #account-menu>
|
|
109
|
+
<div class="border-t border-ink/10 px-4 py-3">
|
|
110
|
+
<ThemeSwitcher />
|
|
111
|
+
</div>
|
|
112
|
+
</template>
|
|
113
|
+
</Header>`,
|
|
114
|
+
}),
|
|
115
|
+
};
|
|
116
|
+
|
|
97
117
|
/**
|
|
98
118
|
* The organisation slot replaces the organisation heading at the top of the
|
|
99
119
|
* account menu, e.g. with a row that switches organisation. A divider sits
|
|
@@ -108,13 +128,13 @@ export const OrganisationSwitcher: Story = {
|
|
|
108
128
|
<template #organisation="{ close }">
|
|
109
129
|
<button
|
|
110
130
|
type="button"
|
|
111
|
-
class="flex w-full items-center gap-2 px-4 py-3 text-left text-sm hover:bg-
|
|
131
|
+
class="flex w-full items-center gap-2 px-4 py-3 text-left text-sm hover:bg-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus"
|
|
112
132
|
@click="close"
|
|
113
133
|
>
|
|
114
134
|
<Building2 class="size-4 shrink-0" aria-hidden="true" />
|
|
115
135
|
<span class="flex min-w-0 flex-1 flex-col">
|
|
116
136
|
<span class="truncate font-bold">The Keston School</span>
|
|
117
|
-
<span class="text-xs text-
|
|
137
|
+
<span class="text-xs text-ink/65">Switch organisation</span>
|
|
118
138
|
</span>
|
|
119
139
|
<ChevronRight class="size-4 shrink-0" aria-hidden="true" />
|
|
120
140
|
</button>
|
|
@@ -161,11 +181,11 @@ export const WithMiddle: Story = {
|
|
|
161
181
|
setup: () => ({ args }),
|
|
162
182
|
template: `
|
|
163
183
|
<Header v-bind="args">
|
|
164
|
-
<nav aria-label="Breadcrumb" class="ml-2 hidden items-center gap-1 text-sm text-
|
|
184
|
+
<nav aria-label="Breadcrumb" class="ml-2 hidden items-center gap-1 text-sm text-ink/65 sm:flex [&_svg]:size-4">
|
|
165
185
|
<ChevronRight aria-hidden="true" />
|
|
166
186
|
<a href="#" class="hover:underline">Students</a>
|
|
167
187
|
<ChevronRight aria-hidden="true" />
|
|
168
|
-
<span aria-current="page" class="text-
|
|
188
|
+
<span aria-current="page" class="text-ink">Ben Smith</span>
|
|
169
189
|
</nav>
|
|
170
190
|
<template #trailing>
|
|
171
191
|
<Button variant="ghost" square aria-label="Notifications"><Bell /></Button>
|
|
@@ -199,7 +219,7 @@ export const Sticky: Story = {
|
|
|
199
219
|
<div class="h-96 overflow-y-auto bg-background">
|
|
200
220
|
<Header v-bind="args" />
|
|
201
221
|
<div class="flex flex-col gap-3 p-4">
|
|
202
|
-
<p v-for="n in 30" :key="n" class="text-sm text-
|
|
222
|
+
<p v-for="n in 30" :key="n" class="text-sm text-ink/65">Row {{ n }}</p>
|
|
203
223
|
</div>
|
|
204
224
|
</div>`,
|
|
205
225
|
}),
|