@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
@@ -135,7 +135,7 @@ const titleLink = computed(() => {
135
135
  // As a link the title looks the same, with a ghost button's hover and press
136
136
  // backgrounds round it; the negative margin keeps the text where it was.
137
137
  const titleLinkClass = [
138
- '-mx-2 rounded px-2 py-1 transition-colors hover:bg-black/10 active:bg-black/15',
138
+ '-mx-2 rounded px-2 py-1 transition-colors hover:bg-hover active:bg-pressed',
139
139
  'outline-2 outline-offset-1 outline-transparent focus-visible:outline-focus forced-colors:not-focus-visible:outline-0'
140
140
  ]
141
141
 
@@ -152,7 +152,7 @@ function runAction(action: HeaderUserAction, close: () => void) {
152
152
  <template>
153
153
  <header
154
154
  :class="cn(
155
- 'flex h-12 shrink-0 items-center gap-2 border-b border-black/15 bg-white px-4 text-black',
155
+ 'flex h-12 shrink-0 items-center gap-2 border-b border-ink/10 bg-surface px-4 text-ink',
156
156
  sticky && 'sticky top-0 z-40',
157
157
  props.class
158
158
  )"
@@ -207,9 +207,9 @@ function runAction(action: HeaderUserAction, close: () => void) {
207
207
  <div class="flex flex-col">
208
208
  <!-- The organisation at the top, with a divider under it. The
209
209
  organisation slot replaces the plain heading. -->
210
- <div v-if="user.organisation || $slots.organisation" class="border-b border-black/15">
210
+ <div v-if="user.organisation || $slots.organisation" class="border-b border-ink/10">
211
211
  <slot name="organisation" :close="close">
212
- <p class="truncate px-4 py-3 text-xs font-bold text-black/65 uppercase" :title="user.organisation">
212
+ <p class="truncate px-4 py-3 text-xs font-bold text-ink/65 uppercase" :title="user.organisation">
213
213
  {{ user.organisation }}
214
214
  </p>
215
215
  </slot>
@@ -221,7 +221,7 @@ function runAction(action: HeaderUserAction, close: () => void) {
221
221
  <Avatar :user="user" size="lg" decorative />
222
222
  <div class="flex min-w-0 flex-col">
223
223
  <span class="truncate font-bold" :title="user.name">{{ user.name }}</span>
224
- <span v-if="user.email" class="truncate text-sm text-black/65" :title="user.email">{{ user.email }}</span>
224
+ <span v-if="user.email" class="truncate text-sm text-ink/65" :title="user.email">{{ user.email }}</span>
225
225
  </div>
226
226
  <Button
227
227
  v-if="userActions.includes('account-settings')"
@@ -239,7 +239,7 @@ function runAction(action: HeaderUserAction, close: () => void) {
239
239
  <!-- Switch account on the left, Log out on the right. -->
240
240
  <div
241
241
  v-if="userActions.includes('switch-account') || userActions.includes('log-out')"
242
- class="flex items-center gap-2 border-t border-black/15 px-4 py-3"
242
+ class="flex items-center gap-2 border-t border-ink/10 px-4 py-3"
243
243
  >
244
244
  <Button v-if="userActions.includes('switch-account')" @click="runAction('switch-account', close)">
245
245
  <template #leading><ArrowLeftRight /></template>
@@ -36,7 +36,7 @@ export const InTableHeading: Story = {
36
36
  setup: () => ({ args }),
37
37
  template: `
38
38
  <table class="text-sm">
39
- <thead><tr class="border-b border-black/15">
39
+ <thead><tr class="border-b border-ink/10">
40
40
  <th class="px-3 py-2 text-left font-bold">Student</th>
41
41
  <th class="px-3 py-2 text-left font-bold"><span class="inline-flex items-center gap-1">FSM <InfoTip v-bind="args" /></span></th>
42
42
  </tr></thead>
@@ -33,7 +33,7 @@ const descriptionId = `${useId()}-description`
33
33
  :aria-label="label"
34
34
  :aria-describedby="descriptionId"
35
35
  :class="cn(
36
- 'inline-flex shrink-0 rounded-full p-0.5 align-middle text-black transition hover:bg-black/10 data-[state=open]:bg-black/10',
36
+ 'inline-flex shrink-0 rounded-full p-0.5 align-middle text-ink transition hover:bg-hover data-[state=open]:bg-selected',
37
37
  'outline-2 outline-offset-1 outline-transparent focus-visible:outline-focus [&_svg]:size-4',
38
38
  props.class
39
39
  )"
@@ -87,7 +87,7 @@ const statusText = computed(() => props.statusText ?? lengthError.value)
87
87
  :disabled="disabled"
88
88
  :aria-invalid="invalid"
89
89
  :aria-describedby="describedBy"
90
- class="h-5 min-w-0 flex-1 bg-transparent outline-none placeholder:text-black/55 disabled:cursor-not-allowed"
90
+ class="h-5 min-w-0 flex-1 bg-transparent outline-none placeholder:text-ink/55 disabled:cursor-not-allowed"
91
91
  @blur="touched = true"
92
92
  />
93
93
  </template>
@@ -35,7 +35,7 @@ export const Default: Story = {};
35
35
  export const EmailCode: Story = {
36
36
  args: {
37
37
  label: "Code from your email",
38
- helper: "We sent a 6-digit code to b•••@keston.school. It expires in 10 minutes.",
38
+ helper: "We sent a 6-digit code to b***@keston.school. It expires in 10 minutes.",
39
39
  },
40
40
  };
41
41
 
@@ -92,9 +92,9 @@ const onComplete = (value: Box[]) => emit('complete', toCode(value))
92
92
  // Each box looks like FormField's box (a medium basic Button), with the
93
93
  // focus ring on the box being typed in.
94
94
  const box = [
95
- 'size-10 shrink-0 rounded border border-black/15 bg-white text-center text-lg tabular-nums text-black transition',
95
+ 'size-10 shrink-0 rounded border border-ink/45 bg-surface shadow-xs text-center text-lg tabular-nums text-ink transition',
96
96
  'outline-2 outline-offset-1 outline-transparent focus:outline-focus forced-colors:not-focus:outline-0',
97
- 'placeholder:text-black/25 disabled:cursor-not-allowed'
97
+ 'placeholder:text-ink/25 disabled:cursor-not-allowed'
98
98
  ]
99
99
  const statusBorder: Record<InputCodeStatus, string> = {
100
100
  error: 'border-red',
@@ -104,14 +104,14 @@ const statusBorder: Record<InputCodeStatus, string> = {
104
104
  </script>
105
105
 
106
106
  <template>
107
- <div :class="cn('flex flex-col gap-1.5 text-black', props.class)">
107
+ <div :class="cn('flex flex-col gap-1.5 text-ink', props.class)">
108
108
  <div class="flex flex-col gap-0.5">
109
109
  <div class="flex items-center gap-1">
110
110
  <label :id="labelId" :for="`${id}-0`" class="text-sm">{{ label }}</label>
111
111
  <InfoTip v-if="helper && helperPlacement === 'icon'" :text="helper" :label="t('ui.formField.about', { label })" />
112
112
  </div>
113
113
  <!-- Behind the ?: hidden, but still the boxes' description. -->
114
- <p v-if="helper" :id="helperId" :hidden="helperPlacement === 'icon'" class="text-xs text-black/65">
114
+ <p v-if="helper" :id="helperId" :hidden="helperPlacement === 'icon'" class="text-xs text-ink/65">
115
115
  {{ helper }}
116
116
  </p>
117
117
  </div>
@@ -25,7 +25,7 @@ const meta = {
25
25
  },
26
26
  template: `
27
27
  <InputDate v-bind="args" v-model="value" />
28
- <small class="mt-3 block text-xs text-black/60">
28
+ <small class="mt-3 block text-xs text-ink/60">
29
29
  Value: {{ value ?? "undefined" }}
30
30
  </small>`,
31
31
  }),
@@ -203,9 +203,9 @@ function onCalendarPick(value: string | undefined) {
203
203
  // InputNumber's + button. Negative margins cancel the box's padding.
204
204
  const trigger = [
205
205
  'flex w-9 shrink-0 -my-2 -mr-3 self-stretch items-center justify-center',
206
- 'rounded-r border-l border-black/15 bg-white cursor-pointer transition',
207
- 'not-disabled:hover:brightness-90 not-disabled:active:brightness-80 [&_svg]:opacity-100!',
208
- 'data-[state=open]:brightness-90 disabled:cursor-not-allowed',
206
+ 'rounded-r border-l border-ink/10 bg-surface cursor-pointer transition',
207
+ 'not-disabled:hover:bg-surface-hover not-disabled:active:bg-surface-pressed [&_svg]:opacity-100!',
208
+ 'data-[state=open]:bg-surface-pressed disabled:cursor-not-allowed',
209
209
  'outline-2 -outline-offset-2 outline-transparent focus-visible:outline-focus'
210
210
  ]
211
211
  </script>
@@ -235,14 +235,14 @@ const trigger = [
235
235
  :disabled="disabled"
236
236
  :aria-invalid="invalid"
237
237
  :aria-describedby="describedBy"
238
- class="h-5 min-w-0 flex-1 bg-transparent tabular-nums outline-none placeholder:text-black/55 disabled:cursor-not-allowed"
238
+ class="h-5 min-w-0 flex-1 bg-transparent tabular-nums outline-none placeholder:text-ink/55 disabled:cursor-not-allowed"
239
239
  @input="onTextInput"
240
240
  @blur="onTextBlur"
241
241
  @keydown.enter="onTextEnter"
242
242
  />
243
243
 
244
244
  <!-- The date a typed phrase means, e.g. "tmrw" → 11/11/2026. -->
245
- <span v-if="phrasePreview" aria-hidden="true" class="shrink-0 tabular-nums text-black/55">
245
+ <span v-if="phrasePreview" aria-hidden="true" class="shrink-0 tabular-nums text-ink/55">
246
246
  {{ phrasePreview }}
247
247
  </span>
248
248
 
@@ -25,7 +25,7 @@ const meta = {
25
25
  },
26
26
  template: `
27
27
  <InputNumber v-bind="args" v-model="value" />
28
- <small class="mt-3 block text-xs text-black/60">
28
+ <small class="mt-3 block text-xs text-ink/60">
29
29
  Value: {{ value === undefined ? "undefined" : value }}
30
30
  </small>`,
31
31
  }),
@@ -57,15 +57,15 @@ const valueText = computed(() =>
57
57
  // split from the value by a divider, so the field looks like
58
58
  // [ − | value | + ]. Negative margins cancel the box's padding (px-3 py-2), so
59
59
  // each button is 36×36 inside the 38px box. They behave like a basic Button:
60
- // white fill that darkens on hover / press, icon at full colour (the box mutes
60
+ // surface fill with the surface hover / pressed colours, icon at full colour (the box mutes
61
61
  // decorative icons). When disabled (min / max reached) only the icon fades.
62
62
  const stepButton = [
63
- 'flex w-9 shrink-0 -my-2 self-stretch items-center justify-center bg-white cursor-pointer transition',
64
- 'not-disabled:hover:brightness-90 not-disabled:active:brightness-80 [&_svg]:opacity-100!',
63
+ 'flex w-9 shrink-0 -my-2 self-stretch items-center justify-center bg-surface cursor-pointer transition',
64
+ 'not-disabled:hover:bg-surface-hover not-disabled:active:bg-surface-pressed [&_svg]:opacity-100!',
65
65
  'disabled:cursor-not-allowed disabled:[&_svg]:opacity-40!'
66
66
  ]
67
- const decrement = '-ml-3 rounded-l border-r border-black/15'
68
- const increment = '-mr-3 rounded-r border-l border-black/15'
67
+ const decrement = '-ml-3 rounded-l border-r border-ink/10'
68
+ const increment = '-mr-3 rounded-r border-l border-ink/10'
69
69
  </script>
70
70
 
71
71
  <template>
@@ -101,7 +101,7 @@ const increment = '-mr-3 rounded-r border-l border-black/15'
101
101
  :aria-invalid="invalid"
102
102
  :aria-describedby="describedBy"
103
103
  :aria-valuetext="valueText"
104
- class="h-5 min-w-0 flex-1 bg-transparent text-center tabular-nums outline-none placeholder:text-black/55 disabled:cursor-not-allowed"
104
+ class="h-5 min-w-0 flex-1 bg-transparent text-center tabular-nums outline-none placeholder:text-ink/55 disabled:cursor-not-allowed"
105
105
  />
106
106
  <NumberFieldIncrement :class="[stepButton, increment]">
107
107
  <Plus />
@@ -79,9 +79,9 @@ const statusText = computed(() => props.statusText ?? (capsLock.value ? t('ui.in
79
79
  // [ password | 👁 ]. Pressing it keeps focus (and the caret) in the input.
80
80
  const toggle = [
81
81
  'flex w-9 shrink-0 -my-2 -mr-3 self-stretch items-center justify-center',
82
- 'bg-white rounded-r border-l border-black/15 cursor-pointer transition',
83
- 'not-disabled:hover:brightness-90 not-disabled:active:brightness-80 [&_svg]:opacity-100!',
84
- 'outline-none focus-visible:bg-black/5 disabled:cursor-not-allowed'
82
+ 'bg-surface rounded-r border-l border-ink/10 cursor-pointer transition',
83
+ 'not-disabled:hover:bg-surface-hover not-disabled:active:bg-surface-pressed [&_svg]:opacity-100!',
84
+ 'outline-none focus-visible:bg-surface-hover disabled:cursor-not-allowed'
85
85
  ]
86
86
  </script>
87
87
 
@@ -114,7 +114,7 @@ const toggle = [
114
114
  :disabled="disabled"
115
115
  :aria-invalid="invalid"
116
116
  :aria-describedby="describedBy"
117
- class="h-5 min-w-0 flex-1 bg-transparent outline-none placeholder:text-black/55 disabled:cursor-not-allowed"
117
+ class="h-5 min-w-0 flex-1 bg-transparent outline-none placeholder:text-ink/55 disabled:cursor-not-allowed"
118
118
  @keydown="checkCapsLock"
119
119
  @keyup="checkCapsLock"
120
120
  @blur="capsLock = false"
@@ -23,7 +23,7 @@ const meta = {
23
23
  setup: () => ({ args, value: ref("") }),
24
24
  template: `
25
25
  <InputRichText v-bind="args" v-model="value" />
26
- <pre class="mt-4 text-xs whitespace-pre-wrap text-black/65">{{ value || '(empty)' }}</pre>`,
26
+ <pre class="mt-4 text-xs whitespace-pre-wrap text-ink/65">{{ value || '(empty)' }}</pre>`,
27
27
  }),
28
28
  } satisfies Meta<typeof InputRichText>;
29
29
 
@@ -146,7 +146,7 @@ const editable = [
146
146
  'min-h-24 max-h-80 overflow-y-auto px-3 py-2 text-sm pointer-coarse:text-base outline-none cursor-text',
147
147
  '[&_p+p]:mt-2',
148
148
  '[&_p.is-editor-empty:first-child]:before:pointer-events-none [&_p.is-editor-empty:first-child]:before:float-left',
149
- '[&_p.is-editor-empty:first-child]:before:h-0 [&_p.is-editor-empty:first-child]:before:text-black/55',
149
+ '[&_p.is-editor-empty:first-child]:before:h-0 [&_p.is-editor-empty:first-child]:before:text-ink/55',
150
150
  '[&_p.is-editor-empty:first-child]:before:content-[attr(data-placeholder)]'
151
151
  ].join(' ')
152
152
  </script>
@@ -172,7 +172,7 @@ const editable = [
172
172
  role="toolbar"
173
173
  :aria-label="t('ui.inputRichText.formattingFor', { label })"
174
174
  :aria-controls="slot.id"
175
- class="flex items-center gap-0.5 border-b border-black/15 px-1.5 py-1 [&_svg]:opacity-100!"
175
+ class="flex items-center gap-0.5 border-b border-ink/10 px-1.5 py-1 [&_svg]:opacity-100!"
176
176
  @mousedown.prevent
177
177
  >
178
178
  <Tooltip v-for="mark in marks" :key="mark.name" :text="`${mark.label} (${mod}${mark.key})`" :disabled="disabled">
@@ -184,7 +184,7 @@ const editable = [
184
184
  :aria-pressed="active[mark.name]"
185
185
  :aria-keyshortcuts="`${isMac ? 'Meta' : 'Control'}+${mark.key}`"
186
186
  :disabled="disabled"
187
- class="aria-pressed:bg-black/15"
187
+ class="aria-pressed:bg-selected"
188
188
  @click="mark.toggle()"
189
189
  >
190
190
  <component :is="mark.icon" />
@@ -82,7 +82,7 @@ defineExpose({ focus: () => area.value?.focus() })
82
82
  :disabled="disabled"
83
83
  :aria-invalid="invalid"
84
84
  :aria-describedby="describedBy"
85
- class="field-sizing-content -my-0.5 max-h-80 min-h-24 min-w-0 flex-1 resize-none bg-transparent text-sm leading-5 outline-none placeholder:text-black/55 disabled:cursor-not-allowed pointer-coarse:text-base"
85
+ class="field-sizing-content -my-0.5 max-h-80 min-h-24 min-w-0 flex-1 resize-none bg-transparent text-sm leading-5 outline-none placeholder:text-ink/55 disabled:cursor-not-allowed pointer-coarse:text-base"
86
86
  />
87
87
  </template>
88
88
  </FormField>
@@ -0,0 +1,47 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite'
2
+ import LineChart from './LineChart.vue'
3
+ import Card from '../Card/Card.vue'
4
+
5
+ const weeks = Array.from({ length: 12 }, (_, i) => ({
6
+ label: `W${i + 1}`,
7
+ fullLabel: `Week ${i + 1}`,
8
+ values: {
9
+ thisYear: [12, 18, 25, 31, 44, 52, 61, 58, 70, 83, 91, 104][i],
10
+ lastYear: [10, 14, 20, 29, 35, 41, 50, 55, 60, 66, 73, 80][i],
11
+ },
12
+ }))
13
+
14
+ const meta = {
15
+ title: 'Components/Data/LineChart',
16
+ component: LineChart,
17
+ tags: ['autodocs'],
18
+ args: {
19
+ label: 'Applications per week',
20
+ categoryLabel: 'Week',
21
+ data: weeks,
22
+ series: [
23
+ { key: 'thisYear', label: 'This year' },
24
+ { key: 'lastYear', label: 'Last year' },
25
+ ],
26
+ area: false,
27
+ },
28
+ render: (args) => ({
29
+ components: { LineChart, Card },
30
+ setup: () => ({ args }),
31
+ template: `
32
+ <Card title="Applications per week" description="This admissions round against last year's." class="max-w-2xl">
33
+ <LineChart v-bind="args" />
34
+ </Card>`,
35
+ }),
36
+ } satisfies Meta<typeof LineChart>
37
+
38
+ export default meta
39
+ type Story = StoryObj<typeof meta>
40
+
41
+ /** Two lines to compare. Hover for the values at a week; "Show as table" for all of them. */
42
+ export const Default: Story = {}
43
+
44
+ /** One line with a light wash under it. */
45
+ export const OneSeriesWithArea: Story = {
46
+ args: { series: [{ key: 'thisYear', label: 'Applications' }], area: true },
47
+ }
@@ -0,0 +1,173 @@
1
+ <script setup lang="ts">
2
+ import { computed, type HTMLAttributes } from 'vue'
3
+ import { useI18n } from 'vue-i18n'
4
+ import { cn } from '../../lib/cn'
5
+ import { niceScale, seriesColor, valueOf, type ChartPoint, type ChartSeries } from '../../lib/chart'
6
+ import ChartData from '../BarChart/ChartData.vue'
7
+
8
+ /**
9
+ * Change over time as lines: applications per week across a term,
10
+ * attendance by month. One series, or a few to compare (up to four reads
11
+ * well; past that, use separate charts).
12
+ *
13
+ * Every chart carries its numbers as a table: always there for screen
14
+ * readers, and shown to anyone with "Show as table". Hovering shows a line
15
+ * across the chart and every series' value at that point. Put it in a Card
16
+ * whose title says what it shows.
17
+ *
18
+ * Colours come from the chart palette (chart-1 to chart-8), in order unless a
19
+ * series sets its own `color`.
20
+ */
21
+ export interface LineChartProps {
22
+ /** What the chart shows, e.g. "Applications per week". The table's caption; not shown (the Card's title says it). */
23
+ label: string
24
+ /** One point per step along the bottom, in order (oldest first). */
25
+ data: ChartPoint[]
26
+ /** The lines. One series needs no legend; two or more get one. */
27
+ series: ChartSeries[]
28
+ /** A light wash under a single line, to show it as an amount. */
29
+ area?: boolean
30
+ /** Heading of the table's first column, e.g. "Week". Default "Category". */
31
+ categoryLabel?: string
32
+ /** Height of the plot in px. */
33
+ height?: number
34
+ /** How values are written on the axis, in tooltips and the table. Default: whole numbers in the app's language. */
35
+ format?: (value: number) => string
36
+ class?: HTMLAttributes['class']
37
+ }
38
+
39
+ const { t, locale } = useI18n()
40
+ const props = withDefaults(defineProps<LineChartProps>(), {
41
+ height: 160
42
+ })
43
+
44
+ const numberFormat = computed(() => new Intl.NumberFormat(locale.value))
45
+ const fmt = (value: number) => (props.format ? props.format(value) : numberFormat.value.format(value))
46
+
47
+ const scale = computed(() =>
48
+ niceScale(Math.max(0, ...props.data.flatMap((point) => props.series.map((s) => valueOf(point, s.key)))))
49
+ )
50
+
51
+ // Positions in percent of the plot: x along, y up from the bottom.
52
+ const count = computed(() => props.data.length)
53
+ const xAt = (i: number) => (count.value > 1 ? (i / (count.value - 1)) * 100 : 50)
54
+ const yAt = (value: number) => (value / scale.value.max) * 100
55
+
56
+ const lines = computed(() =>
57
+ props.series.map((s, i) => {
58
+ const points = props.data.map((point, p) => `${xAt(p)},${100 - yAt(valueOf(point, s.key))}`)
59
+ return {
60
+ series: s,
61
+ color: seriesColor(s, i),
62
+ points: points.join(' '),
63
+ // Closed down to the baseline, for the wash.
64
+ area: `0,100 ${points.join(' ')} ${xAt(count.value - 1)},100`,
65
+ last: count.value ? yAt(valueOf(props.data[count.value - 1], s.key)) : 0
66
+ }
67
+ })
68
+ )
69
+
70
+ // Labels along the bottom: at most about seven, evenly spaced, so they don't collide.
71
+ const labelEvery = computed(() => Math.max(1, Math.ceil(count.value / 7)))
72
+ // The last point is always labelled; a regular one too close to it is skipped.
73
+ const showLabel = (i: number) =>
74
+ i === count.value - 1 || (i % labelEvery.value === 0 && count.value - 1 - i >= labelEvery.value)
75
+ </script>
76
+
77
+ <template>
78
+ <div :class="cn('flex flex-col gap-3', props.class)">
79
+ <!-- The plot, hidden from screen readers: ChartData's table has the same numbers. -->
80
+ <div class="flex gap-2" aria-hidden="true">
81
+ <div class="relative w-8 shrink-0 text-right text-xs text-ink/65 tabular-nums" :style="{ height: `${height}px` }">
82
+ <span
83
+ v-for="tick in scale.ticks"
84
+ :key="tick"
85
+ class="absolute right-0 translate-y-1/2 leading-none"
86
+ :style="{ bottom: `${yAt(tick)}%` }"
87
+ >{{ fmt(tick) }}</span>
88
+ </div>
89
+
90
+ <div class="flex min-w-0 flex-1 flex-col gap-1.5">
91
+ <div class="relative" :style="{ height: `${height}px` }">
92
+ <div
93
+ v-for="tick in scale.ticks"
94
+ :key="tick"
95
+ class="absolute inset-x-0 h-px bg-ink/10"
96
+ :style="{ bottom: `${yAt(tick)}%` }"
97
+ />
98
+ <!-- Lines: stretched to the plot, with strokes kept at 2px. -->
99
+ <svg class="absolute inset-0 size-full overflow-visible" viewBox="0 0 100 100" preserveAspectRatio="none">
100
+ <polygon
101
+ v-if="area && lines.length === 1"
102
+ :points="lines[0].area"
103
+ :fill="lines[0].color"
104
+ fill-opacity="0.1"
105
+ />
106
+ <polyline
107
+ v-for="line in lines"
108
+ :key="line.series.key"
109
+ :points="line.points"
110
+ fill="none"
111
+ :stroke="line.color"
112
+ stroke-width="2"
113
+ stroke-linejoin="round"
114
+ stroke-linecap="round"
115
+ vector-effect="non-scaling-stroke"
116
+ />
117
+ </svg>
118
+ <!-- End dots: 8px, with a ring of the surface so they stand clear of the lines. -->
119
+ <span
120
+ v-for="line in lines"
121
+ :key="line.series.key"
122
+ class="absolute size-2 -translate-x-1/2 translate-y-1/2 rounded-full ring-2 ring-surface"
123
+ :style="{ left: `${xAt(count - 1)}%`, bottom: `${line.last}%`, background: line.color }"
124
+ />
125
+
126
+ <!-- Hover: a slice per point. Shows a line across, a dot on each series and the values. -->
127
+ <div
128
+ v-for="(point, i) in data"
129
+ :key="i"
130
+ class="group/point absolute inset-y-0 hover:z-20"
131
+ :style="{ left: `${count > 1 ? xAt(i) - 50 / (count - 1) : 0}%`, width: `${count > 1 ? 100 / (count - 1) : 100}%` }"
132
+ >
133
+ <div class="absolute inset-y-0 left-1/2 hidden w-px bg-ink/25 group-hover/point:block" />
134
+ <span
135
+ v-for="line in lines"
136
+ :key="line.series.key"
137
+ class="absolute left-1/2 hidden size-2 -translate-x-1/2 translate-y-1/2 rounded-full ring-2 ring-surface group-hover/point:block"
138
+ :style="{ bottom: `${yAt(valueOf(point, line.series.key))}%`, background: line.color }"
139
+ />
140
+ <div
141
+ class="pointer-events-none absolute bottom-full left-1/2 mb-1 hidden w-max max-w-56 -translate-x-1/2 flex-col gap-1 rounded-md border border-ink/10 bg-surface-elevated px-2.5 py-1.5 text-xs text-ink shadow-md group-hover/point:flex"
142
+ >
143
+ <span class="font-bold">{{ point.fullLabel ?? point.label }}</span>
144
+ <span v-for="(s, si) in series" :key="s.key" class="flex items-center gap-1.5">
145
+ <span class="size-2 rounded-full" :style="{ background: seriesColor(s, si) }" />
146
+ {{ s.label }}<span class="ml-auto pl-3 tabular-nums">{{ fmt(valueOf(point, s.key)) }}</span>
147
+ </span>
148
+ </div>
149
+ </div>
150
+ </div>
151
+ <!-- Labels along the bottom, under their points. -->
152
+ <div class="relative h-4 text-xs text-ink/65">
153
+ <template v-for="(point, i) in data" :key="i">
154
+ <span
155
+ v-if="showLabel(i)"
156
+ class="absolute whitespace-nowrap"
157
+ :class="i === 0 && count > 1 ? '' : i === count - 1 && count > 1 ? '-translate-x-full' : '-translate-x-1/2'"
158
+ :style="{ left: `${xAt(i)}%` }"
159
+ >{{ point.label }}</span>
160
+ </template>
161
+ </div>
162
+ </div>
163
+ </div>
164
+
165
+ <ChartData
166
+ :label="label"
167
+ :category-label="categoryLabel ?? t('ui.chart.category')"
168
+ :series="series"
169
+ :data="data"
170
+ :format="fmt"
171
+ />
172
+ </div>
173
+ </template>
@@ -14,7 +14,7 @@ const meta = {
14
14
  render: (args) => ({
15
15
  components: { Link },
16
16
  setup: () => ({ args }),
17
- template: `<p class="text-sm text-black"><Link :href="args.href" :new-tab="args.newTab" :icon="args.icon">{{ args.text }}</Link></p>`,
17
+ template: `<p class="text-sm text-ink"><Link :href="args.href" :new-tab="args.newTab" :icon="args.icon">{{ args.text }}</Link></p>`,
18
18
  }),
19
19
  } satisfies Meta<LinkStoryArgs>;
20
20
 
@@ -35,7 +35,7 @@ export const InASentence: Story = {
35
35
  render: () => ({
36
36
  components: { Link },
37
37
  template: `
38
- <p class="max-w-100 text-xs text-black/65">
38
+ <p class="max-w-100 text-xs text-ink/65">
39
39
  Make sure you trust Keston Admissions: read its
40
40
  <Link href="#" new-tab>privacy policy</Link> and <Link href="#" new-tab>terms</Link>.
41
41
  You can remove its access at any time in your <Link href="#">Keston account</Link>.
@@ -48,7 +48,7 @@ export const Footer: Story = {
48
48
  render: () => ({
49
49
  components: { Link },
50
50
  template: `
51
- <nav aria-label="Legal and help" class="flex items-center gap-2 text-xs text-black/65">
51
+ <nav aria-label="Legal and help" class="flex items-center gap-2 text-xs text-ink/65">
52
52
  <Link href="#" new-tab>Privacy</Link>
53
53
  <span aria-hidden="true">·</span>
54
54
  <Link href="#" new-tab>Terms</Link>
@@ -63,7 +63,7 @@ export const Sizes: Story = {
63
63
  render: () => ({
64
64
  components: { Link },
65
65
  template: `
66
- <div class="flex flex-col gap-2 text-black">
66
+ <div class="flex flex-col gap-2 text-ink">
67
67
  <p class="text-xs"><Link href="#" new-tab>Extra small</Link></p>
68
68
  <p class="text-sm"><Link href="#" new-tab>Small</Link></p>
69
69
  <p class="text-base"><Link href="#" new-tab>Base</Link></p>
@@ -33,7 +33,7 @@ const props = withDefaults(defineProps<LinkProps>(), {
33
33
  // thickens the line. Keyboard focus gets the usual focus ring.
34
34
  const base = [
35
35
  'cursor-pointer rounded-xs underline underline-offset-2 transition-colors',
36
- 'hover:text-black hover:decoration-2',
36
+ 'hover:text-ink hover:decoration-2',
37
37
  'outline-2 outline-offset-2 outline-transparent focus-visible:outline-focus'
38
38
  ]
39
39
  </script>
@@ -62,12 +62,13 @@ function attrsFor(item: MenuItem) {
62
62
  return {}
63
63
  }
64
64
 
65
- // Like Select's options: 32px rows, 8px either side, tinted like a ghost
66
- // Button when highlighted.
65
+ // Like Select's options: 32px rows running the full width of the panel,
66
+ // square (the panel keeps its rounded corners), text 12px from the edge,
67
+ // tinted when highlighted.
67
68
  const item = [
68
- 'flex min-h-8 cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm text-black no-underline outline-none select-none',
69
+ 'flex min-h-8 cursor-pointer items-center gap-2 px-3 py-1.5 text-sm text-ink no-underline outline-none select-none',
69
70
  '[&_svg]:size-4 [&_svg]:shrink-0',
70
- 'data-highlighted:bg-black/10',
71
+ 'data-highlighted:bg-selected',
71
72
  'data-disabled:cursor-not-allowed data-disabled:opacity-40'
72
73
  ]
73
74
  </script>
@@ -84,7 +85,7 @@ const item = [
84
85
  align="end"
85
86
  :side-offset="4"
86
87
  :collision-padding="8"
87
- :class="cn(popoverContent, 'min-w-48 p-1')"
88
+ :class="cn(popoverContent, 'min-w-48 overflow-hidden py-1')"
88
89
  >
89
90
  <DropdownMenuItem
90
91
  v-for="i in items"
@@ -79,8 +79,8 @@ export const Rows: Story = {
79
79
  components: { Notification },
80
80
  setup: () => ({ items: createNotifications(sampleNotifications()).items }),
81
81
  template: `
82
- <ul class="rounded border border-black/15 bg-white">
83
- <li v-for="item in items" :key="item.id" class="border-b border-black/15 last:border-b-0">
82
+ <ul class="rounded border border-ink/10 bg-surface">
83
+ <li v-for="item in items" :key="item.id" class="border-b border-ink/10 last:border-b-0">
84
84
  <Notification appearance="row" v-bind="item" :created-at="item.createdAt" :unread="!item.read" />
85
85
  </li>
86
86
  </ul>`,
@@ -171,7 +171,7 @@ export const Playground: Story = {
171
171
  <template #trailing><NotificationPane :notifications="notifications" /></template>
172
172
  </Header>
173
173
  <div class="flex flex-col gap-4 p-6">
174
- <p class="max-w-prose text-sm text-black/65">Each button sends a notification. It pops up as a toast and is added to the bell.</p>
174
+ <p class="max-w-prose text-sm text-ink/65">Each button sends a notification. It pops up as a toast and is added to the bell.</p>
175
175
  <div class="flex flex-wrap gap-2">
176
176
  <Button @click="notifications.notify(samples.info)">Info</Button>
177
177
  <Button @click="notifications.notify(samples.success)">Success</Button>
@@ -62,10 +62,10 @@ defineSlots<{
62
62
  const titleId = `${useId()}-title`
63
63
 
64
64
  const types = {
65
- info: { icon: Info, colour: 'text-blue', word: 'Information' },
66
- success: { icon: CircleCheck, colour: 'text-green', word: 'Success' },
67
- warning: { icon: TriangleAlert, colour: 'text-yellow', word: 'Warning' },
68
- error: { icon: CircleX, colour: 'text-red', word: 'Error' }
65
+ info: { icon: Info, colour: 'text-blue-fg', word: 'Information' },
66
+ success: { icon: CircleCheck, colour: 'text-green-fg', word: 'Success' },
67
+ warning: { icon: TriangleAlert, colour: 'text-yellow-fg', word: 'Warning' },
68
+ error: { icon: CircleX, colour: 'text-red-fg', word: 'Error' }
69
69
  } as const
70
70
 
71
71
  // A string, or a render function (for bold text, links).
@@ -86,11 +86,11 @@ function runAction() {
86
86
  role="group"
87
87
  :class="
88
88
  cn(
89
- 'relative flex text-sm text-black',
89
+ 'relative flex text-sm text-ink',
90
90
  oneLine ? 'items-center gap-3' : 'gap-3',
91
- appearance === 'row' ? 'px-4 py-3' : 'rounded border border-black/15 bg-white',
91
+ appearance === 'row' ? 'px-4 py-3' : 'rounded border border-ink/10 bg-surface shadow-xs',
92
92
  appearance === 'card' && (oneLine ? cn('py-1.5 pl-5', dismissible ? 'pr-1.5' : 'pr-4') : 'py-4 pr-4 pl-5'),
93
- appearance === 'row' && unread && 'bg-blue/5',
93
+ appearance === 'row' && unread && 'bg-blue-fg/5',
94
94
  props.class
95
95
  )
96
96
  "
@@ -102,11 +102,11 @@ function runAction() {
102
102
  <span class="sr-only">{{ types[type].word }}: </span>{{ title }}
103
103
  </p>
104
104
 
105
- <div v-if="!oneLine && (description || $slots.default)" class="text-black/65 [&_a]:font-bold [&_a]:text-primary [&_a]:underline [&_b]:font-bold [&_b]:text-black [&_strong]:font-bold [&_strong]:text-black">
105
+ <div v-if="!oneLine && (description || $slots.default)" class="text-ink/65 [&_a]:font-bold [&_a]:text-primary-fg [&_a]:underline [&_b]:font-bold [&_b]:text-ink [&_strong]:font-bold [&_strong]:text-ink">
106
106
  <slot><Description /></slot>
107
107
  </div>
108
108
 
109
- <p v-if="appearance === 'row' && (createdAt || unread)" class="flex items-center gap-1.5 text-xs text-black/65">
109
+ <p v-if="appearance === 'row' && (createdAt || unread)" class="flex items-center gap-1.5 text-xs text-ink/65">
110
110
  <span v-if="unread" class="size-2 shrink-0 rounded-full bg-primary" aria-hidden="true" />
111
111
  <span v-if="unread" class="sr-only">Unread, </span>
112
112
  <RelativeTime v-if="createdAt" :date="createdAt" :now="now" />