feat(theme): Light/Dark/System, reduced motion, and one radius scale
CI / verify (pull_request) Successful in 1m10s
CI / infrastructure-smoke (pull_request) Successful in 34s
CI / package-release (pull_request) Successful in 52s
CI / migration-smoke (pull_request) Successful in 2m20s
CI / image-build (pull_request) Successful in 1m5s
CI / deploy-smoke (same-origin) (pull_request) Successful in 50s
CI / package-publication (pull_request) Successful in 58s
CI / deploy-smoke (split) (pull_request) Successful in 2m38s

The theme foundation DESIGN.md requires (ADR 0060):

- A design token may carry a `dark` value and a `reduced` value. The
  token stylesheet selects them in CSS alone: dark under
  prefers-color-scheme unless the host chose light, or when it chose
  dark; motion durations zero under prefers-reduced-motion unless it
  allowed motion, or when it chose reduce. `color-scheme` travels with
  the tokens. System is live, an explicit choice wins, and every module
  root follows through custom-property inheritance, with no module
  contract change.
- @ekklesia/design-tokens adds a small appearance API: system/light/dark
  and system/reduce/allow, parsers for untrusted stored values,
  resolvers, and a controller that applies the attributes immediately.
  The shell applies it before React renders. That is the hook the
  account preferences work will feed; nothing is persisted. The
  Dashboard page declares `color-scheme: light dark` so a dark system
  never flashes white. Displays stay light.
- A designed dark theme: teal-tinted charcoal, never pure black or
  white, the same teal accent.
- WCAG AA contrast is tested for 41 element pairings in both schemes.
  Two light pairings failed and are fixed visibly: text.muted darkens,
  and form controls get a new border.control (3:1).
  background.placeholder keeps skeletons visible in dark.
- Motion tokens (duration-short, duration-ambient) replace literal
  durations and every per-element reduced-motion rule. radius.scale
  multiplies sm/md/lg, unchanged at its default of 1.
- The sign-in card and module loading/error text move from literal
  colours to tokens. Guards keep raw colours and literal radii out of
  Dashboard product source and @ekklesia/ui.
- Fixes ConfirmationDialog's phrase input, which used a class that
  does not exist (`ek-input`) and so was unstyled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ekklesia
2026-10-14 20:00:39 -05:00
co-authored by Claude Opus 5.5
parent e3e2a901a7
commit d42b64a093
25 changed files with 1294 additions and 78 deletions
+1 -1
View File
@@ -150,7 +150,7 @@ export function ConfirmationDialog(props: ConfirmationDialogProps): ReactElement
autoCapitalize="off"
autoComplete="off"
autoCorrect="off"
className="ek-input ek-focusable"
className="ek-control ek-focusable"
disabled={busy}
id={phraseId}
onChange={(event) => setTyped(event.currentTarget.value)}
+9 -14
View File
@@ -162,7 +162,7 @@ export const EKKLESIA_UI_STYLESHEET = `
.ek-control {
background: ${designToken("background.surface")};
border: ${designToken("border.width")} solid ${designToken("border.base")};
border: ${designToken("border.width")} solid ${designToken("border.control")};
border-radius: ${designToken("radius.md")};
box-sizing: border-box;
color: ${designToken("text.primary")};
@@ -587,7 +587,8 @@ export const EKKLESIA_UI_STYLESHEET = `
}
.ek-spinner {
animation: ek-spin 1s linear infinite;
/* Spins at 0.625 of the ambient cycle (1s by default); not at all when motion is reduced. */
animation: ek-spin calc(${designToken("motion.duration-ambient")} * 0.625) linear infinite;
border: ${designToken("state.focus-visible-width")} solid ${designToken("border.base")};
border-block-start-color: ${designToken("accent.base")};
border-radius: ${designToken("radius.pill")};
@@ -656,7 +657,7 @@ export const EKKLESIA_UI_STYLESHEET = `
}
.ek-toast-region .ek-toast {
animation: ek-toast-enter 160ms ease-out;
animation: ek-toast-enter ${designToken("motion.duration-short")} ease-out;
pointer-events: auto;
}
@@ -727,8 +728,8 @@ export const EKKLESIA_UI_STYLESHEET = `
}
.ek-skeleton {
animation: ek-skeleton-pulse 1.6s ease-in-out infinite;
background: ${designToken("background.inset")};
animation: ek-skeleton-pulse ${designToken("motion.duration-ambient")} ease-in-out infinite;
background: ${designToken("background.placeholder")};
border-radius: ${designToken("radius.sm")};
display: block;
}
@@ -768,15 +769,9 @@ export const EKKLESIA_UI_STYLESHEET = `
}
}
/* Every animation in these elements stops for a person who asked for reduced motion; nothing in
them depends on movement to be understood. */
@media (prefers-reduced-motion: reduce) {
.ek-spinner,
.ek-skeleton,
.ek-toast-region .ek-toast {
animation: none;
}
}
/* Every animation above takes its duration from a motion token, which is zero when motion is
reduced — by the system, or by a person's own preference (ADR 0060) — so none of them needs a
reduced-motion rule of its own, and nothing here depends on movement to be understood. */
`;
/** Marks a stylesheet this package installed, so installation is idempotent per root. */
+6 -5
View File
@@ -725,12 +725,13 @@ describe("Skeleton", () => {
expect(group.textContent).toBe("Loading displays");
});
it("stops moving for a person who asked for reduced motion", () => {
const reduced = EKKLESIA_UI_STYLESHEET.slice(
EKKLESIA_UI_STYLESHEET.indexOf("@media (prefers-reduced-motion: reduce)"),
it("stops moving for a person who asked for reduced motion, through the shared motion tokens", () => {
// The pulse lasts one ambient cycle, which the token stylesheet zeroes when motion is reduced —
// by the system or by an explicit preference (ADR 0060) — so the element needs no rule of its own.
expect(EKKLESIA_UI_STYLESHEET).toMatch(
/\.ek-skeleton \{[^}]*animation: ek-skeleton-pulse var\(--ekklesia-motion-duration-ambient\)/su,
);
expect(reduced).toMatch(/\.ek-skeleton[,\s]/u);
expect(reduced).toContain("animation: none");
expect(EKKLESIA_UI_STYLESHEET).not.toContain("prefers-reduced-motion");
});
});
+28
View File
@@ -91,3 +91,31 @@ describe("the shared elements consume design tokens, never hardcoded theme value
expect(document.querySelectorAll(`style[${EKKLESIA_UI_STYLE_ATTRIBUTE}]`).length).toBe(0);
});
});
describe("the element stylesheet takes every colour, radius, and duration from a token (ADR 0060)", () => {
// Comments are dropped: they may mention a value without using it.
const css = EKKLESIA_UI_STYLESHEET.replace(/\/\*[\s\S]*?\*\//gu, "");
it("contains no raw colour", () => {
expect(css).not.toMatch(/#[0-9a-f]{3,8}\b/iu);
expect(css).not.toMatch(/\b(?:rgba?|hsla?|oklch|lab|lch|hwb)\(/iu);
// A named colour is a raw colour too; `transparent` and `currentColor` are not colours.
expect(css).not.toMatch(/:\s*(?:white|black|red|green|blue|gray|grey)\s*;/iu);
});
it("rounds corners only with radius tokens", () => {
for (const match of css.matchAll(/border-radius:\s*([^;]+);/gu)) {
// Each corner is a radius token, or square.
for (const corner of (match[1] ?? "").split(/\s+/u)) {
expect(corner, match[0]).toMatch(/^(?:var\(--ekklesia-radius-[a-z]+\)|0)$/u);
}
}
});
it("animates only for motion-token durations", () => {
for (const match of css.matchAll(/(?:animation|transition):\s*([^;]+);/gu)) {
expect(match[1], match[0]).not.toMatch(/\b\d+(?:\.\d+)?m?s\b/u);
expect(match[1], match[0]).toContain("--ekklesia-motion-duration-");
}
});
});