@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.14 → 2.2.0-next.16

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 (85) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +366 -354
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +39 -1
  4. package/dist/ar/chart-object-vessel-button/chart-object-vessel-button.css_inline.js +4 -8
  5. package/dist/ar/poi-button/poi-button.css_inline.js +6 -12
  6. package/dist/automation/automation-badge/automation-badge.css_inline.js +6 -0
  7. package/dist/automation/automation-badge/automation-badge.d.ts +61 -1
  8. package/dist/automation/automation-badge/automation-badge.d.ts.map +1 -1
  9. package/dist/automation/automation-badge/automation-badge.js +83 -1
  10. package/dist/automation/automation-badge/automation-badge.js.map +1 -1
  11. package/dist/automation/automation-button/abstract-automation-button.d.ts +5 -2
  12. package/dist/automation/automation-button/abstract-automation-button.d.ts.map +1 -1
  13. package/dist/automation/automation-button/abstract-automation-button.js +6 -0
  14. package/dist/automation/automation-button/abstract-automation-button.js.map +1 -1
  15. package/dist/automation/automation-readout/automation-readout.css_inline.js +4 -10
  16. package/dist/automation/automation-tank/automation-tank.css_inline.js +26 -42
  17. package/dist/automation/automation-tank/automation-tank.d.ts.map +1 -1
  18. package/dist/automation/automation-tank/automation-tank.js +7 -2
  19. package/dist/automation/automation-tank/automation-tank.js.map +1 -1
  20. package/dist/automation/bus/bus.css_inline.js +3 -6
  21. package/dist/automation/specialty-tank/abstract-specialty-tank.d.ts.map +1 -1
  22. package/dist/automation/specialty-tank/abstract-specialty-tank.js +7 -2
  23. package/dist/automation/specialty-tank/abstract-specialty-tank.js.map +1 -1
  24. package/dist/automation/specialty-tank/specialty-tank.css_inline.js +2 -4
  25. package/dist/automation/transmitter/transmitter.css_inline.js +5 -9
  26. package/dist/automation/transmitter-button/transmitter-button.css_inline.js +2 -4
  27. package/dist/automation/transmitter-stack/transmitter-stack.css_inline.js +6 -10
  28. package/dist/charthelpers/chart-legend.css_inline.js +1 -1
  29. package/dist/charthelpers/constants.d.ts +10 -10
  30. package/dist/charthelpers/constants.d.ts.map +1 -1
  31. package/dist/charthelpers/constants.js +10 -10
  32. package/dist/charthelpers/constants.js.map +1 -1
  33. package/dist/components/audio-recording-item/audio-recording-item.css_inline.js +2 -4
  34. package/dist/components/automation-button-readout-stack/automation-button-readout-stack.css_inline.js +26 -39
  35. package/dist/components/brilliance-menu/brilliance-menu.css_inline.js +10 -8
  36. package/dist/components/command-menu/command-menu.css_inline.js +8 -4
  37. package/dist/components/number-input-field/number-input-field.css_inline.js +5 -9
  38. package/dist/components/progress-bar/progress-bar.css_inline.js +10 -20
  39. package/dist/components/sequence-card/sequence-card.css_inline.js +21 -26
  40. package/dist/components/sequence-item/sequence-item.css_inline.js +8 -16
  41. package/dist/components/sequence-modal/sequence-modal.css_inline.js +5 -4
  42. package/dist/components/sequence-step/sequence-step.css_inline.js +6 -12
  43. package/dist/components/system-menu/system-menu.css_inline.js +10 -8
  44. package/dist/components/text-input-field/text-input-field.css_inline.js +2 -4
  45. package/dist/integration-systems/integration-fleet-button/integration-fleet-button.css_inline.js +8 -9
  46. package/dist/navigation-instruments/compass-indicator/compass-indicator.js +3 -3
  47. package/dist/navigation-instruments/compass-indicator/compass-indicator.js.map +1 -1
  48. package/dist/navigation-instruments/instrument-field/instrument-field.css_inline.js +26 -28
  49. package/package.json +3 -2
  50. package/script/check-typography-ramp.ts +144 -0
  51. package/script/typography/ramp.ts +237 -0
  52. package/script/typography-ramp.test.ts +267 -0
  53. package/src/ar/chart-object-vessel-button/chart-object-vessel-button.css +2 -2
  54. package/src/ar/poi-button/poi-button.css +3 -3
  55. package/src/automation/analog-valve/analog-valve.stories.ts +8 -0
  56. package/src/automation/automation-badge/automation-badge.css +6 -0
  57. package/src/automation/automation-badge/automation-badge.stories.ts +47 -3
  58. package/src/automation/automation-badge/automation-badge.ts +124 -1
  59. package/src/automation/automation-button/abstract-automation-button.ts +13 -0
  60. package/src/automation/automation-readout/automation-readout.css +2 -2
  61. package/src/automation/automation-tank/automation-tank.css +10 -10
  62. package/src/automation/automation-tank/automation-tank.ts +11 -6
  63. package/src/automation/bus/bus.css +2 -1
  64. package/src/automation/specialty-tank/abstract-specialty-tank.ts +11 -6
  65. package/src/automation/specialty-tank/specialty-tank.css +1 -1
  66. package/src/automation/transmitter-button/transmitter-button.css +1 -1
  67. package/src/automation/transmitter-stack/transmitter-stack.css +1 -1
  68. package/src/charthelpers/chart-legend.css +1 -1
  69. package/src/charthelpers/constants.ts +11 -10
  70. package/src/components/audio-recording-item/audio-recording-item.css +1 -1
  71. package/src/components/automation-button-readout-stack/automation-button-readout-stack.css +8 -8
  72. package/src/components/brilliance-menu/brilliance-menu.css +2 -2
  73. package/src/components/command-menu/command-menu.css +1 -1
  74. package/src/components/number-input-field/number-input-field.css +2 -2
  75. package/src/components/progress-bar/progress-bar.css +5 -5
  76. package/src/components/sequence-card/sequence-card.css +13 -11
  77. package/src/components/sequence-item/sequence-item.css +4 -4
  78. package/src/components/sequence-modal/sequence-modal.css +1 -1
  79. package/src/components/sequence-step/sequence-step.css +3 -3
  80. package/src/components/system-menu/system-menu.css +2 -2
  81. package/src/integration-systems/integration-fleet-button/integration-fleet-button.css +2 -2
  82. package/src/mixins/base-input-field.css +1 -1
  83. package/src/mixins/transmitter.css +5 -1
  84. package/src/navigation-instruments/compass-indicator/compass-indicator.ts +3 -3
  85. package/src/navigation-instruments/instrument-field/instrument-field.css +7 -7
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Fails when a component reads a font-size or line-height token that a size
3
+ * class leaves undeclared, at 0, or smaller than the class before it, so its
4
+ * text keeps the regular size, disappears or shrinks there (see
5
+ * `typography/ramp.ts`).
6
+ *
7
+ * ```bash
8
+ * npm run lint:typography
9
+ * ```
10
+ *
11
+ * A token the design file cannot fill yet goes in `KNOWN_GAPS` with the size
12
+ * classes it gaps in and the issue that tracks it; the entry fails as stale
13
+ * once the export carries the value.
14
+ */
15
+ import * as fs from 'fs';
16
+ import * as path from 'path';
17
+ import {globby} from 'globby';
18
+ import {maskCssText} from './css/mask.js';
19
+ import {stripComments} from './source-links.js';
20
+ import {
21
+ type KnownGap,
22
+ type RampGap,
23
+ mixinTokens,
24
+ rampGaps,
25
+ readPalette,
26
+ readTokens,
27
+ } from './typography/ramp.js';
28
+
29
+ const SKYPLOT = 'src/navigation-instruments/gnss-skyplot/gnss-skyplot.css';
30
+ const GENERAL_SIZES =
31
+ 'the General styles have no medium, large or xl sizes in the design file; obc-gnss-skyplot reads them by design and keeps its regular size there (#1420)';
32
+ const UI_TITLE_XL = 'UI/Title has no XL value in the design file (#1422)';
33
+ const AUTOMATION_XL =
34
+ 'the automation styles carry their regular sizes in the XL mode of the design file, smaller than in large (#1422)';
35
+
36
+ /** Token → the size classes it gaps in, the readers that may keep reading it if only some, and why. */
37
+ const KNOWN_GAPS: Record<string, KnownGap> = {
38
+ '--global-typography-general-xs-font-size': {
39
+ classes: ['medium', 'large', 'xl'],
40
+ readers: [SKYPLOT],
41
+ reason: GENERAL_SIZES,
42
+ },
43
+ '--global-typography-general-xs-line-height': {
44
+ classes: ['medium', 'large', 'xl'],
45
+ readers: [SKYPLOT],
46
+ reason: GENERAL_SIZES,
47
+ },
48
+ '--global-typography-ui-title-font-size': {
49
+ classes: ['xl'],
50
+ reason: UI_TITLE_XL,
51
+ },
52
+ '--global-typography-ui-title-line-height': {
53
+ classes: ['xl'],
54
+ reason: UI_TITLE_XL,
55
+ },
56
+ '--automation-components-typography-unit-regular-font-size': {
57
+ classes: ['xl'],
58
+ reason: AUTOMATION_XL,
59
+ },
60
+ '--automation-components-typography-label-font-size': {
61
+ classes: ['xl'],
62
+ reason: AUTOMATION_XL,
63
+ },
64
+ '--automation-components-typography-label-line-height': {
65
+ classes: ['xl'],
66
+ reason: AUTOMATION_XL,
67
+ },
68
+ '--global-typography-instrument-value-medium-font-size': {
69
+ classes: ['xl'],
70
+ reason:
71
+ 'Instrument/Value medium is 36 px in the XL mode of the design file, smaller than 44 px in large (#1422)',
72
+ },
73
+ };
74
+
75
+ function gapText(gap: RampGap): string {
76
+ switch (gap.kind) {
77
+ case 'missing':
78
+ return 'not declared';
79
+ case 'zero':
80
+ return gap.value ?? '0';
81
+ case 'shrinks':
82
+ return `${gap.sizes?.[0]}, smaller than the ${gap.sizes?.[1]} of the class before,`;
83
+ }
84
+ }
85
+
86
+ async function run(): Promise<void> {
87
+ const root = process.cwd();
88
+ const read = (file: string) => fs.readFileSync(path.join(root, file), 'utf8');
89
+ const mixinFiles = await globby('src/mixins/*.css', {cwd: root});
90
+ const mixins = mixinTokens(mixinFiles.map((f) => maskCssText(read(f))));
91
+ const files = await globby(['src/**/*.css', 'src/**/*.ts'], {
92
+ cwd: root,
93
+ ignore: [
94
+ 'src/palettes/**',
95
+ 'src/mixins/**',
96
+ 'src/icons/**',
97
+ 'src/generated/**',
98
+ 'src/**/*.stories.ts',
99
+ 'src/**/*.spec.ts',
100
+ ],
101
+ });
102
+ const readers = new Map<string, Set<string>>();
103
+ for (const file of files.sort()) {
104
+ const text = file.endsWith('.css')
105
+ ? maskCssText(read(file))
106
+ : stripComments(read(file));
107
+ for (const token of readTokens(text, mixins)) {
108
+ readers.set(token, (readers.get(token) ?? new Set()).add(file));
109
+ }
110
+ }
111
+ const palette = readPalette(read('src/palettes/variables.css'));
112
+ const {gaps, stale} = rampGaps(readers, palette, KNOWN_GAPS);
113
+ const sizeTokens = Array.from(readers.keys()).filter(
114
+ (t) =>
115
+ /-(?:font-size|line-height)$/.test(t) && palette.classes.regular.has(t)
116
+ );
117
+
118
+ console.log(
119
+ `typography ramp: ${sizeTokens.length} size tokens read by ${files.length} files, ${Object.keys(KNOWN_GAPS).length} known gaps`
120
+ );
121
+ for (const gap of gaps) {
122
+ const where = gap.readers.slice(0, 3).join(', ');
123
+ const more = gap.readers.length > 3 ? ` +${gap.readers.length - 3}` : '';
124
+ console.error(
125
+ ` - ${gap.token} is ${gapText(gap)} in .obc-component-size-${gap.sizeClass}, read by ${where}${more}`
126
+ );
127
+ }
128
+ for (const entry of stale) {
129
+ console.error(
130
+ ` - KNOWN_GAPS lists ${entry.token}, but ${entry.detail}; narrow or delete the entry`
131
+ );
132
+ }
133
+ if (gaps.length || stale.length) {
134
+ console.error(
135
+ '\n[lint:typography] text on these tokens keeps its regular size, disappears or shrinks in that class. Keep it on a style whose variables carry every size class (IMPLEMENTATION_GUIDELINES.md § Instrument and automation fonts), or list the token in KNOWN_GAPS with the issue that tracks the design file.'
136
+ );
137
+ process.exit(1);
138
+ }
139
+ console.log(
140
+ '✅ every size token components read has a value in every size class and never shrinks.'
141
+ );
142
+ }
143
+
144
+ run();
@@ -0,0 +1,237 @@
1
+ /**
2
+ * @module TypographyRamp
3
+ * @description
4
+ * The size classes (`.obc-component-size-regular` / `-medium` / `-large` /
5
+ * `-xl`) scale text through the font-size and line-height tokens each class
6
+ * block of `src/palettes/variables.css` declares. A token a block does not
7
+ * declare keeps the regular value there, a token the export leaves at 0 hides
8
+ * the text, and a value smaller than the class before it shrinks the text as
9
+ * the class grows. The first went unnoticed until a consumer found the text
10
+ * stuck at the regular size (#1420). `rampGaps()` lists all three for the
11
+ * tokens components read, directly or through a mixin;
12
+ * `check-typography-ramp.ts` fails on them.
13
+ */
14
+ import type {Declarations} from '../palette/export.js';
15
+ import {parseDeclarations, parseTopLevelBlocks} from '../palette/export.js';
16
+
17
+ export const SIZE_CLASSES = ['regular', 'medium', 'large', 'xl'] as const;
18
+ export type SizeClass = (typeof SIZE_CLASSES)[number];
19
+
20
+ const TOKEN_RE = /--[\w-]+/g;
21
+ const SIZE_TOKEN_RE = /-(?:font-size|line-height)$/;
22
+ const MIXIN_NAME_RE = /@define-mixin\s+([\w-]+)[^;{}]*$/;
23
+ const MIXIN_USE_RE = /@mixin\s+([\w-]+)/g;
24
+ const LENGTH_RE = /^([+-]?(?:\d+\.?\d*|\.\d+))([a-z%]*)$/i;
25
+ const VAR_RE = /^var\((--[\w-]+)\)$/;
26
+
27
+ function tokensIn(text: string): Set<string> {
28
+ return new Set(text.match(TOKEN_RE) ?? []);
29
+ }
30
+
31
+ /**
32
+ * Mixin name → the custom properties its body reads, nested rules and the
33
+ * mixins it applies included.
34
+ */
35
+ export function mixinTokens(mixinSources: string[]): Map<string, Set<string>> {
36
+ const direct = new Map<string, Set<string>>();
37
+ const applies = new Map<string, string[]>();
38
+ for (const source of mixinSources) {
39
+ for (const block of parseTopLevelBlocks(source)) {
40
+ const name = block.selector.match(MIXIN_NAME_RE)?.[1];
41
+ if (!name) continue;
42
+ direct.set(name, tokensIn(block.body));
43
+ applies.set(
44
+ name,
45
+ Array.from(block.body.matchAll(MIXIN_USE_RE), (use) => use[1])
46
+ );
47
+ }
48
+ }
49
+ const resolved = new Map<string, Set<string>>();
50
+ const resolve = (name: string, seen: Set<string>): Set<string> => {
51
+ const cached = resolved.get(name);
52
+ if (cached) return cached;
53
+ const tokens = new Set(direct.get(name) ?? []);
54
+ for (const inner of applies.get(name) ?? []) {
55
+ if (seen.has(inner)) continue;
56
+ for (const t of resolve(inner, new Set([...seen, inner]))) tokens.add(t);
57
+ }
58
+ resolved.set(name, tokens);
59
+ return tokens;
60
+ };
61
+ for (const name of direct.keys()) resolve(name, new Set([name]));
62
+ return resolved;
63
+ }
64
+
65
+ /**
66
+ * The custom properties a source file reads: every name in it (inside `var()`
67
+ * or as a bare string, as `charthelpers/constants.ts` keeps them) and those of
68
+ * every mixin it applies. Mask comments first, or a name in one counts.
69
+ */
70
+ export function readTokens(
71
+ text: string,
72
+ mixins: Map<string, Set<string>>
73
+ ): Set<string> {
74
+ const tokens = tokensIn(text);
75
+ for (const m of text.matchAll(MIXIN_USE_RE)) {
76
+ for (const t of mixins.get(m[1]) ?? []) tokens.add(t);
77
+ }
78
+ return tokens;
79
+ }
80
+
81
+ export interface Palette {
82
+ /** The declarations of each size-class block. */
83
+ classes: Record<SizeClass, Declarations>;
84
+ /** Every declaration outside them, the first one winning: what a size token's `var()` points at. */
85
+ primitives: Declarations;
86
+ }
87
+
88
+ export function readPalette(variablesCss: string): Palette {
89
+ const blocks = parseDeclarations(variablesCss);
90
+ const classes = {} as Record<SizeClass, Declarations>;
91
+ const owners = new Set<Declarations>();
92
+ for (const sizeClass of SIZE_CLASSES) {
93
+ const selector = `.obc-component-size-${sizeClass}`;
94
+ const found = Array.from(blocks.entries()).find(([s]) =>
95
+ s.split(',').some((part) => part.trim() === selector)
96
+ );
97
+ if (!found) throw new Error(`variables.css has no ${selector} block`);
98
+ classes[sizeClass] = found[1];
99
+ owners.add(found[1]);
100
+ }
101
+ const primitives: Declarations = new Map();
102
+ for (const declarations of blocks.values()) {
103
+ if (owners.has(declarations)) continue;
104
+ for (const [name, value] of declarations) {
105
+ if (!primitives.has(name)) primitives.set(name, value);
106
+ }
107
+ }
108
+ return {classes, primitives};
109
+ }
110
+
111
+ export interface Length {
112
+ n: number;
113
+ unit: string;
114
+ }
115
+
116
+ /** A value as a number and its unit, following `var()` through the class block and the primitives. */
117
+ export function resolveLength(
118
+ value: string | undefined,
119
+ block: Declarations,
120
+ primitives: Declarations
121
+ ): Length | undefined {
122
+ for (let depth = 0; value !== undefined && depth < 8; depth++) {
123
+ const ref = value.match(VAR_RE);
124
+ if (!ref) break;
125
+ value = block.get(ref[1]) ?? primitives.get(ref[1]);
126
+ }
127
+ const m = value?.match(LENGTH_RE);
128
+ return m ? {n: Number(m[1]), unit: m[2].toLowerCase()} : undefined;
129
+ }
130
+
131
+ export type GapKind = 'missing' | 'zero' | 'shrinks';
132
+
133
+ export interface RampGap {
134
+ token: string;
135
+ sizeClass: SizeClass;
136
+ kind: GapKind;
137
+ /** The declared value, `undefined` when the block does not declare the token. */
138
+ value: string | undefined;
139
+ /** For `shrinks`: the resolved value here and in the class before. */
140
+ sizes?: [string, string];
141
+ readers: string[];
142
+ }
143
+
144
+ export interface KnownGap {
145
+ /** The size classes the gap is accepted in. */
146
+ classes: SizeClass[];
147
+ /** When set, the only files the gap is accepted for; any other reader is reported. */
148
+ readers?: string[];
149
+ /** Why, with the issue that tracks it. */
150
+ reason: string;
151
+ }
152
+
153
+ export interface StaleEntry {
154
+ token: string;
155
+ detail: string;
156
+ }
157
+
158
+ export interface RampReport {
159
+ gaps: RampGap[];
160
+ /** Known-gap entries that accept more than is still a gap, so they get narrowed or deleted. */
161
+ stale: StaleEntry[];
162
+ }
163
+
164
+ const show = (length: Length) => `${length.n}${length.unit}`;
165
+
166
+ /**
167
+ * Every font-size or line-height token of the size classes that a file reads
168
+ * and that a class leaves undeclared, at 0, or smaller than the class before,
169
+ * minus what `known` accepts; a known entry that accepts more than is still a
170
+ * gap comes back as stale.
171
+ */
172
+ export function rampGaps(
173
+ readers: Map<string, Set<string>>,
174
+ palette: Palette,
175
+ known: Record<string, KnownGap> = {}
176
+ ): RampReport {
177
+ const gaps: RampGap[] = [];
178
+ const stale: StaleEntry[] = [];
179
+ for (const [token, files] of readers) {
180
+ if (!SIZE_TOKEN_RE.test(token)) continue;
181
+ if (!SIZE_CLASSES.some((c) => palette.classes[c].has(token))) continue;
182
+ const entry = known[token];
183
+ const sortedFiles = Array.from(files).sort();
184
+ let previous: Length | undefined;
185
+ for (const sizeClass of SIZE_CLASSES) {
186
+ const block = palette.classes[sizeClass];
187
+ const declared = block.get(token);
188
+ const length = resolveLength(
189
+ declared ?? palette.classes.regular.get(token),
190
+ block,
191
+ palette.primitives
192
+ );
193
+ let kind: GapKind | undefined;
194
+ if (declared === undefined) kind = 'missing';
195
+ else if (length?.n === 0) kind = 'zero';
196
+ else if (
197
+ length &&
198
+ previous &&
199
+ length.unit === previous.unit &&
200
+ length.n < previous.n
201
+ ) {
202
+ kind = 'shrinks';
203
+ }
204
+ const accepted = entry?.classes.includes(sizeClass) ?? false;
205
+ if (accepted && !kind) {
206
+ stale.push({token, detail: `it has a value in ${sizeClass}`});
207
+ }
208
+ if (kind) {
209
+ const allowed = accepted ? (entry?.readers ?? sortedFiles) : [];
210
+ const extra = sortedFiles.filter((f) => !allowed.includes(f));
211
+ if (extra.length) {
212
+ gaps.push({
213
+ token,
214
+ sizeClass,
215
+ kind,
216
+ value: declared,
217
+ sizes:
218
+ kind === 'shrinks' && length && previous
219
+ ? [show(length), show(previous)]
220
+ : undefined,
221
+ readers: extra,
222
+ });
223
+ }
224
+ }
225
+ if (length) previous = length;
226
+ }
227
+ for (const reader of entry?.readers ?? []) {
228
+ if (!files.has(reader)) {
229
+ stale.push({token, detail: `${reader} no longer reads it`});
230
+ }
231
+ }
232
+ }
233
+ for (const token of Object.keys(known)) {
234
+ if (!readers.has(token)) stale.push({token, detail: 'nothing reads it'});
235
+ }
236
+ return {gaps, stale};
237
+ }
@@ -0,0 +1,267 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import {stripComments} from './source-links.js';
3
+ import {
4
+ mixinTokens,
5
+ rampGaps,
6
+ readPalette,
7
+ readTokens,
8
+ resolveLength,
9
+ } from './typography/ramp.js';
10
+
11
+ const VARIABLES = `:root,
12
+ .obc-component-size-regular {
13
+ --global-typography-value-font-size: var(--font-size-100);
14
+ --global-typography-value-line-height: 20px;
15
+ --global-typography-value-font-weight: 570;
16
+ --global-typography-label-font-size: 12px;
17
+ --global-typography-title-font-size: 24px;
18
+ --automation-components-typography-unit-font-size: var(--font-size-100);
19
+ }
20
+ .obc-component-size-medium {
21
+ --global-typography-value-font-size: 22px;
22
+ --global-typography-value-line-height: 24px;
23
+ --global-typography-value-font-weight: 0;
24
+ --global-typography-title-font-size: 32px;
25
+ --automation-components-typography-unit-font-size: 24px;
26
+ }
27
+ .obc-component-size-large {
28
+ --global-typography-value-font-size: 34px;
29
+ --global-typography-value-line-height: 32px;
30
+ --global-typography-label-font-size: 22px;
31
+ --global-typography-title-font-size: 44px;
32
+ --automation-components-typography-unit-font-size: 32px;
33
+ }
34
+ .obc-component-size-xl {
35
+ --global-typography-value-font-size: 40px;
36
+ --global-typography-value-line-height: 48px;
37
+ --global-typography-label-font-size: 32px;
38
+ --global-typography-title-font-size: 0.0px;
39
+ --automation-components-typography-unit-font-size: var(--font-size-100);
40
+ }
41
+ * {
42
+ --font-size-100: 16px;
43
+ }
44
+ `;
45
+
46
+ const MIXINS = `@define-mixin font-value {
47
+ font-size: var(--global-typography-value-font-size);
48
+ line-height: var(--global-typography-value-line-height);
49
+ font-weight: var(--global-typography-value-font-weight);
50
+ }
51
+ @define-mixin font-label {
52
+ font-size: var(--global-typography-label-font-size);
53
+ }
54
+ @define-mixin value-tag {
55
+ @mixin font-label;
56
+ color: red;
57
+ }
58
+ @define-mixin empty-state {
59
+ .icon {
60
+ height: 96px;
61
+ }
62
+ .title {
63
+ @mixin font-label;
64
+ }
65
+ }
66
+ @define-mixin style $style, $wrapper: .x {
67
+ outline: 1px solid var(--global-typography-title-font-size);
68
+ }
69
+ `;
70
+
71
+ const mixins = mixinTokens([MIXINS]);
72
+ const palette = readPalette(VARIABLES);
73
+
74
+ describe('mixinTokens', () => {
75
+ it('collects the tokens of a mixin and of the mixins it applies', () => {
76
+ expect(mixins.get('font-value')).toEqual(
77
+ new Set([
78
+ '--global-typography-value-font-size',
79
+ '--global-typography-value-line-height',
80
+ '--global-typography-value-font-weight',
81
+ ])
82
+ );
83
+ expect(mixins.get('value-tag')).toEqual(
84
+ new Set(['--global-typography-label-font-size'])
85
+ );
86
+ expect(mixins.get('style')).toEqual(
87
+ new Set(['--global-typography-title-font-size'])
88
+ );
89
+ });
90
+
91
+ it('reads the whole body, past a nested rule', () => {
92
+ expect(mixins.get('empty-state')).toEqual(
93
+ new Set(['--global-typography-label-font-size'])
94
+ );
95
+ });
96
+ });
97
+
98
+ describe('readTokens', () => {
99
+ it('reads var() uses, bare names in TypeScript and applied mixins', () => {
100
+ expect(
101
+ readTokens(
102
+ '.a {\n @mixin value-tag;\n height: var(--global-typography-value-line-height);\n}\n',
103
+ mixins
104
+ )
105
+ ).toEqual(
106
+ new Set([
107
+ '--global-typography-label-font-size',
108
+ '--global-typography-value-line-height',
109
+ ])
110
+ );
111
+ expect(
112
+ readTokens(
113
+ "const VALUE = {fontSizeVar: '--global-typography-value-font-size'};",
114
+ mixins
115
+ )
116
+ ).toEqual(new Set(['--global-typography-value-font-size']));
117
+ });
118
+
119
+ it('does not count a name in a TypeScript comment once comments are stripped', () => {
120
+ const source =
121
+ "// was --global-typography-title-font-size\nconst a = '--global-typography-value-font-size';";
122
+ expect(readTokens(stripComments(source), mixins)).toEqual(
123
+ new Set(['--global-typography-value-font-size'])
124
+ );
125
+ });
126
+ });
127
+
128
+ describe('readPalette', () => {
129
+ it('finds the four blocks, the regular one shared with :root, and the primitives', () => {
130
+ expect(
131
+ palette.classes.regular.get('--global-typography-value-font-size')
132
+ ).toBe('var(--font-size-100)');
133
+ expect(palette.classes.xl.get('--global-typography-title-font-size')).toBe(
134
+ '0.0px'
135
+ );
136
+ expect(palette.primitives.get('--font-size-100')).toBe('16px');
137
+ });
138
+
139
+ it('throws when a size class block is missing', () => {
140
+ expect(() => readPalette(':root { --a: 1px; }')).toThrow(
141
+ '.obc-component-size-regular'
142
+ );
143
+ });
144
+ });
145
+
146
+ describe('resolveLength', () => {
147
+ it('follows var() to the primitive and reads its number and unit', () => {
148
+ expect(
149
+ resolveLength(
150
+ 'var(--font-size-100)',
151
+ palette.classes.xl,
152
+ palette.primitives
153
+ )
154
+ ).toEqual({n: 16, unit: 'px'});
155
+ expect(
156
+ resolveLength('0.0px', palette.classes.xl, palette.primitives)
157
+ ).toEqual({n: 0, unit: 'px'});
158
+ expect(
159
+ resolveLength('normal', palette.classes.xl, palette.primitives)
160
+ ).toBeUndefined();
161
+ });
162
+ });
163
+
164
+ describe('rampGaps', () => {
165
+ const readers = new Map([
166
+ ['--global-typography-value-font-size', new Set(['a.css'])],
167
+ ['--global-typography-value-line-height', new Set(['a.css'])],
168
+ ['--global-typography-value-font-weight', new Set(['a.css'])],
169
+ ['--global-typography-label-font-size', new Set(['b.css', 'c.ts'])],
170
+ ['--global-typography-title-font-size', new Set(['d.css'])],
171
+ ['--automation-components-typography-unit-font-size', new Set(['e.css'])],
172
+ ['--component-local-font-size', new Set(['f.css'])],
173
+ ]);
174
+
175
+ it('reports a size token a class leaves undeclared, at 0 or smaller than the class before', () => {
176
+ expect(rampGaps(readers, palette).gaps).toEqual([
177
+ {
178
+ token: '--global-typography-label-font-size',
179
+ sizeClass: 'medium',
180
+ kind: 'missing',
181
+ value: undefined,
182
+ sizes: undefined,
183
+ readers: ['b.css', 'c.ts'],
184
+ },
185
+ {
186
+ token: '--global-typography-title-font-size',
187
+ sizeClass: 'xl',
188
+ kind: 'zero',
189
+ value: '0.0px',
190
+ sizes: undefined,
191
+ readers: ['d.css'],
192
+ },
193
+ {
194
+ token: '--automation-components-typography-unit-font-size',
195
+ sizeClass: 'xl',
196
+ kind: 'shrinks',
197
+ value: 'var(--font-size-100)',
198
+ sizes: ['16px', '32px'],
199
+ readers: ['e.css'],
200
+ },
201
+ ]);
202
+ });
203
+
204
+ it('ignores tokens that do not size text, and tokens no size class declares', () => {
205
+ const {gaps} = rampGaps(
206
+ new Map([
207
+ ['--global-typography-value-font-weight', new Set(['a.css'])],
208
+ ['--component-local-font-size', new Set(['f.css'])],
209
+ ]),
210
+ palette
211
+ );
212
+ expect(gaps).toEqual([]);
213
+ });
214
+
215
+ it('accepts a known gap only in the classes it names', () => {
216
+ const {gaps, stale} = rampGaps(readers, palette, {
217
+ '--global-typography-title-font-size': {
218
+ classes: ['medium', 'xl'],
219
+ reason: 'no XL value yet (#1422)',
220
+ },
221
+ });
222
+ expect(gaps.map((g) => `${g.token} ${g.sizeClass}`)).not.toContain(
223
+ '--global-typography-title-font-size xl'
224
+ );
225
+ expect(stale).toEqual([
226
+ {
227
+ token: '--global-typography-title-font-size',
228
+ detail: 'it has a value in medium',
229
+ },
230
+ ]);
231
+ });
232
+
233
+ it('reports a reader a known gap does not list', () => {
234
+ const {gaps, stale} = rampGaps(readers, palette, {
235
+ '--global-typography-label-font-size': {
236
+ classes: ['medium'],
237
+ readers: ['b.css', 'gone.css'],
238
+ reason: 'b.css reads it by design',
239
+ },
240
+ });
241
+ expect(
242
+ gaps.find((g) => g.token === '--global-typography-label-font-size')
243
+ ?.readers
244
+ ).toEqual(['c.ts']);
245
+ expect(stale).toEqual([
246
+ {
247
+ token: '--global-typography-label-font-size',
248
+ detail: 'gone.css no longer reads it',
249
+ },
250
+ ]);
251
+ });
252
+
253
+ it('flags an entry for a token nothing reads', () => {
254
+ const {stale} = rampGaps(readers, palette, {
255
+ '--global-typography-unread-font-size': {
256
+ classes: ['xl'],
257
+ reason: 'left over',
258
+ },
259
+ });
260
+ expect(stale).toEqual([
261
+ {
262
+ token: '--global-typography-unread-font-size',
263
+ detail: 'nothing reads it',
264
+ },
265
+ ]);
266
+ });
267
+ });
@@ -231,7 +231,7 @@
231
231
  .name-wrapper {
232
232
  position: absolute;
233
233
  top: calc(100% - var(--label-y-offset));
234
- @mixin font-general-xs-regular;
234
+ @mixin font-instrument-deprecated-value-small-neutral;
235
235
  color: var(--element-active-color);
236
236
  text-wrap: nowrap;
237
237
  transition:
@@ -255,7 +255,7 @@
255
255
  .state-alarm {
256
256
  .number-wrapper,
257
257
  .name-wrapper {
258
- @mixin font-general-xs-semibold;
258
+ @mixin font-instrument-deprecated-value-small-active;
259
259
  }
260
260
  }
261
261
 
@@ -563,19 +563,19 @@
563
563
  .value {
564
564
  color: var(--element-active-color);
565
565
  text-align: center;
566
- @mixin font-general-xs-semibold;
566
+ @mixin font-instrument-deprecated-value-small-active;
567
567
  }
568
568
 
569
569
  .label {
570
570
  color: var(--element-neutral-color);
571
571
  text-align: center;
572
- @mixin font-general-xs-semibold;
572
+ @mixin font-instrument-deprecated-label;
573
573
  }
574
574
 
575
575
  .unit {
576
576
  color: var(--element-neutral-color);
577
577
  text-align: center;
578
- @mixin font-general-xs-regular;
578
+ @mixin font-instrument-deprecated-unit;
579
579
  }
580
580
 
581
581
  &:not(:last-child)::after {
@@ -82,6 +82,14 @@ export const WithBadges: Story = {
82
82
  },
83
83
  };
84
84
 
85
+ export const WithSimulationBadge: Story = {
86
+ args: {
87
+ open: true,
88
+ value: 20,
89
+ badgeCommandLocked: AutomationButtonBadgeCommandLocked.Simulation,
90
+ },
91
+ };
92
+
85
93
  export const ClosedWithHandle: Story = {
86
94
  args: {
87
95
  open: false,