Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to `sessionpipe-gui`. The format follows

## [Unreleased]

### Fixed

- Skin contrast warnings use the text floors promised by the built-in tokens: 7:1 for secondary text and 5:1 for meta text.

## [0.8.18] - 2026-12-04

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions docs/skin-authoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ the **colour tokens**; the scheme's defaults fill the rest:

Values are plain CSS colours (`oklch(…)`, `#hex`, `rgb(…)`, a keyword): no `url()`, no
braces, no semicolons. Keep the text tiers at their floors on the page and the card
(`--fg` ≥ 7:1, `--fg-2` ≥ 5:1, `--fg-3` ≥ 4.5:1 for the 12–13 px meta text, `--fg-4`
(`--fg` ≥ 7:1, `--fg-2` ≥ 7:1, `--fg-3` ≥ 5:1 for the 12–13 px meta text, `--fg-4`
≥ 3:1, marks only, each on `--bg` and `--bg-2`). The server measures them when it lists
a skin (`shared/contrast.ts`; oklch, hex and rgb values; a token you leave unset is
measured against the stock scheme's) and reports a shortfall in the skin's `warning`
("low contrast: --fg-3 on --bg 3.9:1, needs 4.5"), shown in the popover's row; the skin
("low contrast: --fg-3 on --bg 3.9:1, needs 5"), shown in the popover's row; the skin
still applies. The themes repo's `packages/color-themes/scripts/check.mjs` measures a
whole token set, with more pairs.

Expand Down
2 changes: 1 addition & 1 deletion server/skins/skins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ describe("contrast", () => {
const { contrastWarning } = requireRegistry();
for (const b of BUILTIN_SKINS) expect(contrastWarning(b), b.id).toBeUndefined();
const low = contrastWarning({ scheme: "light", tokens: { light: { "--fg-3": "oklch(0.7 0.01 60)" } } });
expect(low).toMatch(/^low contrast: --fg-3 on --bg \d\.\d:1, needs 4\.5 · --fg-3 on --bg-2/);
expect(low).toMatch(/^low contrast: --fg-3 on --bg \d\.\d:1, needs 5 · --fg-3 on --bg-2/);
const both = contrastWarning({
scheme: "both",
tokens: { dark: { "--fg-4": "oklch(0.3 0 0)" }, light: { "--fg": "#000", "--bg": "#fff" } },
Expand Down
15 changes: 15 additions & 0 deletions shared/contrast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,18 @@ describe("the focus ring's floor", () => {
expect(textTierWarnings({ "--focus": "color-mix(in oklch, var(--fg) 20%, transparent)" }, "light")).toEqual([]);
});
});

describe("the text tiers' floors are the ones tokens.css promises", () => {
it("secondary text under 7:1 and meta text under 5:1 warn, though they clear 5 and 4.5", () => {
expect(textTierWarnings({ "--fg-2": "#6b6b6b", "--fg-3": "#757575" }, "light")).toEqual([
"--fg-2 on --bg 5.3:1, needs 7",
"--fg-2 on --bg-2 5.3:1, needs 7",
"--fg-3 on --bg 4.6:1, needs 5",
"--fg-3 on --bg-2 4.6:1, needs 5",
]);
});

it("tiers at the floors do not", () => {
expect(textTierWarnings({ "--fg-2": "#595959", "--fg-3": "#6e6e6e" }, "light")).toEqual([]);
});
});
10 changes: 5 additions & 5 deletions shared/contrast.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// WCAG contrast for the token values a skin sets, so the server can say when a skin's
// text tiers or marks fall under the floors tokens.css promises (fg ≥ 7:1, fg-2 ≥ 5:1,
// fg-3 ≥ 4.5:1 for 12–13 px meta text, fg-4 ≥ 3:1 for marks only, the focus ring ≥ 3:1)
// text tiers or marks fall under the floors tokens.css promises (fg ≥ 7:1, fg-2 ≥ 7:1,
// fg-3 ≥ 5:1 for 12–13 px meta text, fg-4 ≥ 3:1 for marks only, the focus ring ≥ 3:1)
// on the page and the card. Parses the colour forms a skin is likely to use: oklch(),
// #hex, rgb(). Anything else is left unmeasured rather than guessed. No dependencies.
import type { SkinTokens } from "./skin-api.js";
Expand Down Expand Up @@ -56,8 +56,8 @@ export function contrastRatio(a: string, b: string): number | null {
/** The text tiers and the floor each must clear on `--bg` and `--bg-2`. */
export const TEXT_TIERS: readonly [token: "--fg" | "--fg-2" | "--fg-3" | "--fg-4", floor: number][] = [
["--fg", 7],
["--fg-2", 5],
["--fg-3", 4.5],
["--fg-2", 7],
["--fg-3", 5],
["--fg-4", 3],
];
/** The marks that are not text and the floor each must clear on `--bg` and `--bg-2`: the
Expand Down Expand Up @@ -94,7 +94,7 @@ export const STOCK_TEXT_TOKENS: Record<
};

/** Every text tier and mark under its floor on the page or the card, as one short line each
* ("--fg-3 on --bg 3.9:1, needs 4.5"); empty when all clear or nothing is measurable. */
* ("--fg-3 on --bg 3.9:1, needs 5"); empty when all clear or nothing is measurable. */
export function textTierWarnings(tokens: SkinTokens, scheme: "dark" | "light"): string[] {
const stock = STOCK_TEXT_TOKENS[scheme];
const value = (k: keyof typeof stock): string => tokens[k] ?? stock[k];
Expand Down
2 changes: 1 addition & 1 deletion shared/skin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export interface InstalledSkin {
/** Why it cannot be applied; listed so the problem shows. */
error?: string;
/** Applied all the same, but its text tiers fall under the floors (shared/contrast.ts):
* "--fg-3 on --bg 3.9:1, needs 4.5 · …", per scheme for a "both" skin. */
* "--fg-3 on --bg 3.9:1, needs 5 · …", per scheme for a "both" skin. */
warning?: string;
}

Expand Down