Skip to content

Add accessible text tokens (text-warning/error/success-foreground)#24

Merged
MaxGhenis merged 1 commit intomainfrom
feat/accessible-text-tokens
May 9, 2026
Merged

Add accessible text tokens (text-warning/error/success-foreground)#24
MaxGhenis merged 1 commit intomainfrom
feat/accessible-text-tokens

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

Adds three semantic accessible-on-white text variants to src/theme/tokens.css, mirroring the existing --destructive-foreground shadcn convention:

Token Value Contrast
--text-warning #d9480f (Mantine orange.9) 4.81:1 on white
--text-error #B91C1C (Tailwind red-700) 5.94:1 on white
--text-success #285E61 (primary[700]) 7.07:1 on white

Bridged through @theme inline so consumers get matching Tailwind utilities:

  • text-warning-foreground
  • text-error-foreground
  • text-success-foreground

The existing fill values (--color-warning, --color-error, --color-success) are unchanged. They stay tuned for badges, dots, and chart series — none of those clear WCAG AA when rendered as text on white or on a 12–15% -soft tint.

Why

Discovered while doing a WCAG 2.2 AA pass on policybench. Without these tokens, every consumer ends up redefining accessible text colors locally. With them, the design system covers the case once.

Verification

  • bun run typecheck clean.
  • bun run test — 215/215 pass.
  • bun run build clean.

🤖 Generated with Claude Code

The token set already exposes --color-warning, --color-error, and
--color-success as fill values tuned for badges, status dots, and
chart series. None of those clear WCAG AA when used as text on white
or on a 12-15% -soft tint.

Add three accessible-on-white text variants and bridge them as
Tailwind utilities consistent with the existing --destructive-
foreground convention:

- --text-warning: #d9480f (Mantine orange.9, 4.81:1 on white)
- --text-error:   #B91C1C (Tailwind red-700, 5.94:1 on white)
- --text-success: #285E61 (primary[700], 7.07:1 on white)

Bridges:
- --color-warning-foreground (Tailwind: text-warning-foreground)
- --color-error-foreground   (Tailwind: text-error-foreground)
- --color-success-foreground (Tailwind: text-success-foreground)

Discovered while doing a WCAG 2.2 AA pass on policybench; without these
tokens every consumer ends up redefining accessible text colors locally.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-ui-kit Ready Ready Preview, Comment May 9, 2026 4:26am

Request Review

MaxGhenis added a commit to PolicyEngine/policybench that referenced this pull request May 9, 2026
@policyengine/ui-kit is the canonical PolicyEngine design system per
the org's CLAUDE guidance (new standalone tools should ship on
ui-kit). The legacy @policyengine/design-system lives inside
PolicyEngine/policyengine-app-v2/packages/design-system and is on a
deprecation track.

Changes
- package.json: drop @policyengine/design-system, add
  @policyengine/ui-kit ^0.4.0.
- globals.css: import @policyengine/ui-kit/theme.css instead of the
  design-system one.
- theme.css: rewrite the policybench-local --color-* alias layer to
  resolve to ui-kit's :root vars (--background, --card, --border-medium,
  --text-primary, --primary, --color-teal-500, --color-gray-600, etc.)
  rather than --pe-color-*. The accessible text aliases route through
  --text-warning / --text-error / --text-success (added in
  PolicyEngine/policyengine-ui-kit#24, with hex fallbacks until a
  release ships).
- modelMeta.ts: replace runtime imports of `colors` and `chartColors`
  from design-system with var(--color-...) string references that the
  CSSOM resolves at render time. No JS-bundled color values.

The component layer is unchanged — every Tailwind class call site
(`bg-card`, `text-text-secondary`, `text-text-muted`, etc.) still
works because the same alias names are re-exported through theme.css.

Verification
- bunx eslint . --max-warnings=0 clean
- bun run build clean (still ○ static)
- SSR HTML / contains: <h1 class="sr-only">, skip-to-content,
  Open-set banner, Snapshot 2026-05-01 pill, Sensitivity views
  including Household-weighted, Show 95% intervals toggle,
  aria-disabled / aria-pressed states intact.
@MaxGhenis MaxGhenis merged commit 9233f86 into main May 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant