From 58969359c90990819f417af376566b7cfd3dacfa Mon Sep 17 00:00:00 2001 From: David Gracia Date: Thu, 19 Nov 2026 19:45:17 +0100 Subject: [PATCH] feat(tokens): add color.semantic.warning.border, the warning amber for borders and bars oklch(62% 0.128 80) (#AE7C02): 3.69:1 on surface.card and 3.53:1 on surface.canvas (WCAG 1.4.11), where semantic.warning.fg reaches 2.03:1 and 1.94:1. Born in the Pharos artifact (version 1795113014-0060); snapshot refreshed verbatim. No existing token changes value. Co-Authored-By: Claude Opus 5.5 --- .changeset/warning-border-token.md | 5 +++++ README.md | 4 +++- artifact/README.md | 2 +- artifact/tokens.json | 7 +++++++ src/color.tokens.json | 5 +++++ tests/dist-types/consumer.ts | 1 + tests/wcag-contrast.test.ts | 21 ++++++++++++++++++++- 7 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .changeset/warning-border-token.md diff --git a/.changeset/warning-border-token.md b/.changeset/warning-border-token.md new file mode 100644 index 0000000..b8937d8 --- /dev/null +++ b/.changeset/warning-border-token.md @@ -0,0 +1,5 @@ +--- +'@code-sherpas/pharos-tokens': minor +--- + +Add `color.semantic.warning.border` (`--pharos-color-semantic-warning-border`, `tokens.color.semantic.warning.border`): `oklch(62% 0.128 80)` (#AE7C02), the warning amber for borders and bars, such as the side bar of a warning Alert. It reaches 3.69:1 on `surface.card` and 3.53:1 on `surface.canvas` (WCAG 1.4.11 asks 3:1), where `semantic.warning.fg` reaches 2.03:1 and 1.94:1. Not for text. It comes from the Pharos design system artifact (version `1795113014-0060`). No existing token changes value. diff --git a/README.md b/README.md index d070b81..f4f4bb6 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,8 @@ See [the rules for consumers](https://app.notion.com/p/4071751eee1081b2b000e212c | Width | `width.panel` | Widths by role. `panel`: Sheet and SidePanel (24rem). | | Breakpoint | `breakpoint.{compact,panel}` | By role (D32), read in JS. `compact`: a phone, < 40rem. | +`color.semantic.warning.border` is the warning amber for borders and bars, such as the side bar of a warning Alert: it clears WCAG 3:1 non-text contrast on `surface.card` and `surface.canvas`, where the amber `warning.fg` is a fill and does not. It is not for text. + ## Contributing 1. `pnpm install` @@ -104,7 +106,7 @@ See [the rules for consumers](https://app.notion.com/p/4071751eee1081b2b000e212c 5. `pnpm changeset` — declare the type of change (patch / minor / major). 6. Open a PR. -CI validates WCAG 2.1 AA contrast on every color/on-color pair. A PR cannot be merged if it breaks contrast. +CI validates WCAG 2.1 AA contrast on every color/on-color pair, and 3:1 non-text contrast for the border tokens on the surfaces they sit on. A PR cannot be merged if it breaks contrast. ## License diff --git a/artifact/README.md b/artifact/README.md index 3d77ca4..780e831 100644 --- a/artifact/README.md +++ b/artifact/README.md @@ -11,7 +11,7 @@ because the artifact cannot be read from CI (it needs a claude.ai session): | `tokens.json` | `project/tokens.json` | color, spacing, radius, shadow, z-index, width, breakpoint, text styles (`type.groups`) + usage | | `bundle.css` | `project/components/bundle.css` | font primitives, duration, easing (`:root` vars) | -Snapshot taken from artifact version `1795112145-4b72` on 2026-11-19. +Snapshot taken from artifact version `1795113014-0060` on 2026-11-19. ## Refreshing it diff --git a/artifact/tokens.json b/artifact/tokens.json index 50ddb3a..888abe0 100644 --- a/artifact/tokens.json +++ b/artifact/tokens.json @@ -247,6 +247,13 @@ }, "usage": "Dark text on a semantic-warning-fg (amber) fill." }, + { + "name": "pharos-color-semantic-warning-border", + "value": { + "light": "oklch(62% 0.128 80)" + }, + "usage": "System state only: the warning amber for borders and bars (#AE7C02), such as the side bar of a warning Alert. Clears WCAG 3:1 non-text contrast on surface-card (3.69:1) and surface-canvas (3.53:1), where semantic-warning-fg does not (2.03:1 and 1.94:1). Not for text." + }, { "name": "pharos-color-semantic-info-fg", "value": { diff --git a/src/color.tokens.json b/src/color.tokens.json index e5d5837..1b615a4 100644 --- a/src/color.tokens.json +++ b/src/color.tokens.json @@ -181,6 +181,11 @@ "$value": "{color.neutral.900}", "$type": "color", "$description": "Dark text on a semantic-warning-fg (amber) fill." + }, + "border": { + "$value": "oklch(62% 0.128 80)", + "$type": "color", + "$description": "System state only: the warning amber for borders and bars (#AE7C02), such as the side bar of a warning Alert. Clears WCAG 3:1 non-text contrast on surface-card (3.69:1) and surface-canvas (3.53:1), where semantic-warning-fg does not (2.03:1 and 1.94:1). Not for text." } }, "info": { diff --git a/tests/dist-types/consumer.ts b/tests/dist-types/consumer.ts index d4652a3..d115bd7 100644 --- a/tests/dist-types/consumer.ts +++ b/tests/dist-types/consumer.ts @@ -11,6 +11,7 @@ export const compactBreakpoint: string = tokens.breakpoint.compact; export const panelBreakpoint: string = tokens.breakpoint.panel; export const panelWidth: string = tokens.width.panel; export const neutral900: string = tokens.color.neutral['900']; +export const warningBorder: string = tokens.color.semantic.warning.border; export const sameObject: PharosTokens = defaultTokens; // @ts-expect-error a token that does not exist must not compile, so a rename breaks the consumer diff --git a/tests/wcag-contrast.test.ts b/tests/wcag-contrast.test.ts index 9e338f4..44f6775 100644 --- a/tests/wcag-contrast.test.ts +++ b/tests/wcag-contrast.test.ts @@ -7,6 +7,7 @@ const tokens = tokensRaw as typeof tokensRaw & { base: { white: string; black: string }; neutral: Record; primary: Record; + surface: { canvas: string; card: string }; semantic: { success: { fg: string; bg: string; on: string }; error: { @@ -16,7 +17,7 @@ const tokens = tokensRaw as typeof tokensRaw & { bg: string; on: string; }; - warning: { fg: string; bg: string; on: string }; + warning: { fg: string; bg: string; on: string; border: string }; info: { fg: string; bg: string; on: string }; }; }; @@ -40,6 +41,9 @@ const AA_NORMAL = 4.5; // WCAG 2.1 Level AA minimum contrast ratio for large text // (18pt and larger, or 14pt bold and larger): 3.0:1. const AA_LARGE = 3.0; +// WCAG 2.1 SC 1.4.11 Non-text Contrast: borders, bars and other parts of a +// user-interface component that tell its state apart: 3:1. +const AA_NON_TEXT = 3.0; describe('WCAG 2.1 AA contrast for semantic color pairs', () => { // For each semantic family, `.fg` is the filled surface color (the red pill, @@ -90,6 +94,21 @@ describe('WCAG 2.1 AA contrast for semantic color pairs', () => { }); }); +describe('WCAG 2.1 AA non-text contrast for semantic borders and bars', () => { + // A border or a bar that tells a state apart (the side bar of a warning + // Alert) is a user-interface component part: WCAG 1.4.11 asks 3:1 against + // the colour it sits on. Alerts sit on cards and on the page itself. + const warningBorder = tokens.color.semantic.warning.border; + const surfaces: Array<[string, string]> = [ + ['surface.card', tokens.color.surface.card], + ['surface.canvas', tokens.color.surface.canvas], + ]; + + it.each(surfaces)('semantic.warning.border on %s passes 3:1', (_name, surface) => { + expect(contrast(warningBorder, surface)).toBeGreaterThanOrEqual(AA_NON_TEXT); + }); +}); + describe('WCAG 2.1 AA contrast for error hover/active states', () => { // Interactive states on filled destructive buttons must still be legible // against the same `on` color used for the base state. Hover/active shades