@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.
Files changed (124) hide show
  1. package/dist/components/ActionList/ActionList.vue.d.ts +63 -0
  2. package/dist/components/Alert/Alert.vue.d.ts +55 -0
  3. package/dist/components/AvatarGroup/AvatarGroup.vue.d.ts +1 -1
  4. package/dist/components/BarChart/BarChart.vue.d.ts +37 -0
  5. package/dist/components/BarChart/ChartData.vue.d.ts +20 -0
  6. package/dist/components/Button/Button.vue.d.ts +1 -1
  7. package/dist/components/Collapsible/Collapsible.vue.d.ts +48 -0
  8. package/dist/components/FileUpload/FileUpload.vue.d.ts +55 -0
  9. package/dist/components/Footer/Footer.vue.d.ts +11 -1
  10. package/dist/components/Header/Header.vue.d.ts +1 -1
  11. package/dist/components/LineChart/LineChart.vue.d.ts +37 -0
  12. package/dist/components/Notification/Notification.vue.d.ts +2 -2
  13. package/dist/components/Popover/popover.d.ts +3 -2
  14. package/dist/components/Progress/Progress.vue.d.ts +14 -1
  15. package/dist/components/Slideover/Slideover.vue.d.ts +7 -5
  16. package/dist/components/Spinner/Spinner.vue.d.ts +2 -2
  17. package/dist/components/ThemeSwitcher/ThemeSwitcher.vue.d.ts +18 -0
  18. package/dist/i18n/en.d.ts +27 -0
  19. package/dist/index.d.ts +17 -0
  20. package/dist/keston-ui.js +4369 -3509
  21. package/dist/lib/chart.d.ts +32 -0
  22. package/dist/lib/theme.d.ts +23 -0
  23. package/package.json +8 -3
  24. package/src/components/ActionList/ActionList.stories.ts +59 -0
  25. package/src/components/ActionList/ActionList.vue +116 -0
  26. package/src/components/Alert/Alert.stories.ts +65 -0
  27. package/src/components/Alert/Alert.vue +110 -0
  28. package/src/components/AppLauncher/AppLauncher.vue +3 -3
  29. package/src/components/AppShell/AppShell.stories.ts +2 -2
  30. package/src/components/AppShell/AppShell.vue +2 -2
  31. package/src/components/Avatar/Avatar.vue +3 -3
  32. package/src/components/AvatarGroup/AvatarGroup.vue +4 -4
  33. package/src/components/Badge/Badge.vue +2 -2
  34. package/src/components/BarChart/BarChart.stories.ts +62 -0
  35. package/src/components/BarChart/BarChart.vue +153 -0
  36. package/src/components/BarChart/ChartData.vue +64 -0
  37. package/src/components/Breadcrumb/Breadcrumb.vue +5 -5
  38. package/src/components/Button/Button.stories.ts +1 -1
  39. package/src/components/Button/Button.vue +12 -9
  40. package/src/components/Calendar/Calendar.stories.ts +2 -2
  41. package/src/components/Calendar/Calendar.vue +11 -10
  42. package/src/components/Card/Card.stories.ts +5 -5
  43. package/src/components/Card/Card.vue +3 -3
  44. package/src/components/CardSelect/CardSelect.vue +10 -7
  45. package/src/components/ChangeIndicator/ChangeIndicator.vue +2 -2
  46. package/src/components/Checkbox/Checkbox.vue +5 -5
  47. package/src/components/CheckboxGroup/CheckboxGroup.stories.ts +1 -1
  48. package/src/components/CheckboxGroup/CheckboxGroup.vue +2 -2
  49. package/src/components/Checklist/Checklist.vue +3 -3
  50. package/src/components/Chip/Chip.stories.ts +1 -1
  51. package/src/components/Chip/Chip.vue +2 -2
  52. package/src/components/Collapsible/Collapsible.stories.ts +32 -0
  53. package/src/components/Collapsible/Collapsible.vue +68 -0
  54. package/src/components/Divider/Divider.vue +4 -4
  55. package/src/components/EmptyState/EmptyState.vue +3 -3
  56. package/src/components/FileUpload/FileUpload.stories.ts +38 -0
  57. package/src/components/FileUpload/FileUpload.vue +150 -0
  58. package/src/components/Footer/Footer.stories.ts +10 -2
  59. package/src/components/Footer/Footer.vue +26 -8
  60. package/src/components/FormField/FieldMessage.vue +3 -3
  61. package/src/components/FormField/FormField.stories.ts +1 -1
  62. package/src/components/FormField/FormField.vue +8 -3
  63. package/src/components/Header/Header.stories.ts +28 -8
  64. package/src/components/Header/Header.vue +6 -6
  65. package/src/components/InfoTip/InfoTip.stories.ts +1 -1
  66. package/src/components/InfoTip/InfoTip.vue +1 -1
  67. package/src/components/Input/Input.vue +1 -1
  68. package/src/components/InputCode/InputCode.stories.ts +1 -1
  69. package/src/components/InputCode/InputCode.vue +4 -4
  70. package/src/components/InputDate/InputDate.stories.ts +1 -1
  71. package/src/components/InputDate/InputDate.vue +5 -5
  72. package/src/components/InputNumber/InputNumber.stories.ts +1 -1
  73. package/src/components/InputNumber/InputNumber.vue +6 -6
  74. package/src/components/InputPassword/InputPassword.vue +4 -4
  75. package/src/components/InputRichText/InputRichText.stories.ts +1 -1
  76. package/src/components/InputRichText/InputRichText.vue +3 -3
  77. package/src/components/InputTextArea/InputTextArea.vue +1 -1
  78. package/src/components/LineChart/LineChart.stories.ts +47 -0
  79. package/src/components/LineChart/LineChart.vue +173 -0
  80. package/src/components/Link/Link.stories.ts +4 -4
  81. package/src/components/Link/Link.vue +1 -1
  82. package/src/components/Menu/Menu.vue +6 -5
  83. package/src/components/Notification/Notification.stories.ts +3 -3
  84. package/src/components/Notification/Notification.vue +9 -9
  85. package/src/components/Notification/NotificationPane.vue +3 -3
  86. package/src/components/Notification/Toaster.vue +1 -1
  87. package/src/components/PageHeader/PageHeader.vue +2 -2
  88. package/src/components/Popover/Popover.stories.ts +2 -2
  89. package/src/components/Popover/popover.ts +4 -3
  90. package/src/components/Progress/Progress.stories.ts +18 -0
  91. package/src/components/Progress/Progress.vue +58 -1
  92. package/src/components/RadioGroup/RadioGroup.vue +7 -7
  93. package/src/components/RelativeTime/RelativeTime.stories.ts +1 -1
  94. package/src/components/Select/Select.stories.ts +1 -1
  95. package/src/components/Select/Select.vue +26 -20
  96. package/src/components/SettingsRow/SettingsRow.vue +1 -1
  97. package/src/components/Sidebar/Sidebar.stories.ts +2 -2
  98. package/src/components/Sidebar/Sidebar.vue +9 -9
  99. package/src/components/Slideover/Slideover.stories.ts +5 -5
  100. package/src/components/Slideover/Slideover.vue +111 -35
  101. package/src/components/Spinner/Spinner.stories.ts +7 -7
  102. package/src/components/Spinner/Spinner.vue +1 -1
  103. package/src/components/StatTile/StatTile.stories.ts +2 -2
  104. package/src/components/StatTile/StatTile.vue +6 -6
  105. package/src/components/Steps/Steps.vue +2 -2
  106. package/src/components/SummaryList/SummaryList.vue +8 -8
  107. package/src/components/Switch/Switch.vue +3 -3
  108. package/src/components/Table/Table.vue +12 -12
  109. package/src/components/Tabs/Tabs.vue +4 -4
  110. package/src/components/ThemeSwitcher/ThemeSwitcher.stories.ts +22 -0
  111. package/src/components/ThemeSwitcher/ThemeSwitcher.vue +48 -0
  112. package/src/components/Tooltip/Tooltip.stories.ts +1 -1
  113. package/src/components/Tooltip/Tooltip.vue +1 -1
  114. package/src/components/UnsavedChangesBar/UnsavedChangesBar.stories.ts +1 -1
  115. package/src/components/UnsavedChangesBar/UnsavedChangesBar.vue +1 -1
  116. package/src/examples/AppPages.stories.ts +3 -3
  117. package/src/examples/FormLayout.stories.ts +3 -3
  118. package/src/examples/KestonIdPages.stories.ts +18 -18
  119. package/src/examples/SchoolPages.stories.ts +5 -5
  120. package/src/i18n/en.ts +16 -4
  121. package/src/index.ts +17 -0
  122. package/src/lib/chart.ts +47 -0
  123. package/src/lib/theme.ts +75 -0
  124. package/src/styles/theme.css +117 -5
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { useI18n } from 'vue-i18n'
3
- import { computed, nextTick, ref, useId, watch, type HTMLAttributes } from 'vue'
3
+ import { computed, ref, useId, watch, type HTMLAttributes } from 'vue'
4
4
  import {
5
5
  DialogClose,
6
6
  DialogContent,
@@ -30,9 +30,11 @@ import Progress from '../Progress/Progress.vue'
30
30
  *
31
31
  * Multi-step forms: pass `steps` (one name per step) and show the current
32
32
  * step's fields in the body slot, which gets `{ step }`. The header shows a
33
- * segment per step and "Step 2 of 4: Contact details"; the footer gets
34
- * Cancel / Previous and Next / Finish, unless you fill the footer slot.
35
- * Enter in a text field presses Next / Finish.
33
+ * segment per step (press a finished one to go back to it), then the title
34
+ * with the step under it (e.g. "Turn on MFA" / "Step 2 of 3 – Enter the
35
+ * code"). Changing step slides the step line, the body and the buttons. The
36
+ * footer gets Cancel / Previous and Next / Finish, unless you fill the footer
37
+ * slot. Enter in a text field presses Next / Finish.
36
38
  */
37
39
  export interface SlideoverProps {
38
40
  /** Heading of the panel. Also its accessible name, so always set it (or the title slot). */
@@ -149,24 +151,68 @@ const stepText = computed(() => (props.steps ? t('ui.slideover.stepOf', { curren
149
151
  const announcement = ref('')
150
152
  const body = ref<HTMLElement>()
151
153
 
154
+ // Changing step: the step line under the title, the body's content and the
155
+ // footer's buttons all slide and fade, one page after the other (mode out-in, so the old and new
156
+ // never overlap). Forward (Next) slides left, back slides right; 16px, inside
157
+ // the 24px padding, so nothing needs clipping. Fade only with reduced motion.
158
+ const direction = ref<'forward' | 'back'>('forward')
159
+ const stepTransition = computed(() => {
160
+ const ahead = direction.value === 'forward' ? 'translate-x-4' : '-translate-x-4'
161
+ const behind = direction.value === 'forward' ? '-translate-x-4' : 'translate-x-4'
162
+ return {
163
+ mode: 'out-in' as const,
164
+ enterActiveClass: 'transition duration-200 ease-out motion-reduce:transition-opacity',
165
+ enterFromClass: `opacity-0 motion-reduce:translate-x-0 ${ahead}`,
166
+ // pointer-events-none: a double-click can't press a button on its way out.
167
+ leaveActiveClass: 'pointer-events-none transition duration-150 ease-in motion-reduce:transition-opacity',
168
+ leaveToClass: `opacity-0 motion-reduce:translate-x-0 ${behind}`
169
+ }
170
+ })
171
+
172
+ // The new step's content only arrives once the old one has gone, so goTo
173
+ // waits for it before moving focus into it.
174
+ let stepEntered: (() => void) | undefined
175
+ function onStepEnter() {
176
+ body.value?.scrollTo({ top: 0 })
177
+ stepEntered?.()
178
+ stepEntered = undefined
179
+ }
180
+
181
+ // The footer's buttons are replaced too. If one had focus (Next / Previous),
182
+ // the new step's matching button gets it, so keyboard use carries on: Next →
183
+ // Next or Finish, Previous → Previous or Cancel.
184
+ let buttonToFocus: string | undefined
185
+ function onFooterEnter(el: Element) {
186
+ if (!buttonToFocus) return
187
+ el.querySelector<HTMLElement>(`[data-step-button="${buttonToFocus}"]`)?.focus()
188
+ buttonToFocus = undefined
189
+ }
190
+
152
191
  async function goTo(index: number) {
153
192
  // If focus is in this step's fields (e.g. Enter was pressed in one), they're
154
193
  // about to go: carry on in the new step's first control (or the panel, on
155
194
  // touch screens, so the keyboard doesn't pop up). Focus on Next / Previous
156
- // stays where it is.
195
+ // moves to the new step's matching button (onFooterEnter).
157
196
  const focusInStep = !!body.value?.contains(document.activeElement)
197
+ const panel = body.value?.closest('[role=dialog]')
198
+ const focusedButton = document.activeElement?.closest<HTMLElement>('[data-step-button]')
199
+ buttonToFocus = focusedButton && panel?.contains(focusedButton) ? focusedButton.dataset.stepButton : undefined
200
+ // A step picked on the progress bar: its button goes once you're on it.
201
+ const fromSegment = !!document.activeElement?.closest('[data-progress-segment]')
158
202
  announcement.value = ''
203
+ direction.value = index < step.value ? 'back' : 'forward'
204
+ stepEntered?.()
205
+ const entered = new Promise<void>((resolve) => (stepEntered = resolve))
159
206
  step.value = index
160
- // Start the new step from the top.
161
- body.value?.scrollTo({ top: 0 })
162
- await nextTick()
207
+ // The new step starts from the top (onStepEnter).
208
+ await entered
163
209
  const touch = window.matchMedia('(pointer: coarse)').matches
164
210
  const field = focusInStep && !touch ? body.value?.querySelector<HTMLElement>(stepControlSelector) : null
165
211
  if (field) {
166
212
  field.focus()
167
213
  return
168
214
  }
169
- if (focusInStep) body.value?.closest<HTMLElement>('[role=dialog]')?.focus()
215
+ if (focusInStep || fromSegment) body.value?.closest<HTMLElement>('[role=dialog]')?.focus()
170
216
  announcement.value = stepText.value
171
217
  }
172
218
 
@@ -262,7 +308,7 @@ const sides: Record<NonNullable<SlideoverProps['side']>, string> = {
262
308
  }
263
309
 
264
310
  const panel = [
265
- 'fixed z-50 flex flex-col bg-white text-black border-black/15 shadow-xl outline-none',
311
+ 'fixed z-50 flex flex-col bg-surface text-ink border-ink/10 shadow-xl outline-none',
266
312
  // Reduced motion: fade instead of sliding.
267
313
  'motion-reduce:data-[state=open]:animate-fade-in motion-reduce:data-[state=closed]:animate-fade-out'
268
314
  ]
@@ -293,28 +339,45 @@ const panel = [
293
339
  <slot name="content" :close="closePanel">
294
340
  <header
295
341
  v-if="title || description || close || steps || $slots.header || $slots.title"
296
- :class="cn('flex flex-col gap-4 border-b border-black/15 px-6 py-4', ui?.header)"
342
+ :class="cn('flex flex-col gap-4 border-b border-ink/10 px-6 py-4', ui?.header)"
297
343
  >
298
- <!-- The step sits above its progress bar. -->
299
- <p v-if="steps" :id="stepLabelId" class="text-sm text-black/65">
300
- Step {{ step + 1 }} of {{ stepCount }}: <span class="text-black">{{ steps[step] }}</span>
301
- </p>
302
- <Progress v-if="steps" :label="title ?? t('ui.slideover.steps')" segments :value="step + 1" :max="stepCount" />
344
+ <!-- Finished steps can be picked to go back to them. -->
345
+ <Progress
346
+ v-if="steps"
347
+ :label="title ?? t('ui.slideover.steps')"
348
+ segments
349
+ :value="step + 1"
350
+ :max="stepCount"
351
+ :segment-labels="steps"
352
+ :disabled="nextStatus === 'loading'"
353
+ @select="goTo"
354
+ />
303
355
  <div class="flex items-start gap-4">
304
356
  <slot name="header" :close="closePanel">
305
357
  <div class="flex min-w-0 flex-1 flex-col gap-1">
306
358
  <DialogTitle :class="title || $slots.title ? cn('text-lg', ui?.title) : 'sr-only'">
307
359
  <slot name="title">{{ title }}</slot>
308
360
  </DialogTitle>
361
+ <!--
362
+ Steps: "Step 2 of 4 – Contact" under the title, sliding with
363
+ the body (stepTransition). The line keeps its height (h-5)
364
+ while it's briefly empty. Hidden from screen readers, which
365
+ get "Step 2 of 4: …" instead.
366
+ -->
367
+ <div v-if="steps" class="h-5" aria-hidden="true">
368
+ <Transition v-bind="stepTransition">
369
+ <p :key="step" class="truncate text-sm text-ink/65">{{ t('ui.slideover.stepHeading', { current: step + 1, total: stepCount, name: steps[step] }) }}</p>
370
+ </Transition>
371
+ </div>
309
372
  <!-- The step is part of the description, so it's read out with
310
373
  the title when the panel opens. -->
311
374
  <DialogDescription
312
375
  v-if="description || $slots.description || steps"
313
376
  as="div"
314
- class="flex flex-col gap-1 text-sm text-black/65"
377
+ class="flex flex-col gap-1 text-sm text-ink/65"
315
378
  >
316
379
  <p v-if="description || $slots.description"><slot name="description">{{ description }}</slot></p>
317
- <p v-if="steps" class="sr-only">{{ stepText }}</p>
380
+ <p v-if="steps" :id="stepLabelId" class="sr-only">{{ stepText }}</p>
318
381
  </DialogDescription>
319
382
  <p v-if="steps" aria-live="polite" class="sr-only">{{ announcement }}</p>
320
383
  </div>
@@ -336,29 +399,42 @@ const panel = [
336
399
  :class="cn('flex-1 overflow-y-auto px-6 py-4', ui?.body)"
337
400
  @keydown.enter="onBodyEnter"
338
401
  >
339
- <slot name="body" :close="closePanel" :step="step" />
402
+ <!-- Steps: the content slides with the step line (stepTransition). -->
403
+ <Transition v-if="steps" v-bind="stepTransition" @enter="onStepEnter">
404
+ <div :key="step">
405
+ <slot name="body" :close="closePanel" :step="step" />
406
+ </div>
407
+ </Transition>
408
+ <slot v-else name="body" :close="closePanel" :step="step" />
340
409
  </div>
341
410
 
342
411
  <footer
343
412
  v-if="$slots.footer || steps"
344
- :class="cn('flex justify-end gap-2 border-t border-black/15 px-6 py-4', ui?.footer)"
413
+ :class="cn('flex justify-end gap-2 border-t border-ink/10 px-6 py-4', ui?.footer)"
345
414
  >
346
415
  <slot name="footer" :close="closePanel">
347
- <!-- Steps: Cancel or Previous on the left, Next or Finish on the right. -->
348
- <!-- One button that turns from Previous into Cancel on the first
349
- step, so keyboard focus stays on it. -->
350
- <Button
351
- class="mr-auto"
352
- :disabled="step > 0 && nextStatus === 'loading'"
353
- @click="step === 0 ? closePanel() : goTo(step - 1)"
354
- >
355
- <template v-if="step > 0" #leading><ChevronLeft /></template>
356
- {{ step === 0 ? t('ui.slideover.cancel') : t('ui.slideover.previous') }}
357
- </Button>
358
- <Button variant="primary" :status="nextStatus" @click="next">
359
- {{ isLastStep ? (finishLabel ?? t('ui.slideover.finish')) : t('ui.slideover.next') }}
360
- <template v-if="!isLastStep" #trailing><ChevronRight /></template>
361
- </Button>
416
+ <!-- Steps: Cancel or Previous on the left, Next or Finish on the
417
+ right. They slide with the step (stepTransition); the row
418
+ keeps a button's height (min-h-9.5) while it's empty. -->
419
+ <div v-if="steps" class="flex min-h-9.5 flex-1">
420
+ <Transition v-bind="stepTransition" @enter="onFooterEnter">
421
+ <div :key="step" class="flex flex-1 justify-end gap-2">
422
+ <Button
423
+ data-step-button="back"
424
+ class="mr-auto"
425
+ :disabled="step > 0 && nextStatus === 'loading'"
426
+ @click="step === 0 ? closePanel() : goTo(step - 1)"
427
+ >
428
+ <template v-if="step > 0" #leading><ChevronLeft /></template>
429
+ {{ step === 0 ? t('ui.slideover.cancel') : t('ui.slideover.previous') }}
430
+ </Button>
431
+ <Button data-step-button="next" variant="primary" :status="nextStatus" @click="next">
432
+ {{ isLastStep ? (finishLabel ?? t('ui.slideover.finish')) : t('ui.slideover.next') }}
433
+ <template v-if="!isLastStep" #trailing><ChevronRight /></template>
434
+ </Button>
435
+ </div>
436
+ </Transition>
437
+ </div>
362
438
  </slot>
363
439
  </footer>
364
440
  </slot>
@@ -14,7 +14,7 @@ const meta = {
14
14
  render: (args) => ({
15
15
  components: { Spinner },
16
16
  setup: () => ({ args }),
17
- template: '<Spinner v-bind="args" class="text-primary" />',
17
+ template: '<Spinner v-bind="args" class="text-primary-fg" />',
18
18
  }),
19
19
  } satisfies Meta<typeof Spinner>;
20
20
 
@@ -42,7 +42,7 @@ export const Filling: Story = {
42
42
  onBeforeUnmount(() => clearInterval(timer));
43
43
  return { args, value };
44
44
  },
45
- template: '<Spinner v-bind="args" :value="value" class="text-primary" />',
45
+ template: '<Spinner v-bind="args" :value="value" class="text-primary-fg" />',
46
46
  }),
47
47
  };
48
48
 
@@ -50,7 +50,7 @@ export const Sizes: Story = {
50
50
  render: () => ({
51
51
  components: { Spinner },
52
52
  template: `
53
- <div class="flex items-center gap-6 text-primary">
53
+ <div class="flex items-center gap-6 text-primary-fg">
54
54
  <Spinner size="sm" />
55
55
  <Spinner size="md" />
56
56
  <Spinner size="lg" />
@@ -67,10 +67,10 @@ export const Colours: Story = {
67
67
  components: { Spinner },
68
68
  template: `
69
69
  <div class="flex items-center gap-6">
70
- <Spinner class="text-primary" :value="70" />
71
- <Spinner class="text-green" :value="70" />
72
- <Spinner class="text-red" :value="70" />
73
- <Spinner class="text-black" />
70
+ <Spinner class="text-primary-fg" :value="70" />
71
+ <Spinner class="text-green-fg" :value="70" />
72
+ <Spinner class="text-red-fg" :value="70" />
73
+ <Spinner class="text-ink" />
74
74
  <span class="inline-flex rounded bg-primary p-2 text-white">
75
75
  <Spinner />
76
76
  </span>
@@ -11,7 +11,7 @@ import { cn } from '../../lib/cn'
11
11
  * - `value` from 0 to `max`: a ring that fills as the value goes up.
12
12
  *
13
13
  * It takes the surrounding text colour, like an icon, so put a text colour
14
- * class on it or its parent (e.g. `class="text-primary"`).
14
+ * class on it or its parent (e.g. `class="text-primary-fg"`).
15
15
  */
16
16
  export interface SpinnerProps {
17
17
  /** Progress from 0 to `max`. Leave out (or null) for a continuous spinner. */
@@ -68,7 +68,7 @@ export const WithDescriptionAndFooter: Story = {
68
68
  setup: () => ({ args }),
69
69
  template: `
70
70
  <StatTile v-bind="args">
71
- <template #footer><a href="#" class="font-bold text-primary underline-offset-2 hover:underline">View applications</a></template>
71
+ <template #footer><a href="#" class="font-bold text-primary-fg underline-offset-2 hover:underline">View applications</a></template>
72
72
  </StatTile>`,
73
73
  }),
74
74
  };
@@ -79,6 +79,6 @@ export const WithUnit: Story = {
79
79
  render: (args) => ({
80
80
  components: { StatTile },
81
81
  setup: () => ({ args }),
82
- template: `<StatTile v-bind="args"><template #value>27.4 <span class="text-sm font-normal text-black/65">students</span></template></StatTile>`,
82
+ template: `<StatTile v-bind="args"><template #value>27.4 <span class="text-sm font-normal text-ink/65">students</span></template></StatTile>`,
83
83
  }),
84
84
  };
@@ -70,7 +70,7 @@ const tone = computed(() => {
70
70
  return 'neutral'
71
71
  })
72
72
 
73
- const toneClasses = { positive: 'text-green', negative: 'text-red', neutral: 'text-black/65' } as const
73
+ const toneClasses = { positive: 'text-green-fg', negative: 'text-red-fg', neutral: 'text-ink/65' } as const
74
74
  const trendIcon = computed(() =>
75
75
  props.trend === 'up' ? ArrowUpRight : props.trend === 'down' ? ArrowDownRight : props.trend === 'flat' ? ArrowRight : undefined
76
76
  )
@@ -90,16 +90,16 @@ const trendWords = computed(() => ({ up: t('ui.statTile.up'), down: t('ui.statTi
90
90
  :class="
91
91
  cn(
92
92
  isLink &&
93
- 'relative h-full transition-[border-color,box-shadow,background-color] duration-150 motion-reduce:transition-none group-hover:border-black/40 group-hover:shadow-md group-active:bg-black/1',
93
+ 'relative h-full transition-[border-color,box-shadow,background-color] duration-150 motion-reduce:transition-none group-hover:border-ink/20 group-hover:shadow-sm group-active:bg-surface-hover',
94
94
  props.class
95
95
  )
96
96
  "
97
97
  :ui="{ body: 'gap-1' }"
98
98
  >
99
99
  <!-- Still, decorative: the link role is what screen readers get. -->
100
- <ArrowUpRight v-if="isLink" class="absolute end-4 top-4 size-4 text-black/65" aria-hidden="true" />
100
+ <ArrowUpRight v-if="isLink" class="absolute end-4 top-4 size-4 text-ink/65" aria-hidden="true" />
101
101
 
102
- <p :class="cn('flex items-center gap-2 text-sm text-black/65', isLink && 'pe-6')">
102
+ <p :class="cn('flex items-center gap-2 text-sm text-ink/65', isLink && 'pe-6')">
103
103
  <component :is="icon" v-if="icon" class="size-4 shrink-0" aria-hidden="true" />
104
104
  {{ label }}
105
105
  </p>
@@ -112,11 +112,11 @@ const trendWords = computed(() => ({ up: t('ui.statTile.up'), down: t('ui.statTi
112
112
  <component :is="trendIcon" v-if="trendIcon" class="size-4 shrink-0" aria-hidden="true" />
113
113
  <span v-if="trend" class="sr-only">{{ trendWords[trend] }}</span>
114
114
  <span v-if="change" class="font-bold tabular-nums">{{ change }}</span>
115
- <span v-if="changeLabel" class="text-black/65">&nbsp;{{ changeLabel }}</span>
115
+ <span v-if="changeLabel" class="text-ink/65">&nbsp;{{ changeLabel }}</span>
116
116
  </p>
117
117
  </div>
118
118
 
119
- <p v-if="description || $slots.description" class="text-sm text-black/65">
119
+ <p v-if="description || $slots.description" class="text-sm text-ink/65">
120
120
  <slot name="description">{{ description }}</slot>
121
121
  </p>
122
122
 
@@ -26,11 +26,11 @@ const props = defineProps<StepsProps>()
26
26
 
27
27
  <template>
28
28
  <div :class="cn('flex flex-col gap-3', props.class)">
29
- <p class="text-sm text-black/65" aria-live="polite">
29
+ <p class="text-sm text-ink/65" aria-live="polite">
30
30
  <I18nT keypath="ui.steps.stepOfNamed" scope="global" tag="span">
31
31
  <template #current>{{ step + 1 }}</template>
32
32
  <template #total>{{ steps.length }}</template>
33
- <template #name><span class="text-black">{{ steps[step] }}</span></template>
33
+ <template #name><span class="text-ink">{{ steps[step] }}</span></template>
34
34
  </I18nT>
35
35
  </p>
36
36
  <Progress :label="label" segments :value="step + 1" :max="steps.length" />
@@ -61,7 +61,7 @@ const labelWidths = {
61
61
  </script>
62
62
 
63
63
  <template>
64
- <div :class="cn('@container text-sm text-black', props.class)">
64
+ <div :class="cn('@container text-sm text-ink', props.class)">
65
65
  <dl
66
66
  :class="
67
67
  cn(
@@ -78,18 +78,18 @@ const labelWidths = {
78
78
  :key="item.label"
79
79
  :class="
80
80
  cn(
81
- 'grid grid-cols-[1fr_auto] gap-x-4 gap-y-1 border-b border-black/15 py-3 first:pt-0 last:border-b-0 last:pb-0',
81
+ 'grid grid-cols-[1fr_auto] gap-x-4 gap-y-1 border-b border-ink/10 py-3 first:pt-0 last:border-b-0 last:pb-0',
82
82
  labelWidths[labelWidth]
83
83
  )
84
84
  "
85
85
  >
86
- <dt class="col-span-2 text-black/65 @sm:col-span-1">{{ item.label }}</dt>
86
+ <dt class="col-span-2 text-ink/65 @sm:col-span-1">{{ item.label }}</dt>
87
87
  <dd :class="cn('min-w-0 break-words', item.emphasis && 'font-bold', !$slots.action && 'col-span-2')">
88
88
  <slot name="value" :item="item" :index="index">
89
89
  <template v-if="!isEmpty(item.value)">{{ item.value }}</template>
90
- <template v-else><span class="text-black/40" aria-hidden="true">—</span><span class="sr-only">{{ emptyLabel ?? t('ui.summaryList.notSet') }}</span></template>
90
+ <template v-else><span class="text-ink/40" aria-hidden="true">—</span><span class="sr-only">{{ emptyLabel ?? t('ui.summaryList.notSet') }}</span></template>
91
91
  </slot>
92
- <span v-if="item.description" class="mt-0.5 block text-black/65">{{ item.description }}</span>
92
+ <span v-if="item.description" class="mt-0.5 block text-ink/65">{{ item.description }}</span>
93
93
  </dd>
94
94
  <dd v-if="$slots.action" class="justify-self-end">
95
95
  <slot name="action" :item="item" :index="index" />
@@ -104,7 +104,7 @@ const labelWidths = {
104
104
  :key="item.label"
105
105
  :class="layout === 'compact' ? 'col-span-2 grid grid-cols-subgrid items-baseline' : 'flex min-w-0 flex-col gap-1'"
106
106
  >
107
- <dt class="text-black/65">{{ item.label }}</dt>
107
+ <dt class="text-ink/65">{{ item.label }}</dt>
108
108
  <dd
109
109
  :class="
110
110
  cn(
@@ -116,9 +116,9 @@ const labelWidths = {
116
116
  >
117
117
  <slot name="value" :item="item" :index="index">
118
118
  <template v-if="!isEmpty(item.value)">{{ item.value }}</template>
119
- <template v-else><span class="text-black/40" aria-hidden="true">—</span><span class="sr-only">{{ emptyLabel ?? t('ui.summaryList.notSet') }}</span></template>
119
+ <template v-else><span class="text-ink/40" aria-hidden="true">—</span><span class="sr-only">{{ emptyLabel ?? t('ui.summaryList.notSet') }}</span></template>
120
120
  </slot>
121
- <span v-if="item.description" class="mt-0.5 block font-normal text-black/65">{{ item.description }}</span>
121
+ <span v-if="item.description" class="mt-0.5 block font-normal text-ink/65">{{ item.description }}</span>
122
122
  <span v-if="$slots.action" class="mt-1 block font-normal"><slot name="action" :item="item" :index="index" /></span>
123
123
  </dd>
124
124
  </div>
@@ -62,7 +62,7 @@ function pressControl(event: MouseEvent, id: string) {
62
62
  // 16px. Off is a mid grey, dark enough to see against the page.
63
63
  const track = [
64
64
  'inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full p-0.5 transition-colors',
65
- 'bg-black/45 not-disabled:hover:bg-black/55 data-[state=checked]:bg-primary data-[state=checked]:hover:bg-primary',
65
+ 'bg-ink/45 not-disabled:hover:bg-ink/55 data-[state=checked]:bg-primary data-[state=checked]:hover:bg-primary',
66
66
  'disabled:cursor-not-allowed',
67
67
  'outline-2 outline-offset-2 outline-transparent focus-visible:outline-focus'
68
68
  ]
@@ -70,7 +70,7 @@ const thumb = 'size-4 rounded-full bg-white shadow-sm transition-transform data-
70
70
  </script>
71
71
 
72
72
  <template>
73
- <div :class="cn('flex flex-col gap-1.5 text-black', disabled && 'opacity-40', props.class)">
73
+ <div :class="cn('flex flex-col gap-1.5 text-ink', disabled && 'opacity-40', props.class)">
74
74
  <div class="flex items-start gap-2">
75
75
  <SwitchRoot
76
76
  :id="controlId"
@@ -88,7 +88,7 @@ const thumb = 'size-4 rounded-full bg-white shadow-sm transition-transform data-
88
88
  @click="pressControl($event, controlId)"
89
89
  >
90
90
  <label :for="controlId" :class="cn('text-sm', disabled ? 'cursor-not-allowed' : 'cursor-pointer')">{{ label }}</label>
91
- <p v-if="description" :id="descriptionId" class="text-xs text-black/65">
91
+ <p v-if="description" :id="descriptionId" class="text-xs text-ink/65">
92
92
  {{ description }}
93
93
  </p>
94
94
  </div>
@@ -175,7 +175,7 @@ const rowLinkClass = [
175
175
  'focus-visible:after:outline-focus forced-colors:not-focus-visible:after:outline-0'
176
176
  ]
177
177
  const linkedRowClass = [
178
- 'cursor-pointer hover:bg-black/5 has-[[data-row-link]:focus-visible]:bg-black/5',
178
+ 'cursor-pointer hover:bg-hover has-[[data-row-link]:focus-visible]:bg-hover',
179
179
  '[&_:is(a,button,input,select,textarea,label,[tabindex]):not([data-row-link],[data-row-overlay])]:relative',
180
180
  '[&_:is(a,button,input,select,textarea,label,[tabindex]):not([data-row-link],[data-row-overlay])]:z-1'
181
181
  ]
@@ -228,19 +228,19 @@ onBeforeUnmount(() => observer?.disconnect())
228
228
  :aria-label="scrolls && !caption && !$slots.caption ? t('ui.table.table') : undefined"
229
229
  >
230
230
  <table
231
- :class="cn('w-full border-separate border-spacing-0 text-left text-sm text-black', ui?.table)"
231
+ :class="cn('w-full border-separate border-spacing-0 text-left text-sm text-ink', ui?.table)"
232
232
  :aria-busy="loading || undefined"
233
233
  >
234
234
  <caption v-if="caption || $slots.caption" :id="captionId" :class="showCaption ? cn('px-4 pt-4 pb-2 text-left text-base font-bold', inset && 'sm:px-6') : 'sr-only'">
235
235
  <slot name="caption">{{ caption }}</slot>
236
236
  </caption>
237
237
 
238
- <thead :class="cn(stickyHeader && 'sticky top-0 z-10 bg-white', ui?.header)">
238
+ <thead :class="cn(stickyHeader && 'sticky top-0 z-10 bg-surface', ui?.header)">
239
239
  <tr>
240
240
  <th
241
241
  v-if="selectable"
242
242
  scope="col"
243
- :class="cn('border-b border-black/15', cellPadding, selectableKeys.length && selectCell)"
243
+ :class="cn('border-b border-ink/10', cellPadding, selectableKeys.length && selectCell)"
244
244
  @click="onCellPress($event, () => selectableKeys.length && setAll(allState !== true))"
245
245
  >
246
246
  <Checkbox
@@ -257,7 +257,7 @@ onBeforeUnmount(() => observer?.disconnect())
257
257
  :key="column.key"
258
258
  scope="col"
259
259
  :aria-sort="ariaSort(column)"
260
- :class="cn('border-b border-black/15 font-bold text-black/65', cellPadding, columnClasses(column))"
260
+ :class="cn('border-b border-ink/10 font-bold text-ink/65', cellPadding, columnClasses(column))"
261
261
  >
262
262
  <slot :name="`header-${column.key}`" :column="column">
263
263
  <span v-if="column.hideLabel" class="sr-only">{{ column.label }}</span>
@@ -266,9 +266,9 @@ onBeforeUnmount(() => observer?.disconnect())
266
266
  type="button"
267
267
  :class="
268
268
  cn(
269
- '-mx-1 inline-flex cursor-pointer items-center gap-1 rounded px-1 font-bold hover:text-black',
269
+ '-mx-1 inline-flex cursor-pointer items-center gap-1 rounded px-1 font-bold hover:text-ink',
270
270
  column.align === 'end' && 'flex-row-reverse',
271
- sort?.key === column.key && 'text-black',
271
+ sort?.key === column.key && 'text-ink',
272
272
  focusRing
273
273
  )
274
274
  "
@@ -277,7 +277,7 @@ onBeforeUnmount(() => observer?.disconnect())
277
277
  {{ column.label }}
278
278
  <ArrowUp v-if="sort?.key === column.key && sort.direction === 'asc'" class="size-4 shrink-0" aria-hidden="true" />
279
279
  <ArrowDown v-else-if="sort?.key === column.key" class="size-4 shrink-0" aria-hidden="true" />
280
- <ChevronsUpDown v-else class="size-4 shrink-0 text-black/40" aria-hidden="true" />
280
+ <ChevronsUpDown v-else class="size-4 shrink-0 text-ink/40" aria-hidden="true" />
281
281
  </button>
282
282
  <template v-else>{{ column.label }}</template>
283
283
  </slot>
@@ -287,7 +287,7 @@ onBeforeUnmount(() => observer?.disconnect())
287
287
 
288
288
  <tbody :class="cn(loading && shownRows.length && 'opacity-50 transition-opacity')">
289
289
  <tr v-if="!shownRows.length">
290
- <td :colspan="colspan" class="px-4 py-8 text-center text-black/65">
290
+ <td :colspan="colspan" class="px-4 py-8 text-center text-ink/65">
291
291
  <span v-if="loading" class="inline-flex items-center gap-2">
292
292
  <Spinner size="sm" />
293
293
  Loading…
@@ -304,7 +304,7 @@ onBeforeUnmount(() => observer?.disconnect())
304
304
  >
305
305
  <td
306
306
  v-if="selectable"
307
- :class="cn('border-b border-black/15 align-middle', !inset && 'group-last/row:border-b-0', cellPadding, canSelect(row) && selectCell)"
307
+ :class="cn('border-b border-ink/10 align-middle', !inset && 'group-last/row:border-b-0', cellPadding, canSelect(row) && selectCell)"
308
308
  @click="canSelect(row) && onCellPress($event, () => setRow(row, index, !isSelected(row, index)))"
309
309
  >
310
310
  <Checkbox
@@ -322,7 +322,7 @@ onBeforeUnmount(() => observer?.disconnect())
322
322
  :scope="column.rowHeader ? 'row' : undefined"
323
323
  :class="
324
324
  cn(
325
- 'border-b border-black/15 align-middle', !inset && 'group-last/row:border-b-0',
325
+ 'border-b border-ink/10 align-middle', !inset && 'group-last/row:border-b-0',
326
326
  column.rowHeader ? 'font-bold' : 'font-normal',
327
327
  column.align === 'end' && 'tabular-nums',
328
328
  cellPadding,
@@ -368,7 +368,7 @@ onBeforeUnmount(() => observer?.disconnect())
368
368
  v-if="$slots.footer"
369
369
  :class="
370
370
  cn(
371
- 'font-bold *:*:border-t *:*:border-black/15',
371
+ 'font-bold *:*:border-t *:*:border-ink/10',
372
372
  size === 'sm' ? '*:*:px-4 *:*:py-2' : '*:*:px-4 *:*:py-3',
373
373
  inset && '*:*:sm:first:pl-6 *:*:sm:last:pr-6'
374
374
  )
@@ -35,10 +35,10 @@ defineSlots<Record<string, () => unknown>>()
35
35
  // Like Sidebar's items: muted until hovered or chosen; the chosen one is
36
36
  // primary, with a bar under it that slides between tabs.
37
37
  const trigger = [
38
- 'relative inline-flex h-10 items-center gap-2 px-3 text-sm whitespace-nowrap text-black/65 outline-none',
38
+ 'relative inline-flex h-10 items-center gap-2 px-3 text-sm whitespace-nowrap text-ink/65 outline-none',
39
39
  '[&_svg]:size-4 [&_svg]:shrink-0',
40
- 'not-data-disabled:hover:text-black',
41
- 'data-[state=active]:font-bold data-[state=active]:text-primary',
40
+ 'not-data-disabled:hover:text-ink',
41
+ 'data-[state=active]:font-bold data-[state=active]:text-primary-fg',
42
42
  'focus-visible:rounded focus-visible:ring-2 focus-visible:ring-primary',
43
43
  'data-disabled:cursor-not-allowed data-disabled:opacity-40'
44
44
  ]
@@ -51,7 +51,7 @@ const trigger = [
51
51
  @update:model-value="model = String($event)"
52
52
  >
53
53
  <!-- Scrolls sideways on narrow screens rather than wrapping. -->
54
- <TabsList :aria-label="label" class="relative flex overflow-x-auto overflow-y-hidden border-b border-black/15">
54
+ <TabsList :aria-label="label" class="relative flex overflow-x-auto overflow-y-hidden border-b border-ink/10">
55
55
  <TabsTrigger v-for="t in tabs" :key="t.value" :value="t.value" :disabled="t.disabled" :class="trigger">
56
56
  <component :is="t.icon" v-if="t.icon" aria-hidden="true" />
57
57
  {{ t.label }}
@@ -0,0 +1,22 @@
1
+ import type { Meta, StoryObj } from "@storybook/vue3-vite";
2
+ import ThemeSwitcher from "./ThemeSwitcher.vue";
3
+
4
+ const meta = {
5
+ title: "Components/Form/ThemeSwitcher",
6
+ component: ThemeSwitcher,
7
+ tags: ["autodocs"],
8
+ args: { hideLabel: false, disabled: false },
9
+ decorators: [() => ({ template: '<div class="max-w-80"><story /></div>' })],
10
+ } satisfies Meta<typeof ThemeSwitcher>;
11
+
12
+ export default meta;
13
+ type Story = StoryObj<typeof meta>;
14
+
15
+ /**
16
+ * Light, Dark or Match device. The page changes as soon as one is chosen, and
17
+ * the choice is remembered in this browser. (Storybook's Theme toolbar sets
18
+ * it again when you change story.)
19
+ */
20
+ export const Default: Story = {};
21
+
22
+ export const HiddenLabel: Story = { args: { hideLabel: true } };
@@ -0,0 +1,48 @@
1
+ <script setup lang="ts">
2
+ import { computed, type HTMLAttributes } from 'vue'
3
+ import { useI18n } from 'vue-i18n'
4
+ import { Monitor, Moon, Sun } from '@lucide/vue'
5
+ import Select from '../Select/Select.vue'
6
+ import { useTheme, type Theme } from '../../lib/theme'
7
+
8
+ /**
9
+ * Chooses light, dark or matching the device, e.g. in the account menu
10
+ * (Header's `account-menu` slot) or Settings. Applies at once and is
11
+ * remembered in this browser. Call `initTheme()` in main.ts so the saved
12
+ * choice is applied before the app shows.
13
+ */
14
+ export interface ThemeSwitcherProps {
15
+ /** Visible label. Default "Appearance". */
16
+ label?: string
17
+ /** Keep the label for screen readers only. */
18
+ hideLabel?: boolean
19
+ disabled?: boolean
20
+ class?: HTMLAttributes['class']
21
+ }
22
+
23
+ const props = defineProps<ThemeSwitcherProps>()
24
+ const { t } = useI18n()
25
+ const { theme, setTheme } = useTheme()
26
+
27
+ const options = computed(() => [
28
+ { label: t('ui.themeSwitcher.light'), value: 'light', icon: Sun },
29
+ { label: t('ui.themeSwitcher.dark'), value: 'dark', icon: Moon },
30
+ { label: t('ui.themeSwitcher.system'), value: 'system', icon: Monitor }
31
+ ])
32
+
33
+ const model = computed({
34
+ get: () => theme.value,
35
+ set: (value) => setTheme(value as Theme)
36
+ })
37
+ </script>
38
+
39
+ <template>
40
+ <Select
41
+ v-model="model"
42
+ :label="label ?? t('ui.themeSwitcher.label')"
43
+ :hide-label="hideLabel"
44
+ :options="options"
45
+ :disabled="disabled"
46
+ :class="props.class"
47
+ />
48
+ </template>
@@ -50,7 +50,7 @@ export const OnText: Story = {
50
50
  <p class="text-sm">
51
51
  Fees are due by the
52
52
  <Tooltip text="Usually the first school day of each term">
53
- <span tabindex="0" class="underline decoration-black/40 decoration-dotted underline-offset-2 outline-focus focus-visible:outline-2">start of term</span>
53
+ <span tabindex="0" class="underline decoration-ink/40 decoration-dotted underline-offset-2 outline-focus focus-visible:outline-2">start of term</span>
54
54
  </Tooltip>.
55
55
  </p>`,
56
56
  }),