Skip to content

[T-085a] Web design tokens, fonts, base/print CSS and WCAG contrast test #162

Closed

Description

@CodewithJha

Task T-085a · Milestone M8 — Dashboard · Size S · Priority P0 · Epic #8

Implements FR-DSH-008 · NFR-ACC-001

Branch feat/t-085a-web-design-tokens-fonts-base — one task = one branch = one PR (doc 32 §6)

Summary

Implement the 'Field Notebook' design system foundation: web/src/styles/tokens.css (light + dark themes exactly per doc 13 §1.1), tokens.json (single source also consumed by the backend report theme, T-078a), self-hosted fonts (no CDN), base.css, print.css, and a unit test asserting WCAG AA contrast for every text/background token pair.

Context / motivation

Every screen and the static report depend on these tokens; doing them first prevents per-screen colour drift.

Scope

In scope

  • scripts/gen_tokens.ts (or plain JSON → CSS generation) so CSS and JSON can never diverge.
  • Theme switching via data-theme attribute + prefers-color-scheme default.

Out of scope

  • Components (T-086a–c).

Implementation guidance

  • Source of truth web/src/styles/tokens.json ({"light": {"--paper": "#…", …}, "dark": {…}, "font": {…}, "space": {…}, "radius": {…}, "motion": {…}}) holding exactly the values in doc 13 §1.1–1.3. web/scripts/gen-tokens.ts (pnpm gen:tokens, also run in prebuild) emits tokens.css (:root[data-theme="light"]{…} / [data-theme="dark"]{…} plus a prefers-color-scheme: dark default) and copies the JSON to backend/src/roboprobe/reporting/assets/tokens.json for the report theme (T-078a).
  • Fonts (doc 13 §1.2) self-hosted as WOFF2 in web/public/fonts/ with @font-face + font-display: swap; record licences (OFL) in web/public/fonts/LICENSES.md.
  • base.css: modern reset, focus ring outline: 2px solid var(--margin-line) on :focus-visible, prefers-reduced-motion disables transitions. print.css: A4, hide MarginRail, break-before: page utility.
  • The contrast test computes WCAG relative luminance in TS (no dependency) for a declared list of foreground/background pairs (tokens.pairs.json) in both themes.
  • stylelint: stylelint-config-standard + color-no-hex (ignoring src/styles/tokens.css) and a disallowed-list rule for raw px font sizes outside tokens.
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Configuration keys

From the configuration reference (doc 27). Keys marked (new) must be added to the typed settings models and appear in the generated reference (T-003c).

  • defaultTheme / ROBOPROBE_WEB_DEFAULT_THEME (web runtime config)

Acceptance criteria

  • Contrast test passes for all pairs (≥ 4.5:1 body, ≥ 3:1 large/UI).
  • Fonts load offline (no external requests in the built bundle).
  • stylelint rejects raw hex in feature CSS.
  • pnpm gen:tokens is idempotent (second run produces no diff; CI check).
  • Dark theme passes the same contrast pairs.
  • prefers-reduced-motion respected.
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • web/src/styles/tokens.test.ts.
  • Snapshot of generated tokens.css.

Dependencies

Blocked by: #13 (T-007)

Blocks: #163 (T-085b), #166 (T-086a), #167 (T-086b), #174 (T-089b), #175 (T-089c)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • web/src/styles/**
  • web/public/fonts/**
  • web/.stylelintrc.json

Parallel with T-085c (API client).

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-085a (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 13 §1 · doc 13 §1.1 · doc 13 §1.2 · doc 13 §1.3 · doc 16 §4 · doc 27 §4.11

Requirements: FR-DSH-008 · NFR-ACC-001 (traceability: doc 28)

External:

Activity

  1. added this to the M8 — Dashboard milestone on Nov 19, 2026
  2. added a commit that references this issue on Nov 19, 2026
    6c72676
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:dashboardReact web dashboardmilestone:M8M8 — Dashboardpriority:P0Critical path / blocks otherssize:S<= 1 daytaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions