@thekestongroup/ui 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AppLauncher/AppLauncher.vue.d.ts +3 -2
- package/dist/components/AppShell/AppShell.vue.d.ts +1 -1
- package/dist/components/Header/Header.vue.d.ts +2 -1
- package/dist/keston-ui.js +523 -520
- package/package.json +1 -1
- package/src/components/AppLauncher/AppLauncher.stories.ts +1 -1
- package/src/components/AppLauncher/AppLauncher.vue +8 -11
- package/src/components/AppLauncher/apps.ts +5 -5
- package/src/components/AppShell/AppShell.vue +8 -7
- package/src/components/Header/Header.vue +4 -1
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ export const Open: Story = {
|
|
|
25
25
|
export const CustomApps: Story = {
|
|
26
26
|
args: {
|
|
27
27
|
apps: [
|
|
28
|
-
{ id: "a", label: "Rota",
|
|
28
|
+
{ id: "a", label: "Rota", href: "#a" },
|
|
29
29
|
{ id: "b", label: "Reports", href: "#b" },
|
|
30
30
|
],
|
|
31
31
|
},
|
|
@@ -23,8 +23,6 @@ export interface AppLauncherApp {
|
|
|
23
23
|
/** Matches `current` to mark the app you are in. */
|
|
24
24
|
id: string
|
|
25
25
|
label: string
|
|
26
|
-
/** A few words on what the app is for. */
|
|
27
|
-
description?: string
|
|
28
26
|
href: string
|
|
29
27
|
/** An icon component, or the name of one of the Keston app icons (id, admin, work, utilities, design). */
|
|
30
28
|
icon?: Component | string
|
|
@@ -43,13 +41,15 @@ export interface AppLauncherProps {
|
|
|
43
41
|
apps?: AppLauncherApp[]
|
|
44
42
|
/** The `id` of the app you are in, shown as the current page. */
|
|
45
43
|
current?: string
|
|
44
|
+
/** Which edge of the button the panel lines up with: `start` when the button is at the left of the header (AppShell), `end` when at the right. Default `end`. */
|
|
45
|
+
align?: 'start' | 'end'
|
|
46
46
|
/** Name of the button for screen readers. Default "Keston apps". */
|
|
47
47
|
label?: string
|
|
48
48
|
class?: HTMLAttributes['class']
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
const { t } = useI18n()
|
|
52
|
-
const props = withDefaults(defineProps<AppLauncherProps>(), { apps: () => kestonApps })
|
|
52
|
+
const props = withDefaults(defineProps<AppLauncherProps>(), { apps: () => kestonApps, align: 'end' })
|
|
53
53
|
|
|
54
54
|
function iconOf(app: AppLauncherApp): Component {
|
|
55
55
|
if (typeof app.icon === 'string') return builtInIcons[app.icon] ?? AppWindow
|
|
@@ -58,30 +58,27 @@ function iconOf(app: AppLauncherApp): Component {
|
|
|
58
58
|
</script>
|
|
59
59
|
|
|
60
60
|
<template>
|
|
61
|
-
<Popover :content="{ align
|
|
61
|
+
<Popover :content="{ align }" :ui="{ content: 'w-64 p-2' }">
|
|
62
62
|
<Button variant="ghost" square :aria-label="label ?? t('ui.appLauncher.label')" :class="props.class">
|
|
63
63
|
<LayoutGrid />
|
|
64
64
|
</Button>
|
|
65
65
|
<template #content="{ close }">
|
|
66
66
|
<nav :aria-label="label ?? t('ui.appLauncher.label')">
|
|
67
|
-
<ul
|
|
67
|
+
<ul>
|
|
68
68
|
<li v-for="app in apps" :key="app.id">
|
|
69
69
|
<a
|
|
70
70
|
:href="app.href"
|
|
71
71
|
:aria-current="app.id === current ? 'page' : undefined"
|
|
72
72
|
:class="cn(
|
|
73
|
-
'flex
|
|
73
|
+
'flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-bold text-black outline-none hover:bg-black/5 focus-visible:outline-2 focus-visible:outline-focus',
|
|
74
74
|
app.id === current && 'bg-black/5'
|
|
75
75
|
)"
|
|
76
76
|
@click="close()"
|
|
77
77
|
>
|
|
78
|
-
<span class="flex size-
|
|
78
|
+
<span class="flex size-8 shrink-0 items-center justify-center rounded-lg bg-black/5">
|
|
79
79
|
<component :is="iconOf(app)" class="size-5" aria-hidden="true" />
|
|
80
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>
|
|
81
|
+
<span class="min-w-0 truncate">{{ app.label }}</span>
|
|
85
82
|
</a>
|
|
86
83
|
</li>
|
|
87
84
|
</ul>
|
|
@@ -2,9 +2,9 @@ import type { AppLauncherApp } from './AppLauncher.vue'
|
|
|
2
2
|
|
|
3
3
|
/** The Keston Group's apps, as the launcher lists them by default. Apps can pass their own `apps`. */
|
|
4
4
|
export const kestonApps: AppLauncherApp[] = [
|
|
5
|
-
{ id: 'id', label: 'Keston ID',
|
|
6
|
-
{ id: 'admin', label: 'Admin',
|
|
7
|
-
{ id: 'work', label: 'Work',
|
|
8
|
-
{ id: 'utilities', label: 'Utilities',
|
|
9
|
-
{ id: 'design', label: 'Design system',
|
|
5
|
+
{ id: 'id', label: 'Keston ID', href: 'https://id.keston.co', icon: 'id' },
|
|
6
|
+
{ id: 'admin', label: 'Admin', href: 'https://admin.keston.co', icon: 'admin' },
|
|
7
|
+
{ id: 'work', label: 'Work', href: 'https://work.keston.co', icon: 'work' },
|
|
8
|
+
{ id: 'utilities', label: 'Utilities', href: 'https://utilities.keston.co', icon: 'utilities' },
|
|
9
|
+
{ id: 'design', label: 'Design system', href: 'https://ui.keston.co', icon: 'design' }
|
|
10
10
|
]
|
|
@@ -58,7 +58,7 @@ export interface AppShellProps {
|
|
|
58
58
|
collapsible?: boolean
|
|
59
59
|
/** Show the Keston Group footer under the page. The Footer's props: `{ appName, version, … }`. Without it there is no footer. */
|
|
60
60
|
footer?: FooterProps
|
|
61
|
-
/** Show the app launcher (a grid button for moving between Keston apps)
|
|
61
|
+
/** Show the app launcher (a grid button for moving between Keston apps) at the left of the header, before the menu button. `true` for the defaults, or the AppLauncher's props: `{ current: 'admin' }`. */
|
|
62
62
|
launcher?: boolean | AppLauncherProps
|
|
63
63
|
/** Component used for sidebar items with `to`, and the title link, e.g. RouterLink. */
|
|
64
64
|
linkComponent?: SidebarProps['linkComponent']
|
|
@@ -149,13 +149,17 @@ const sidebarId = `${uid}-sidebar`
|
|
|
149
149
|
:user="user"
|
|
150
150
|
:user-actions="userActions"
|
|
151
151
|
:sign-in="signIn"
|
|
152
|
-
:ui="{ ...header?.ui, menu: cn('lg:hidden', header?.ui?.menu) }"
|
|
152
|
+
:ui="{ ...header?.ui, menu: cn('lg:hidden', launcher && 'ml-0', header?.ui?.menu) }"
|
|
153
153
|
@menu="menuOpen = true"
|
|
154
154
|
@account-settings="emit('account-settings')"
|
|
155
155
|
@switch-account="emit('switch-account')"
|
|
156
156
|
@log-out="emit('log-out')"
|
|
157
157
|
@sign-in="emit('sign-in')"
|
|
158
158
|
>
|
|
159
|
+
<!-- First in the header, to the left of the menu / collapse button. -->
|
|
160
|
+
<template v-if="launcher" #start>
|
|
161
|
+
<AppLauncher align="start" v-bind="launcher === true ? {} : launcher" class="-ml-2.5" />
|
|
162
|
+
</template>
|
|
159
163
|
<template #leading>
|
|
160
164
|
<!-- Wide screens: in place of the menu button (same look and spot),
|
|
161
165
|
collapses the sidebar beside the page to icons and back. -->
|
|
@@ -166,7 +170,7 @@ const sidebarId = `${uid}-sidebar`
|
|
|
166
170
|
:aria-label="collapsed ? t('ui.appShell.expandSidebar') : t('ui.appShell.collapseSidebar')"
|
|
167
171
|
:aria-expanded="!collapsed"
|
|
168
172
|
:aria-controls="sidebarId"
|
|
169
|
-
class="-ml-2.5
|
|
173
|
+
:class="cn('max-lg:hidden', launcher ? 'ml-0' : '-ml-2.5')"
|
|
170
174
|
@click="collapsed = !collapsed"
|
|
171
175
|
>
|
|
172
176
|
<Menu />
|
|
@@ -174,10 +178,7 @@ const sidebarId = `${uid}-sidebar`
|
|
|
174
178
|
<slot name="header-leading" />
|
|
175
179
|
</template>
|
|
176
180
|
<slot name="header-middle" />
|
|
177
|
-
<template v-if="$slots['header-trailing']
|
|
178
|
-
<slot name="header-trailing" />
|
|
179
|
-
<AppLauncher v-if="launcher" v-bind="launcher === true ? {} : launcher" />
|
|
180
|
-
</template>
|
|
181
|
+
<template v-if="$slots['header-trailing']" #trailing><slot name="header-trailing" /></template>
|
|
181
182
|
<template v-if="$slots.account" #account><slot name="account" /></template>
|
|
182
183
|
<template v-if="$slots['account-menu']" #account-menu="slotProps"><slot name="account-menu" v-bind="slotProps" /></template>
|
|
183
184
|
<template v-if="$slots.organisation" #organisation="slotProps"><slot name="organisation" v-bind="slotProps" /></template>
|
|
@@ -26,7 +26,7 @@ export type HeaderUserAction = 'account-settings' | 'switch-account' | 'log-out'
|
|
|
26
26
|
* the right (Account settings, Switch account, Log out). Each part can be
|
|
27
27
|
* overridden with a slot.
|
|
28
28
|
*
|
|
29
|
-
* Slots: leading (before the title, e.g. a logo), title, default (the middle,
|
|
29
|
+
* Slots: start (the very first thing, before the menu button, e.g. the app launcher; give it a `-ml-2.5` button to line up with the padding), leading (before the title, e.g. a logo), title, default (the middle,
|
|
30
30
|
* fills the space between title and trailing), trailing (actions before the
|
|
31
31
|
* account menu), account (replaces the account menu, or the Sign in button),
|
|
32
32
|
* account-menu (extra content in the account menu, above Switch account /
|
|
@@ -104,6 +104,7 @@ const emit = defineEmits<{
|
|
|
104
104
|
}>()
|
|
105
105
|
|
|
106
106
|
defineSlots<{
|
|
107
|
+
start?(): unknown
|
|
107
108
|
leading?(): unknown
|
|
108
109
|
title?(): unknown
|
|
109
110
|
default?(): unknown
|
|
@@ -156,6 +157,8 @@ function runAction(action: HeaderUserAction, close: () => void) {
|
|
|
156
157
|
props.class
|
|
157
158
|
)"
|
|
158
159
|
>
|
|
160
|
+
<slot name="start" />
|
|
161
|
+
|
|
159
162
|
<!-- A ghost icon Button; the negative margin lines its icon up with the
|
|
160
163
|
header's padding, as the × does in Slideover. -->
|
|
161
164
|
<Button
|