@thekestongroup/ui 0.20.0 → 0.21.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/Header/Header.vue.d.ts +5 -0
- package/dist/components/Popover/popover.d.ts +1 -1
- package/dist/keston-ui.js +503 -489
- package/package.json +1 -1
- package/src/components/Header/Header.stories.ts +20 -0
- package/src/components/Header/Header.vue +35 -9
- package/src/components/Popover/popover.ts +2 -2
- package/src/components/Tooltip/Tooltip.vue +1 -1
package/package.json
CHANGED
|
@@ -223,6 +223,26 @@ export const WithLockup: Story = {
|
|
|
223
223
|
args: { lockup: sampleLockup, titleTo: "#home" },
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
+
const sampleOrgLogo = (colour: string) =>
|
|
227
|
+
"data:image/svg+xml," +
|
|
228
|
+
encodeURIComponent(
|
|
229
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 180 24"><path d="M12 1 2 5v7c0 6 4.5 9.5 10 11 5.5-1.5 10-5 10-11V5Z" fill="${colour}"/><text x="30" y="17" font-family="Georgia, serif" font-weight="700" font-size="15" fill="${colour}">The Keston School</text></svg>`,
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* organisationLogo: the organisation's logo at the top of the account menu
|
|
234
|
+
* (open it) instead of its name. Pass `{ light, dark }` for a dark-mode
|
|
235
|
+
* version; its alt text is the organisation's name.
|
|
236
|
+
*/
|
|
237
|
+
export const WithOrganisationLogo: Story = {
|
|
238
|
+
args: {
|
|
239
|
+
user: {
|
|
240
|
+
...user,
|
|
241
|
+
organisationLogo: { light: sampleOrgLogo("#023750"), dark: sampleOrgLogo("#ffffff") },
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
|
|
226
246
|
/** Stays at the top while the page scrolls (the default). Scroll the box below. */
|
|
227
247
|
export const Sticky: Story = {
|
|
228
248
|
render: (args) => ({
|
|
@@ -13,6 +13,11 @@ export interface HeaderUser {
|
|
|
13
13
|
email?: string
|
|
14
14
|
/** Organisation or school the account belongs to, shown at the top of the account menu. */
|
|
15
15
|
organisation?: string
|
|
16
|
+
/**
|
|
17
|
+
* The organisation's logo (e.g. a wordmark), shown at the top of the
|
|
18
|
+
* account menu instead of its name. Its alt text is the organisation's name.
|
|
19
|
+
*/
|
|
20
|
+
organisationLogo?: HeaderImage
|
|
16
21
|
/** Picture URL. Initials are shown without one. */
|
|
17
22
|
avatar?: string
|
|
18
23
|
}
|
|
@@ -157,6 +162,7 @@ const titleLinkClass = [
|
|
|
157
162
|
|
|
158
163
|
const image = (i: HeaderImage | undefined) => (typeof i === 'string' ? { light: i, dark: undefined } : i)
|
|
159
164
|
const logoImage = computed(() => image(props.logo))
|
|
165
|
+
const organisationLogo = computed(() => image(props.user?.organisationLogo))
|
|
160
166
|
const lockupImage = computed(() => image(props.lockup))
|
|
161
167
|
|
|
162
168
|
function runAction(action: HeaderUserAction, close: () => void) {
|
|
@@ -239,11 +245,25 @@ function runAction(action: HeaderUserAction, close: () => void) {
|
|
|
239
245
|
|
|
240
246
|
<template #content="{ close }">
|
|
241
247
|
<div class="flex flex-col">
|
|
242
|
-
<!-- The organisation at the top, with a divider under it
|
|
243
|
-
|
|
244
|
-
|
|
248
|
+
<!-- The organisation at the top, with a divider under it: its
|
|
249
|
+
logo if it has one, otherwise its name. The organisation
|
|
250
|
+
slot replaces both. -->
|
|
251
|
+
<div v-if="user.organisation || organisationLogo || $slots.organisation" class="border-b border-ink/10">
|
|
245
252
|
<slot name="organisation" :close="close">
|
|
246
|
-
<
|
|
253
|
+
<div v-if="organisationLogo" class="p-3">
|
|
254
|
+
<img
|
|
255
|
+
:src="organisationLogo.light"
|
|
256
|
+
:alt="user.organisation ?? ''"
|
|
257
|
+
:class="cn('h-6 w-auto max-w-full object-contain object-left', organisationLogo.dark && 'dark:hidden')"
|
|
258
|
+
/>
|
|
259
|
+
<img
|
|
260
|
+
v-if="organisationLogo.dark"
|
|
261
|
+
:src="organisationLogo.dark"
|
|
262
|
+
:alt="user.organisation ?? ''"
|
|
263
|
+
class="hidden h-6 w-auto max-w-full object-contain object-left dark:block"
|
|
264
|
+
/>
|
|
265
|
+
</div>
|
|
266
|
+
<p v-else class="truncate p-3 text-xs font-bold text-ink/65 uppercase" :title="user.organisation">
|
|
247
267
|
{{ user.organisation }}
|
|
248
268
|
</p>
|
|
249
269
|
</slot>
|
|
@@ -251,7 +271,7 @@ function runAction(action: HeaderUserAction, close: () => void) {
|
|
|
251
271
|
<!-- Two columns: the avatar at the top left, beside the name and
|
|
252
272
|
email; Account settings sits under them in the text column,
|
|
253
273
|
without moving the avatar. -->
|
|
254
|
-
<div class="grid grid-cols-[auto_minmax(0,1fr)] items-start gap-x-3 gap-y-2
|
|
274
|
+
<div class="grid grid-cols-[auto_minmax(0,1fr)] items-start gap-x-3 gap-y-2 p-3">
|
|
255
275
|
<Avatar :user="user" size="lg" decorative />
|
|
256
276
|
<div class="flex min-w-0 flex-col">
|
|
257
277
|
<span class="truncate font-bold" :title="user.name">{{ user.name }}</span>
|
|
@@ -270,18 +290,24 @@ function runAction(action: HeaderUserAction, close: () => void) {
|
|
|
270
290
|
|
|
271
291
|
<slot name="account-menu" :close="close" />
|
|
272
292
|
|
|
273
|
-
<!-- Switch account
|
|
293
|
+
<!-- Switch account and Log out fill the row, each growing from its
|
|
294
|
+
own text width (so Switch account stays the wider), with the
|
|
295
|
+
same 12px around them on every side, like the rest of the menu. -->
|
|
274
296
|
<div
|
|
275
297
|
v-if="userActions.includes('switch-account') || userActions.includes('log-out')"
|
|
276
|
-
class="flex items-center gap-2 border-t border-ink/10
|
|
298
|
+
class="flex items-center gap-2 border-t border-ink/10 p-3"
|
|
277
299
|
>
|
|
278
|
-
<Button
|
|
300
|
+
<Button
|
|
301
|
+
v-if="userActions.includes('switch-account')"
|
|
302
|
+
class="flex-auto"
|
|
303
|
+
@click="runAction('switch-account', close)"
|
|
304
|
+
>
|
|
279
305
|
<template #leading><ArrowLeftRight /></template>
|
|
280
306
|
Switch account
|
|
281
307
|
</Button>
|
|
282
308
|
<Button
|
|
283
309
|
v-if="userActions.includes('log-out')"
|
|
284
|
-
class="
|
|
310
|
+
class="flex-auto"
|
|
285
311
|
@click="runAction('log-out', close)"
|
|
286
312
|
>
|
|
287
313
|
<template #leading><LogOut /></template>
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* Reka's popper (e.g. InputDate's calendar), so they all match.
|
|
4
4
|
*
|
|
5
5
|
* An elevated panel (white; a step lighter than the page in dark mode) with
|
|
6
|
-
* the same border
|
|
6
|
+
* the same border as a basic Button, 8px corners like a Card or dialog, a shadow,
|
|
7
7
|
* and the theme's fade in / out (Reka waits for the fade-out to finish
|
|
8
8
|
* before removing the panel).
|
|
9
9
|
*/
|
|
10
10
|
export const popoverContent = [
|
|
11
|
-
'z-50 rounded border border-ink/10 bg-surface-elevated text-ink shadow-md outline-none',
|
|
11
|
+
'z-50 rounded-lg border border-ink/10 bg-surface-elevated text-ink shadow-md outline-none',
|
|
12
12
|
'data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out'
|
|
13
13
|
]
|
|
14
14
|
|
|
@@ -72,7 +72,7 @@ const MaybeProvider: FunctionalComponent = (_, { slots }) =>
|
|
|
72
72
|
:collision-padding="8"
|
|
73
73
|
:class="
|
|
74
74
|
cn(
|
|
75
|
-
'z-100 max-w-72 rounded-
|
|
75
|
+
'z-100 max-w-72 rounded-lg bg-neutral-900 dark:bg-neutral-700 px-2.5 py-1.5 text-xs/4 text-white shadow-lg ring-1 ring-white/10',
|
|
76
76
|
'data-[state=closed]:animate-fade-out data-[state=delayed-open]:animate-fade-in data-[state=instant-open]:animate-fade-in',
|
|
77
77
|
props.class
|
|
78
78
|
)
|