@tangle-network/brand 1.23.1 → 1.24.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 33cfa62: Canonical surface ladder: every theme without its own ladder now derives its field wells and field border from its own page, card, hairline and ink. Dark wells recess 4.6 L under the page (they sat 3.1 above it), light wells take the opposite plane (5 L either way; the old well sat 2.6 under the white card), and the field border clears 4:1 on the card in both modes (it was the 1.5:1 hairline). Hospitality keeps its tuned ladder.
8
+
3
9
  ## 1.23.1
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/brand",
3
- "version": "1.23.1",
3
+ "version": "1.24.0",
4
4
  "description": "Tangle brand system — design tokens, logo, Tailwind v4 theme. Single source of truth for every Tangle app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  /* GENERATED by scripts/gen-compat.mjs. Do not edit.
2
2
  * Source: tokens.css + named-themes.css
3
- * SHA-256: d9f91f8d9c731a2b37749d49fcb621a42a5e4fe4a2d6e7157e6b4eef71a5f3b5
3
+ * SHA-256: 6c805f42ca39150c46bc17c76de5083bf24e8b1e12baa70614d51a27e94777f7
4
4
  * Light-default compatibility; all explicit modes remain canonical.
5
5
  */
6
6
  :where(:root),
@@ -647,12 +647,12 @@
647
647
  [data-theme] {
648
648
  --hsl-raised: var(--hsl-card);
649
649
  --hsl-raised-2: var(--hsl-card);
650
- --well-page: var(--bg-input);
651
- --well-card: var(--bg-input);
652
- --well-raised: var(--bg-input);
653
- --well-raised-2: var(--bg-input);
650
+ --well-page: color-mix(in oklab, hsl(var(--hsl-background)) 70%, black);
651
+ --well-card: var(--well-page);
652
+ --well-raised: var(--well-page);
653
+ --well-raised-2: var(--well-page);
654
654
  --well: var(--well-page);
655
- --field-border: hsl(var(--hsl-border));
655
+ --field-border: color-mix(in oklab, hsl(var(--hsl-border)), hsl(var(--hsl-foreground)) 45%);
656
656
  --shadow-raised: var(--shadow-card);
657
657
  --shadow-well: 0 0 0 0 transparent;
658
658
  --edge-highlight: 0 0 0 0 transparent;
@@ -674,6 +674,10 @@
674
674
  :where(:root) {
675
675
  --ix-sel-bg: hsl(var(--hsl-ring) / 0.13);
676
676
  --ix-hover-bg: hsl(var(--hsl-ring) / 0.07);
677
+ --well-page: hsl(var(--hsl-card));
678
+ --well-card: hsl(var(--hsl-background));
679
+ --well-raised: hsl(var(--hsl-background));
680
+ --well-raised-2: hsl(var(--hsl-background));
677
681
  }
678
682
  [data-slot="card"] :where(*) {
679
683
  --card: var(--hsl-raised);
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { describe, expect, it } from "vitest";
4
- import { blockIn, contrastRatio, declIn, hexIn, hslIn, hslToRgb, oklchLightness } from "./css-test-utils";
4
+ import { blockIn, blocksIn, contrastRatio, declIn, hexIn, hslIn, hslToRgb, oklchLightness } from "./css-test-utils";
5
5
 
6
6
  /**
7
7
  * The surface ladder and the interaction palette.
@@ -168,14 +168,10 @@ describe("shared surface context and interaction tokens (tokens.css)", () => {
168
168
  }
169
169
  });
170
170
 
171
- it("defaults every new ladder token to the plain spine, so other themes look as they did", () => {
171
+ it("defaults the raised planes and shadows to the plain spine (wells: the canonical suite below)", () => {
172
172
  expect(declIn(body, "hsl-raised")).toBe("var(--hsl-card)");
173
173
  expect(declIn(body, "hsl-raised-2")).toBe("var(--hsl-card)");
174
- for (const well of ["well-page", "well-card", "well-raised", "well-raised-2"]) {
175
- expect(declIn(body, well)).toBe("var(--bg-input)");
176
- }
177
174
  expect(declIn(body, "well")).toBe("var(--well-page)");
178
- expect(declIn(body, "field-border")).toBe("hsl(var(--hsl-border))");
179
175
  expect(declIn(body, "shadow-raised")).toBe("var(--shadow-card)");
180
176
  // A shadow token joins a comma list; "none" would void the list.
181
177
  expect(declIn(body, "shadow-well")).toBe("0 0 0 0 transparent");
@@ -190,7 +186,7 @@ describe("shared surface context and interaction tokens (tokens.css)", () => {
190
186
  expect(declIn(body, "ix-sel-ring")).toBe("hsl(var(--hsl-ring) / 0.85)");
191
187
  expect(declIn(body, "ix-sel-bg")).toBe("hsl(var(--hsl-ring) / 0.18)");
192
188
  expect(declIn(body, "ix-hover-bg")).toBe("hsl(var(--hsl-ring) / 0.08)");
193
- const lightTint = css.match(/([^{}]*)\{\s*--ix-sel-bg:\s*hsl\(var\(--hsl-ring\) \/ 0\.13\);\s*--ix-hover-bg:\s*hsl\(var\(--hsl-ring\) \/ 0\.07\);\s*\}/);
189
+ const lightTint = css.match(/([^{}]*)\{\s*--ix-sel-bg:\s*hsl\(var\(--hsl-ring\) \/ 0\.13\);\s*--ix-hover-bg:\s*hsl\(var\(--hsl-ring\) \/ 0\.07\);[^{}]*\}/);
194
190
  expect(lightTint, "light tint override").not.toBeNull();
195
191
  expect(lightTint![1]).toContain('[data-theme="hospitality"]:where(:not(.dark))');
196
192
  expect(lightTint![1]).toContain(".light");
@@ -223,3 +219,69 @@ describe("shared surface context and interaction tokens (tokens.css)", () => {
223
219
  }
224
220
  });
225
221
  });
222
+
223
+ describe("Canonical surface ladder (every theme without its own ladder)", () => {
224
+ // The spine's shared --bg-input sat +3.1 L above the dark page and -2.6 L under
225
+ // the white card, so a field read as the plane it was on. The defaults derive
226
+ // wells and the field border from each theme's own page, card, hairline and ink.
227
+ const withWells = (selector: string) => {
228
+ const block = blocksIn(tokens, selector).find((b) => /--well-page:/.test(b));
229
+ if (!block) throw new Error(`no well defaults under ${selector}`);
230
+ return block;
231
+ };
232
+ const defaults = withWells("[data-theme]");
233
+ const lightDefaults = withWells('[data-theme$="-light"]');
234
+ const DARK = blockIn(tokens, ".dark");
235
+ const LIGHT = blockIn(tokens, ".light");
236
+
237
+ type Rgb = [number, number, number];
238
+ const toLab = (rgb: Rgb) => {
239
+ const lin = (c: number) => ((c /= 255) <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4);
240
+ const [r, g, b] = rgb.map(lin);
241
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
242
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
243
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
244
+ return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s];
245
+ };
246
+ const fromLab = ([L, a, b]: number[]): Rgb => {
247
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
248
+ const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
249
+ const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
250
+ const enc = (c: number) => 255 * Math.min(1, Math.max(0, c <= 0.0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055));
251
+ return [enc(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s), enc(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s), enc(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s)];
252
+ };
253
+ /** `color-mix(in oklab, a, b <t>)`. */
254
+ const mix = (a: Rgb, b: Rgb, t: number) => fromLab(toLab(a).map((v, i) => v * (1 - t) + toLab(b)[i] * t));
255
+ const spine = (css: string, token: string) => hslToRgb(hslIn(css, token)) as Rgb;
256
+
257
+ it("declares the derivations this suite measures", () => {
258
+ expect(declIn(defaults, "well-page")).toBe("color-mix(in oklab, hsl(var(--hsl-background)) 70%, black)");
259
+ expect(declIn(defaults, "field-border")).toBe("color-mix(in oklab, hsl(var(--hsl-border)), hsl(var(--hsl-foreground)) 45%)");
260
+ expect(declIn(lightDefaults, "well-page")).toBe("hsl(var(--hsl-card))");
261
+ for (const token of ["well-card", "well-raised", "well-raised-2"]) {
262
+ expect(declIn(defaults, token)).toBe("var(--well-page)");
263
+ expect(declIn(lightDefaults, token)).toBe("hsl(var(--hsl-background))");
264
+ }
265
+ });
266
+
267
+ it("recesses the dark well at least 4 L below the page and the card", () => {
268
+ const well = mix(spine(DARK, "hsl-background"), [0, 0, 0], 0.3);
269
+ expect(oklchLightness(spine(DARK, "hsl-background")) - oklchLightness(well)).toBeGreaterThanOrEqual(4);
270
+ expect(oklchLightness(spine(DARK, "hsl-card")) - oklchLightness(well)).toBeGreaterThanOrEqual(10);
271
+ });
272
+
273
+ it("steps the light well 4 L or more off the page and the card", () => {
274
+ const page = oklchLightness(spine(LIGHT, "hsl-background"));
275
+ const card = oklchLightness(spine(LIGHT, "hsl-card"));
276
+ expect(card - page).toBeGreaterThanOrEqual(4);
277
+ });
278
+
279
+ it.each([
280
+ ["dark", () => DARK],
281
+ ["light", () => LIGHT],
282
+ ])("draws a field border that clears 3:1 on the card and the page in %s (WCAG 1.4.11)", (_mode, css) => {
283
+ const border = mix(spine(css(), "hsl-border"), spine(css(), "hsl-foreground"), 0.45);
284
+ expect(contrastRatio(border, spine(css(), "hsl-card")), "on the card").toBeGreaterThanOrEqual(3);
285
+ expect(contrastRatio(border, spine(css(), "hsl-background")), "on the page").toBeGreaterThanOrEqual(3);
286
+ });
287
+ });
@@ -950,9 +950,15 @@
950
950
  * level in, --hsl-raised-2 two levels in.
951
951
  * --well the field fill: --well-page on the page, --well-card in a card,
952
952
  * --well-raised in a card in a card, --well-raised-2 deeper still.
953
- * A theme that tunes its ladder (Hospitality) sets these per mode. The defaults
954
- * below reproduce the plain spine exactly — every level paints the card and
955
- * every well is --bg-input — so a theme that does not set them looks as it did.
953
+ * A theme that tunes its ladder (Hospitality) sets these per mode. Every other
954
+ * theme gets wells derived from its own page and card, so a field always sits
955
+ * at least 3 OKLCH L points off the plane it is on (agent-app-signoff
956
+ * surface-ladder): dark wells recess below the page (page + 30% black: -4.6 L on
957
+ * the page, -10.9 L in a card on the spine); light wells take the opposite plane
958
+ * (the card on the page, the page in a card: 5 L either way). The old shared
959
+ * --bg-input sat +3.1 above the dark page and -2.6 under the white card. Raised
960
+ * levels still paint the card here: --hsl-raised is an HSL triplet and cannot
961
+ * be derived per theme.
956
962
  *
957
963
  * INTERACTION. Four states, all from the focus ring hue (--hsl-ring), so one
958
964
  * green or one indigo marks every interactive thing in a theme:
@@ -972,12 +978,14 @@
972
978
  [data-theme] {
973
979
  --hsl-raised: var(--hsl-card);
974
980
  --hsl-raised-2: var(--hsl-card);
975
- --well-page: var(--bg-input);
976
- --well-card: var(--bg-input);
977
- --well-raised: var(--bg-input);
978
- --well-raised-2: var(--bg-input);
981
+ --well-page: color-mix(in oklab, hsl(var(--hsl-background)) 70%, black);
982
+ --well-card: var(--well-page);
983
+ --well-raised: var(--well-page);
984
+ --well-raised-2: var(--well-page);
979
985
  --well: var(--well-page);
980
- --field-border: hsl(var(--hsl-border));
986
+ /* The hairline is 1.5:1 by design; a field edge is non-text UI and needs 3:1.
987
+ * 45% toward the ink measures 4.0:1 on the spine card in both modes. */
988
+ --field-border: color-mix(in oklab, hsl(var(--hsl-border)), hsl(var(--hsl-foreground)) 45%);
981
989
  --shadow-raised: var(--shadow-card);
982
990
  /* A shadow token joins a comma list, so "none" would void the whole list. */
983
991
  --shadow-well: 0 0 0 0 transparent;
@@ -991,8 +999,9 @@
991
999
  --ix-hover-bg: hsl(var(--hsl-ring) / 0.08);
992
1000
  }
993
1001
 
994
- /* Light planes need less tint for the same step. Same scope list as the chart
995
- * light rule below; dark is the default. */
1002
+ /* Light planes need less tint for the same step, and take their wells from the
1003
+ * opposite plane. Same scope list as the chart light rule below; dark is the
1004
+ * default. */
996
1005
  [data-sandbox-theme="vault"]:where(:not(.dark)),
997
1006
  [data-sandbox-theme="dawn"]:where(:not(.dark)),
998
1007
  [data-theme="hospitality"]:where(:not(.dark)),
@@ -1002,6 +1011,10 @@
1002
1011
  [data-theme$="-light"] {
1003
1012
  --ix-sel-bg: hsl(var(--hsl-ring) / 0.13);
1004
1013
  --ix-hover-bg: hsl(var(--hsl-ring) / 0.07);
1014
+ --well-page: hsl(var(--hsl-card));
1015
+ --well-card: hsl(var(--hsl-background));
1016
+ --well-raised: hsl(var(--hsl-background));
1017
+ --well-raised-2: hsl(var(--hsl-background));
1005
1018
  }
1006
1019
 
1007
1020
  /* Surface context: keyed only on the Card primitive's data-slot, never on app