Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/components/app-sidebar/bots-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export function BotsPanel({ hidden = false }: { hidden?: boolean }) {
title="Bots"
>
<SidebarContent className="scroll-fade-b px-2 pb-2">
<InputGroup className="h-9 rounded-lg bg-background text-sm">
<InputGroup className="bg-background text-sm">
<InputGroupInput
aria-label="Search Bots"
onChange={(event) => setSearch(event.target.value)}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/gallery/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function FormEntry({
) : field.type === "select" ? (
<select
{...shared}
className="h-9 w-full rounded-lg border border-input bg-background px-2.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50"
className="h-9 w-full rounded-md border border-input bg-background px-2.5 text-sm transition-colors outline-none hover:border-foreground/30 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed disabled:border-input disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive"
onChange={(event) => change(event.target.value)}
>
<option value="">Choose an option</option>
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/ui/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function ComboboxChips({
<ComboboxPrimitive.Chips
data-slot="combobox-chips"
className={cn(
"flex min-h-8 flex-wrap items-center gap-1 rounded-md border border-input bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1",
"flex min-h-8 flex-wrap items-center gap-1 rounded-md border border-input bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors hover:border-foreground/30 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring has-aria-invalid:border-destructive has-data-[slot=combobox-chip]:px-1",
className,
)}
{...props}
Expand Down
6 changes: 3 additions & 3 deletions app/src/components/ui/input-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
data-slot="input-group"
role="group"
className={cn(
"group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border border-input bg-card transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
"group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border border-input bg-card transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 hover:border-foreground/30 has-[[data-slot=input-group-control]:read-only:enabled]:bg-muted has-disabled:border-input has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring has-[[data-slot][aria-invalid=true]]:border-destructive has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
className,
)}
{...props}
Expand Down Expand Up @@ -120,7 +120,7 @@ function InputGroupInput({
<Input
data-slot="input-group-control"
className={cn(
"flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",
"flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 read-only:bg-transparent focus-visible:ring-0 disabled:bg-transparent",
className,
)}
{...props}
Expand All @@ -136,7 +136,7 @@ function InputGroupTextarea({
<Textarea
data-slot="input-group-control"
className={cn(
"flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",
"flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 read-only:bg-transparent focus-visible:ring-0 disabled:bg-transparent",
className,
)}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/ui/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
type={type}
data-slot="input"
className={cn(
"h-9 w-full min-w-0 rounded-md border border-input bg-card px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm",
"h-9 w-full min-w-0 rounded-md border border-input bg-card px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground read-only:bg-muted hover:border-foreground/30 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive md:text-sm",
className,
)}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/ui/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function SelectTrigger({
data-size={size}
className={cn(
// As wide as its words, and never wider than where it is put: there the words give way.
"flex w-fit max-w-full min-w-0 items-center justify-between gap-1.5 rounded-md border border-input bg-card py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-7 data-[size=sm]:rounded-md [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
"flex w-fit max-w-full min-w-0 items-center justify-between gap-1.5 rounded-md border border-input bg-card py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none hover:border-foreground/30 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed disabled:border-input disabled:opacity-50 aria-invalid:border-destructive data-placeholder:text-muted-foreground data-readonly:bg-muted data-[size=default]:h-9 data-[size=sm]:h-7 data-[size=sm]:rounded-md [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className,
)}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/ui/textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
<textarea
data-slot="textarea"
className={cn(
"flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-card px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm",
"flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-card px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground read-only:bg-muted hover:border-foreground/30 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed disabled:border-input disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive md:text-sm",
className,
)}
{...props}
Expand Down
60 changes: 60 additions & 0 deletions app/tests/ui-primitives-look.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,64 @@ describe("the primitives keep the look", () => {
expect(has(file, "bg-card")).toBe(true);
},
);

/*
* Keyboard focus is a solid ring in `ring`, drawn outside the control (docs/design-system.md,
* Primitives). shadcn's half-strength `ring-ring/50` is under the 3:1 a focus ring needs, and an
* invalid field's `ring-destructive/20` halo hid the focus ring of the field that needed it most.
*/
const FIELDS = [
"input.tsx",
"textarea.tsx",
"select.tsx",
"input-group.tsx",
"combobox.tsx",
];

test.each(FIELDS)(
"%s: keyboard focus is a solid ring in --ring, 4px in all",
(file) => {
const focus = classes(source(file)).filter((name) =>
/(^|:)focus-(visible|within):|:focus-visible\]:/.test(name),
);
expect(focus.some((name) => name.endsWith(":ring-ring"))).toBe(true);
expect(focus.some((name) => name.endsWith(":ring-3"))).toBe(true);
expect(focus.some((name) => name.endsWith(":border-ring"))).toBe(true);
},
);

test.each(FIELDS)(
"%s: no faded focus ring, and no halo that hides it",
(file) => {
const faded = classes(source(file)).filter((name) =>
/(^|:)ring-(ring|destructive)\/\d+$/.test(name),
);
expect(faded).toEqual([]);
},
);

// The UI kit draws an invalid field on its own surface, marked by its edge and the message under
// it: no fill.
test.each(FIELDS)(
"%s: an invalid field has a destructive edge and no fill",
(file) => {
const invalid = classes(source(file)).filter((name) =>
name.includes("invalid"),
);
expect(invalid.some((name) => name.endsWith(":border-destructive"))).toBe(
true,
);
expect(invalid.filter((name) => /:bg-destructive/.test(name))).toEqual(
[],
);
},
);

test("a field inside a combobox has a control's corner", () => {
const chips = /function ComboboxChips[\s\S]*?cn\(\s*"([^"]*)"/.exec(
source("combobox.tsx"),
)?.[1];
expect(chips?.split(/\s+/)).toContain("rounded-md");
expect(chips?.split(/\s+/)).not.toContain("rounded-lg");
});
});
5 changes: 4 additions & 1 deletion docs/app-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ changes, for every screen at once, in a change agreed first.
(`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`.
another. That is a field's edge at rest: under the pointer it darkens to `foreground/30`. An
invalid field keeps its surface and takes a `destructive` edge, with no fill, and a read-only
one a `muted` 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;
Expand Down
17 changes: 13 additions & 4 deletions docs/design-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions tokens/tests/contrast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ const PAIRS: [Token, Token[], number][] = [
["sidebar-foreground", ["sidebar"], TEXT],
["sidebar-primary-foreground", ["sidebar-primary"], TEXT],
["sidebar-accent-foreground", ["sidebar-accent", "sidebar"], TEXT],
// A read-only field is filled with `muted`.
["foreground", ["muted"], 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],
];

Expand Down