Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/warning-border-token.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion artifact/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions artifact/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 5 additions & 0 deletions src/color.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions tests/dist-types/consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion tests/wcag-contrast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const tokens = tokensRaw as typeof tokensRaw & {
base: { white: string; black: string };
neutral: Record<string, string>;
primary: Record<string, string>;
surface: { canvas: string; card: string };
semantic: {
success: { fg: string; bg: string; on: string };
error: {
Expand All @@ -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 };
};
};
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down