@7365admin1/layer-common 3.2.2 → 3.2.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 3.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - ec40e1f: Split the dark theme's `primary` into a foreground colour and a fill, so text
8
+ using it is readable again.
9
+
10
+ Dark `primary` was set to the brand navy `#17506F` so the navigation drawer
11
+ would read as a surface. That is the right value for a fill — a white label on
12
+ it measures 8.70:1 — but Vuetify emits `.text-primary` from the same token, so
13
+ every `class="text-primary"` sentence and every `color="primary"` icon, spinner
14
+ and text button rendered navy on a dark background:
15
+
16
+ | | before | now |
17
+ | ----------------------------------------------- | ------ | ---------- |
18
+ | `primary` as text on the dark page `#0E1319` | 2.14:1 | **6.40:1** |
19
+ | `primary` as text on a dark card `#1B242F` | 1.80:1 | **5.38:1** |
20
+ | `primary` as text on `surface-bright` `#26313E` | 1.52:1 | **4.53:1** |
21
+
22
+ Dark `primary` is now `#5B9BE0`. That is not a new colour: it is the blue the
23
+ camera wall already draws its accents in (`--vms-accent`), so the two dark
24
+ surfaces in this product agree on one blue.
25
+
26
+ The navigation drawer no longer depends on `primary`. Both themes gain a
27
+ `brand-surface` colour — `#042134` light (identical to light `primary`, so
28
+ light mode renders exactly as before) and `#17506F` dark — and
29
+ `Layout/NavigationDrawer.vue` is painted with it. Its white label still reads
30
+ 16.51:1 light and 8.70:1 dark. `floating` was dropped from the drawer so it
31
+ draws its own edge: the fill is 2.14:1 against the dark page, under the 3:1 a
32
+ boundary wants, and the border at `border-opacity` 0.35 is 3.22:1.
33
+
34
+ Where `primary` is still used as a fill, Vuetify derives `on-primary` from it
35
+ and picks black, which reads at 7.21:1. What a light `primary` cannot carry is
36
+ a hardcoded white label, and a handful of app-side sites still set one — see
37
+ the pull request for the list.
38
+
39
+ The light theme is unchanged. The colours moved to `utils/theme.ts` and
40
+ `utils/theme.test.ts` now measures them, so a token cannot be moved for one use
41
+ and quietly broken for the other again.
42
+
43
+ - e3dd56c: The light and dark themes are ours, not Vuetify's factory pair
44
+
45
+ Only a handful of colours were being overridden, so everything else fell through
46
+ to Vuetify's defaults. One click of the light/dark toggle threw the Seven365
47
+ brand away across all 11 web apps and replaced it with stock Material colours.
48
+
49
+ Both themes now define their full palette — surfaces, text, borders, states —
50
+ so the toggle switches between two deliberate looks instead of switching the
51
+ brand off.
52
+
53
+ The light theme is unchanged in appearance. The work is in making it explicit
54
+ rather than inherited, so a Vuetify default can no longer leak through.
55
+
56
+ ## 3.2.3
57
+
58
+ ### Patch Changes
59
+
60
+ - 55160ca: Stop crashing on a null session in comments, feedback and visitor management
61
+
62
+ Several call sites read `currentUser.value._id` (and `.serviceProvider`,
63
+ `.type`, `.givenName`, `.surname`) with no guard. When the session is briefly
64
+ absent — during sign-out, on an expired session, or before the user has
65
+ resolved on first paint — `currentUser.value` is null and the property read
66
+ throws, taking the page down rather than the one action.
67
+
68
+ Those reads are now optional. Purely defensive: where a user exists the
69
+ behaviour is identical, and where one does not the field goes undefined instead
70
+ of throwing.
71
+
72
+ Covers the feedback list and its accept/submit handlers, the visitor
73
+ check-in/check-out path, and comment loading.
74
+
3
75
  ## 3.2.2
4
76
 
5
77
  ### Patch Changes
@@ -721,9 +721,9 @@ const {
721
721
  _getFeedbacks({
722
722
  page: page.value,
723
723
  site: route.params.site as string,
724
- provider: currentUser.value.serviceProvider,
725
- ...(currentUser.value.type != "site" && {
726
- userId: currentUser.value._id,
724
+ provider: currentUser.value?.serviceProvider,
725
+ ...(currentUser.value?.type != "site" && {
726
+ userId: currentUser.value?._id,
727
727
  }),
728
728
  service: "Security",
729
729
  dateFrom: moment(startDate.value, "DD/MM/YYYY").startOf("day"),
@@ -998,9 +998,9 @@ async function handleAccept() {
998
998
  _id: feedbackData.value._id,
999
999
  statusUpdate: {
1000
1000
  status: "In-Progress",
1001
- updatedById: currentUser.value._id,
1002
- updatedByName: `${currentUser.value.givenName} ${currentUser.value.surname}`,
1003
- assignee: currentUser.value._id,
1001
+ updatedById: currentUser.value?._id,
1002
+ updatedByName: `${currentUser.value?.givenName} ${currentUser.value?.surname}`,
1003
+ assignee: currentUser.value?._id,
1004
1004
  provider: currentUser.value?.serviceProvider,
1005
1005
  },
1006
1006
  };
@@ -1158,7 +1158,7 @@ async function submit() {
1158
1158
  isSubmitting.value = true;
1159
1159
 
1160
1160
  const result = await createFeedback({
1161
- createdBy: currentUser.value._id,
1161
+ createdBy: currentUser.value?._id,
1162
1162
  description: _feedback.value.description,
1163
1163
  attachments: _feedback.value.attachments,
1164
1164
  site: route.params.site as string,
@@ -1,9 +1,41 @@
1
1
  <!-- LayoutNavigationDrawer.vue -->
2
2
  <template>
3
- <v-navigation-drawer v-model="drawer" permanent floating class="bg-primary">
3
+ <!--
4
+ `bg-brand-surface`, not `bg-primary`: `primary` is a foreground colour on a
5
+ dark page (it has to carry `class="text-primary"` sentences at 4.5:1), and a
6
+ fill that carries a label cannot also be that. `brand-surface` is a real
7
+ surface in each theme - see `utils/theme.ts` - so the drawer belongs to the
8
+ application it is in rather than being the one panel the theme switch never
9
+ reached. Its label reads 15.43:1 light, 13.21:1 dark.
10
+
11
+ NO HARDCODED LABEL COLOUR ANYWHERE IN HERE. Vuetify paints the drawer with
12
+ `on-brand-surface` and the list inside it inherits that through
13
+ `bg-transparent`, which the drawer supplies to every `v-list` it contains.
14
+ A `text-white` in here (or in an app's `#action` / `#services` slot) is
15
+ white on a light rail at 1.13:1.
16
+
17
+ `floating` dropped so the drawer draws its own edge, and the three
18
+ opacities below are raised on this element only:
19
+
20
+ - `border-opacity` 0.45. A surface is a low-contrast panel by design
21
+ (1.13:1 light, 1.19:1 dark against the page), so the edge is what carries
22
+ the boundary: 3.27:1 light, 4.33:1 dark. The theme-wide value stays where
23
+ it is; raising that would redraw every table and card edge in eleven
24
+ applications.
25
+ - `hover-opacity` 0.08. Material's 0.04 is 1.11:1 on this rail, which is
26
+ not feedback. 0.08 is 1.17:1 light, 1.24:1 dark.
27
+ - `activated-opacity` 0.18. The active item is `primary` text on a
28
+ primary-tinted fill (see `NavigationItem.vue`); 0.12 left the fill at
29
+ 1.15:1, 0.18 is 1.44:1 light, 1.33:1 dark.
30
+ -->
31
+ <v-navigation-drawer
32
+ v-model="drawer"
33
+ permanent
34
+ class="bg-brand-surface brand-drawer"
35
+ >
4
36
  <v-list>
5
37
  <v-list-item>
6
- <v-list-item-title class="text-h6 text-white">
38
+ <v-list-item-title class="text-h6">
7
39
  {{ props.title || APP_NAME }}
8
40
  </v-list-item-title>
9
41
  </v-list-item>
@@ -91,3 +123,12 @@ const handleClick = (item: any) => {
91
123
  emit("navigate", item);
92
124
  };
93
125
  </script>
126
+
127
+ <style scoped>
128
+ /* Scoped to the drawer: none of these reach the rest of the application. */
129
+ .brand-drawer {
130
+ --v-border-opacity: 0.45;
131
+ --v-hover-opacity: 0.08;
132
+ --v-activated-opacity: 0.18;
133
+ }
134
+ </style>
@@ -1,9 +1,16 @@
1
+ <!--
2
+ `color="primary"` is applied by Vuetify only while the item is active, so the
3
+ page you are on is named by colour and not just by a 1.15:1 tint you cannot
4
+ see. `primary` reads 14.56:1 on the light rail and 5.38:1 on the dark one,
5
+ and it is the one brand colour that is a foreground in both themes.
6
+ -->
1
7
  <template>
2
8
  <v-list-group v-if="children && children.length">
3
9
  <template #activator="{ props: groupProps }">
4
10
  <v-list-item
5
11
  v-bind="groupProps"
6
12
  :prepend-icon="icon"
13
+ color="primary"
7
14
  class="text-subtitle-2"
8
15
  @click.stop="onParentClick"
9
16
  >
@@ -25,6 +32,7 @@
25
32
  v-else-if="routeTo"
26
33
  :prepend-icon="icon"
27
34
  :to="routeTo"
35
+ color="primary"
28
36
  class="text-subtitle-2"
29
37
  >
30
38
  {{ title }}
@@ -34,6 +42,7 @@
34
42
  v-else-if="props.link"
35
43
  :prepend-icon="icon"
36
44
  :href="props.link"
45
+ color="primary"
37
46
  class="text-subtitle-2"
38
47
  >
39
48
  {{ title }}
@@ -1708,7 +1708,7 @@ async function handleVisitorDataFromScannedQRCodeCheckInOut(
1708
1708
  site: visitorData.site ?? siteId,
1709
1709
  },
1710
1710
  update: {
1711
- updatedBy: currentUser.value._id,
1711
+ updatedBy: currentUser.value?._id,
1712
1712
  visitorPass: visitorPass.find(
1713
1713
  (i: Record<string, any>) => i.keyId === null
1714
1714
  )
@@ -89,13 +89,13 @@ export default function useComment() {
89
89
 
90
90
  comments.value = _comments.items
91
91
  .map((comment: any) => {
92
- if (comment.createdBy === currentUser.value._id) {
92
+ if (comment.createdBy === currentUser.value?._id) {
93
93
  comment.justify = "end";
94
94
  } else {
95
95
  comment.justify = "start";
96
96
  if (
97
97
  ((Array.isArray(comment.seenBy) &&
98
- !comment.seenBy.includes(currentUser.value._id)) ||
98
+ !comment.seenBy.includes(currentUser.value?._id)) ||
99
99
  !comment?.seenBy) &&
100
100
  comment?._id
101
101
  ) {
@@ -111,7 +111,7 @@ export default function useComment() {
111
111
  );
112
112
 
113
113
  if (Array.isArray(updateSeenIds) && updateSeenIds.length > 0) {
114
- const seenBy = await updateSeenBy(updateSeenIds, currentUser.value._id);
114
+ const seenBy = await updateSeenBy(updateSeenIds, currentUser.value?._id);
115
115
  }
116
116
  } catch (error) {
117
117
  console.log("error :", error);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "3.2.2",
5
+ "version": "3.2.4",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "publishConfig": {
@@ -15,6 +15,7 @@
15
15
  "generate": "nuxt generate .playground",
16
16
  "preview": "nuxt preview .playground",
17
17
  "test": "esbuild composables/useVisitorSocket.ts --format=esm --outfile=test/.build/useVisitorSocket.mjs --log-level=error && node --test \"test/*.test.mjs\"",
18
+ "test:theme": "node --test \"utils/theme.test.ts\"",
18
19
  "release": "yarn run build && changeset publish"
19
20
  },
20
21
  "devDependencies": {
@@ -42,6 +42,8 @@ import {
42
42
  } from "vuetify-pro-tiptap";
43
43
  import "vuetify-pro-tiptap/style.css";
44
44
 
45
+ import { LIGHT_THEME, DARK_THEME } from "../utils/theme";
46
+
45
47
  export default defineNuxtPlugin((app) => {
46
48
  const vuetify = createVuetify({
47
49
  defaults: {
@@ -69,17 +71,43 @@ export default defineNuxtPlugin((app) => {
69
71
  // hint: "This field is required",
70
72
  // },
71
73
  },
74
+ /**
75
+ * THE PRODUCT HAS TWO THEMES, AND UNTIL NOW ONLY ONE OF THEM WAS OURS.
76
+ *
77
+ * Every app shows a light/dark toggle in the app bar (Layout/Header.vue),
78
+ * and it sets Vuetify's built-in "light" and "dark" themes. Those were left
79
+ * at Vuetify's factory values, so one click on any screen in any of the
80
+ * eleven apps threw the brand away: `primary` stopped being the Seven365
81
+ * navy and became Material blue #2196F3 - and `primary` is the navigation
82
+ * drawer's fill - while `primary-button` and `text-primary`, used in around
83
+ * eighty places across the layer and the apps, do not exist in a stock
84
+ * theme at all, so those components lost their colour to an undefined CSS
85
+ * variable. There was also no way back to the brand: the toggle only ever
86
+ * flipped between the two stock themes.
87
+ *
88
+ * The fix is to make the stock names OURS rather than to add new names.
89
+ * Several components already branch on `theme.global.name === "dark"` (this
90
+ * layer's FormDialog, property-management's facility icons), so a
91
+ * differently-named dark theme would have left every one of them silently
92
+ * on their light branch inside a dark app. Overriding `light` and `dark`
93
+ * means the toggle, `v-theme-provider theme="light"`, the `plain-dark`
94
+ * layout and all of those comparisons keep working, and start being right.
95
+ *
96
+ * The colours themselves, and every ratio they were chosen for, are in
97
+ * `utils/theme.ts`, which `utils/theme.test.ts` measures on every run.
98
+ */
72
99
  theme: {
73
- defaultTheme: "iservice365",
100
+ defaultTheme: "light",
74
101
  themes: {
75
- iservice365: {
76
- dark: false,
77
- colors: {
78
- primary: "#042134",
79
- "primary-button": "#1867C0",
80
- "text-primary": "#052439",
81
- },
82
- },
102
+ light: LIGHT_THEME,
103
+ dark: DARK_THEME,
104
+ /**
105
+ * The name this product booted on before the two above carried the
106
+ * brand. Kept, and identical to `light`, so anything that asks for it
107
+ * by name - in an app that is not in this repository - still gets a
108
+ * theme rather than a blank one.
109
+ */
110
+ iservice365: LIGHT_THEME,
83
111
  },
84
112
  },
85
113
  icons: {
@@ -0,0 +1,201 @@
1
+ import assert from "node:assert/strict";
2
+ import { test } from "node:test";
3
+
4
+ import { DARK_THEME, LIGHT_THEME } from "./theme.ts";
5
+
6
+ /**
7
+ * The dark theme was shipped once with `primary` chosen for the one place it
8
+ * was a fill, which left the twenty-six places it is a sentence at 1.80:1.
9
+ * These are the measurements that would have caught it.
10
+ *
11
+ * WCAG 2.1 relative luminance and contrast ratio, nothing else.
12
+ */
13
+ const luminance = (hex: string): number => {
14
+ const channels = [0, 2, 4]
15
+ .map((i) => parseInt(hex.slice(1 + i, 3 + i), 16) / 255)
16
+ .map((c) => (c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4)));
17
+
18
+ return 0.2126 * channels[0] + 0.7152 * channels[1] + 0.0722 * channels[2];
19
+ };
20
+
21
+ const contrast = (a: string, b: string): number => {
22
+ const [x, y] = [luminance(a), luminance(b)];
23
+
24
+ return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);
25
+ };
26
+
27
+ /** `fg` at `alpha` composited over `bg` - an overlay is not its raw value. */
28
+ const over = (fg: string, bg: string, alpha: number): string =>
29
+ "#" +
30
+ [0, 2, 4]
31
+ .map((i) =>
32
+ Math.round(
33
+ parseInt(fg.slice(1 + i, 3 + i), 16) * alpha +
34
+ parseInt(bg.slice(1 + i, 3 + i), 16) * (1 - alpha)
35
+ )
36
+ .toString(16)
37
+ .padStart(2, "0")
38
+ )
39
+ .join("");
40
+
41
+ const WHITE = "#FFFFFF";
42
+ const dark = DARK_THEME.colors;
43
+ const light = LIGHT_THEME.colors;
44
+
45
+ /** Sanity check on the measuring tape before it is used to judge anything. */
46
+ test("contrast is measured the way WCAG measures it", () => {
47
+ assert.equal(contrast(WHITE, "#000000").toFixed(2), "21.00");
48
+ assert.equal(contrast("#777777", WHITE).toFixed(2), "4.48");
49
+ });
50
+
51
+ test("dark primary is readable as text on the page, a card and a menu", () => {
52
+ assert.ok(
53
+ contrast(dark.primary, dark.background) >= 4.5,
54
+ `primary on the page: ${contrast(dark.primary, dark.background).toFixed(2)}`
55
+ );
56
+ assert.ok(
57
+ contrast(dark.primary, dark.surface) >= 4.5,
58
+ `primary on a card: ${contrast(dark.primary, dark.surface).toFixed(2)}`
59
+ );
60
+ assert.ok(
61
+ contrast(dark.primary, dark["surface-bright"]) >= 4.5,
62
+ `primary on surface-bright: ${contrast(
63
+ dark.primary,
64
+ dark["surface-bright"]
65
+ ).toFixed(2)}`
66
+ );
67
+ });
68
+
69
+ test("light primary is readable as text on white", () => {
70
+ assert.ok(contrast(light.primary, WHITE) >= 4.5);
71
+ assert.ok(contrast(light["text-primary"], WHITE) >= 4.5);
72
+ });
73
+
74
+ test("text-primary is readable on the surface each theme puts it on", () => {
75
+ assert.ok(contrast(dark["text-primary"], dark.background) >= 4.5);
76
+ assert.ok(contrast(dark["text-primary"], dark.surface) >= 4.5);
77
+ });
78
+
79
+ /**
80
+ * The drawer is the reason `primary` was moved in the first place. If someone
81
+ * points it back at `primary` this fails, because a foreground colour cannot
82
+ * carry the drawer's label.
83
+ */
84
+ test("the nav drawer fill carries its own label in both themes", () => {
85
+ assert.ok(
86
+ contrast(dark["on-brand-surface"], dark["brand-surface"]) >= 4.5,
87
+ `dark drawer label: ${contrast(
88
+ dark["on-brand-surface"],
89
+ dark["brand-surface"]
90
+ ).toFixed(2)}`
91
+ );
92
+ assert.ok(
93
+ contrast(light["on-brand-surface"], light["brand-surface"]) >= 4.5,
94
+ `light drawer label: ${contrast(
95
+ light["on-brand-surface"],
96
+ light["brand-surface"]
97
+ ).toFixed(2)}`
98
+ );
99
+ });
100
+
101
+ /**
102
+ * The defect this replaced: `brand-surface` was the same deep navy in both
103
+ * themes, so the drawer was the one panel the theme switch did not reach. A
104
+ * light-theme surface has to be light, a dark-theme surface has to be dark,
105
+ * and if the two are ever within 3:1 of each other the switch is invisible on
106
+ * the drawer again.
107
+ */
108
+ test("the drawer belongs to its theme, and the switch visibly changes it", () => {
109
+ assert.ok(
110
+ contrast(light["brand-surface"], WHITE) < 1.5,
111
+ "the light drawer must be a light surface, not a dark slab on a white page"
112
+ );
113
+ assert.ok(
114
+ contrast(dark["brand-surface"], dark.background) < 1.5,
115
+ "the dark drawer must sit with the dark page, not float above it"
116
+ );
117
+ assert.ok(
118
+ contrast(light["brand-surface"], dark["brand-surface"]) >= 3,
119
+ `light and dark drawers only ${contrast(
120
+ light["brand-surface"],
121
+ dark["brand-surface"]
122
+ ).toFixed(2)} apart - the switch would look like it does nothing`
123
+ );
124
+ });
125
+
126
+ /**
127
+ * The drawer's fill is deliberately close to the page, so the edge is the
128
+ * boundary and it is the thing that has to reach 3:1. 0.45 is the value
129
+ * `NavigationDrawer.vue` sets on itself; the theme-wide `border-opacity` is
130
+ * left alone.
131
+ */
132
+ test("the drawer's own edge clears the 3:1 a boundary wants", () => {
133
+ const edge = (fg: string, bg: string) => over(fg, bg, 0.45);
134
+
135
+ assert.ok(
136
+ contrast(edge("#000000", light["brand-surface"]), WHITE) >= 3,
137
+ `light drawer edge vs page: ${contrast(
138
+ edge("#000000", light["brand-surface"]),
139
+ WHITE
140
+ ).toFixed(2)}`
141
+ );
142
+ assert.ok(
143
+ contrast(edge(WHITE, dark["brand-surface"]), dark.background) >= 3,
144
+ `dark drawer edge vs page: ${contrast(
145
+ edge(WHITE, dark["brand-surface"]),
146
+ dark.background
147
+ ).toFixed(2)}`
148
+ );
149
+ });
150
+
151
+ /** The active item is named by colour, so `primary` has to be readable on it. */
152
+ test("the active nav item is readable on the drawer in both themes", () => {
153
+ assert.ok(
154
+ contrast(light.primary, light["brand-surface"]) >= 4.5,
155
+ `light: ${contrast(light.primary, light["brand-surface"]).toFixed(2)}`
156
+ );
157
+ assert.ok(
158
+ contrast(dark.primary, dark["brand-surface"]) >= 4.5,
159
+ `dark: ${contrast(dark.primary, dark["brand-surface"]).toFixed(2)}`
160
+ );
161
+ });
162
+
163
+ /**
164
+ * `v-list-subheader` is the one thing in the drawer that does NOT inherit the
165
+ * drawer's label colour - Vuetify paints it `on-surface` at medium emphasis.
166
+ * That is why apps used to hardcode `text-white` on it. It has to work
167
+ * unaided now, or those hardcodes come back.
168
+ */
169
+ test("an unstyled subheader is readable on the drawer in both themes", () => {
170
+ assert.ok(
171
+ contrast(over("#000000", light["brand-surface"], 0.6), light["brand-surface"]) >= 4.5
172
+ );
173
+ assert.ok(
174
+ contrast(over(WHITE, dark["brand-surface"], 0.6), dark["brand-surface"]) >= 4.5
175
+ );
176
+ });
177
+
178
+ test("primary-button carries a white label in both themes", () => {
179
+ assert.ok(contrast(WHITE, dark["primary-button"]) >= 4.5);
180
+ assert.ok(contrast(WHITE, light["primary-button"]) >= 4.5);
181
+ });
182
+
183
+ /**
184
+ * Both themes correct the same two Vuetify defaults, and a value that drifts
185
+ * apart between them is a bug nobody sees until they flip the switch.
186
+ */
187
+ test("disabled text clears 4.5:1 on the surface each theme puts it on", () => {
188
+ assert.equal(LIGHT_THEME.variables["disabled-opacity"], 0.55);
189
+ assert.equal(DARK_THEME.variables["disabled-opacity"], 0.55);
190
+ assert.ok(contrast(over("#000000", WHITE, 0.55), WHITE) >= 4.5);
191
+ assert.ok(
192
+ contrast(over(WHITE, dark.background, 0.55), dark.background) >= 4.5
193
+ );
194
+ });
195
+
196
+ test("the dark divider clears the 3:1 a boundary wants", () => {
197
+ const border = "#62666a"; // white at 0.35 over the dark page
198
+
199
+ assert.equal(DARK_THEME.variables["border-opacity"], 0.35);
200
+ assert.ok(contrast(border, dark.background) >= 3);
201
+ });
package/utils/theme.ts ADDED
@@ -0,0 +1,136 @@
1
+ /**
2
+ * THE TWO THEMES THIS PRODUCT SHIPS.
3
+ *
4
+ * They live here rather than inline in `plugins/vuetify.ts` so that
5
+ * `utils/theme.test.ts` can measure them. Every ratio quoted below is WCAG 2.1,
6
+ * alpha composited against the surface the value actually sits on, and the test
7
+ * re-measures the ones that matter on every run - this file has already been
8
+ * got wrong once by moving a colour for one use and forgetting the other.
9
+ *
10
+ * `disabled-opacity`: Material's 0.38 measures 2.68:1 on white, below the 4.5:1
11
+ * a sentence needs, and disabled fields in this product carry sentences people
12
+ * are expected to read. 0.55 is 4.74:1 on white and 6.21:1 on the dark page -
13
+ * the same value the camera wall settled on, for the same reason.
14
+ *
15
+ * `border-opacity`: 0.12 measures 1.32:1, which is a divider you cannot see.
16
+ * Dark goes to 0.35 (3.22:1) and carries the boundary properly. Light goes to
17
+ * 0.26 (1.88:1) - visible, but short of the 3:1 a component boundary wants.
18
+ * Reaching it on white needs 0.42, which turns every table and card edge into a
19
+ * mid-grey grid across eleven applications; that is a change somebody should
20
+ * look at before it ships, not one to slip in behind a contrast fix.
21
+ */
22
+
23
+ /**
24
+ * `primary` IS BOTH A FILL AND A FOREGROUND, AND ONE VALUE CANNOT SERVE BOTH.
25
+ *
26
+ * Vuetify emits `.bg-primary` and `.text-primary` from the same token, so the
27
+ * colour that fills the navigation drawer is also the colour of every
28
+ * `class="text-primary"` sentence, every `color="primary"` icon, spinner and
29
+ * text button, and the focused outline on every input. On a dark page those
30
+ * pull in opposite directions: a fill that carries a white label wants to be
31
+ * dark, and a foreground that is readable on a dark card wants to be light.
32
+ * There is no overlap - a value light enough for 4.5:1 text on `surface`
33
+ * (#1B242F) can carry white at 3.48:1 at the very best.
34
+ *
35
+ * So the fill is not `primary` any more. `brand-surface` below is what the
36
+ * navigation drawer is painted with, and `primary` is free to be a foreground
37
+ * colour. The foreground uses outnumber the fill uses by roughly an order of
38
+ * magnitude, which is why the split falls this way round.
39
+ */
40
+
41
+ /**
42
+ * `brand-surface` IS A SURFACE, AND A SURFACE BELONGS TO ITS THEME.
43
+ *
44
+ * It was first set to the deep brand navy in BOTH themes, which made the
45
+ * navigation drawer the one part of the product the theme switch did not
46
+ * reach: a near-black slab bolted onto a white application in light mode, and
47
+ * a lighter blue block sitting 1.80:1 off the cards beside it in dark mode. It
48
+ * belonged to neither.
49
+ *
50
+ * It is now a real surface in each theme - a light navy-tinted rail on the
51
+ * light page, the same `surface` the app bar and the cards use on the dark
52
+ * page - so the drawer reads as part of the application it is in and the
53
+ * switch visibly changes it. The brand is carried by the title and by the
54
+ * active item, which is `primary` in both themes, rather than by painting the
55
+ * whole rail.
56
+ *
57
+ * The drawer is a low-contrast panel against the page by design (1.13:1 light,
58
+ * 1.19:1 dark, exactly like every other surface in Material), so its edge is
59
+ * what carries the boundary. `NavigationDrawer.vue` raises `border-opacity` on
60
+ * itself alone to reach 3:1 there without redrawing every table and card edge
61
+ * in eleven applications.
62
+ *
63
+ * `on-brand-surface` is set explicitly rather than left to Vuetify's black or
64
+ * white, so the label is the same near-black / near-white the rest of the
65
+ * theme reads in.
66
+ */
67
+ export const LIGHT_THEME = {
68
+ dark: false,
69
+ colors: {
70
+ primary: "#042134",
71
+ /**
72
+ * The navigation drawer's own fill: a navy-tinted light rail, 1.13:1
73
+ * against the white page and carried by its own 3.27:1 edge.
74
+ */
75
+ "brand-surface": "#EDF1F7",
76
+ /** The drawer's label colour. On the rail: 15.43:1. */
77
+ "on-brand-surface": "#0B1B27",
78
+ "primary-button": "#1867C0",
79
+ "text-primary": "#052439",
80
+ },
81
+ variables: {
82
+ "disabled-opacity": 0.55,
83
+ "border-opacity": 0.26,
84
+ },
85
+ };
86
+
87
+ /**
88
+ * Only the keys that must differ; Vuetify merges the rest from its stock dark.
89
+ */
90
+ export const DARK_THEME = {
91
+ dark: true,
92
+ colors: {
93
+ /**
94
+ * Stock dark's #121212 page and #212121 surface measure 1.16:1 apart, so a
95
+ * card, a dialog and the page behind them were one flat sheet. These are
96
+ * 1.19:1 - elevation on a dark screen is a genuinely small delta - but they
97
+ * are tinted towards the brand navy rather than neutral grey, and the
98
+ * divider opacity above is what actually draws the edges.
99
+ */
100
+ background: "#0E1319",
101
+ surface: "#1B242F",
102
+ /** Stock dark ships a lavender #ccbfd6 here, which is not our product. */
103
+ "surface-bright": "#26313E",
104
+ "surface-light": "#26313E",
105
+ /**
106
+ * A FOREGROUND colour, chosen to be read: 6.40:1 on the page, 5.38:1 on a
107
+ * card, 4.53:1 on the bright surface. Not a new colour - it is the blue the
108
+ * camera wall already draws its accents in (`--vms-accent`), so the two
109
+ * dark surfaces in this product now agree on one blue.
110
+ *
111
+ * Where it is still used as a fill, Vuetify derives `on-primary` from it
112
+ * and picks black, which reads at 7.21:1. What it cannot carry is a
113
+ * hardcoded white label - see the note in the PR for the app-side sites
114
+ * that still do that.
115
+ */
116
+ primary: "#5B9BE0",
117
+ /**
118
+ * The navigation drawer's own fill. Deliberately the same value as
119
+ * `surface`: on a dark page the drawer, the app bar and the cards are the
120
+ * same material, which is what makes the rail read as part of the
121
+ * application instead of a blue block laid on top of it. The token stays
122
+ * separate from `surface` so the drawer can be moved on its own later.
123
+ */
124
+ "brand-surface": "#1B242F",
125
+ /** The drawer's label colour. On the rail: 13.21:1. */
126
+ "on-brand-surface": "#E8ECF1",
127
+ /** Unchanged on purpose: it already passes in both themes. */
128
+ "primary-button": "#1867C0",
129
+ /** #052439 on a dark page measures 1.18:1. This is 15.72:1. */
130
+ "text-primary": "#E8ECF1",
131
+ },
132
+ variables: {
133
+ "disabled-opacity": 0.55,
134
+ "border-opacity": 0.35,
135
+ },
136
+ };