@tangle-network/brand 1.23.0 → 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 +12 -0
- package/bin/tangle-drift.mjs +13 -3
- package/package.json +1 -1
- package/src/styles/legacy-light.css +10 -6
- package/src/styles/surface-ladder.test.ts +69 -7
- package/src/styles/tokens.css +23 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 1.23.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 9e9dec0: tangle-drift no longer counts issue references in comments ("React error #310", "(#346)") as hex colours. hex reads whole files with comments blanked (/* */, //, <!-- -->), like header_height_literal and transcript_type_override. A Hospitality recovery release failed on such a comment.
|
|
14
|
+
|
|
3
15
|
## 1.23.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/bin/tangle-drift.mjs
CHANGED
|
@@ -55,7 +55,6 @@ const PRIMS = "Button|IconButton|Badge|Card|Chip|Tag|Pill|Avatar|Dialog|Modal|Sh
|
|
|
55
55
|
/** PCRE patterns, passed to `git grep -P`. */
|
|
56
56
|
export const PATTERNS = {
|
|
57
57
|
raw_palette: String.raw`\b(?:bg|text|border|ring|fill|stroke|from|to|via|outline|divide|decoration|accent|caret|shadow)-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-[0-9]{2,3}\b`,
|
|
58
|
-
hex: String.raw`#[0-9a-fA-F]{6}\b|#[0-9a-fA-F]{3}\b`,
|
|
59
58
|
arbitrary_color: String.raw`-\[(?:#|rgb|hsl|oklch)`,
|
|
60
59
|
css_var_defs: String.raw`^\s*--[a-zA-Z0-9-]+\s*:`,
|
|
61
60
|
local_primitive_count: String.raw`export\s+(?:default\s+)?(?:function|const)\s+(?:${PRIMS})\b`,
|
|
@@ -93,6 +92,12 @@ const LITERAL_HEIGHT_UTILITY = String.raw`(?<![\w-])(?:h|min-h|max-h)-(?:[0-9]|\
|
|
|
93
92
|
* `git grep -l` and the same pathspecs, so the excluded paths match the line metrics.
|
|
94
93
|
*/
|
|
95
94
|
export const RULE_PATTERNS = {
|
|
95
|
+
// A colour literal: `#rgb` or `#rrggbb`. Read as a rule metric so comments are blanked first: an
|
|
96
|
+
// issue reference such as "React error #310" or "(#346)" in a comment is not a colour.
|
|
97
|
+
hex: {
|
|
98
|
+
prefilter: String.raw`#[0-9a-fA-F]{3}`,
|
|
99
|
+
patterns: [String.raw`#[0-9a-fA-F]{6}\b|#[0-9a-fA-F]{3}\b`],
|
|
100
|
+
},
|
|
96
101
|
// A header row given its own height. The shell owns one header height
|
|
97
102
|
// (`--shell-header-height`, `ShellHeader`); content fills the row and never sets it, so the
|
|
98
103
|
// main pane's divider lands on the sidebar's. Token references (`var(--shell-header-height)`)
|
|
@@ -124,7 +129,8 @@ const LOCAL_PRIM_NAME = new RegExp(String.raw`(?:function|const)\s+(${PRIMS})\b`
|
|
|
124
129
|
const SHARED = ["@tangle-network/brand", "@tangle-network/ui", "@tangle-network/sandbox-ui", "@tangle-network/agent-app"];
|
|
125
130
|
|
|
126
131
|
/** The counts the gate ratchets. Everything else in a row is informational. */
|
|
127
|
-
|
|
132
|
+
const LINE_METRICS = Object.keys(PATTERNS);
|
|
133
|
+
export const GATED = [LINE_METRICS[0], "hex", ...LINE_METRICS.slice(1), ...Object.keys(RULE_PATTERNS).filter((m) => m !== "hex")];
|
|
128
134
|
|
|
129
135
|
function extensions(surface, metric) {
|
|
130
136
|
const extra = SURFACES[surface]?.extraExt ?? [];
|
|
@@ -202,7 +208,11 @@ export function ruleMatches(source, roots, metric, exts) {
|
|
|
202
208
|
for (const path of files) {
|
|
203
209
|
// Comments name things without styling them (a CSS note that mentions "transcript" or
|
|
204
210
|
// "header"); blank them, keeping offsets and newlines, so only real rules count.
|
|
205
|
-
const
|
|
211
|
+
const blank = (comment) => comment.replace(/[^\n]/g, " ");
|
|
212
|
+
const text = readFile(source, path)
|
|
213
|
+
.replace(/\/\*[\s\S]*?\*\//g, blank)
|
|
214
|
+
.replace(/<!--[\s\S]*?-->/g, blank)
|
|
215
|
+
.replace(/(^|[\s;{}(])\/\/[^\n]*/gm, (m, lead) => lead + blank(m.slice(lead.length)));
|
|
206
216
|
const found = new Map();
|
|
207
217
|
for (const pattern of patterns) {
|
|
208
218
|
for (const m of text.matchAll(new RegExp(pattern, "g"))) found.set(m.index, m[0]);
|
package/package.json
CHANGED
|
@@ -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:
|
|
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(--
|
|
651
|
-
--well-card: var(--
|
|
652
|
-
--well-raised: var(--
|
|
653
|
-
--well-raised-2: var(--
|
|
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
|
|
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\)
|
|
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
|
+
});
|
package/src/styles/tokens.css
CHANGED
|
@@ -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.
|
|
954
|
-
*
|
|
955
|
-
*
|
|
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(--
|
|
976
|
-
--well-card: var(--
|
|
977
|
-
--well-raised: var(--
|
|
978
|
-
--well-raised-2: var(--
|
|
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
|
-
|
|
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
|
|
995
|
-
* light rule below; dark is the
|
|
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
|