From 4b693a979456d9087aabd89e6b0dc1b08ee82124 Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Wed, 2 Dec 2026 10:12:07 +0300 Subject: [PATCH 01/13] Add a RadioGroup primitive with the checkbox's edge and a solid focus ring --- app/src/components/ui/radio-group.tsx | 50 +++++++++++++++++++++++++++ app/tests/ui-primitives-look.test.ts | 34 ++++++++++++++++++ docs/design-system.md | 25 +++++++++----- tokens/tests/contrast.test.ts | 3 ++ 4 files changed, 104 insertions(+), 8 deletions(-) create mode 100644 app/src/components/ui/radio-group.tsx diff --git a/app/src/components/ui/radio-group.tsx b/app/src/components/ui/radio-group.tsx new file mode 100644 index 0000000000..1b286829d0 --- /dev/null +++ b/app/src/components/ui/radio-group.tsx @@ -0,0 +1,50 @@ +import { Radio as RadioPrimitive } from "@base-ui/react/radio"; +import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group"; + +import { cn } from "@/lib/utils"; + +function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) { + return ( + + ); +} + +/* + * shadcn's radio group (Base UI), drawn as the checkbox beside it is drawn. + * + * THE EDGE IS `muted-foreground`, not shadcn's `input`. A radio nobody has chosen is nothing but + * its edge, and `input` is the faint line of a field, about 1.25:1 against a card in light and + * 1.38:1 in dark; WCAG 2.2's 1.4.11 asks for 3:1. The checkbox's edge is `muted-foreground` for + * the same reason (app/tests/checkbox-contrast.test.tsx). + * + * A CHOSEN RADIO IS A RING WITH A DOT: the edge turns `primary` and a `primary` dot sits on what + * the radio stands on, so it never reads as a ticked checkbox. + * + * KEYBOARD FOCUS IS THE BUTTON'S SOLID RING: the edge turns `ring`, chosen or not, and 3px more of + * it are drawn outside, 4px in all. An invalid radio is filled with `destructive/10` and keeps its + * edge under the ring: `destructive`, or `primary` once chosen. No halo hides the ring. Disabled + * is half strength. No hover, as the checkbox has none, and no shadow. + */ +function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) { + return ( + + + + ); +} + +export { RadioGroup, RadioGroupItem }; diff --git a/app/tests/ui-primitives-look.test.ts b/app/tests/ui-primitives-look.test.ts index 3d93a45eb2..5fc96fa86e 100644 --- a/app/tests/ui-primitives-look.test.ts +++ b/app/tests/ui-primitives-look.test.ts @@ -120,6 +120,40 @@ describe("the primitives keep the look", () => { expect(sizes).toContain('page: "h-9 text-sm"'); }); + /* + * A radio is shadcn's, drawn as the checkbox beside it is (components/ui/radio-group.tsx): an + * edge that can be seen, a ring with a dot when chosen, and the button's solid focus ring. + */ + test("a radio's edge can be seen: muted-foreground, never a field's faint input", () => { + expect(has("radio-group.tsx", "border-muted-foreground")).toBe(true); + expect(has("radio-group.tsx", "border-input")).toBe(false); + }); + + test("a chosen radio is a ring in primary with a dot, never a filled disc", () => { + const all = classes(source("radio-group.tsx")); + expect(all).toContain("data-checked:border-primary"); + // Invalid too: `aria-invalid` comes after `data-checked` in Tailwind's order. + expect(all).toContain("aria-invalid:aria-checked:border-primary"); + expect(all.filter((name) => name.startsWith("data-checked:bg-"))).toEqual( + [], + ); + // The dot. + expect(all).toContain("bg-primary"); + }); + + test("a radio's keyboard focus is a solid ring in --ring, chosen or not", () => { + const all = classes(source("radio-group.tsx")); + expect(all).toContain("focus-visible:border-ring"); + expect(all).toContain("focus-visible:ring-3"); + expect(all).toContain("focus-visible:ring-ring"); + // A chosen radio's `primary` edge would otherwise win over the focus edge. + expect(all).toContain("data-checked:focus-visible:border-ring"); + // No faded ring, and no invalid halo laid over it. + expect( + all.filter((name) => /(^|:)ring-(ring|destructive)\/\d+$/.test(name)), + ).toEqual([]); + }); + test("the page's panel is flat, with the card's corner", () => { const inset = classes(source("sidebar.tsx")).filter((name) => name.includes("peer-data-[variant=inset]:"), diff --git a/docs/design-system.md b/docs/design-system.md index 08ae60b509..2abe9d644e 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -29,9 +29,9 @@ compatible means two things stay true, and a change is checked against both: 1. **A stock shadcn component fits in.** Copy a component from shadcn's registry into `components/ui`, in its Base UI flavor, and it takes our colors, corners and type from the - tokens as it is. The one edit it may need is to its corner and shadow steps, to the ones - [the look](app-guidelines.md#the-look) names. If it needs more than that, the system has - drifted. + tokens as it is. The edits it may need are its corner and shadow steps, to the ones + [the look](app-guidelines.md#the-look) names, and its focus ring, made solid (see + [Primitives](#primitives)). If it needs more than that, the system has drifted. 2. **A stock shadcn theme restyles everything.** Set only shadcn's standard variables (`--background`, `--primary`, `--radius` and the rest) and the whole app follows: every primitive, every screen, light and dark. @@ -96,7 +96,8 @@ changed in `tokens/src/scheme.ts` and written out with `bun run tokens:generate` `--spacing-menu-item-x`, not `--radius-card`. A stock shadcn theme doesn't set them, so they stay at our values while everything else changes, and the theme is broken. A state is made from the tokens there are, as shadcn does it: hover is `hover:bg-primary/80` or `hover:bg-muted`, disabled - is `disabled:opacity-50`, focus is `ring-ring/50`, invalid is `destructive`. + is `disabled:opacity-50`, focus is a solid ring in `ring` (see [Primitives](#primitives)), + invalid is `destructive`. - **A token is a token wherever it is declared.** `:root`, `.dark`, `@theme` or a component's own stylesheet: the rules above hold for all of them. The test reads only `:root` and `.dark`; the rule is wider than the test. @@ -132,6 +133,14 @@ changed in `tokens/src/scheme.ts` and written out with `bun run tokens:generate` screens as they were, it is the wrong change. - **Every state, both modes.** A primitive is done when rest, hover, focus, pressed, disabled and invalid are all drawn, in light and in dark, and the keyboard reaches it. +- **Keyboard focus is a solid ring in `ring`, drawn outside the control.** The edge turns `ring` + and 3px more are drawn outside it, 4px in all: `focus-visible:border-ring focus-visible:ring-3 + focus-visible:ring-ring`, or the same on `has-[…:focus-visible]` where a field is a group. + Outside, the ring is read against what the control stands on, which + `tokens/tests/contrast.test.ts` holds at 3:1; shadcn's half-strength `ring-ring/50` is 1.75:1 on + the page in light. No state fades the ring or gives it another color: an invalid field keeps its + `destructive` edge and gets the same ring. A primitive that still draws the half ring moves to + this one in a pull request of its own. ## The rest of the look @@ -156,10 +165,10 @@ icons a screen draws with. What it leaves to this page: onboarding and empty states included. If a design hands you a video of an animation, build the animation. - **Check contrast before you choose a color,** in light and in dark: 4.5:1 for text, 3:1 for the - edge of a control that has no other cue, such as a checkbox, and for the focus ring. A line - (`border`, `input`) is about 1.25:1 against a card in light and 1.38:1 in dark, so such an edge, - and a mark like the scrollbar's thumb, is `muted-foreground`, never a line. A color that fails as - text is not rescued with a second token for "the same color, as text". + edge of a control that has no other cue, such as a checkbox or a radio, and for the focus ring. A + line (`border`, `input`) is about 1.25:1 against a card in light and 1.38:1 in dark, so such an + edge, and a mark like the scrollbar's thumb, is `muted-foreground`, never a line. A color that + fails as text is not rescued with a second token for "the same color, as text". - **Motion stops when less motion is asked for.** An animation in code can stand still. Don't swap in a picture of one frame. diff --git a/tokens/tests/contrast.test.ts b/tokens/tests/contrast.test.ts index 6257a273fe..e25ca30e60 100644 --- a/tokens/tests/contrast.test.ts +++ b/tokens/tests/contrast.test.ts @@ -38,6 +38,9 @@ const PAIRS: [Token, Token[], number][] = [ ["sidebar-accent-foreground", ["sidebar-accent", "sidebar"], TEXT], ["ring", ["background"], NON_TEXT], ["ring", ["card"], NON_TEXT], + // A control's ring is drawn outside it, on whatever it stands on: a dialog, a muted row. + ["ring", ["popover"], NON_TEXT], + ["ring", ["muted"], NON_TEXT], ["sidebar-ring", ["sidebar"], NON_TEXT], ]; From 3e9976107234042f67e328b161e3c602cc2bc269 Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Wed, 2 Dec 2026 21:34:16 +0300 Subject: [PATCH 02/13] Add a Badge primitive: pills, a dot for success and warning, chips through render Co-Authored-By: Claude Opus 5.5 --- app/src/components/ui/badge.tsx | 69 ++++++++++++++++++++++++++++ app/tests/ui-primitives-look.test.ts | 43 +++++++++++++++++ docs/design-system.md | 4 +- tokens/tests/contrast.test.ts | 34 ++++++++++++-- 4 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 app/src/components/ui/badge.tsx diff --git a/app/src/components/ui/badge.tsx b/app/src/components/ui/badge.tsx new file mode 100644 index 0000000000..8a7c9b4044 --- /dev/null +++ b/app/src/components/ui/badge.tsx @@ -0,0 +1,69 @@ +import { mergeProps } from "@base-ui/react/merge-props"; +import { useRender } from "@base-ui/react/use-render"; +import { cva, type VariantProps } from "class-variance-authority"; + +import { cn } from "@/lib/utils"; + +/* + * shadcn's badge (Base UI): a pill, in shadcn's one size, 20px with `text-xs`. + * + * SUCCESS AND WARNING ARE A DOT AND A TINT, and the words are `foreground`. As words, `success` + * and `warning` fall under 4.5:1 in light once their 10% tint is under them on the page, a muted + * row or the sidebar (success 4.05 to 4.48, warning 4.33 and 4.44), and a color that fails as text + * is not rescued with a second token (docs/design-system.md). The dot carries the color: 3:1 or + * more on its tint. A leading icon takes the dot's place and its color. `destructive` reads as + * text on its tint everywhere, 5.15:1 or more, so an error badge keeps its colored words, as the + * button's `destructive` does. + * + * A CHIP IS THE SAME BADGE, rendered as a link or a button (`render`). Only then does the pointer + * deepen its fill, and its keyboard focus is the button's solid ring. Disabled is half strength. + */ +const badgeVariants = cva( + "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,background-color,border-color,box-shadow] duration-150 ease-out outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:pointer-events-none [&>svg]:size-3!", + { + variants: { + variant: { + default: + "bg-primary text-primary-foreground [a,button]:hover:bg-primary/80", + secondary: + "bg-secondary text-secondary-foreground [a,button]:hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]", + destructive: + "bg-destructive/10 text-destructive [a,button]:hover:bg-destructive/20", + success: + "bg-success/10 pl-1.5 text-foreground before:size-1.5 before:shrink-0 before:rounded-full before:bg-success before:content-[''] has-data-[icon=inline-start]:before:hidden [&>svg]:text-success [a,button]:hover:bg-success/20", + warning: + "bg-warning/10 pl-1.5 text-foreground before:size-1.5 before:shrink-0 before:rounded-full before:bg-warning before:content-[''] has-data-[icon=inline-start]:before:hidden [&>svg]:text-warning [a,button]:hover:bg-warning/20", + outline: "border-border text-foreground [a,button]:hover:bg-muted", + ghost: "[a,button]:hover:bg-muted", + link: "text-primary underline-offset-4 [a,button]:hover:underline", + }, + }, + defaultVariants: { + variant: "default", + }, + }, +); + +function Badge({ + className, + variant = "default", + render, + ...props +}: useRender.ComponentProps<"span"> & VariantProps) { + return useRender({ + defaultTagName: "span", + props: mergeProps<"span">( + { + className: cn(badgeVariants({ variant }), className), + }, + props, + ), + render, + state: { + slot: "badge", + variant, + }, + }); +} + +export { Badge, badgeVariants }; diff --git a/app/tests/ui-primitives-look.test.ts b/app/tests/ui-primitives-look.test.ts index 5fc96fa86e..5bf3406e0c 100644 --- a/app/tests/ui-primitives-look.test.ts +++ b/app/tests/ui-primitives-look.test.ts @@ -154,6 +154,49 @@ describe("the primitives keep the look", () => { ).toEqual([]); }); + /* + * A badge is shadcn's, a pill in shadcn's one size (components/ui/badge.tsx). Success and + * warning are a dot and a tint with `foreground` words: as words they fail on some surfaces + * (tokens/tests/contrast.test.ts). A chip is the same badge rendered as a link or a button. + */ + test("a badge is a pill in one size", () => { + const all = classes(source("badge.tsx")); + expect(all).toContain("rounded-full"); + expect(all).toContain("h-5"); + expect(all).toContain("text-xs"); + expect(all.filter((name) => /^(h|text)-(\d|sm|base)/.test(name))).toEqual([ + "h-5", + ]); + }); + + test("a success or warning badge is a dot and a tint, with foreground words", () => { + const all = classes(source("badge.tsx")); + for (const tone of ["success", "warning"]) { + expect(all).toContain(`bg-${tone}/10`); + expect(all).toContain(`before:bg-${tone}`); + expect(all).not.toContain(`text-${tone}`); + } + expect(all).toContain("text-foreground"); + // An error badge keeps its colored words, as the button's destructive does. + expect(all).toContain("text-destructive"); + }); + + test("a badge changes under the pointer only as a chip, with the solid focus ring", () => { + const all = classes(source("badge.tsx")); + expect( + all.filter( + (name) => + name.includes("hover:") && !name.startsWith("[a,button]:hover:"), + ), + ).toEqual([]); + expect(all).toContain("focus-visible:border-ring"); + expect(all).toContain("focus-visible:ring-3"); + expect(all).toContain("focus-visible:ring-ring"); + expect( + all.filter((name) => /(^|:)ring-(ring|destructive)\/\d+$/.test(name)), + ).toEqual([]); + }); + test("the page's panel is flat, with the card's corner", () => { const inset = classes(source("sidebar.tsx")).filter((name) => name.includes("peer-data-[variant=inset]:"), diff --git a/docs/design-system.md b/docs/design-system.md index 2abe9d644e..6c5daa3932 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -168,7 +168,9 @@ icons a screen draws with. What it leaves to this page: edge of a control that has no other cue, such as a checkbox or a radio, and for the focus ring. A line (`border`, `input`) is about 1.25:1 against a card in light and 1.38:1 in dark, so such an edge, and a mark like the scrollbar's thumb, is `muted-foreground`, never a line. A color that - fails as text is not rescued with a second token for "the same color, as text". + fails as text is not rescued with a second token for "the same color, as text": the words go in + `foreground` and the color goes on a mark, as a `success` or `warning` badge carries its color + on a dot. - **Motion stops when less motion is asked for.** An animation in code can stand still. Don't swap in a picture of one frame. diff --git a/tokens/tests/contrast.test.ts b/tokens/tests/contrast.test.ts index e25ca30e60..a942428d6e 100644 --- a/tokens/tests/contrast.test.ts +++ b/tokens/tests/contrast.test.ts @@ -9,15 +9,18 @@ import { type Mode, scheme, type Token } from "../src/scheme"; * second token for "the same color, as text". * * WCAG 2's relative luminance and contrast ratio (tokens/src/color.ts), on the scheme's sRGB - * values. A translucent color (the selected sidebar row's tint) is laid over the surface it sits - * on first. + * values. A translucent color (the selected sidebar row's tint, an invalid field's + * `destructive/10`) is laid over the surface it sits on first. */ const TEXT = 4.5; const NON_TEXT = 3; +/** A surface: a token, or a token at an opacity as Tailwind writes it (`destructive/10`). */ +type Layer = Token | `${Token}/${number}`; + /** [what is read, the surfaces it is read on (a translucent one over the one after it), minimum] */ -const PAIRS: [Token, Token[], number][] = [ +const PAIRS: [Token, Layer[], number][] = [ ["foreground", ["background"], TEXT], ["card-foreground", ["card"], TEXT], ["popover-foreground", ["popover"], TEXT], @@ -36,6 +39,19 @@ const PAIRS: [Token, Token[], number][] = [ ["sidebar-foreground", ["sidebar"], TEXT], ["sidebar-primary-foreground", ["sidebar-primary"], TEXT], ["sidebar-accent-foreground", ["sidebar-accent", "sidebar"], TEXT], + // A badge's words on its fill, wherever a badge stands: the page, a card, a menu, a muted row, + // the sidebar. Success and warning are a dot on a tint with `foreground` words; an error badge + // keeps its colored words, at rest and under the pointer (a chip's `destructive/20`). + ...(["background", "card", "popover", "muted", "sidebar"] as const).flatMap( + (ground): [Token, Layer[], number][] => [ + ["foreground", ["success/10", ground], TEXT], + ["foreground", ["warning/10", ground], TEXT], + ["destructive", ["destructive/10", ground], TEXT], + ["destructive", ["destructive/20", ground], TEXT], + ["success", ["success/10", ground], NON_TEXT], + ["warning", ["warning/10", ground], NON_TEXT], + ], + ), ["ring", ["background"], NON_TEXT], ["ring", ["card"], NON_TEXT], // A control's ring is drawn outside it, on whatever it stands on: a dialog, a muted row. @@ -44,8 +60,16 @@ const PAIRS: [Token, Token[], number][] = [ ["sidebar-ring", ["sidebar"], NON_TEXT], ]; -function surface(mode: Mode, layers: Token[]): Rgb { - const colors = layers.map((token) => oklchToRgb(scheme[mode][token])); +function color(mode: Mode, layer: Layer): Rgb { + const [token, percent] = layer.split("/") as [Token, string | undefined]; + const rgb = oklchToRgb(scheme[mode][token]); + return percent === undefined + ? rgb + : { ...rgb, alpha: (rgb.alpha * Number(percent)) / 100 }; +} + +function surface(mode: Mode, layers: Layer[]): Rgb { + const colors = layers.map((layer) => color(mode, layer)); return colors.reduceRight((under, top) => over(top, under)); } From 948ab46c6b50e2217f3d9ad1045dbf8308a686bc Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Thu, 3 Dec 2026 09:44:56 +0300 Subject: [PATCH 03/13] Add an Alert primitive: a tint, the icon on a tile, foreground words, an action on the right Co-Authored-By: Claude Opus 5.5 --- app/src/components/ui/alert.tsx | 99 ++++++++++++++++++++++++++++ app/tests/ui-primitives-look.test.ts | 22 +++++++ docs/design-system.md | 2 +- tokens/tests/contrast.test.ts | 11 ++++ 4 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 app/src/components/ui/alert.tsx diff --git a/app/src/components/ui/alert.tsx b/app/src/components/ui/alert.tsx new file mode 100644 index 0000000000..27127bc0fb --- /dev/null +++ b/app/src/components/ui/alert.tsx @@ -0,0 +1,99 @@ +import { cva, type VariantProps } from "class-variance-authority"; +import type * as React from "react"; + +import { cn } from "@/lib/utils"; + +/* + * shadcn's Alert: a notice that stands in the page, with an icon, a title, a description and an + * action, drawn as the design's Notifications draw a toast (a tint, the icon on a tile of its own, + * the action on the right). + * + * IT SITS IN THE PAGE, so it has a card's corner and a card's hairline in `border`, and no shadow. + * The design's toast floats over the app; that is `toast.tsx`, not this. + * + * `success` and `warning` are ours, beside shadcn's `default` and `destructive`. Every status is a + * 10% tint, and its color is on the icon and its tile; the words are `foreground`, so they read on + * the tint wherever the alert stands. `success` and `warning` fall under 4.5:1 as words on their + * tint in light (components/ui/badge.tsx), and a red title over a red tint is shouting. `default` + * is a card with `muted-foreground` words under the title, as shadcn draws it. + */ +const alertVariants = cva( + "group/alert relative grid w-full grid-cols-[minmax(0,1fr)] items-center gap-x-3 gap-y-0.5 rounded-lg border border-border px-4 py-3 text-left text-sm has-[>svg]:grid-cols-[auto_minmax(0,1fr)] has-data-[slot=alert-action]:grid-cols-[minmax(0,1fr)_auto] has-[>svg]:has-data-[slot=alert-action]:grid-cols-[auto_minmax(0,1fr)_auto] has-data-[slot=alert-description]:[&>svg]:row-span-2 [&>svg]:size-8 [&>svg]:shrink-0 [&>svg]:self-start [&>svg]:rounded-md [&>svg]:p-2", + { + variants: { + variant: { + default: "bg-card text-card-foreground [&>svg]:bg-muted", + destructive: + "bg-destructive/10 text-foreground *:data-[slot=alert-description]:text-foreground [&>svg]:bg-destructive/10 [&>svg]:text-destructive", + success: + "bg-success/10 text-foreground *:data-[slot=alert-description]:text-foreground [&>svg]:bg-success/10 [&>svg]:text-success", + warning: + "bg-warning/10 text-foreground *:data-[slot=alert-description]:text-foreground [&>svg]:bg-warning/10 [&>svg]:text-warning", + }, + }, + defaultVariants: { + variant: "default", + }, + }, +); + +function Alert({ + className, + variant = "default", + ...props +}: React.ComponentProps<"div"> & VariantProps) { + return ( +
+ ); +} + +function AlertTitle({ className, ...props }: React.ComponentProps<"div">) { + return ( +
svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3", + className, + )} + {...props} + /> + ); +} + +function AlertDescription({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_p:not(:last-child)]:mb-4", + className, + )} + {...props} + /> + ); +} + +/** What the alert asks for, on its right: a button or two. */ +function AlertAction({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ); +} + +export { Alert, AlertAction, AlertDescription, AlertTitle }; diff --git a/app/tests/ui-primitives-look.test.ts b/app/tests/ui-primitives-look.test.ts index 5bf3406e0c..fa64a16dc7 100644 --- a/app/tests/ui-primitives-look.test.ts +++ b/app/tests/ui-primitives-look.test.ts @@ -197,6 +197,28 @@ describe("the primitives keep the look", () => { ).toEqual([]); }); + /* + * An alert is shadcn's, standing in the page (components/ui/alert.tsx): a card's corner and + * hairline, no shadow. A status is a tint, with its color on the icon and its tile; the words + * are `foreground` (tokens/tests/contrast.test.ts). + */ + test("an alert sits in the page: a card's corner and hairline, no shadow", () => { + const all = classes(source("alert.tsx")); + expect(all).toContain("rounded-lg"); + expect(all).toContain("border-border"); + expect(all.filter((name) => /(^|:)shadow-/.test(name))).toEqual([]); + }); + + test("an alert's status is a tint and an icon, with foreground words", () => { + const all = classes(source("alert.tsx")); + for (const tone of ["destructive", "success", "warning"]) { + expect(all).toContain(`bg-${tone}/10`); + expect(all).toContain(`[&>svg]:text-${tone}`); + expect(all).not.toContain(`text-${tone}`); + } + expect(all).toContain("*:data-[slot=alert-description]:text-foreground"); + }); + test("the page's panel is flat, with the card's corner", () => { const inset = classes(source("sidebar.tsx")).filter((name) => name.includes("peer-data-[variant=inset]:"), diff --git a/docs/design-system.md b/docs/design-system.md index 6c5daa3932..bfbf45880f 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -170,7 +170,7 @@ icons a screen draws with. What it leaves to this page: edge, and a mark like the scrollbar's thumb, is `muted-foreground`, never a line. A color that fails as text is not rescued with a second token for "the same color, as text": the words go in `foreground` and the color goes on a mark, as a `success` or `warning` badge carries its color - on a dot. + on a dot and an alert on its icon. - **Motion stops when less motion is asked for.** An animation in code can stand still. Don't swap in a picture of one frame. diff --git a/tokens/tests/contrast.test.ts b/tokens/tests/contrast.test.ts index a942428d6e..1d92500a4e 100644 --- a/tokens/tests/contrast.test.ts +++ b/tokens/tests/contrast.test.ts @@ -52,6 +52,17 @@ const PAIRS: [Token, Layer[], number][] = [ ["warning", ["warning/10", ground], NON_TEXT], ], ), + // An alert's words on its tint, and its icon on its tile (the tint again, over the tint), wherever + // an alert stands: the page, a card, a menu, a muted row. + ...(["background", "card", "popover", "muted"] as const).flatMap( + (ground): [Token, Layer[], number][] => + (["destructive", "success", "warning"] as const).flatMap( + (tone): [Token, Layer[], number][] => [ + ["foreground", [`${tone}/10`, ground], TEXT], + [tone, [`${tone}/10`, `${tone}/10`, ground], NON_TEXT], + ], + ), + ), ["ring", ["background"], NON_TEXT], ["ring", ["card"], NON_TEXT], // A control's ring is drawn outside it, on whatever it stands on: a dialog, a muted row. From 8475653d470435e9b6ff76d9a602dc0c8798be60 Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Thu, 3 Dec 2026 10:34:00 +0300 Subject: [PATCH 04/13] Checkbox: a dash when partly ticked, a hover, the solid focus ring, flat; the radio's hover too Co-Authored-By: Claude Opus 5.5 --- app/src/components/ui/checkbox.tsx | 18 +++++++++++-- app/src/components/ui/radio-group.tsx | 9 ++++--- app/tests/ui-primitives-look.test.ts | 38 +++++++++++++++++++++++++++ docs/app-guidelines.md | 2 +- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/app/src/components/ui/checkbox.tsx b/app/src/components/ui/checkbox.tsx index 699acdf8a7..035a84cccf 100644 --- a/app/src/components/ui/checkbox.tsx +++ b/app/src/components/ui/checkbox.tsx @@ -10,13 +10,23 @@ import { cn } from "@/lib/utils"; * 1.4.11 asks for 3:1 between a control and what is beside it; `muted-foreground` is the app's * secondary text, at 4.5:1 or more on every surface in every skin. Ticked, focused and invalid keep * their own edges. app/tests/checkbox-contrast.test.tsx measures what the browser paints. + * + * PARTLY TICKED (`indeterminate`) is filled as a ticked box is, with a dash for the tick. + * + * UNDER THE POINTER an empty box's edge turns `foreground`, and a ticked one's fill eases to + * `primary/80`, as the button's does. An invalid box keeps its `destructive` edge. + * + * KEYBOARD FOCUS IS THE BUTTON'S SOLID RING: the edge turns `ring`, ticked or not, and 3px more of + * it are drawn outside, 4px in all. An invalid box is filled with `destructive/10` under a + * `destructive` edge; ticked, it stays `primary`, as a chosen radio does. No halo hides the ring. + * Disabled is half strength. Flat, as the radio is: no shadow. */ function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) { return ( - + + ); diff --git a/app/src/components/ui/radio-group.tsx b/app/src/components/ui/radio-group.tsx index 1b286829d0..71ad0fcf1d 100644 --- a/app/src/components/ui/radio-group.tsx +++ b/app/src/components/ui/radio-group.tsx @@ -27,21 +27,24 @@ function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) { * KEYBOARD FOCUS IS THE BUTTON'S SOLID RING: the edge turns `ring`, chosen or not, and 3px more of * it are drawn outside, 4px in all. An invalid radio is filled with `destructive/10` and keeps its * edge under the ring: `destructive`, or `primary` once chosen. No halo hides the ring. Disabled - * is half strength. No hover, as the checkbox has none, and no shadow. + * is half strength, and there is no shadow. + * + * UNDER THE POINTER, as the checkbox: an empty radio's edge turns `foreground`, and a chosen one's + * edge and dot ease to `primary/80`. An invalid radio keeps its `destructive` edge. */ function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) { return ( ); diff --git a/app/tests/ui-primitives-look.test.ts b/app/tests/ui-primitives-look.test.ts index fa64a16dc7..088807bdf4 100644 --- a/app/tests/ui-primitives-look.test.ts +++ b/app/tests/ui-primitives-look.test.ts @@ -154,6 +154,44 @@ describe("the primitives keep the look", () => { ).toEqual([]); }); + /* + * The checkbox (components/ui/checkbox.tsx): a dash when partly ticked, the button's solid focus + * ring, a ticked box that stays `primary` when invalid, as a chosen radio does. Under the pointer + * an empty box or radio darkens its edge; a ticked or chosen one eases to `primary/80`. Both are + * flat. + */ + test("a partly ticked checkbox is filled, with a dash for the tick", () => { + const all = classes(source("checkbox.tsx")); + expect(all).toContain("data-indeterminate:bg-primary"); + expect(all).toContain("group-data-indeterminate/checkbox:hidden"); + expect(all).toContain("group-data-indeterminate/checkbox:block"); + }); + + test("a checkbox's keyboard focus is the solid ring, and ticked stays primary when invalid", () => { + const all = classes(source("checkbox.tsx")); + expect(all).toContain("focus-visible:ring-ring"); + expect(all).toContain("data-checked:focus-visible:border-ring"); + expect(all).toContain("aria-invalid:bg-destructive/10"); + expect(all).toContain("aria-invalid:data-checked:bg-primary"); + expect( + all.filter((name) => /(^|:)ring-(ring|destructive)\/\d+$/.test(name)), + ).toEqual([]); + }); + + test.each(["checkbox.tsx", "radio-group.tsx"])( + "%s answers the pointer and stays flat", + (file) => { + const all = classes(source(file)); + expect(all).toContain( + "data-unchecked:hover:not-data-disabled:not-aria-invalid:border-foreground", + ); + expect(all).toContain( + "data-checked:hover:not-data-disabled:border-primary/80", + ); + expect(all.filter((name) => /(^|:)shadow-/.test(name))).toEqual([]); + }, + ); + /* * A badge is shadcn's, a pill in shadcn's one size (components/ui/badge.tsx). Success and * warning are a dot and a tint with `foreground` words: as words they fail on some surfaces diff --git a/docs/app-guidelines.md b/docs/app-guidelines.md index dc973e180f..57cff4c312 100644 --- a/docs/app-guidelines.md +++ b/docs/app-guidelines.md @@ -374,7 +374,7 @@ changes, for every screen at once, in a change agreed first. steps only: - none for everything in the page: the panel, cards, rows, fields, the sidebar; - `shadow-xs` for a control pressed on a surface: an outlined button, a switch's knob, the - chosen tab, a checkbox; + chosen tab. A checkbox and a radio are flat; - `shadow-lg` and a border for what opens beside the thing that opened it: menus, selects, popovers, tooltips, toasts; - `shadow-2xl` and a border for what sits over the app: dialogs, the command menu, sheets. From d2560bcc4df4738e5889dbf0292507777dcf1dae Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Thu, 3 Dec 2026 13:28:25 +0300 Subject: [PATCH 05/13] Tabs: pills, regular words, a flat white chosen tab, a hover fill and the solid focus ring Co-Authored-By: Claude Opus 5.5 --- app/src/components/ui/tabs.tsx | 15 +++++++++++---- app/tests/ui-primitives-look.test.ts | 26 +++++++++++++++++++++----- docs/app-guidelines.md | 13 +++++++------ 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/app/src/components/ui/tabs.tsx b/app/src/components/ui/tabs.tsx index 8d63d99d95..e425d0f9ea 100644 --- a/app/src/components/ui/tabs.tsx +++ b/app/src/components/ui/tabs.tsx @@ -21,7 +21,7 @@ function Tabs({ } const tabsListVariants = cva( - "group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none", + "group/tabs-list inline-flex w-fit items-center justify-center rounded-full p-[3px] group-data-vertical/tabs:rounded-lg text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none", { variants: { variant: { @@ -50,14 +50,21 @@ function TabsList({ ); } +/* + * A tab is a pill on a pill-shaped list, as a button is (a vertical list keeps the control + * corners). The words are regular, in `muted-foreground`. The chosen tab is flat: a `card` on the + * list's `muted`, with `foreground` words, no line and no shadow. Under the pointer a tab not + * chosen takes the list's fill a step darker, as a `secondary` button does. Keyboard focus is the + * button's solid ring. The `line` variant keeps shadcn's underline and draws no fill. + */ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) { return ( { /outline:\s*"([^"]*)"/.exec(source("button.tsx"))?.[1] ?? ""; expect(outline.split(/\s+/)).toContain("shadow-xs"); expect(has("switch.tsx", "shadow-xs")).toBe(true); - expect( - classes(source("tabs.tsx")).some((name) => - name.endsWith("data-active:shadow-xs"), - ), - ).toBe(true); + }); + + /* + * Tabs are pills on a pill, as the design draws them (components/ui/tabs.tsx), in regular + * `muted-foreground` words. The chosen tab is flat: a `card` on the list's `muted`, with no line + * and no shadow. A tab not chosen takes a + * darker fill under the pointer. Focus is the button's solid ring. + */ + test("a row of tabs is a pill, its chosen tab flat, its focus the solid ring", () => { + const all = classes(source("tabs.tsx")); + expect(all).toContain("rounded-full"); + expect(all).toContain("data-active:bg-card"); + expect(all).toContain("text-muted-foreground"); + expect(all).toContain("font-normal"); + expect(all.filter((name) => /(^|:)shadow-/.test(name))).toEqual([]); + expect(all).not.toContain("data-active:border-border"); + expect(all.some((name) => name.includes("hover:not-data-active:bg-"))).toBe( + true, + ); + expect(all).toContain("focus-visible:ring-ring"); + expect(all.filter((name) => /(^|:)ring-ring\/\d+$/.test(name))).toEqual([]); }); test("a sidebar row keeps shadcn's sizes, and a page's menu has its own beside them", () => { diff --git a/docs/app-guidelines.md b/docs/app-guidelines.md index 57cff4c312..2905290f4c 100644 --- a/docs/app-guidelines.md +++ b/docs/app-guidelines.md @@ -361,10 +361,11 @@ changes, for every screen at once, in a change agreed first. `text-sm`; labels, times and counts are `text-xs`. The line under a row's name (`ItemDescription`) is `text-sm` too, in `muted-foreground`: the name's weight and color set it apart. No text size written by hand (`text-[13px]`). -3. **Corners.** All from `--radius`, 10px, the design's radius base. Controls are `rounded-md` - (8px), cards and the page's panel `rounded-lg` (10px), menus, dialogs and the message box - `rounded-xl` (14px), round things `rounded-full`. `rounded-none` squares a part off. No other - step and no corner of its own (`rounded-[20px]`). +3. **Corners.** From `--radius`, 10px, the design's radius base, except a row of tabs'. Controls + are `rounded-md` (8px), cards and the page's panel `rounded-lg` (10px), menus, dialogs and the + message box `rounded-xl` (14px), round things `rounded-full`. Tabs and their list are pills + (`rounded-full`) at any `--radius`. `rounded-none` squares a part off. No other step and no + corner of its own (`rounded-[20px]`). 4. **Surfaces.** The frame (`sidebar`), the panel the page sits in (`background`), cards on it (`card`). A card has a hairline border in light and in dark. Every line (`border`, a field's `input`, the sidebar's `sidebar-border`) is the text color at 10% in light and 12% in dark, @@ -373,8 +374,8 @@ changes, for every screen at once, in a change agreed first. 5. **Shadows.** A shadow says how far something floats, as Linear draws it, and Tailwind's own steps only: - none for everything in the page: the panel, cards, rows, fields, the sidebar; - - `shadow-xs` for a control pressed on a surface: an outlined button, a switch's knob, the - chosen tab. A checkbox and a radio are flat; + - `shadow-xs` for a control pressed on a surface: an outlined button, a switch's knob. A + checkbox, a radio and the chosen tab are flat; - `shadow-lg` and a border for what opens beside the thing that opened it: menus, selects, popovers, tooltips, toasts; - `shadow-2xl` and a border for what sits over the app: dialogs, the command menu, sheets. From 7c8d36d68a706d9fe193d608a1a305ea9aeb5d68 Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Thu, 3 Dec 2026 17:36:06 +0300 Subject: [PATCH 06/13] Table: a muted header strip, xs regular headings and a shared sort button Co-Authored-By: Claude Opus 5.5 --- app/src/components/artifacts/kinds/table.tsx | 51 ++++++---------- app/src/components/audit/audit-table.tsx | 30 +++++---- app/src/components/ui/table.tsx | 64 ++++++++++++++++++-- app/tests/ui-look-guard.allowlist.json | 2 +- app/tests/ui-primitives-look.test.ts | 33 +++++++++- docs/app-guidelines.md | 6 +- docs/design-system.md | 4 +- 7 files changed, 129 insertions(+), 61 deletions(-) diff --git a/app/src/components/artifacts/kinds/table.tsx b/app/src/components/artifacts/kinds/table.tsx index 50626c7f3f..9767f51160 100644 --- a/app/src/components/artifacts/kinds/table.tsx +++ b/app/src/components/artifacts/kinds/table.tsx @@ -10,6 +10,7 @@ import { TableHead, TableHeader, TableRow, + TableSortButton, } from "@/components/ui/table"; import { cn } from "@/lib/utils"; import { ALIGN_CLASS, alignOf, CellText } from "./cells"; @@ -112,51 +113,39 @@ export function ArtifactTable({ className={size === "large" ? "text-lg" : undefined} containerClassName="min-h-0 flex-1" > - - + + {columns.map((column, index) => { const align = alignOf(column); - const active = sort?.column === index; + const order = + sort?.column === index + ? sort.ascending + ? "ascending" + : "descending" + : undefined; return ( {onPaper ? ( // Paper can't be sorted: the heading alone. - - {column.label} - + column.label ) : ( - + {column.label} + )} ); diff --git a/app/src/components/audit/audit-table.tsx b/app/src/components/audit/audit-table.tsx index 6325a6c7dd..738154047a 100644 --- a/app/src/components/audit/audit-table.tsx +++ b/app/src/components/audit/audit-table.tsx @@ -1,9 +1,4 @@ -import { - IconArrowDown, - IconArrowUp, - IconCirclePlus, - IconSearch, -} from "@/components/icons"; +import { IconCirclePlus, IconSearch } from "@/components/icons"; import { useQuery } from "@tanstack/react-query"; import { type ColumnDef, @@ -36,6 +31,7 @@ import { TableHead, TableHeader, TableRow, + TableSortButton, } from "@/components/ui/table"; import { useIsMobile } from "@/hooks/use-mobile"; import { type AuditOutcome, outcomeOf } from "@/lib/audit/outcome"; @@ -92,6 +88,13 @@ const STACKED_ON_A_PHONE = new Set(["bot", "decision"]); const INITIAL_SORT: SortingState = [{ id: "when", desc: true }]; +/** A heading's `aria-sort`, for the column the rows are sorted by. */ +function ariaSort(sorted: false | "asc" | "desc") { + if (sorted === "asc") return "ascending"; + if (sorted === "desc") return "descending"; + return undefined; +} + const OUTCOME_LABEL: Record = { allowed: "Allowed", refused: "Blocked", @@ -206,11 +209,12 @@ export function AuditTable({ > {table.getHeaderGroups().map((group) => ( - + {group.headers .filter((header) => drawn(header.column.id)) .map((header) => ( { const sorted = column.getIsSorted(); return ( - + ); }, cell: ({ row }) => , diff --git a/app/src/components/ui/table.tsx b/app/src/components/ui/table.tsx index dfb6ea52d7..257378a8bb 100644 --- a/app/src/components/ui/table.tsx +++ b/app/src/components/ui/table.tsx @@ -1,4 +1,9 @@ import type * as React from "react"; +import { + IconArrowDown, + IconArrowsVertical, + IconArrowUp, +} from "@/components/icons"; import { cn } from "@/lib/utils"; @@ -32,11 +37,12 @@ function TableHeader({ className, ...props }: React.ComponentProps<"thead">) { ) { ); } +/** A column's heading: a label, so `text-xs` in regular weight and `muted-foreground`. */ function TableHead({ className, ...props }: React.ComponentProps<"th">) { return ( ) { ); } +/* + * A heading that sorts its column: the words and an arrow, with no fill. The arrow says the order: + * up for ascending, down for descending, and a pair when the column isn't sorted. The sorted + * column's arrow is `foreground`, its words stay `muted-foreground`. Under the pointer the words and + * the arrow turn `foreground`. Keyboard focus is the button's solid ring, drawn round the words; the + * button reaches 6px into the cell's padding on each side so the words line up with the column's. + * Disabled is half strength. The heading cell carries `aria-sort`. + */ +function TableSortButton({ + className, + children, + sort = false, + ...props +}: React.ComponentProps<"button"> & { + sort?: "ascending" | "descending" | false; +}) { + const Arrow = + sort === "ascending" + ? IconArrowUp + : sort === "descending" + ? IconArrowDown + : IconArrowsVertical; + return ( + + ); +} + function TableCell({ className, ...props }: React.ComponentProps<"td">) { return ( ) { ); } -export { Table, TableBody, TableCell, TableHead, TableHeader, TableRow }; +export { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, + TableSortButton, +}; diff --git a/app/tests/ui-look-guard.allowlist.json b/app/tests/ui-look-guard.allowlist.json index 753e6a06f3..0a39a2f785 100644 --- a/app/tests/ui-look-guard.allowlist.json +++ b/app/tests/ui-look-guard.allowlist.json @@ -31,7 +31,7 @@ }, "components/audit/audit-table.tsx": { "corner": 1, - "cornerStep": 2 + "cornerStep": 1 }, "components/auth/cloud-sign-in.tsx": { "darkColor": 3 diff --git a/app/tests/ui-primitives-look.test.ts b/app/tests/ui-primitives-look.test.ts index 12ecf0ac29..4d55748288 100644 --- a/app/tests/ui-primitives-look.test.ts +++ b/app/tests/ui-primitives-look.test.ts @@ -22,9 +22,6 @@ const ALLOWED: Partial>>> = { "checkbox.tsx": { cornerStep: ["rounded-sm"] }, // The same 16px box, drawn for a questionnaire's choices. "questionnaire.tsx": { cornerStep: ["rounded-sm"] }, - // A line, not depth: the pinned header's rule. A collapsed table border belongs to the rows - // and scrolls away with them, so the line is drawn inside the header instead. - "table.tsx": { shadow: ["shadow-[inset_0_-1px_0_var(--color-border)]"] }, }; describe("the primitives keep the look", () => { @@ -128,6 +125,36 @@ describe("the primitives keep the look", () => { expect(all.filter((name) => /(^|:)ring-ring\/\d+$/.test(name))).toEqual([]); }); + /* + * A table's header is a strip of `muted` with no line under it, its headings labels: `text-xs`, + * regular, `muted-foreground` (components/ui/table.tsx). A heading that sorts is its words and an + * arrow, with no fill: under the pointer they turn `foreground`. Focus is the button's solid ring. + */ + test("a table's header is a muted strip, its headings regular xs labels", () => { + const all = classes(source("table.tsx")); + expect(all).toContain("bg-muted"); + expect(all.filter((name) => /(^|:)shadow-/.test(name))).toEqual([]); + expect(all).toContain("[&_tr]:hover:bg-transparent"); + expect(all).toContain("text-xs"); + expect(all).toContain("font-normal"); + expect(all).not.toContain("font-medium"); + expect(all).toContain("text-muted-foreground"); + }); + + test("a table's sorting heading has no fill, and the solid focus ring", () => { + const sort = + /function TableSortButton[\s\S]*?className=\{cn\(\s*"([^"]*)"/.exec( + source("table.tsx"), + )?.[1] ?? ""; + const all = sort.split(/\s+/); + expect(all).toContain("hover:text-foreground"); + expect(all.filter((name) => /(^|:)bg-/.test(name))).toEqual([]); + expect(all).toContain("focus-visible:border-ring"); + expect(all).toContain("focus-visible:ring-3"); + expect(all).toContain("focus-visible:ring-ring"); + expect(all.filter((name) => /(^|:)ring-ring\/\d+$/.test(name))).toEqual([]); + }); + test("a sidebar row keeps shadcn's sizes, and a page's menu has its own beside them", () => { const sizes = /size:\s*\{([^}]*)\}/.exec(source("sidebar.tsx"))?.[1] ?? ""; expect(sizes).toContain('default: "h-8 text-sm"'); diff --git a/docs/app-guidelines.md b/docs/app-guidelines.md index 2905290f4c..c16a84e9bd 100644 --- a/docs/app-guidelines.md +++ b/docs/app-guidelines.md @@ -358,9 +358,9 @@ changes, for every screen at once, in a change agreed first. 1. **Colors.** Only the scheme's tokens, as above. 2. **Type.** Figtree on Tailwind's own type scale, in whole pixels: `text-xs` is 12px, `text-sm` 14px, `text-base` 16px and a page title's `text-2xl` 24px. Controls, rows and navigation are - `text-sm`; labels, times and counts are `text-xs`. The line under a row's name - (`ItemDescription`) is `text-sm` too, in `muted-foreground`: the name's weight and color set it - apart. No text size written by hand (`text-[13px]`). + `text-sm`; labels (a table's column headings among them), times and counts are `text-xs`. The + line under a row's name (`ItemDescription`) is `text-sm` too, in `muted-foreground`: the name's + weight and color set it apart. No text size written by hand (`text-[13px]`). 3. **Corners.** From `--radius`, 10px, the design's radius base, except a row of tabs'. Controls are `rounded-md` (8px), cards and the page's panel `rounded-lg` (10px), menus, dialogs and the message box `rounded-xl` (14px), round things `rounded-full`. Tabs and their list are pills diff --git a/docs/design-system.md b/docs/design-system.md index bfbf45880f..9c6998a47a 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -51,8 +51,8 @@ A screen is a few surfaces, one on another. Each level has its token, and the to | Beside | `popover` | What opens beside what opened it: menus, selects, popovers. | A border and `shadow-lg` | | Over | `popover` | What sits over the app: dialogs, sheets, the command menu. | A border and `shadow-2xl` | -On a surface, a fill marks a part of it: `secondary` and `muted` for a button, a badge or a tile, -`accent` for the highlighted row of a menu. Each surface and fill has a `-foreground` for the text +On a surface, a fill marks a part of it: `secondary` and `muted` for a button, a badge, a tile or a +table's header, `accent` for the highlighted row of a menu. Each surface and fill has a `-foreground` for the text on it. Every line is `border`, the text color at one strength (10% in light, 12% in dark), so no line is fainter than another. From 8d530263877e4bbc2e3541eab5dcae13b3af7e3d Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Thu, 3 Dec 2026 18:59:01 +0300 Subject: [PATCH 07/13] Item: a row that opens something lights under the pointer, link or button, with the solid focus ring Co-Authored-By: Claude Opus 5.5 --- .claude/skills/openbot-screen-layout/SKILL.md | 4 +++- app/src/components/artifacts/artifacts-page.tsx | 5 +---- app/src/components/settings/learning-review.tsx | 2 +- app/src/components/ui/item.tsx | 8 +++++++- app/src/routes/_authed/admin/components/$name.tsx | 4 ++-- app/src/skins/openfuse/bots-sheet.tsx | 4 ++-- app/src/skins/openfuse/menu-sheet.tsx | 2 +- app/src/skins/openfuse/ui.tsx | 2 +- app/tests/ui-primitives-look.test.ts | 15 +++++++++++++++ 9 files changed, 33 insertions(+), 13 deletions(-) diff --git a/.claude/skills/openbot-screen-layout/SKILL.md b/.claude/skills/openbot-screen-layout/SKILL.md index bd933ddfd6..82d26624b8 100644 --- a/.claude/skills/openbot-screen-layout/SKILL.md +++ b/.claude/skills/openbot-screen-layout/SKILL.md @@ -158,7 +158,9 @@ button. `className="line-clamp-none"`. 7. To make the whole row navigate or open something, pass `render`: `render={
- + + } + /> diff --git a/app/tests/ui-primitives-look.test.ts b/app/tests/ui-primitives-look.test.ts index 3344313e1d..a4ad16c6a6 100644 --- a/app/tests/ui-primitives-look.test.ts +++ b/app/tests/ui-primitives-look.test.ts @@ -171,11 +171,11 @@ describe("the primitives keep the look", () => { }); /* - * The switch, a chat bubble that is a link or a button, and a questionnaire's choice and field take - * the button's solid focus ring; an invalid switch or field keeps its `destructive` edge with no - * halo laid over the ring. + * The switch, a chat bubble that is a link or a button, a questionnaire's choice and field, and a + * toast take the button's solid focus ring; an invalid switch or field keeps its `destructive` + * edge with no halo laid over the ring. */ - test.each(["switch.tsx", "bubble.tsx", "questionnaire.tsx"])( + test.each(["switch.tsx", "bubble.tsx", "questionnaire.tsx", "toast.tsx"])( "%s draws the solid focus ring, never the faded one or a halo", (file) => { const all = classes(source(file)); @@ -188,6 +188,19 @@ describe("the primitives keep the look", () => { }, ); + /* + * A toast is the design's notification: a popover card with its status on the icon's tile, as an + * alert's (components/ui/toast.tsx), and its one action the main button. + */ + test("a toast carries its status on the icon's tile, and its action is the main button", () => { + const text = source("toast.tsx"); + const all = classes(text); + for (const tone of ["success", "warning", "destructive"]) + expect(all).toContain(`bg-${tone}/10`); + expect(all).toContain("size-8"); + expect(text).not.toContain('variant="outline"'); + }); + test("a sidebar row keeps shadcn's sizes, and a page's menu has its own beside them", () => { const sizes = /size:\s*\{([^}]*)\}/.exec(source("sidebar.tsx"))?.[1] ?? ""; expect(sizes).toContain('default: "h-8 text-sm"'); diff --git a/docs/design-system.md b/docs/design-system.md index 9c6998a47a..a20fe871e9 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -170,7 +170,7 @@ icons a screen draws with. What it leaves to this page: edge, and a mark like the scrollbar's thumb, is `muted-foreground`, never a line. A color that fails as text is not rescued with a second token for "the same color, as text": the words go in `foreground` and the color goes on a mark, as a `success` or `warning` badge carries its color - on a dot and an alert on its icon. + on a dot, and an alert or a toast on its icon's tile. - **Motion stops when less motion is asked for.** An animation in code can stand still. Don't swap in a picture of one frame. From 543d3806278b4bce83716bea73367a515a587a79 Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Thu, 3 Dec 2026 19:59:42 +0300 Subject: [PATCH 10/13] Lines: one opaque gray, the design's Lines/border (#E7E7E8 light, #2B323A dark) Co-Authored-By: Claude Opus 5.5 --- app/src/lib/artifacts/tokens.css | 12 +++---- app/src/theme.css | 12 +++---- app/tests/ui-look-theme.test.ts | 23 ++++++-------- desktop/src-tauri/src/connected/sign_in.rs | 4 +-- desktop/src-tauri/src/first_paint.rs | 4 +-- desktop/src/styles.css | 8 ++--- docs/app-guidelines.md | 7 ++-- docs/design-system.md | 10 +++--- mobile/global.css | 16 +++++----- mobile/src/scheme.ts | 12 +++---- tokens/src/scheme.ts | 21 ++++++------ tokens/tests/generated.test.ts | 37 ++++++++++++++++------ 12 files changed, 91 insertions(+), 75 deletions(-) diff --git a/app/src/lib/artifacts/tokens.css b/app/src/lib/artifacts/tokens.css index 1c1d3ce30e..82ed3a413a 100644 --- a/app/src/lib/artifacts/tokens.css +++ b/app/src/lib/artifacts/tokens.css @@ -19,8 +19,8 @@ --destructive: oklch(0.46 0.173 22.6); --success: oklch(0.514 0.1 167.2); --warning: oklch(0.521 0.143 47.7); - --border: oklch(0.108 0.042 264.7 / 10%); - --input: oklch(0.108 0.042 264.7 / 10%); + --border: oklch(0.928 0.001 252); + --input: oklch(0.928 0.001 252); --ring: oklch(0.638 0.167 276.1); --chart-1: oklch(0.46 0.2 264); --chart-2: oklch(0.66 0.146 66); @@ -34,7 +34,7 @@ --sidebar-primary-foreground: oklch(1 0 0); --sidebar-accent: oklch(0.832 0.085 281.4 / 30%); --sidebar-accent-foreground: oklch(0.108 0.042 264.7); - --sidebar-border: oklch(0.108 0.042 264.7 / 10%); + --sidebar-border: oklch(0.928 0.001 252); --sidebar-ring: oklch(0.638 0.167 276.1); --radius: 0.625rem; } @@ -58,8 +58,8 @@ --destructive: oklch(0.792 0.121 16.4); --success: oklch(0.832 0.13 170.1); --warning: oklch(0.828 0.189 84.4); - --border: oklch(0.956 0.004 252 / 12%); - --input: oklch(0.956 0.004 252 / 12%); + --border: oklch(0.314 0.017 251.8); + --input: oklch(0.314 0.017 251.8); --ring: oklch(0.713 0.151 277.7); --chart-1: oklch(0.58 0.2 264); --chart-2: oklch(0.76 0.168 66); @@ -73,6 +73,6 @@ --sidebar-primary-foreground: oklch(0.108 0.017 252); --sidebar-accent: oklch(0.832 0.085 281.4 / 12%); --sidebar-accent-foreground: oklch(0.956 0.004 252); - --sidebar-border: oklch(0.956 0.004 252 / 12%); + --sidebar-border: oklch(0.314 0.017 251.8); --sidebar-ring: oklch(0.713 0.151 277.7); } diff --git a/app/src/theme.css b/app/src/theme.css index 6bc3c73c7a..7e85e7a125 100644 --- a/app/src/theme.css +++ b/app/src/theme.css @@ -31,8 +31,8 @@ --destructive: oklch(0.46 0.173 22.6); --success: oklch(0.514 0.1 167.2); --warning: oklch(0.521 0.143 47.7); - --border: oklch(0.108 0.042 264.7 / 10%); - --input: oklch(0.108 0.042 264.7 / 10%); + --border: oklch(0.928 0.001 252); + --input: oklch(0.928 0.001 252); --ring: oklch(0.638 0.167 276.1); --chart-1: oklch(0.46 0.2 264); --chart-2: oklch(0.66 0.146 66); @@ -46,7 +46,7 @@ --sidebar-primary-foreground: oklch(1 0 0); --sidebar-accent: oklch(0.832 0.085 281.4 / 30%); --sidebar-accent-foreground: oklch(0.108 0.042 264.7); - --sidebar-border: oklch(0.108 0.042 264.7 / 10%); + --sidebar-border: oklch(0.928 0.001 252); --sidebar-ring: oklch(0.638 0.167 276.1); /* end of tokens/src/scheme.ts */ /* @@ -84,8 +84,8 @@ --destructive: oklch(0.792 0.121 16.4); --success: oklch(0.832 0.13 170.1); --warning: oklch(0.828 0.189 84.4); - --border: oklch(0.956 0.004 252 / 12%); - --input: oklch(0.956 0.004 252 / 12%); + --border: oklch(0.314 0.017 251.8); + --input: oklch(0.314 0.017 251.8); --ring: oklch(0.713 0.151 277.7); --chart-1: oklch(0.58 0.2 264); --chart-2: oklch(0.76 0.168 66); @@ -99,7 +99,7 @@ --sidebar-primary-foreground: oklch(0.108 0.017 252); --sidebar-accent: oklch(0.832 0.085 281.4 / 12%); --sidebar-accent-foreground: oklch(0.956 0.004 252); - --sidebar-border: oklch(0.956 0.004 252 / 12%); + --sidebar-border: oklch(0.314 0.017 251.8); --sidebar-ring: oklch(0.713 0.151 277.7); /* end of tokens/src/scheme.ts */ --empty-pattern-opacity: 0.15; diff --git a/app/tests/ui-look-theme.test.ts b/app/tests/ui-look-theme.test.ts index fd64a85bed..c4f0839c43 100644 --- a/app/tests/ui-look-theme.test.ts +++ b/app/tests/ui-look-theme.test.ts @@ -50,29 +50,24 @@ describe("the look's theme values", () => { }); /* - * A hairline is the text color, at 10% in light and 12% in dark (Sam, 2026-12-01): about 1.25:1 - * against a card in light and 1.38:1 in dark. At 20% and 16% (1.6:1) cards and rows read heavy and - * boxed beside ChatGPT, Claude and Grok, whose lines are 4% to 10%. One value for lines between - * things, a field's edge and the sidebar's lines, so no line in the app is fainter than another. - * An edge that must reach 3:1 (a checkbox's) is `muted-foreground`, never a line. + * A hairline is one opaque gray, the design's `Lines/border` (Figma UI Kit, 2026-12-03): #E7E7E8 + * in light and #2B323A in dark, about 1.24:1 against a card in light and 1.36:1 in dark, as light + * as the lines in ChatGPT, Claude and Grok. One value for lines between things, a field's edge and + * the sidebar's lines. On a gray fill it is fainter than on a card: a line never has to carry a + * control. An edge that must reach 3:1 (a checkbox's) is `muted-foreground`, never a line. */ test.each([ - [":root", "10%"], - [".dark", "12%"], - ])("%s draws every line in the text color at %s", (selector, strength) => { + [":root", "oklch(0.928 0.001 252)"], + [".dark", "oklch(0.314 0.017 251.8)"], + ])("%s draws every line in one opaque gray, %s", (selector, gray) => { const block = new RegExp( `(?:^|[};])\\s*${selector.replace(".", "\\.")}\\s*\\{([^}]*)\\}`, ).exec(withoutComments)?.[1] ?? ""; const value = (name: string) => new RegExp(`--${name}:\\s*([^;]+);`).exec(block)?.[1].trim(); - const foreground = value("foreground")?.replace(/\)$/, ""); - expect(foreground).toBeDefined(); for (const name of ["border", "input", "sidebar-border"]) - expect({ name, value: value(name) }).toEqual({ - name, - value: `${foreground} / ${strength})`, - }); + expect({ name, value: value(name) }).toEqual({ name, value: gray }); }); /* diff --git a/desktop/src-tauri/src/connected/sign_in.rs b/desktop/src-tauri/src/connected/sign_in.rs index 6c3a15d8c4..55c4a613e1 100644 --- a/desktop/src-tauri/src/connected/sign_in.rs +++ b/desktop/src-tauri/src/connected/sign_in.rs @@ -1367,7 +1367,7 @@ const END_PAGE_STYLE: &str = r#" --foreground: oklch(0.108 0.042 264.7); --card: oklch(1 0 0); --muted-foreground: oklch(0.506 0.045 257.4); - --border: oklch(0.108 0.042 264.7 / 10%); + --border: oklch(0.928 0.001 252); --sidebar: oklch(0.948 0.01 251.8); /* end of tokens/src/scheme.ts */ --shadow: 0 1px 2px oklch(0.108 0.042 264.7 / 4%), 0 24px 64px -16px oklch(0.45 0.12 276 / 22%); @@ -1382,7 +1382,7 @@ const END_PAGE_STYLE: &str = r#" --foreground: oklch(0.956 0.004 252); --card: oklch(0.212 0.017 252); --muted-foreground: oklch(0.69 0.016 252); - --border: oklch(0.956 0.004 252 / 12%); + --border: oklch(0.314 0.017 251.8); --sidebar: oklch(0.156 0.017 252); /* end of tokens/src/scheme.ts */ --shadow: 0 1px 2px oklch(0 0 0 / 30%), 0 24px 64px -16px oklch(0 0 0 / 60%); diff --git a/desktop/src-tauri/src/first_paint.rs b/desktop/src-tauri/src/first_paint.rs index 77baa2480a..b2ccd7e660 100644 --- a/desktop/src-tauri/src/first_paint.rs +++ b/desktop/src-tauri/src/first_paint.rs @@ -67,7 +67,7 @@ pub const LIGHT: Palette = Palette { // tokens/src/scheme.ts, light: ground=sidebar card=card border=border ink=foreground soft=muted-foreground (bun run tokens:generate) ground: (0xe9, 0xee, 0xf4), card: (0xff, 0xff, 0xff), - border: (0xe6, 0xe6, 0xe7), + border: (0xe7, 0xe7, 0xe8), ink: (0x01, 0x03, 0x13), soft: (0x55, 0x66, 0x7f), // end of tokens/src/scheme.ts @@ -78,7 +78,7 @@ pub const DARK: Palette = Palette { // tokens/src/scheme.ts, dark: ground=sidebar card=card border=border ink=foreground soft=muted-foreground (bun run tokens:generate) ground: (0x07, 0x0d, 0x14), card: (0x13, 0x19, 0x20), - border: (0x2d, 0x33, 0x39), + border: (0x2b, 0x32, 0x3a), ink: (0xee, 0xf1, 0xf3), soft: (0x94, 0x9c, 0xa5), // end of tokens/src/scheme.ts diff --git a/desktop/src/styles.css b/desktop/src/styles.css index f15a804dc0..f3645c4a47 100644 --- a/desktop/src/styles.css +++ b/desktop/src/styles.css @@ -32,8 +32,8 @@ --muted-foreground: oklch(0.506 0.045 257.4); --destructive: oklch(0.46 0.173 22.6); --success: oklch(0.514 0.1 167.2); - --border: oklch(0.108 0.042 264.7 / 10%); - --input: oklch(0.108 0.042 264.7 / 10%); + --border: oklch(0.928 0.001 252); + --input: oklch(0.928 0.001 252); --ring: oklch(0.638 0.167 276.1); --sidebar: oklch(0.948 0.01 251.8); --sidebar-accent: oklch(0.832 0.085 281.4 / 30%); @@ -2527,8 +2527,8 @@ main > .sheet:has(.journey.handing-off) .self-contained-why { --muted-foreground: oklch(0.69 0.016 252); --destructive: oklch(0.792 0.121 16.4); --success: oklch(0.832 0.13 170.1); - --border: oklch(0.956 0.004 252 / 12%); - --input: oklch(0.956 0.004 252 / 12%); + --border: oklch(0.314 0.017 251.8); + --input: oklch(0.314 0.017 251.8); --ring: oklch(0.713 0.151 277.7); --sidebar: oklch(0.156 0.017 252); --sidebar-accent: oklch(0.832 0.085 281.4 / 12%); diff --git a/docs/app-guidelines.md b/docs/app-guidelines.md index c16a84e9bd..d31ac0a876 100644 --- a/docs/app-guidelines.md +++ b/docs/app-guidelines.md @@ -368,9 +368,10 @@ changes, for every screen at once, in a change agreed first. corner of its own (`rounded-[20px]`). 4. **Surfaces.** The frame (`sidebar`), the panel the page sits in (`background`), cards on it (`card`). A card has a hairline border in light and in dark. Every line (`border`, a field's - `input`, the sidebar's `sidebar-border`) is the text color at 10% in light and 12% in dark, - about 1.25:1 against a card in light and 1.38:1 in dark, so no line in the app is fainter than - another. A line is never the only cue of a control: a checkbox's edge is `muted-foreground`. + `input`, the sidebar's `sidebar-border`) is one opaque gray, the design's `Lines/border`: + #E7E7E8 in light and #2B323A in dark, about 1.24:1 against a card in light and 1.36:1 in dark, + fainter on a gray fill. A line is never the only cue of a control: a checkbox's edge is + `muted-foreground`. 5. **Shadows.** A shadow says how far something floats, as Linear draws it, and Tailwind's own steps only: - none for everything in the page: the panel, cards, rows, fields, the sidebar; diff --git a/docs/design-system.md b/docs/design-system.md index a20fe871e9..62f7c39da2 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -52,9 +52,11 @@ A screen is a few surfaces, one on another. Each level has its token, and the to | Over | `popover` | What sits over the app: dialogs, sheets, the command menu. | A border and `shadow-2xl` | On a surface, a fill marks a part of it: `secondary` and `muted` for a button, a badge, a tile or a -table's header, `accent` for the highlighted row of a menu. Each surface and fill has a `-foreground` for the text -on it. Every line is `border`, the text color at one strength (10% in light, 12% in dark), so no -line is fainter than another. +table's header, `accent` for the highlighted row of a menu. Each surface and fill has a +`-foreground` for the text on it. Every line is `border`, one opaque gray, the design's +`Lines/border` (#E7E7E8 in light, #2B323A in dark): a line between things, a field's edge and the +sidebar's lines are the same value. It is about 1.24:1 on a card and fainter on a gray fill, so a +line never carries a control on its own. - **Choose the level by what the thing is,** never by the shade you want. A form is a card. A list of rows sits on the panel, split by lines, with no card. If a card looks wrong where you @@ -215,7 +217,7 @@ A change to a token or a primitive changes every screen, so it lands differently | [`app/tests/color-scheme.test.ts`](../app/tests/color-scheme.test.ts) | No class from Tailwind's palette in a screen. | | [`app/tests/ui-look-guard.test.ts`](../app/tests/ui-look-guard.test.ts) | No corner, shadow, text size, `dark:` color or hand-drawn card of a screen's own. | | [`app/tests/ui-primitives-look.test.ts`](../app/tests/ui-primitives-look.test.ts) | Every primitive keeps the look's corner and shadow steps, a copied shadcn one included. | -| [`app/tests/ui-look-theme.test.ts`](../app/tests/ui-look-theme.test.ts) | The one radius, the icons' line, and every line at one strength. | +| [`app/tests/ui-look-theme.test.ts`](../app/tests/ui-look-theme.test.ts) | The one radius, the icons' line, and every line in one opaque gray. | | [`app/tests/icon-set.test.ts`](../app/tests/icon-set.test.ts) | One icon set in the web app, the extension and OpenBot Desktop, taken from its module. | | [`tokens/tests/slate.test.ts`](../tokens/tests/slate.test.ts) | The grays are one family, in light and in dark. | | [`tokens/tests/contrast.test.ts`](../tokens/tests/contrast.test.ts) | Text reads on the surfaces it is set on (4.5:1) and the focus ring shows (3:1), in light and in dark. | diff --git a/mobile/global.css b/mobile/global.css index 87f0a846eb..0872bae5e1 100644 --- a/mobile/global.css +++ b/mobile/global.css @@ -51,7 +51,7 @@ --field-background: oklch(1 0 0); --field-foreground: oklch(0.108 0.042 264.7); --field-placeholder: oklch(0.506 0.045 257.4); - --field-border: oklch(0.108 0.042 264.7 / 10%); + --field-border: oklch(0.928 0.001 252); --success: oklch(0.514 0.1 167.2); --success-foreground: oklch(1 0 0); --warning: oklch(0.521 0.143 47.7); @@ -60,8 +60,8 @@ --danger-foreground: oklch(1 0 0); --segment: oklch(1 0 0); --segment-foreground: oklch(0.108 0.042 264.7); - --border: oklch(0.108 0.042 264.7 / 10%); - --separator: oklch(0.108 0.042 264.7 / 10%); + --border: oklch(0.928 0.001 252); + --separator: oklch(0.928 0.001 252); --focus: oklch(0.638 0.167 276.1); --link: oklch(0.108 0.042 264.7); --fill: oklch(0.956 0.009 250.2); @@ -69,7 +69,7 @@ --sidebar-foreground: oklch(0.108 0.042 264.7); --sidebar-accent: oklch(0.832 0.085 281.4 / 30%); --sidebar-accent-foreground: oklch(0.108 0.042 264.7); - --sidebar-border: oklch(0.108 0.042 264.7 / 10%); + --sidebar-border: oklch(0.928 0.001 252); /* end of tokens/src/scheme.ts */ } @variant dark { @@ -92,7 +92,7 @@ --field-background: oklch(0.212 0.017 252); --field-foreground: oklch(0.956 0.004 252); --field-placeholder: oklch(0.69 0.016 252); - --field-border: oklch(0.956 0.004 252 / 12%); + --field-border: oklch(0.314 0.017 251.8); --success: oklch(0.832 0.13 170.1); --success-foreground: oklch(0.108 0.017 252); --warning: oklch(0.828 0.189 84.4); @@ -101,8 +101,8 @@ --danger-foreground: oklch(0.108 0.017 252); --segment: oklch(0.212 0.017 252); --segment-foreground: oklch(0.956 0.004 252); - --border: oklch(0.956 0.004 252 / 12%); - --separator: oklch(0.956 0.004 252 / 12%); + --border: oklch(0.314 0.017 251.8); + --separator: oklch(0.314 0.017 251.8); --focus: oklch(0.713 0.151 277.7); --link: oklch(0.956 0.004 252); --fill: oklch(0.253 0.017 252); @@ -110,7 +110,7 @@ --sidebar-foreground: oklch(0.956 0.004 252); --sidebar-accent: oklch(0.832 0.085 281.4 / 12%); --sidebar-accent-foreground: oklch(0.956 0.004 252); - --sidebar-border: oklch(0.956 0.004 252 / 12%); + --sidebar-border: oklch(0.314 0.017 251.8); /* end of tokens/src/scheme.ts */ } } diff --git a/mobile/src/scheme.ts b/mobile/src/scheme.ts index 69e1a20777..3980b4f64e 100644 --- a/mobile/src/scheme.ts +++ b/mobile/src/scheme.ts @@ -20,8 +20,8 @@ export const scheme = { destructive: "#a31526", success: "#12795b", warning: "#a84900", - border: "#0103131a", - input: "#0103131a", + border: "#e7e7e8", + input: "#e7e7e8", ring: "#727eef", "chart-1": "#1949c5", "chart-2": "#cd7d04", @@ -35,7 +35,7 @@ export const scheme = { "sidebar-primary-foreground": "#ffffff", "sidebar-accent": "#bec2ff4d", "sidebar-accent-foreground": "#010313", - "sidebar-border": "#0103131a", + "sidebar-border": "#e7e7e8", "sidebar-ring": "#727eef", }, dark: { @@ -56,8 +56,8 @@ export const scheme = { destructive: "#ff9aa0", success: "#5fe3bb", warning: "#ffb900", - border: "#eef1f31f", - input: "#eef1f31f", + border: "#2b323a", + input: "#2b323a", ring: "#8d97ff", "chart-1": "#3a70ee", "chart-2": "#f79807", @@ -71,7 +71,7 @@ export const scheme = { "sidebar-primary-foreground": "#020409", "sidebar-accent": "#bec2ff1f", "sidebar-accent-foreground": "#eef1f3", - "sidebar-border": "#eef1f31f", + "sidebar-border": "#2b323a", "sidebar-ring": "#8d97ff", }, } as const; diff --git a/tokens/src/scheme.ts b/tokens/src/scheme.ts index 53796c0e94..31763472fe 100644 --- a/tokens/src/scheme.ts +++ b/tokens/src/scheme.ts @@ -82,13 +82,14 @@ const light: Palette = { success: "oklch(0.514 0.1 167.2)", warning: "oklch(0.521 0.143 47.7)", /* - * Every line (`border`, `input`, `sidebar-border`) is the text color at one strength: 10% here, - * 12% in dark. That is about 1.25:1 against a card in light and 1.38:1 in dark, as light as the - * lines in ChatGPT, Claude and Grok. A line is never the only cue of a control: a checkbox's or a - * radio's edge is `muted-foreground` (docs/design-system.md). + * Every line (`border`, `input`, `sidebar-border`) is one opaque gray, the design's `Lines/border`: + * #E7E7E8 here, #2B323A in dark. That is about 1.24:1 against a card in light and 1.36:1 in dark; + * on a gray fill (`muted`, `secondary`, the sidebar) it is fainter, about 1.1:1 in light. A line + * is never the only cue of a control: a checkbox's or a radio's edge is `muted-foreground` + * (docs/design-system.md). */ - border: "oklch(0.108 0.042 264.7 / 10%)", - input: "oklch(0.108 0.042 264.7 / 10%)", + border: "oklch(0.928 0.001 252)", + input: "oklch(0.928 0.001 252)", ring: "oklch(0.638 0.167 276.1)", /* * The chart series are OpenBot's own hues: the brand blue, warning's amber, success's teal, @@ -108,7 +109,7 @@ const light: Palette = { "sidebar-primary-foreground": "oklch(1 0 0)", "sidebar-accent": "oklch(0.832 0.085 281.4 / 30%)", "sidebar-accent-foreground": "oklch(0.108 0.042 264.7)", - "sidebar-border": "oklch(0.108 0.042 264.7 / 10%)", + "sidebar-border": "oklch(0.928 0.001 252)", "sidebar-ring": "oklch(0.638 0.167 276.1)", }; @@ -137,8 +138,8 @@ const dark: Palette = { destructive: "oklch(0.792 0.121 16.4)", success: "oklch(0.832 0.13 170.1)", warning: "oklch(0.828 0.189 84.4)", - border: "oklch(0.956 0.004 252 / 12%)", - input: "oklch(0.956 0.004 252 / 12%)", + border: "oklch(0.314 0.017 251.8)", + input: "oklch(0.314 0.017 251.8)", ring: "oklch(0.713 0.151 277.7)", "chart-1": "oklch(0.58 0.2 264)", "chart-2": "oklch(0.76 0.168 66)", @@ -152,7 +153,7 @@ const dark: Palette = { "sidebar-primary-foreground": "oklch(0.108 0.017 252)", "sidebar-accent": "oklch(0.832 0.085 281.4 / 12%)", "sidebar-accent-foreground": "oklch(0.956 0.004 252)", - "sidebar-border": "oklch(0.956 0.004 252 / 12%)", + "sidebar-border": "oklch(0.314 0.017 251.8)", "sidebar-ring": "oklch(0.713 0.151 277.7)", }; diff --git a/tokens/tests/generated.test.ts b/tokens/tests/generated.test.ts index 85c4a86e2a..2bcda02471 100644 --- a/tokens/tests/generated.test.ts +++ b/tokens/tests/generated.test.ts @@ -92,27 +92,44 @@ describe("oklch to hex", () => { describe("an RGB copy of a translucent color", () => { /* - * An RGB copy (the desktop window's first paint) has no opacity. A translucent color, such as a - * line drawn as the text color at 12%, is written as it shows on a card: blended over `card`, - * the surface every line in the first paint sits on. Dropping the opacity would draw the line at - * full strength. + * An RGB copy (the desktop window's first paint) has no opacity. A translucent color, such as the + * sidebar's highlighted row (`sidebar-accent`, lavender at 30% in light and 12% in dark), is + * written as it shows on a card: blended over `card`. Dropping the opacity would draw it at full + * strength. The lines are opaque (`border`), so they are written as they are. */ test.each(["light", "dark"] as const)( - "%s: the border is written blended over the card", + "%s: a translucent color is written blended over the card", (mode) => { const region = [ - ` // tokens/src/scheme.ts, ${mode}: edge=border (bun run tokens:generate)`, + ` // tokens/src/scheme.ts, ${mode}: tint=sidebar-accent (bun run tokens:generate)`, " // end of tokens/src/scheme.ts", ].join("\n"); const written = fillRegions(region, "example.rs"); - const line = oklchToRgb(scheme[mode].border); + const tint = oklchToRgb(scheme[mode]["sidebar-accent"]); const card = oklchToRgb(scheme[mode].card); - expect(line.alpha).toBeLessThan(1); + expect(tint.alpha).toBeLessThan(1); const blend = (top: number, under: number) => - Math.round(top * line.alpha + under * (1 - line.alpha)); + Math.round(top * tint.alpha + under * (1 - tint.alpha)); const hex = (n: number) => `0x${n.toString(16).padStart(2, "0")}`; - const expected = `edge: (${hex(blend(line.r, card.r))}, ${hex(blend(line.g, card.g))}, ${hex(blend(line.b, card.b))}),`; + const expected = `tint: (${hex(blend(tint.r, card.r))}, ${hex(blend(tint.g, card.g))}, ${hex(blend(tint.b, card.b))}),`; expect(written).toContain(expected); }, ); + + test.each(["light", "dark"] as const)( + "%s: the opaque border is written as it is", + (mode) => { + const region = [ + ` // tokens/src/scheme.ts, ${mode}: edge=border (bun run tokens:generate)`, + " // end of tokens/src/scheme.ts", + ].join("\n"); + const line = oklchToRgb(scheme[mode].border); + expect(line.alpha).toBe(1); + const hex = (n: number) => + `0x${Math.round(n).toString(16).padStart(2, "0")}`; + expect(fillRegions(region, "example.rs")).toContain( + `edge: (${hex(line.r)}, ${hex(line.g)}, ${hex(line.b)}),`, + ); + }, + ); }); From f4785929e07d5dbdefdfe2b503437fc0ba20c776 Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Thu, 3 Dec 2026 21:52:00 +0300 Subject: [PATCH 11/13] Tabs: the control corners again, as the design's kit draws them (list rounded-lg, tab rounded-md) Co-Authored-By: Claude Opus 5.5 --- app/src/components/ui/tabs.tsx | 8 ++++---- app/tests/ui-primitives-look.test.ts | 14 ++++++++------ docs/app-guidelines.md | 9 ++++----- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/src/components/ui/tabs.tsx b/app/src/components/ui/tabs.tsx index f5f83544c3..411825a49a 100644 --- a/app/src/components/ui/tabs.tsx +++ b/app/src/components/ui/tabs.tsx @@ -21,7 +21,7 @@ function Tabs({ } const tabsListVariants = cva( - "group/tabs-list inline-flex w-fit items-center justify-center rounded-full p-[3px] group-data-vertical/tabs:rounded-lg text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none", + "group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none", { variants: { variant: { @@ -51,8 +51,8 @@ function TabsList({ } /* - * A tab is a pill on a pill-shaped list, as a button is (a vertical list keeps the control - * corners). The words are regular, in `muted-foreground`. The chosen tab is flat: a `card` on the + * A tab has the control corner (`rounded-md`) on a list with the card corner (`rounded-lg`), as + * the design draws them, so both follow `--radius`. The words are regular, in `muted-foreground`. The chosen tab is flat: a `card` on the * list's `muted`, with `foreground` words, no line and no shadow. Under the pointer a tab not * chosen takes the list's fill a step darker, as a `secondary` button does. Keyboard focus is the * button's solid ring. The `line` variant keeps shadcn's underline and draws no fill. @@ -62,7 +62,7 @@ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) { { }); /* - * Tabs are pills on a pill, as the design draws them (components/ui/tabs.tsx), in regular - * `muted-foreground` words. The chosen tab is flat: a `card` on the list's `muted`, with no line - * and no shadow. A tab not chosen takes a - * darker fill under the pointer. Focus is the button's solid ring. + * A tab has the control corner on a list with the card corner, as the design draws them + * (components/ui/tabs.tsx), in regular `muted-foreground` words. The chosen tab is flat: a `card` + * on the list's `muted`, with no line and no shadow. A tab not chosen takes a darker fill under + * the pointer. Focus is the button's solid ring. */ - test("a row of tabs is a pill, its chosen tab flat, its focus the solid ring", () => { + test("a row of tabs has the control corners, its chosen tab flat, its focus the solid ring", () => { const all = classes(source("tabs.tsx")); - expect(all).toContain("rounded-full"); + expect(all).toContain("rounded-lg"); + expect(all).toContain("rounded-md"); + expect(all).not.toContain("rounded-full"); expect(all).toContain("data-active:bg-card"); expect(all).toContain("text-muted-foreground"); expect(all).toContain("font-normal"); diff --git a/docs/app-guidelines.md b/docs/app-guidelines.md index d31ac0a876..249fccb189 100644 --- a/docs/app-guidelines.md +++ b/docs/app-guidelines.md @@ -361,11 +361,10 @@ changes, for every screen at once, in a change agreed first. `text-sm`; labels (a table's column headings among them), times and counts are `text-xs`. The line under a row's name (`ItemDescription`) is `text-sm` too, in `muted-foreground`: the name's weight and color set it apart. No text size written by hand (`text-[13px]`). -3. **Corners.** From `--radius`, 10px, the design's radius base, except a row of tabs'. Controls - are `rounded-md` (8px), cards and the page's panel `rounded-lg` (10px), menus, dialogs and the - message box `rounded-xl` (14px), round things `rounded-full`. Tabs and their list are pills - (`rounded-full`) at any `--radius`. `rounded-none` squares a part off. No other step and no - corner of its own (`rounded-[20px]`). +3. **Corners.** All from `--radius`, 10px, the design's radius base. Controls are `rounded-md` + (8px), cards and the page's panel `rounded-lg` (10px), menus, dialogs and the message box + `rounded-xl` (14px), round things `rounded-full`. `rounded-none` squares a part off. No other + step and no corner of its own (`rounded-[20px]`). 4. **Surfaces.** The frame (`sidebar`), the panel the page sits in (`background`), cards on it (`card`). A card has a hairline border in light and in dark. Every line (`border`, a field's `input`, the sidebar's `sidebar-border`) is one opaque gray, the design's `Lines/border`: From 499004206b0151cedcbd54f170e7fb878c47fd86 Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Fri, 4 Dec 2026 10:52:15 +0300 Subject: [PATCH 12/13] Checkbox, radio, questionnaire: red when invalid, as the design's kit draws them Co-Authored-By: Claude Opus 5.5 --- app/src/components/ui/checkbox.tsx | 10 ++++--- app/src/components/ui/questionnaire.tsx | 2 +- app/src/components/ui/radio-group.tsx | 13 +++++---- app/tests/ui-primitives-look.test.ts | 38 +++++++++++++++++-------- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/app/src/components/ui/checkbox.tsx b/app/src/components/ui/checkbox.tsx index 035a84cccf..de64990e76 100644 --- a/app/src/components/ui/checkbox.tsx +++ b/app/src/components/ui/checkbox.tsx @@ -17,16 +17,18 @@ import { cn } from "@/lib/utils"; * `primary/80`, as the button's does. An invalid box keeps its `destructive` edge. * * KEYBOARD FOCUS IS THE BUTTON'S SOLID RING: the edge turns `ring`, ticked or not, and 3px more of - * it are drawn outside, 4px in all. An invalid box is filled with `destructive/10` under a - * `destructive` edge; ticked, it stays `primary`, as a chosen radio does. No halo hides the ring. - * Disabled is half strength. Flat, as the radio is: no shadow. + * it are drawn outside, 4px in all. AN INVALID BOX IS RED, as the design draws it: filled with + * `destructive/10` under a `destructive` edge, and ticked or partly ticked it is filled with + * `destructive`, as a chosen radio's dot turns `destructive`. It keeps that edge under the focus + * ring and doesn't change under the pointer. No halo hides the ring. Disabled is half strength. + * Flat, as the radio is: no shadow. */ function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props) { return ( ); diff --git a/app/tests/ui-primitives-look.test.ts b/app/tests/ui-primitives-look.test.ts index efd4ef6d1d..e7a270d1ee 100644 --- a/app/tests/ui-primitives-look.test.ts +++ b/app/tests/ui-primitives-look.test.ts @@ -213,7 +213,8 @@ describe("the primitives keep the look", () => { /* * A radio is shadcn's, drawn as the checkbox beside it is (components/ui/radio-group.tsx): an - * edge that can be seen, a ring with a dot when chosen, and the button's solid focus ring. + * edge that can be seen, a ring with a dot when chosen, red when invalid as the design draws it, + * and the button's solid focus ring. */ test("a radio's edge can be seen: muted-foreground, never a field's faint input", () => { expect(has("radio-group.tsx", "border-muted-foreground")).toBe(true); @@ -223,8 +224,6 @@ describe("the primitives keep the look", () => { test("a chosen radio is a ring in primary with a dot, never a filled disc", () => { const all = classes(source("radio-group.tsx")); expect(all).toContain("data-checked:border-primary"); - // Invalid too: `aria-invalid` comes after `data-checked` in Tailwind's order. - expect(all).toContain("aria-invalid:aria-checked:border-primary"); expect(all.filter((name) => name.startsWith("data-checked:bg-"))).toEqual( [], ); @@ -232,13 +231,25 @@ describe("the primitives keep the look", () => { expect(all).toContain("bg-primary"); }); + test("an invalid radio is red, chosen or not", () => { + const all = classes(source("radio-group.tsx")); + expect(all).toContain("aria-invalid:border-destructive"); + expect(all).toContain("aria-invalid:bg-destructive/10"); + expect(all).toContain("aria-invalid:data-checked:border-destructive"); + expect(all).toContain("group-aria-invalid/radio:bg-destructive"); + expect(all).not.toContain("aria-invalid:aria-checked:border-primary"); + }); + test("a radio's keyboard focus is a solid ring in --ring, chosen or not", () => { const all = classes(source("radio-group.tsx")); expect(all).toContain("focus-visible:border-ring"); expect(all).toContain("focus-visible:ring-3"); expect(all).toContain("focus-visible:ring-ring"); - // A chosen radio's `primary` edge would otherwise win over the focus edge. - expect(all).toContain("data-checked:focus-visible:border-ring"); + // A chosen radio's `primary` edge would otherwise win over the focus edge; an invalid one keeps + // its `destructive` edge under the ring. + expect(all).toContain( + "data-checked:not-aria-invalid:focus-visible:border-ring", + ); // No faded ring, and no invalid halo laid over it. expect( all.filter((name) => /(^|:)ring-(ring|destructive)\/\d+$/.test(name)), @@ -247,9 +258,9 @@ describe("the primitives keep the look", () => { /* * The checkbox (components/ui/checkbox.tsx): a dash when partly ticked, the button's solid focus - * ring, a ticked box that stays `primary` when invalid, as a chosen radio does. Under the pointer - * an empty box or radio darkens its edge; a ticked or chosen one eases to `primary/80`. Both are - * flat. + * ring, and red when invalid as the design draws it: a tint when empty, filled with `destructive` + * when ticked. Under the pointer an empty box or radio darkens its edge; a ticked or chosen one + * eases to `primary/80`, an invalid one stays as it is. Both are flat. */ test("a partly ticked checkbox is filled, with a dash for the tick", () => { const all = classes(source("checkbox.tsx")); @@ -258,12 +269,15 @@ describe("the primitives keep the look", () => { expect(all).toContain("group-data-indeterminate/checkbox:block"); }); - test("a checkbox's keyboard focus is the solid ring, and ticked stays primary when invalid", () => { + test("a checkbox's keyboard focus is the solid ring, and an invalid box is red", () => { const all = classes(source("checkbox.tsx")); expect(all).toContain("focus-visible:ring-ring"); - expect(all).toContain("data-checked:focus-visible:border-ring"); + expect(all).toContain( + "data-checked:not-aria-invalid:focus-visible:border-ring", + ); expect(all).toContain("aria-invalid:bg-destructive/10"); - expect(all).toContain("aria-invalid:data-checked:bg-primary"); + expect(all).toContain("aria-invalid:data-checked:bg-destructive"); + expect(all).toContain("aria-invalid:data-indeterminate:bg-destructive"); expect( all.filter((name) => /(^|:)ring-(ring|destructive)\/\d+$/.test(name)), ).toEqual([]); @@ -277,7 +291,7 @@ describe("the primitives keep the look", () => { "data-unchecked:hover:not-data-disabled:not-aria-invalid:border-foreground", ); expect(all).toContain( - "data-checked:hover:not-data-disabled:border-primary/80", + "data-checked:hover:not-data-disabled:not-aria-invalid:border-primary/80", ); expect(all.filter((name) => /(^|:)shadow-/.test(name))).toEqual([]); }, From 319ac5b22b335b9831cc009ece8e000b373e1af0 Mon Sep 17 00:00:00 2001 From: Raman Yasel Date: Fri, 4 Dec 2026 11:30:19 +0300 Subject: [PATCH 13/13] Badge: a status is its color's words on its 10% tint, as the design's kit draws it, and in-progress Co-Authored-By: Claude Opus 5.5 --- app/src/components/ui/badge.tsx | 33 ++++++++++++++-------------- app/tests/ui-primitives-look.test.ts | 20 ++++++++--------- docs/design-system.md | 11 +++++----- tokens/tests/contrast.test.ts | 13 ----------- 4 files changed, 32 insertions(+), 45 deletions(-) diff --git a/app/src/components/ui/badge.tsx b/app/src/components/ui/badge.tsx index 0008524101..fa836bcb7b 100644 --- a/app/src/components/ui/badge.tsx +++ b/app/src/components/ui/badge.tsx @@ -10,23 +10,22 @@ import { cn } from "@/lib/utils"; * `dark:` overrides are gone, since every token already carries its dark value; and keyboard focus * is the button's solid ring, with no halo over it. * - * `muted`, `success` and `warning` are ours, beside shadcn's variants and never in place of one: - * `muted` for a quiet state ("Paused"), `success` for what worked or is working ("Connected"), - * `warning` for one that wants a look ("Needs review"). + * `muted`, `success`, `warning` and `in-progress` are ours, beside shadcn's variants and never in + * place of one: `muted` for a quiet state ("Paused"), `success` for what worked or is working + * ("Connected"), `warning` for one that wants a look ("Needs review"), `in-progress` for one still + * going. * - * SUCCESS AND WARNING ARE A DOT AND A TINT, and the words are `foreground`. As words, `success` - * and `warning` fall under 4.5:1 in light once their 10% tint is under them on the page, a muted - * row or the sidebar (success 4.05 to 4.48, warning 4.33 and 4.44), and a color that fails as text - * is not rescued with a second token (docs/design-system.md). The dot carries the color: 3:1 or - * more on its tint. A leading icon takes the dot's place and its color. `destructive` reads as - * text on its tint everywhere, 5.15:1 or more, so an error badge keeps its colored words, as the - * button's `destructive` does. + * A STATUS IS ITS COLOR'S WORDS ON ITS 10% TINT, as the design's kit draws every badge, in 12px + * regular words. tokens/tests/contrast.test.ts holds each status's words at 4.5:1 on its tint over + * the page, a card, a menu, a muted row and the sidebar, in light and dark; light `warning` is the + * kit's warning/25 so that it does on a muted row. * * A CHIP IS THE SAME BADGE, rendered as a link or a button (`render`). Only then does the pointer - * change it, and only then can the keyboard reach it. Disabled is half strength. + * change it, its tint deepening to 12% as the design's chip does, and only then can the keyboard + * reach it. Disabled is half strength. */ const badgeVariants = cva( - "inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive [&>svg]:pointer-events-none [&>svg]:size-3!", + "inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-normal whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive [&>svg]:pointer-events-none [&>svg]:size-3!", { variants: { variant: { @@ -35,17 +34,17 @@ const badgeVariants = cva( secondary: "bg-secondary text-secondary-foreground [a,button]:hover:bg-secondary/80", destructive: - "bg-destructive/10 text-destructive [a,button]:hover:bg-destructive/20", + "bg-destructive/10 text-destructive [a,button]:hover:bg-destructive/12", outline: "border-border text-foreground [a,button]:hover:bg-muted [a,button]:hover:text-muted-foreground", ghost: "[a,button]:hover:bg-muted [a,button]:hover:text-muted-foreground", link: "text-primary underline-offset-4 [a,button]:hover:underline", muted: "bg-muted text-muted-foreground", - success: - "bg-success/10 pl-1.5 text-foreground before:size-1.5 before:shrink-0 before:rounded-full before:bg-success before:content-[''] has-data-[icon=inline-start]:before:hidden [&>svg]:text-success [a,button]:hover:bg-success/20", - warning: - "bg-warning/10 pl-1.5 text-foreground before:size-1.5 before:shrink-0 before:rounded-full before:bg-warning before:content-[''] has-data-[icon=inline-start]:before:hidden [&>svg]:text-warning [a,button]:hover:bg-warning/20", + success: "bg-success/10 text-success [a,button]:hover:bg-success/12", + warning: "bg-warning/10 text-warning [a,button]:hover:bg-warning/12", + "in-progress": + "bg-in-progress/10 text-in-progress [a,button]:hover:bg-in-progress/12", }, }, defaultVariants: { diff --git a/app/tests/ui-primitives-look.test.ts b/app/tests/ui-primitives-look.test.ts index e7a270d1ee..fdd6836f41 100644 --- a/app/tests/ui-primitives-look.test.ts +++ b/app/tests/ui-primitives-look.test.ts @@ -298,9 +298,9 @@ describe("the primitives keep the look", () => { ); /* - * A badge is shadcn's, a pill in shadcn's one size (components/ui/badge.tsx). Success and - * warning are a dot and a tint with `foreground` words: as words they fail on some surfaces - * (tokens/tests/contrast.test.ts). A chip is the same badge rendered as a link or a button. + * A badge is shadcn's, a pill in shadcn's one size (components/ui/badge.tsx), in regular words. + * A status is its color's words on its 10% tint, as the design's kit draws it; the contrast test + * holds those words at 4.5:1. A chip is the same badge rendered as a link or a button. */ test("a badge is a pill in one size", () => { const all = classes(source("badge.tsx")); @@ -312,16 +312,16 @@ describe("the primitives keep the look", () => { ]); }); - test("a success or warning badge is a dot and a tint, with foreground words", () => { + test("a status badge is its color's words on its tint, with no dot", () => { const all = classes(source("badge.tsx")); - for (const tone of ["success", "warning"]) { + for (const tone of ["success", "warning", "destructive", "in-progress"]) { expect(all).toContain(`bg-${tone}/10`); - expect(all).toContain(`before:bg-${tone}`); - expect(all).not.toContain(`text-${tone}`); + expect(all).toContain(`text-${tone}`); + expect(all).toContain(`[a,button]:hover:bg-${tone}/12`); } - expect(all).toContain("text-foreground"); - // An error badge keeps its colored words, as the button's destructive does. - expect(all).toContain("text-destructive"); + expect(all.filter((name) => name.startsWith("before:"))).toEqual([]); + expect(all).toContain("font-normal"); + expect(all).not.toContain("font-medium"); }); test("a badge changes under the pointer only as a chip, with the solid focus ring", () => { diff --git a/docs/design-system.md b/docs/design-system.md index 62f7c39da2..8424cfe5ca 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -168,11 +168,12 @@ icons a screen draws with. What it leaves to this page: animation. - **Check contrast before you choose a color,** in light and in dark: 4.5:1 for text, 3:1 for the edge of a control that has no other cue, such as a checkbox or a radio, and for the focus ring. A - line (`border`, `input`) is about 1.25:1 against a card in light and 1.38:1 in dark, so such an - edge, and a mark like the scrollbar's thumb, is `muted-foreground`, never a line. A color that - fails as text is not rescued with a second token for "the same color, as text": the words go in - `foreground` and the color goes on a mark, as a `success` or `warning` badge carries its color - on a dot, and an alert or a toast on its icon's tile. + line (`border`, `input`) is about 1.24:1 against a card in light and 1.36:1 in dark, so such an + edge, and a mark like the scrollbar's thumb, is `muted-foreground`, never a line. A status color + is used for words only where it holds 4.5:1 on its own 10% tint over every surface, as a badge's + words do (`tokens/tests/contrast.test.ts`). A color that fails as text is not rescued with a + second token for "the same color, as text": the words go in `foreground` and the color goes on a + mark, as an alert or a toast carries it on its icon's tile. - **Motion stops when less motion is asked for.** An animation in code can stand still. Don't swap in a picture of one frame. diff --git a/tokens/tests/contrast.test.ts b/tokens/tests/contrast.test.ts index 1d92500a4e..2c1f3666a4 100644 --- a/tokens/tests/contrast.test.ts +++ b/tokens/tests/contrast.test.ts @@ -39,19 +39,6 @@ const PAIRS: [Token, Layer[], number][] = [ ["sidebar-foreground", ["sidebar"], TEXT], ["sidebar-primary-foreground", ["sidebar-primary"], TEXT], ["sidebar-accent-foreground", ["sidebar-accent", "sidebar"], TEXT], - // A badge's words on its fill, wherever a badge stands: the page, a card, a menu, a muted row, - // the sidebar. Success and warning are a dot on a tint with `foreground` words; an error badge - // keeps its colored words, at rest and under the pointer (a chip's `destructive/20`). - ...(["background", "card", "popover", "muted", "sidebar"] as const).flatMap( - (ground): [Token, Layer[], number][] => [ - ["foreground", ["success/10", ground], TEXT], - ["foreground", ["warning/10", ground], TEXT], - ["destructive", ["destructive/10", ground], TEXT], - ["destructive", ["destructive/20", ground], TEXT], - ["success", ["success/10", ground], NON_TEXT], - ["warning", ["warning/10", ground], NON_TEXT], - ], - ), // An alert's words on its tint, and its icon on its tile (the tint again, over the tint), wherever // an alert stands: the page, a card, a menu, a muted row. ...(["background", "card", "popover", "muted"] as const).flatMap(