@tangle-network/brand 1.31.0 → 1.31.2

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.
@@ -330,31 +330,16 @@ describe("Canonical surface ladder (the spine: :root, .dark, .light, dark, light
330
330
  }
331
331
  });
332
332
 
333
- it("keeps every named theme with its own planes on the flat ladder until it is tuned", () => {
334
- // The canonical ladder is the spine's indigo planes; a named theme that
335
- // inherited it would nest an indigo card inside its own card.
336
- const flat = css.match(/([^{}]*)\{\s*--hsl-raised:\s*var\(--hsl-card\);[^}]*\}/);
337
- expect(flat, "the named-theme flat rule").not.toBeNull();
338
- const flatBody = flat![0];
339
- for (const [token, value] of [
340
- ["hsl-raised", "var(--hsl-card)"],
341
- ["hsl-raised-2", "var(--hsl-card)"],
342
- ["well-raised", "var(--well-card)"],
343
- ["well-raised-2", "var(--well-card)"],
344
- ["edge-highlight", "0 0 0 0 transparent"],
345
- ]) {
346
- expect(declIn(flatBody, token!), `--${token}`).toBe(value);
333
+ it("gives every named theme its own raised planes and wells", () => {
334
+ for (const body of rules(themes).matchAll(/[^{}]*\{([^{}]*--hsl-background:[^{}]*)\}/g)) {
335
+ const own = body[1]!;
336
+ expect(declIn(own, "hsl-raised")).toBe("var(--hsl-secondary)");
337
+ expect(resolveIn(own, "hsl-raised"), "raised must differ from the card").not.toBe(resolveIn(own, "hsl-card"));
338
+ for (const role of ["well-page", "well-card", "well-raised", "well-raised-2"]) {
339
+ expect(own, role).toContain(`--${role}:`);
340
+ }
347
341
  }
348
- const names = (selectors: string) => [...selectors.matchAll(/data-theme="([^"]+)"/g)].map((m) => m[1]);
349
- const ownPlanes = new Set(
350
- [...rules(themes).matchAll(/([^{}]*)\{([^{}]*)\}/g)]
351
- .filter((m) => m[2]!.includes("--hsl-background:"))
352
- .flatMap((m) => names(m[1]!)),
353
- );
354
- const tuned = new Set(["hospitality"]);
355
- expect(new Set(names(flat![1]!))).toEqual(new Set([...ownPlanes].filter((name) => !tuned.has(name!))));
356
- });
357
- });
342
+ });});
358
343
 
359
344
  describe("Inset workspace backdrop (canonical themes)", () => {
360
345
  // sandbox-ui WorkspaceSurface / WorkspaceLayout surface="inset" paint the
@@ -33,36 +33,36 @@
33
33
  --accent-soft: var(--iris-3);
34
34
  --accent-soft-hover: var(--iris-4);
35
35
  --accent-line: var(--iris-7);
36
- --hsl-background: 270 5.6% 7.1%;
37
- --hsl-foreground: 240 6.2% 93.7%;
38
- --hsl-card: 270 3.8% 10.2%;
39
- --hsl-card-foreground: 240 6.2% 93.7%;
40
- --hsl-popover: 260 4.2% 13.9%;
41
- --hsl-popover-foreground: 240 6.2% 93.7%;
42
- --hsl-primary: 240 60% 59.8%;
36
+ --hsl-background: 270 5.5556% 7.0588%;
37
+ --hsl-foreground: 240 6.25% 93.7255%;
38
+ --hsl-card: 270 3.8462% 10.1961%;
39
+ --hsl-card-foreground: 240 6.25% 93.7255%;
40
+ --hsl-popover: 260 4.2254% 13.9216%;
41
+ --hsl-popover-foreground: 240 6.25% 93.7255%;
42
+ --hsl-primary: 240 60% 59.8039%;
43
43
  --hsl-primary-foreground: 0 0% 100%;
44
- --hsl-secondary: 260 4.2% 13.9%;
45
- --hsl-secondary-foreground: 240 6.2% 93.7%;
46
- --hsl-muted: 260 4.2% 13.9%;
47
- --hsl-muted-foreground: 258 6.9% 71.8%;
48
- --hsl-accent: 270 4.7% 16.9%;
49
- --hsl-accent-foreground: 240 6.2% 93.7%;
50
- --hsl-destructive: 348 68.4% 18.6%;
51
- --hsl-destructive-foreground: 350 100% 91%;
52
- --hsl-border: 270 5% 23.5%;
53
- --hsl-input: 251 4.8% 44.9%;
54
- --hsl-ring: 242 63.7% 64.3%;
55
- --hsl-success: 151 54.7% 41.6%;
56
- --hsl-warning: 42 100% 62%;
57
- --hsl-info: 206 100% 50%;
58
- --sidebar-background: 270 3.8% 10.2%;
59
- --sidebar-foreground: 240 6.2% 93.7%;
60
- --sidebar-primary: 240 60% 59.8%;
44
+ --hsl-secondary: 260 4.2254% 13.9216%;
45
+ --hsl-secondary-foreground: 240 6.25% 93.7255%;
46
+ --hsl-muted: 260 4.2254% 13.9216%;
47
+ --hsl-muted-foreground: 258 6.9444% 71.7647%;
48
+ --hsl-accent: 270 4.6512% 16.8627%;
49
+ --hsl-accent-foreground: 240 6.25% 93.7255%;
50
+ --hsl-destructive: 348 68.4211% 18.6275%;
51
+ --hsl-destructive-foreground: 349.5652 100% 90.9804%;
52
+ --hsl-border: 270 5% 23.5294%;
53
+ --hsl-input: 250.9091 4.8035% 44.902%;
54
+ --hsl-ring: 242.069 63.7363% 64.3137%;
55
+ --hsl-success: 151.0345 54.717% 41.5686%;
56
+ --hsl-warning: 42.0619 100% 61.9608%;
57
+ --hsl-info: 206.1176 100% 50%;
58
+ --sidebar-background: 270 3.8462% 10.1961%;
59
+ --sidebar-foreground: 240 6.25% 93.7255%;
60
+ --sidebar-primary: 240 60% 59.8039%;
61
61
  --sidebar-primary-foreground: 0 0% 100%;
62
- --sidebar-accent: 270 4.7% 16.9%;
63
- --sidebar-accent-foreground: 240 6.2% 93.7%;
64
- --sidebar-border: 270 5% 23.5%;
65
- --sidebar-ring: 242 63.7% 64.3%;
62
+ --sidebar-accent: 270 4.6512% 16.8627%;
63
+ --sidebar-accent-foreground: 240 6.25% 93.7255%;
64
+ --sidebar-border: 270 5% 23.5294%;
65
+ --sidebar-ring: 242.069 63.7363% 64.3137%;
66
66
  --md3-surface: var(--mauve-1);
67
67
  --md3-surface-dim: var(--mauve-1);
68
68
  --md3-surface-bright: var(--mauve-5);
@@ -230,35 +230,35 @@
230
230
  --accent-soft-hover: var(--iris-4);
231
231
  --accent-line: var(--iris-7);
232
232
  --hsl-background: 0 0% 100%;
233
- --hsl-foreground: 257 10.1% 13.5%;
233
+ --hsl-foreground: 257.1429 10.1449% 13.5294%;
234
234
  --hsl-card: 0 0% 100%;
235
- --hsl-card-foreground: 257 10.1% 13.5%;
235
+ --hsl-card-foreground: 257.1429 10.1449% 13.5294%;
236
236
  --hsl-popover: 0 0% 100%;
237
- --hsl-popover-foreground: 257 10.1% 13.5%;
238
- --hsl-primary: 240 60% 59.8%;
237
+ --hsl-popover-foreground: 257.1429 10.1449% 13.5294%;
238
+ --hsl-primary: 240 60% 59.8039%;
239
239
  --hsl-primary-foreground: 0 0% 100%;
240
- --hsl-secondary: 285 14.3% 94.5%;
241
- --hsl-secondary-foreground: 257 10.1% 13.5%;
242
- --hsl-muted: 285 14.3% 94.5%;
243
- --hsl-muted-foreground: 252 4.8% 40.8%;
244
- --hsl-accent: 276 11.6% 91.6%;
245
- --hsl-accent-foreground: 257 10.1% 13.5%;
246
- --hsl-destructive: 358 64.8% 49%;
240
+ --hsl-secondary: 285 14.2857% 94.5098%;
241
+ --hsl-secondary-foreground: 257.1429 10.1449% 13.5294%;
242
+ --hsl-muted: 285 14.2857% 94.5098%;
243
+ --hsl-muted-foreground: 252 4.8077% 40.7843%;
244
+ --hsl-accent: 276 11.6279% 91.5686%;
245
+ --hsl-accent-foreground: 257.1429 10.1449% 13.5294%;
246
+ --hsl-destructive: 358.1481 64.8% 49.0196%;
247
247
  --hsl-destructive-foreground: 0 0% 100%;
248
- --hsl-border: 262 11.4% 86.3%;
249
- --hsl-input: 249 6% 57.5%;
250
- --hsl-ring: 240 60% 59.8%;
251
- --hsl-success: 151 54.7% 41.6%;
252
- --hsl-warning: 42 100% 62%;
253
- --hsl-info: 206 100% 50%;
254
- --sidebar-background: 270 20% 98%;
255
- --sidebar-foreground: 257 10.1% 13.5%;
256
- --sidebar-primary: 240 60% 59.8%;
248
+ --hsl-border: 262.5 11.4286% 86.2745%;
249
+ --hsl-input: 249.2308 5.9908% 57.451%;
250
+ --hsl-ring: 240 60% 59.8039%;
251
+ --hsl-success: 151.0345 54.717% 41.5686%;
252
+ --hsl-warning: 42.0619 100% 61.9608%;
253
+ --hsl-info: 206.1176 100% 50%;
254
+ --sidebar-background: 270 20% 98.0392%;
255
+ --sidebar-foreground: 257.1429 10.1449% 13.5294%;
256
+ --sidebar-primary: 240 60% 59.8039%;
257
257
  --sidebar-primary-foreground: 0 0% 100%;
258
- --sidebar-accent: 276 11.6% 91.6%;
259
- --sidebar-accent-foreground: 257 10.1% 13.5%;
260
- --sidebar-border: 262 11.4% 86.3%;
261
- --sidebar-ring: 240 60% 59.8%;
258
+ --sidebar-accent: 276 11.6279% 91.5686%;
259
+ --sidebar-accent-foreground: 257.1429 10.1449% 13.5294%;
260
+ --sidebar-border: 262.5 11.4286% 86.2745%;
261
+ --sidebar-ring: 240 60% 59.8039%;
262
262
  --md3-surface: #ffffff;
263
263
  --md3-surface-dim: var(--mauve-2);
264
264
  --md3-surface-bright: #ffffff;
@@ -1,6 +1,6 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
- import { blockIn, blocksIn, hslToRgb } from "./css-test-utils";
3
+ import { blockIn, blocksIn, hexIn } from "./css-test-utils";
4
4
 
5
5
  /**
6
6
  * Every theme scope a consumer can select, each with its CSS sources listed
@@ -39,7 +39,7 @@ const named = (selector: string) => spine(themes, selector);
39
39
  * Each scope lists its sources from the most specific to the baseline it
40
40
  * inherits from, as the cascade resolves them.
41
41
  */
42
- export const scopes: Array<{ name: string; sources: string[] }> = [
42
+ const baseScopes: Array<{ name: string; sources: string[] }> = [
43
43
  { name: "canonical dark", sources: [DARK] },
44
44
  { name: "canonical light", sources: [LIGHT, DARK] },
45
45
  {
@@ -80,13 +80,17 @@ export const scopes: Array<{ name: string; sources: string[] }> = [
80
80
  sources: [named('[data-theme="website"]:where(:not(.dark))'), LIGHT, DARK],
81
81
  },
82
82
  { name: "website dark", sources: [named('.dark[data-theme="website"]'), DARK] },
83
- // Every data-accent scope on each canonical mode: its role rule, then the spine.
83
+ ];
84
+
85
+ // Accent is promised on any named boundary, so use every real supported mode,
86
+ // including the light-default projection, rather than only canonical planes.
87
+ export const scopes = [
88
+ ...baseScopes,
84
89
  ...[...themes.matchAll(/^\[data-accent="([a-z]+)"\],$/gm)].flatMap(([, hue]) => {
85
90
  const rule = blockIn(themes, `[data-accent="${hue}"] :is(.light, .dark, [data-theme], [data-sandbox-ui], [data-sandbox-theme])`);
86
- return [
87
- { name: `accent ${hue} on dark`, sources: [rule, DARK] },
88
- { name: `accent ${hue} on light`, sources: [rule, LIGHT, DARK] },
89
- ];
91
+ return baseScopes.filter(({ name }) => !name.startsWith("system ")).map(({ name, sources }) => ({
92
+ name: `accent ${hue} on ${name}`, sources: [rule, ...sources],
93
+ }));
90
94
  }),
91
95
  ];
92
96
 
@@ -98,18 +102,5 @@ export type Rgb = [number, number, number];
98
102
  * declares each name.
99
103
  */
100
104
  export function resolve(sources: string[], token: string): Rgb {
101
- const raw = sources
102
- .map((css) => css.match(new RegExp(`(?<![\\w-])--${token}:\\s*([^;]+);`))?.[1]?.trim())
103
- .find((value) => value !== undefined);
104
- if (raw === undefined) throw new Error(`--${token} resolves to nothing`);
105
-
106
- const ref = /^(?:hsl\()?var\(--([a-z0-9-]+)\)\)?$/.exec(raw);
107
- if (ref) return resolve(sources, ref[1]);
108
- const hex = /^#([0-9a-fA-F]{6})\b/.exec(raw);
109
- if (hex) {
110
- return [0, 2, 4].map((i) => Number.parseInt(hex[1].slice(i, i + 2), 16)) as Rgb;
111
- }
112
- const hsl = /^([\d.]+)\s+([\d.]+)%\s+([\d.]+)%/.exec(raw);
113
- if (hsl) return hslToRgb({ h: Number(hsl[1]), s: Number(hsl[2]), l: Number(hsl[3]) });
114
- throw new Error(`--${token} has an unreadable value: ${raw}`);
105
+ return hexIn(sources, token);
115
106
  }