Skip to content
Myr

Draw text, controls, prose and code from one set of tokens

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- A type scale by role in styles.css (headline, title, want, body, ui, label, mono, with leading-terminal and leading-code), so pages stop inventing sizes; the earlier xs-2xl scale stays for pages not yet rewritten. - New tokens in both schemes, no existing colour changed: --input (control borders at 3.4:1 light, 3.9:1 dark, WCAG 2.2 SC 1.4.11), --skeleton (a placeholder stroke at 1.7:1), low-chroma --syntax-* colours kept 30 degrees from every state hue, and teal/rose --diff-* tints so a diff never borrows landed green or refused red. - The kit's controls carry nothing under 13 px; fields are 16 px below 640 px (iOS zooms a smaller field on focus) and 14 px above; borders come from --input; popups are flat hairlines; Skeleton is a stroke with no pulse. - READMEs render in the page's own type: no backticks around inline code, code blocks on the surface in a hairline, a 70ch measure, an h1 at the title size, colours from the tokens (prose-tokens) instead of prose-invert. - features/code/pierre.ts holds the shared @pierre/diffs and @pierre/trees options and registers a CSS-variable theme read from the tokens; every Pierre drawing spreads it. The theme is named for both schemes because a single name makes Pierre force the theme's own (dark) colour-scheme. Ligatures are off inside the shadow roots, code sits on the paper, the dead --diffs-selection-color-override is gone, and the tree uses the UI face, monochrome icons and the diff tints for its status colours. - Tests: tokens.test.ts (WCAG contrast of every pair in both schemes, the syntax chroma and hue rules, Pierre's variable maps, the kit's 13 px floor and phone field size, the scale), pierre.test.ts (shared options, the library's limits, the theme reading the variables, one module for every drawing), markdown.test.tsx (the prose classes). - ASSUMPTION: iOS Safari zooms on focus for a field under 16 px (known browser behaviour, not tested here). - Keyword weight and italic comments are not drawn: Pierre resolves token weight and slant through light-dark(), which takes colours only.

authored by oscabriel · committed by oscabriel · parent 7912f1e · Browse files · 45 files+925 added−125 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

45 files+925 added−125 removed

  • tests:+519 added−0 removed
  • other:+406 added−125 removed

45 files+925 added−125 removed

modified:apps/web/src/components/ui/accordion.tsx+2 added-2 removed
modified:apps/web/src/components/ui/alert.tsx+2 added-2 removed
modified:apps/web/src/components/ui/avatar.tsx+2 added-2 removed
43 unmodified lines
44 return (45 <AvatarPrimitive.Fallback46 data-slot="avatar-fallback"47 className={cn(48 "bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs",48 "bg-muted text-muted-foreground text-ui group-data-[size=sm]/avatar:text-label flex size-full items-center justify-center rounded-full",49 className50 )}51 {...props}52 />
36 unmodified lines
89 return (90 <div91 data-slot="avatar-group-count"92 className={cn(93 "bg-muted text-muted-foreground ring-background relative flex size-8 shrink-0 items-center justify-center rounded-full text-xs ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",93 "bg-muted text-muted-foreground ring-background text-ui relative flex size-8 shrink-0 items-center justify-center rounded-full ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",94 className95 )}96 {...props}97 />
11 unmodified lines
modified:apps/web/src/components/ui/badge.tsx+1 added-1 removed
2 unmodified lines
3import { cva, type VariantProps } from "class-variance-authority";4import { cn } from "cn";56const badgeVariants = cva(7 "group/badge focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-none border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:ring-[3px] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:pointer-events-none [&>svg]:size-3!",7 "group/badge focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 text-label inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-none border border-transparent px-2 py-0.5 font-medium whitespace-nowrap transition-all focus-visible:ring-[3px] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:pointer-events-none [&>svg]:size-3!",8 {9 variants: {10 variant: {11 default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
40 unmodified lines
modified:apps/web/src/components/ui/breadcrumb.tsx+1 added-1 removed
18 unmodified lines
19 return (20 <ol21 data-slot="breadcrumb-list"22 className={cn(23 "text-muted-foreground flex flex-wrap items-center gap-1.5 text-xs wrap-break-word",23 "text-muted-foreground text-ui flex flex-wrap items-center gap-1.5 wrap-break-word",24 className25 )}26 {...props}27 />
94 unmodified lines
modified:apps/web/src/components/ui/button-group.tsx+1 added-1 removed
46 unmodified lines
47 defaultTagName: "div",48 props: mergeProps<"div">(49 {50 className: cn(51 "bg-muted flex items-center gap-2 rounded-none border px-2.5 text-xs font-medium [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",51 "bg-muted text-ui flex items-center gap-2 rounded-none border px-2.5 font-medium [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",52 className53 ),54 },55 props
32 unmodified lines
modified:apps/web/src/components/ui/button.tsx+3 added-3 removed
1 unmodified line
2import { cva, type VariantProps } from "class-variance-authority";3import { cn } from "cn";45const buttonVariants = cva(6 "group/button focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 inline-flex shrink-0 items-center justify-center rounded-none border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:ring-1 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:ring-1 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",6 "group/button focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 text-ui inline-flex shrink-0 items-center justify-center rounded-none border border-transparent bg-clip-padding font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:ring-1 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:ring-1 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",7 {8 variants: {9 variant: {10 default: "bg-primary text-primary-foreground hover:bg-primary/80",11 outline:12 "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",12 "border-input bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",13 secondary:14 "bg-secondary text-secondary-foreground aria-expanded:bg-secondary aria-expanded:text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]",15 ghost:16 "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
3 unmodified lines
20 },21 size: {22 default:23 "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",24 xs: "h-6 gap-1 rounded-none px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",24 xs: "text-label h-6 gap-1 rounded-none px-2 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",25 sm: "h-7 gap-1 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",26 lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",27 icon: "size-8",28 "icon-xs": "size-6 rounded-none [&_svg:not([class*='size-'])]:size-3",
27 unmodified lines
modified:apps/web/src/components/ui/card.tsx+3 added-3 removed
9 unmodified lines
10 <div11 data-slot="card"12 data-size={size}13 className={cn(14 "group/card bg-card text-card-foreground ring-foreground/10 flex flex-col gap-(--card-spacing) overflow-hidden rounded-none py-(--card-spacing) text-xs/relaxed ring-1 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-none *:[img:last-child]:rounded-none",14 "group/card bg-card text-card-foreground ring-input text-ui flex flex-col gap-(--card-spacing) overflow-hidden rounded-none py-(--card-spacing) ring-1 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-none *:[img:last-child]:rounded-none",15 className16 )}17 {...props}18 />
17 unmodified lines
36 return (37 <div38 data-slot="card-title"39 className={cn(40 "text-sm font-medium group-data-[size=sm]/card:text-sm",40 "text-want group-data-[size=sm]/card:text-ui font-semibold",41 className42 )}43 {...props}44 />
3 unmodified lines
48function CardDescription({ className, ...props }: React.ComponentProps<"div">) {49 return (50 <div51 data-slot="card-description"52 className={cn("text-muted-foreground text-xs/relaxed", className)}52 className={cn("text-muted-foreground text-ui", className)}53 {...props}54 />55 );56}
46 unmodified lines
modified:apps/web/src/components/ui/checkbox.tsx+1 added-1 removed
5 unmodified lines
6 return (7 <CheckboxPrimitive.Root8 data-slot="checkbox"9 className={cn(10 "peer border-input group-has-[:focus-visible]/field-label:not-data-checked:border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary relative flex size-4 shrink-0 items-center justify-center rounded-none border transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1",10 "peer border-input group-has-[:focus-visible]/field-label:not-data-checked:border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary relative flex size-4 shrink-0 items-center justify-center rounded-none border transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1",11 className12 )}13 {...props}14 >
11 unmodified lines
modified:apps/web/src/components/ui/combobox.tsx+6 added-6 removed
107 unmodified lines
108 <ComboboxPrimitive.Popup109 data-slot="combobox-content"110 data-chips={!!anchor}111 className={cn(112 "group/combobox-content bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-none shadow-md ring-1 duration-100 data-[chips=true]:min-w-(--anchor-width) *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:shadow-none",112 "group/combobox-content bg-popover text-popover-foreground ring-input data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-none ring-1 duration-100 data-[chips=true]:min-w-(--anchor-width) *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-9 *:data-[slot=input-group]:bg-transparent *:data-[slot=input-group]:shadow-none sm:*:data-[slot=input-group]:h-8",113 className114 )}115 {...props}116 />
23 unmodified lines
140 return (141 <ComboboxPrimitive.Item142 data-slot="combobox-item"143 className={cn(144 "data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 text-xs outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",144 "data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground text-ui relative flex w-full cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",145 className146 )}147 {...props}148 >
25 unmodified lines
174}: ComboboxPrimitive.GroupLabel.Props) {175 return (176 <ComboboxPrimitive.GroupLabel177 data-slot="combobox-label"178 className={cn("text-muted-foreground px-2 py-2 text-xs", className)}178 className={cn("text-muted-foreground text-label px-2 py-2", className)}179 {...props}180 />181 );182}
8 unmodified lines
191 return (192 <ComboboxPrimitive.Empty193 data-slot="combobox-empty"194 className={cn(195 "text-muted-foreground hidden w-full justify-center py-2 text-center text-xs group-data-empty/combobox-content:flex",195 "text-muted-foreground text-ui hidden w-full justify-center py-2 text-center group-data-empty/combobox-content:flex",196 className197 )}198 {...props}199 />
21 unmodified lines
221 return (222 <ComboboxPrimitive.Chips223 data-slot="combobox-chips"224 className={cn(225 "border-input focus-within:border-ring focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-destructive/20 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40 flex min-h-8 flex-wrap items-center gap-1 rounded-none border bg-transparent bg-clip-padding px-2.5 py-1 text-xs transition-colors focus-within:ring-1 has-aria-invalid:ring-1 has-data-[slot=combobox-chip]:px-1",225 "border-input focus-within:border-ring focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40 sm:text-ui flex min-h-9 flex-wrap items-center gap-1 rounded-none border bg-transparent bg-clip-padding px-2.5 py-1 text-base transition-colors focus-within:ring-1 has-aria-invalid:ring-1 has-data-[slot=combobox-chip]:px-1 sm:min-h-8",226 className227 )}228 {...props}229 />
11 unmodified lines
241 return (242 <ComboboxPrimitive.Chip243 data-slot="combobox-chip"244 className={cn(245 "bg-muted text-foreground flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-none px-1.5 text-xs font-medium whitespace-nowrap has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",245 "bg-muted text-foreground text-label flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-none px-1.5 font-medium whitespace-nowrap has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",246 className247 )}248 {...props}249 >
49 unmodified lines
modified:apps/web/src/components/ui/dialog.tsx+3 added-3 removed
51 unmodified lines
52 <DialogOverlay />53 <DialogPrimitive.Popup54 data-slot="dialog-content"55 className={cn(56 "bg-popover text-popover-foreground ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-none p-4 text-xs/relaxed ring-1 duration-100 outline-none sm:max-w-sm",56 "bg-popover text-popover-foreground ring-input data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 text-ui fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-none p-4 ring-1 duration-100 outline-none sm:max-w-sm",57 className58 )}59 {...props}60 >
58 unmodified lines
119function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {120 return (121 <DialogPrimitive.Title122 data-slot="dialog-title"123 className={cn("text-sm font-medium", className)}123 className={cn("text-want font-semibold", className)}124 {...props}125 />126 );127}
5 unmodified lines
133 return (134 <DialogPrimitive.Description135 data-slot="dialog-description"136 className={cn(137 "text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed *:[a]:underline *:[a]:underline-offset-3",137 "text-muted-foreground *:[a]:hover:text-foreground text-ui *:[a]:underline *:[a]:underline-offset-3",138 className139 )}140 {...props}141 />
15 unmodified lines
modified:apps/web/src/components/ui/dropdown-menu.tsx+8 added-8 removed
37 unmodified lines
38 >39 <MenuPrimitive.Popup40 data-slot="dropdown-menu-content"41 className={cn(42 "bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-none shadow-md ring-1 duration-100 outline-none data-closed:overflow-hidden",42 "bg-popover text-popover-foreground ring-input data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-none ring-1 duration-100 outline-none data-closed:overflow-hidden",43 className44 )}45 {...props}46 />
17 unmodified lines
64 <MenuPrimitive.GroupLabel65 data-slot="dropdown-menu-label"66 data-inset={inset}67 className={cn(68 "text-muted-foreground px-2 py-2 text-xs data-inset:pl-7",68 "text-muted-foreground text-label px-2 py-2 data-inset:pl-7",69 className70 )}71 {...props}72 />
14 unmodified lines
87 data-slot="dropdown-menu-item"88 data-inset={inset}89 data-variant={variant}90 className={cn(91 "group/dropdown-menu-item focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:*:[svg]:text-destructive relative flex cursor-default items-center gap-2 rounded-none px-2 py-2 text-xs outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",91 "group/dropdown-menu-item focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:*:[svg]:text-destructive text-ui relative flex cursor-default items-center gap-2 rounded-none px-2 py-2 outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",92 className93 )}94 {...props}95 />
16 unmodified lines
112 <MenuPrimitive.SubmenuTrigger113 data-slot="dropdown-menu-sub-trigger"114 data-inset={inset}115 className={cn(116 "focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground flex cursor-default items-center gap-2 rounded-none px-2 py-2 text-xs outline-hidden select-none data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",116 "focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground text-ui flex cursor-default items-center gap-2 rounded-none px-2 py-2 outline-hidden select-none data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",117 className118 )}119 {...props}120 >
14 unmodified lines
135 return (136 <DropdownMenuContent137 data-slot="dropdown-menu-sub-content"138 className={cn(139 "bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 w-auto min-w-[96px] rounded-none shadow-lg ring-1 duration-100",139 "bg-popover text-popover-foreground ring-input data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 w-auto min-w-[96px] rounded-none ring-1 duration-100",140 className141 )}142 align={align}143 alignOffset={alignOffset}
17 unmodified lines
161 <MenuPrimitive.CheckboxItem162 data-slot="dropdown-menu-checkbox-item"163 data-inset={inset}164 className={cn(165 "focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 text-xs outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",165 "focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground text-ui relative flex cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",166 className167 )}168 checked={checked}169 {...props}
32 unmodified lines
202 <MenuPrimitive.RadioItem203 data-slot="dropdown-menu-radio-item"204 data-inset={inset}205 className={cn(206 "focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 text-xs outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",206 "focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground text-ui relative flex cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",207 className208 )}209 {...props}210 >
30 unmodified lines
241 return (242 <span243 data-slot="dropdown-menu-shortcut"244 className={cn(245 "text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground ml-auto text-xs tracking-widest",245 "text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground text-label ml-auto",246 className247 )}248 {...props}249 />
20 unmodified lines
modified:apps/web/src/components/ui/empty.tsx+3 added-3 removed
56 unmodified lines
57function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) {58 return (59 <div60 data-slot="empty-title"61 className={cn("text-sm font-medium", className)}61 className={cn("text-want font-semibold", className)}62 {...props}63 />64 );65}
2 unmodified lines
68 return (69 <div70 data-slot="empty-description"71 className={cn(72 "text-muted-foreground [&>a:hover]:text-primary text-xs/relaxed [&>a]:underline [&>a]:underline-offset-4",72 "text-muted-foreground [&>a:hover]:text-primary text-ui [&>a]:underline [&>a]:underline-offset-4",73 className74 )}75 {...props}76 />
4 unmodified lines
81 return (82 <div83 data-slot="empty-content"84 className={cn(85 "flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-xs text-balance",85 "text-ui flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-balance",86 className87 )}88 {...props}89 />
11 unmodified lines
modified:apps/web/src/components/ui/hover-card.tsx+1 added-1 removed
33 unmodified lines
34 >35 <PreviewCardPrimitive.Popup36 data-slot="hover-card-content"37 className={cn(38 "bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 w-64 origin-(--transform-origin) rounded-none p-2.5 text-xs/relaxed shadow-md ring-1 outline-hidden duration-100",38 "bg-popover text-popover-foreground ring-input data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 text-ui z-50 w-64 origin-(--transform-origin) rounded-none p-2.5 ring-1 outline-hidden duration-100",39 className40 )}41 {...props}42 />
6 unmodified lines
modified:apps/web/src/components/ui/input-group.tsx+4 added-4 removed
10 unmodified lines
11 <div12 data-slot="input-group"13 role="group"14 className={cn(15 "group/input-group border-input has-disabled:bg-input/50 has-[[data-slot=input-group-control]:focus-visible]:border-ring 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-destructive/20 dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 relative flex h-8 w-full min-w-0 items-center rounded-none border transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot][aria-invalid=true]]:ring-1 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",15 "group/input-group border-input has-disabled:bg-surface has-[[data-slot=input-group-control]:focus-visible]:border-ring 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-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 relative flex h-9 w-full min-w-0 items-center rounded-none border transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot][aria-invalid=true]]:ring-1 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 sm:h-8 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",16 className17 )}18 {...props}19 />20 );21}2223const inputGroupAddonVariants = cva(24 "text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-xs font-medium select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-none [&>svg:not([class*='size-'])]:size-4",24 "text-muted-foreground text-ui flex h-auto cursor-text items-center justify-center gap-2 py-1.5 font-medium select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-none [&>svg:not([class*='size-'])]:size-4",25 {26 variants: {27 align: {28 "inline-start":
34 unmodified lines
63 );64}6566const inputGroupButtonVariants = cva(67 "flex items-center gap-2 text-xs shadow-none",67 "text-ui flex items-center gap-2 shadow-none",68 {69 variants: {70 size: {71 xs: "h-6 gap-1 rounded-none px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
32 unmodified lines
104function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {105 return (106 <span107 className={cn(108 "text-muted-foreground flex items-center gap-2 text-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",108 "text-muted-foreground text-ui flex items-center gap-2 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",109 className110 )}111 {...props}112 />
43 unmodified lines
modified:apps/web/src/components/ui/input.tsx+1 added-1 removed
6 unmodified lines
7 <InputPrimitive8 type={type}9 data-slot="input"10 className={cn(11 "border-input file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 h-8 w-full min-w-0 rounded-none border bg-transparent px-2.5 py-1 text-xs transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs file:font-medium focus-visible:ring-1 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 md:text-xs",11 "border-input file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-surface aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 file:text-ui sm:text-ui h-9 w-full min-w-0 rounded-none border bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:font-medium focus-visible:ring-1 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 sm:h-8",12 className13 )}14 {...props}15 />
4 unmodified lines
modified:apps/web/src/components/ui/item.tsx+3 added-3 removed
33 unmodified lines
34 );35}3637const itemVariants = cva(38 "group/item focus-visible:border-ring focus-visible:ring-ring/50 [a]:hover:bg-muted flex w-full flex-wrap items-center rounded-none border text-xs transition-colors duration-100 outline-none focus-visible:ring-[3px] [a]:transition-colors",38 "group/item focus-visible:border-ring focus-visible:ring-ring/50 [a]:hover:bg-muted text-ui flex w-full flex-wrap items-center rounded-none border transition-colors duration-100 outline-none focus-visible:ring-[3px] [a]:transition-colors",39 {40 variants: {41 variant: {42 default: "border-transparent",
86 unmodified lines
129 return (130 <div131 data-slot="item-title"132 className={cn(133 "line-clamp-1 flex w-fit items-center gap-2 text-xs font-medium underline-offset-4",133 "text-ui line-clamp-1 flex w-fit items-center gap-2 font-medium underline-offset-4",134 className135 )}136 {...props}137 />
4 unmodified lines
142 return (143 <p144 data-slot="item-description"145 className={cn(146 "text-muted-foreground [&>a:hover]:text-primary line-clamp-2 text-left text-xs/relaxed font-normal group-data-[size=xs]/item:text-xs/relaxed [&>a]:underline [&>a]:underline-offset-4",146 "text-muted-foreground [&>a:hover]:text-primary text-ui group-data-[size=xs]/item:text-ui line-clamp-2 text-left font-normal [&>a]:underline [&>a]:underline-offset-4",147 className148 )}149 {...props}150 />
51 unmodified lines
modified:apps/web/src/components/ui/kbd.tsx+1 added-1 removed
3 unmodified lines
4 return (5 <kbd6 data-slot="kbd"7 className={cn(8 "bg-muted text-muted-foreground in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-none px-1 font-sans text-xs font-medium select-none [&_svg:not([class*='size-'])]:size-3",8 "bg-muted text-muted-foreground in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 text-label pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-none px-1 font-sans font-medium select-none [&_svg:not([class*='size-'])]:size-3",9 className10 )}11 {...props}12 />
14 unmodified lines
modified:apps/web/src/components/ui/label.tsx+1 added-1 removed
6 unmodified lines
7 return (8 <label9 data-slot="label"10 className={cn(11 "flex items-center gap-2 text-xs leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",11 "text-label flex items-center gap-2 leading-none select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",12 className13 )}14 {...props}15 />
4 unmodified lines
modified:apps/web/src/components/ui/popover.tsx+4 added-4 removed
34 unmodified lines
35 >36 <PopoverPrimitive.Popup37 data-slot="popover-content"38 className={cn(39 "bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-none p-2.5 text-xs shadow-md ring-1 outline-hidden duration-100",39 "bg-popover text-popover-foreground ring-input data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 text-ui z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-none p-2.5 ring-1 outline-hidden duration-100",40 className41 )}42 {...props}43 />
5 unmodified lines
49function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {50 return (51 <div52 data-slot="popover-header"53 className={cn("flex flex-col gap-1 text-xs", className)}53 className={cn("text-ui flex flex-col gap-1", className)}54 {...props}55 />56 );57}
1 unmodified line
59function PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {60 return (61 <PopoverPrimitive.Title62 data-slot="popover-title"63 className={cn("text-sm font-medium", className)}63 className={cn("text-ui font-semibold", className)}64 {...props}65 />66 );67}
4 unmodified lines
72}: PopoverPrimitive.Description.Props) {73 return (74 <PopoverPrimitive.Description75 data-slot="popover-description"76 className={cn("text-muted-foreground text-xs/relaxed", className)}76 className={cn("text-muted-foreground text-ui", className)}77 {...props}78 />79 );80}
9 unmodified lines
modified:apps/web/src/components/ui/select.tsx+4 added-4 removed
36 unmodified lines
37 <SelectPrimitive.Trigger38 data-slot="select-trigger"39 data-size={size}40 className={cn(41 "border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 flex w-fit items-center justify-between gap-1.5 rounded-none border bg-transparent py-2 pr-2 pl-2.5 text-xs whitespace-nowrap transition-colors outline-none select-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-none *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",41 "border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 sm:text-ui flex w-fit items-center justify-between gap-1.5 rounded-none border bg-transparent py-2 pr-2 pl-2.5 text-base whitespace-nowrap transition-colors outline-none select-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 data-[size=default]:h-9 data-[size=sm]:h-8 data-[size=sm]:rounded-none *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 sm:data-[size=default]:h-8 sm:data-[size=sm]:h-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",42 className43 )}44 {...props}45 >
34 unmodified lines
80 <SelectPrimitive.Popup81 data-slot="select-content"82 data-align-trigger={alignItemWithTrigger}83 className={cn(84 "bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-none shadow-md ring-1 duration-100 data-[align-trigger=true]:animate-none",84 "bg-popover text-popover-foreground ring-input data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-none ring-1 duration-100 data-[align-trigger=true]:animate-none",85 className86 )}87 {...props}88 >
12 unmodified lines
101}: SelectPrimitive.GroupLabel.Props) {102 return (103 <SelectPrimitive.GroupLabel104 data-slot="select-label"105 className={cn("text-muted-foreground px-2 py-2 text-xs", className)}105 className={cn("text-muted-foreground text-label px-2 py-2", className)}106 {...props}107 />108 );109}
6 unmodified lines
116 return (117 <SelectPrimitive.Item118 data-slot="select-item"119 className={cn(120 "focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 text-xs outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",120 "focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground text-ui relative flex w-full cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",121 className122 )}123 {...props}124 >
75 unmodified lines
modified:apps/web/src/components/ui/skeleton.tsx+1 added-1 removed
2 unmodified lines
3function Skeleton({ className, ...props }: React.ComponentProps<"div">) {4 return (5 <div6 data-slot="skeleton"7 className={cn("bg-muted animate-pulse rounded-none", className)}7 className={cn("border-skeleton rounded-none border", className)}8 {...props}9 />10 );11}
2 unmodified lines
modified:apps/web/src/components/ui/table.tsx+2 added-2 removed
7 unmodified lines
8 className="relative w-full overflow-x-auto"9 >10 <table11 data-slot="table"12 className={cn("w-full caption-bottom text-xs", className)}12 className={cn("text-ui w-full caption-bottom", className)}13 {...props}14 />15 </div>16 );
77 unmodified lines
94}: React.ComponentProps<"caption">) {95 return (96 <caption97 data-slot="table-caption"98 className={cn("text-muted-foreground mt-4 text-xs", className)}98 className={cn("text-muted-foreground text-label mt-4", className)}99 {...props}100 />101 );102}
11 unmodified lines
modified:apps/web/src/components/ui/tabs.tsx+3 added-3 removed
55 unmodified lines
56 return (57 <TabsPrimitive.Tab58 data-slot="tabs-trigger"59 className={cn(60 "text-foreground/60 hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-none border border-transparent px-1.5 py-0.5 text-xs font-medium whitespace-nowrap transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:py-[calc(--spacing(1.25))] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",60 "text-foreground/60 hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:text-muted-foreground dark:hover:text-foreground text-ui relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-none border border-transparent px-1.5 py-0.5 font-medium whitespace-nowrap transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:py-[calc(--spacing(1.25))] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",61 "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",62 "data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",62 "data-active:border-input data-active:bg-background data-active:text-foreground",63 "after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",64 className65 )}66 {...props}
4 unmodified lines
71function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {72 return (73 <TabsPrimitive.Panel74 data-slot="tabs-content"75 className={cn("flex-1 text-xs/relaxed outline-none", className)}75 className={cn("text-ui flex-1 outline-none", className)}76 {...props}77 />78 );79}
2 unmodified lines
modified:apps/web/src/components/ui/textarea.tsx+1 added-1 removed
4 unmodified lines
5 return (6 <textarea7 data-slot="textarea"8 className={cn(9 "border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 flex field-sizing-content min-h-16 w-full rounded-none border bg-transparent px-2.5 py-2 text-xs transition-colors outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1 md:text-xs",9 "border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-surface aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 sm:text-ui flex field-sizing-content min-h-16 w-full rounded-none border bg-transparent px-2.5 py-2 text-base transition-colors outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-1",10 className11 )}12 {...props}13 />
4 unmodified lines
modified:apps/web/src/components/ui/toggle.tsx+1 added-1 removed
3 unmodified lines
4import { cva, type VariantProps } from "class-variance-authority";5import { cn } from "cn";67const toggleVariants = cva(8 "group/toggle hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 inline-flex items-center justify-center gap-1 rounded-none text-xs font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",8 "group/toggle hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 text-ui inline-flex items-center justify-center gap-1 rounded-none font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",9 {10 variants: {11 variant: {12 default: "bg-transparent",
32 unmodified lines
modified:apps/web/src/components/ui/tooltip.tsx+1 added-1 removed
45 unmodified lines
46 >47 <TooltipPrimitive.Popup48 data-slot="tooltip-content"49 className={cn(50 "bg-foreground text-background data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-none px-3 py-1.5 text-xs has-data-[slot=kbd]:pr-1.5 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-none",50 "bg-foreground text-background data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 text-label z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-none px-3 py-1.5 has-data-[slot=kbd]:pr-1.5 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-none",51 className52 )}53 {...props}54 >
9 unmodified lines
modified:apps/web/src/features/code/code-view.tsx+4 added-4 removed
10 unmodified lines
11 *12 * The library and Shiki's grammars are megabytes, so only the browser13 * loads this module (`client-code.tsx`); the Worker never bundles it.14 */15import { DEFAULT_THEMES } from "@pierre/diffs";15import { File } from "@pierre/diffs/react";16import type { FileOptions, SelectedLineRange } from "@pierre/diffs/react";17import { Option } from "effect";18import { useEffect, useMemo, useRef, useState } from "react";1920import { lineHash, parseLineHash } from "./line-hash.ts";21import type { LineRange } from "./line-hash.ts";22import { diffsOptions, registerCodeTheme } from "./pierre.ts";2324registerCodeTheme();2526/** Past this many characters a file is drawn without highlighting. */27const HIGHLIGHT_LIMIT = 300_000;2829export interface FileCodeProps {
63 unmodified lines
93 );9495 const options = useMemo(96 (): FileOptions<undefined, undefined> => ({97 ...diffsOptions,98 enableLineSelection: true,99 lineHoverHighlight: "number",100 onLineSelected: (range: SelectedLineRange | null) => {101 const lines =
17 unmodified lines
119 pending.current.node = node;120 reveal(pending.current);121 },122 overflow: "scroll",120 preferredHighlighter: "shiki-js",121 theme: DEFAULT_THEMES,122 themeType: "system",123 tokenizeMaxLength: HIGHLIGHT_LIMIT,124 }),125 []126 );
10 unmodified lines
modified:apps/web/src/features/code/diff-view.tsx+5 added-5 removed
7 unmodified lines
8 * Each view's section is the file tree's jump target (`diffAnchor`).9 *10 * Only the browser loads this module (`client-code.tsx`).11 */12import { DEFAULT_THEMES } from "@pierre/diffs";12import { MultiFileDiff } from "@pierre/diffs/react";13import type { FileDiffOptions } from "@pierre/diffs/react";14import type { ChangedFile } from "@repo/protocol/domain/code";1516import { diffAnchor } from "./paths.ts";17import { diffsOptions, registerCodeTheme } from "./pierre.ts";1819registerCodeTheme();2021const optionsFor = (split: boolean): FileDiffOptions<undefined, undefined> => ({22 ...diffsOptions,23 diffStyle: split ? "split" : "unified",24 overflow: "wrap",22 preferredHighlighter: "shiki-js",23 theme: DEFAULT_THEMES,24 themeType: "system",25});2627export interface DiffCodeProps {28 readonly files: readonly ChangedFile[];
24 unmodified lines
53 </section>54 ) : (55 <section56 aria-label={file.path}57 className="border-rule border border-dashed px-4 py-3 font-mono text-[0.8125rem]"57 className="border-rule text-mono border border-dashed px-4 py-3 font-mono"58 id={diffAnchor(file.path)}59 key={file.path}60 >61 {file.path}: {file.binary ? "a binary file" : "not shown"},{" "}
10 unmodified lines
added:apps/web/src/features/code/pierre.ts+72 added
1/**2 * What every drawing of code shares: the options each `@pierre/diffs` view3 * spreads into its own (`File`, `MultiFileDiff`, `FileDiff`), the options4 * of the `@pierre/trees` file tree, and the colour theme they draw in.5 *6 * The theme reads CSS variables (`--diffs-token-*`, `--diffs-foreground`,7 * `--diffs-background`), which `styles.css` sets on every8 * `diffs-container` from the web's own tokens: code sits on the paper and9 * follows the system's light or dark setting with the page, in low-chroma10 * colours that never borrow a state's. It is named for both schemes, so11 * Pierre leaves the scheme to the page: a single theme name would fix it12 * to the theme's own type (Shiki calls a variable theme dark). Colour is13 * all it carries: Pierre resolves a token's weight and slant through14 * `light-dark()`, which takes colours only, so a two-scheme drawing drops15 * them.16 *17 * The limits are Pierre's own defaults, written out so a reader sees them:18 * past them a file (or a line, or a changed line's pair) is drawn as plain19 * text, so a minified bundle or a lockfile cannot stall the page.20 *21 * No React and no DOM here: the module loads in Node for its test, and in22 * the browser only through the views that draw.23 */24import {25 DEFAULT_TOKENIZE_MAX_LENGTH,26 registerCustomCSSVariableTheme,27} from "@pierre/diffs";2829/** The token theme's registered name. */30export const CODE_THEME = "repo-tokens";3132/** Spread first into a drawing's own options. */33export const diffsOptions = {34 maxLineDiffLength: 1000,35 preferredHighlighter: "shiki-js",36 theme: { dark: CODE_THEME, light: CODE_THEME },37 themeType: "system",38 tokenizeMaxLength: DEFAULT_TOKENIZE_MAX_LENGTH,39 tokenizeMaxLineLength: 1000,40} as const;4142/** The file tree's look: compact rows, plain icons (`styles.css` greys them). */43export const treesOptions = { density: "compact", icons: "minimal" } as const;4445/**46 * Where a variable is not set (a drawing outside `diffs-container`'s47 * mapping), the page's own tokens stand in.48 */49const variableDefaults = {50 background: "var(--background)",51 foreground: "var(--foreground)",52 "token-comment": "var(--muted)",53 "token-constant": "var(--foreground)",54 "token-function": "var(--foreground)",55 "token-keyword": "var(--foreground)",56 "token-link": "var(--foreground)",57 "token-parameter": "var(--foreground)",58 "token-punctuation": "var(--muted)",59 "token-string": "var(--foreground)",60 "token-string-expression": "var(--foreground)",61};6263/** Whether this page has registered the theme yet; Pierre refuses a name twice. */64const registered = { done: false };6566/** Registers the token theme, once; each drawing calls it before it draws. */67export const registerCodeTheme = () => {68 if (!registered.done) {69 registered.done = true;70 registerCustomCSSVariableTheme(CODE_THEME, variableDefaults);71 }72};
modified:apps/web/src/features/code/repo-tree.tsx+2 added-1 removed
12 unmodified lines
13import { FileTree, useFileTree } from "@pierre/trees/react";14import { useEffect, useMemo } from "react";1516import { ancestorsOf } from "./paths.ts";17import { treesOptions } from "./pierre.ts";1819export interface RepoTreeProps {20 /** The path the page shows, a file or a folder. */21 readonly current?: string | undefined;
15 unmodified lines
37}: RepoTreeProps) => {38 const preparedInput = useMemo(() => prepareFileTreeInput(paths), [paths]);3940 const { model } = useFileTree({40 density: "compact",41 ...treesOptions,42 fileTreeSearchMode: "hide-non-matches",43 id: "repo-tree",44 initialExpandedPaths:45 current === undefined
31 unmodified lines
modified:apps/web/src/features/finish/patch-diff.tsx+6 added-4 removed
5 unmodified lines
6 *7 * The library and Shiki's grammars are megabytes, so only the browser loads8 * this module (`client-diff.tsx`); the Worker never bundles it.9 */10import { DEFAULT_THEMES, parsePatchFiles } from "@pierre/diffs";10import { parsePatchFiles } from "@pierre/diffs";11import { FileDiff } from "@pierre/diffs/react";12import type { FileDiffOptions } from "@pierre/diffs/react";13import { useMemo } from "react";1415import { diffsOptions, registerCodeTheme } from "../code/pierre.ts";1617registerCodeTheme();1819const options = {20 ...diffsOptions,21 diffStyle: "unified",22 overflow: "wrap",18 preferredHighlighter: "shiki-js",19 theme: DEFAULT_THEMES,20 themeType: "system",23} as const satisfies FileDiffOptions<undefined, undefined>;2425export const PatchDiffs = ({ patch }: { readonly patch: string }) => {26 const files = useMemo(
20 unmodified lines
modified:apps/web/src/features/markdown/markdown.tsx+31 added-2 removed
103 unmodified lines
104);105106const components: Components = { a: Anchor, img: Image };107108/**109 * A README in the page's own type: body text at 16 px on a 70-character110 * measure, headings under the page's headline, code in the mono size on111 * the surface, links in ink. Colours come from the tokens112 * (`prose-tokens` in `styles.css`), so both schemes share these classes.113 */114const PROSE = [115 "prose prose-tokens text-body max-w-[70ch] min-w-0",116 // Headings: the h1 at the title size, so the page's own headline leads.117 "prose-headings:font-semibold prose-headings:tracking-[-0.01em]",118 "prose-h1:text-title prose-h1:mb-3 prose-h1:border-b prose-h1:border-rule prose-h1:pb-2",119 "prose-h2:text-[1.0625rem] prose-h2:mt-8 prose-h2:mb-3",120 "prose-h3:text-want prose-h4:text-want",121 // Inline code: the mono face on a surface field, without backticks.122 "prose-code:before:content-none prose-code:after:content-none prose-code:font-normal",123 "[&_:not(pre)>code]:bg-surface [&_:not(pre)>code]:text-mono [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:py-px",124 // A code block: a field on the surface, ruled in a hairline.125 "prose-pre:bg-surface prose-pre:text-foreground prose-pre:border prose-pre:border-rule prose-pre:rounded-none",126 "prose-pre:text-mono prose-pre:leading-terminal prose-pre:px-4 prose-pre:py-3",127 // Links: ink, underlined in a hairline that darkens under the pointer.128 "prose-a:font-normal prose-a:decoration-input hover:prose-a:decoration-foreground",129 // Quotes as plain indented text, without the plugin's quotation marks.130 "prose-blockquote:font-normal prose-blockquote:not-italic",131 "[&_blockquote_p]:before:content-none [&_blockquote_p]:after:content-none",132 // Images inside the measure, set in the line as a README sets them.133 "prose-img:my-0 prose-img:inline-block prose-img:max-w-full",134 "prose-table:text-ui prose-th:font-semibold",135].join(" ");136137export const RepoMarkdown = ({138 at,139 dir,140 project,141 source,142}: RepoMarkdownProps): ReactNode => (114 <div className="prose prose-sm dark:prose-invert max-w-none">143 <div className={PROSE}>144 <Markdown145 components={components}146 rehypePlugins={rehypePluginsFor({ dir, project, sha: at })}147 remarkPlugins={remarkPlugins}
9 unmodified lines
157 source,158}: {159 readonly source: string;160}): ReactNode => (132 <pre className="overflow-x-auto font-mono text-sm whitespace-pre-wrap">161 <pre className="text-mono leading-terminal max-w-[70ch] overflow-x-auto font-mono whitespace-pre-wrap">162 {source}163 </pre>164);165
4 unmodified lines
modified:apps/web/src/features/proposal/client-file.tsx+1 added-1 removed
16 unmodified lines
17 : lazy(() => import("./drafted-file.tsx"));1819/** The file's text as the server and a reader without JavaScript see it. */20const Plain = ({ content }: { readonly content: string }) => (21 <pre className="border-rule bg-surface overflow-x-auto border px-3 py-2 font-mono text-[0.8125rem] leading-5">21 <pre className="border-rule bg-surface text-mono leading-code overflow-x-auto border px-3 py-2 font-mono">22 {content}23 </pre>24);25
28 unmodified lines
modified:apps/web/src/features/proposal/drafted-file.tsx+5 added-4 removed
5 unmodified lines
6 *7 * The library and Shiki's grammars are megabytes, so only the browser8 * loads this module (`client-file.tsx`); the Worker never bundles it.9 */10import { DEFAULT_THEMES } from "@pierre/diffs";10import { File } from "@pierre/diffs/react";11import type { FileOptions } from "@pierre/diffs/react";12import { useMemo } from "react";1314import { diffsOptions, registerCodeTheme } from "../code/pierre.ts";1516registerCodeTheme();1718export interface DraftedFileProps {19 readonly path: string;20 readonly content: string;21}2223const options: FileOptions<undefined, undefined> = {24 ...diffsOptions,25 overflow: "scroll",22 preferredHighlighter: "shiki-js",23 theme: DEFAULT_THEMES,24 themeType: "system",26};2728export const DraftedFile = ({ content, path }: DraftedFileProps) => {29 const file = useMemo(
13 unmodified lines
modified:apps/web/src/features/shared/command.tsx+1 added-1 removed
31 unmodified lines
32 Effect.runFork(copyFor(command, setCopied));33 };3435 return (36 <div className="border-rule bg-surface flex w-fit max-w-full min-w-0 items-start gap-2 border py-1 pr-1 pl-3 font-mono text-[0.8125rem] leading-6">36 <div className="border-rule bg-surface text-mono leading-terminal flex w-fit max-w-full min-w-0 items-start gap-2 border py-1 pr-1 pl-3 font-mono">37 <span aria-hidden="true" className="text-muted-foreground select-none">38 $39 </span>40 <code className="min-w-0 flex-1 py-0.5 [overflow-wrap:anywhere] break-words whitespace-pre-wrap select-all">
17 unmodified lines
modified:apps/web/src/features/shared/credits.tsx+2 added-2 removed
20 unmodified lines
21/** An `Assisted-by:` value as the landing's trailer spells it: `pi:opus-4 (claimed)`. */22export const assistedValue = ({ harness, model, verified }: AgentTrailer) =>23 `${harness}${model === undefined ? "" : `:${model}`} (${verified ? "verified" : "claimed"})`;2425const LINES = "flex flex-col gap-1 font-mono text-[0.8125rem] leading-6";25const LINES = "flex flex-col gap-1 font-mono text-mono leading-terminal";2627const LABEL = "text-xs font-medium text-muted-foreground";27const LABEL = "text-label text-muted-foreground";2829export const CreditTrailers = ({30 assisted,31 credits,
42 unmodified lines
modified:apps/web/src/features/shared/layout.tsx+3 added-5 removed
85 unmodified lines
86}) => (87 <footer className="border-rule border-t">88 <div className={`${COLUMN} grid gap-6 py-8 sm:grid-cols-3`}>89 <section className="flex min-w-0 flex-col gap-2">90 <h2 className="text-muted-foreground text-xs font-medium">90 <h2 className="text-muted-foreground text-label">91 Plain git: clone any project92 </h2>93 <CommandLine command={`git clone ${platformUrl}/<project>.git`} />94 </section>95 <section className="flex min-w-0 flex-col gap-2">96 <h2 className="text-muted-foreground text-xs font-medium">96 <h2 className="text-muted-foreground text-label">97 Install the {Brand.cli} CLI98 </h2>99 <CommandLine command={`curl -fsSL ${platformUrl}/install.sh | sh`} />100 </section>101 <section className="flex min-w-0 flex-col gap-2">102 <h2 className="text-muted-foreground text-xs font-medium">103 Connect an agent104 </h2>102 <h2 className="text-muted-foreground text-label">Connect an agent</h2>103 <p className="text-sm">104 <a105 className="decoration-rule underline hover:decoration-current"106 href="/agents"
9 unmodified lines
modified:apps/web/src/features/shared/outcome.tsx+3 added-3 removed
42 unmodified lines
43);4445const short = (sha: string) => sha.slice(0, 7);4647const ID = "font-mono text-[0.8125rem]";47const ID = "font-mono text-mono";4849interface Reading {50 readonly icon: LucideIcon;51 /** The role colour, as a text class. */
196 unmodified lines
248 className={`mt-0.5 size-3.5 shrink-0 ${tones[state]}`}249 strokeWidth={state === "current" ? 2.5 : 2}250 />251 <span className="flex min-w-0 flex-col leading-tight">252 <span className="truncate text-xs font-medium">252 <span className="text-label truncate">253 {stageNames(name).label}254 </span>255 <span className={`text-[0.6875rem] ${tones[state]}`}>{word}</span>255 <span className={`text-label ${tones[state]}`}>{word}</span>256 </span>257 </li>258 );259 })}
3 unmodified lines
modified:apps/web/src/features/shared/refusal.tsx+1 added-1 removed
15 unmodified lines
16const Lines = ({ refusal }: { readonly refusal: Refusal }) => {17 const prefix = `${refusal._tag}:`;1819 return (20 <samp className="block max-w-[96ch] font-mono text-[0.8125rem] leading-6 [overflow-wrap:anywhere] whitespace-pre-wrap">20 <samp className="text-mono leading-terminal block max-w-[96ch] font-mono [overflow-wrap:anywhere] whitespace-pre-wrap">21 {explain([refusal]).map((line) => (22 <span className="block" key={line}>23 {line.startsWith(prefix) ? (24 <>
50 unmodified lines
modified:apps/web/src/features/why/why-code.tsx+4 added-4 removed
7 unmodified lines
8 * It is Pierre's `File` (as `code-view.tsx` draws a file), which renders9 * on the server too, so its markup can be checked; the page loads it only10 * in the browser (`client-why.tsx`), and the Worker never bundles it.11 */12import { DEFAULT_THEMES } from "@pierre/diffs";12import { File } from "@pierre/diffs/react";13import type { FileOptions, LineAnnotation } from "@pierre/diffs/react";14import type { WhyView } from "@repo/protocol/domain/code";15import type { ProjectName } from "@repo/protocol/ids";
8 unmodified lines
24 DialogTitle,25} from "@/components/ui/dialog";2627import { shortSha } from "../code/paths.ts";28import { diffsOptions, registerCodeTheme } from "../code/pierre.ts";29import { LandingDetails, RangeLinks, RangeSummary } from "./range-summary.tsx";30import { linesWords, rowAt, rowsOf } from "./rows.ts";31import type { WhyRow } from "./rows.ts";3233registerCodeTheme();3435/** Past this many characters a file is drawn without highlighting. */36const HIGHLIGHT_LIMIT = 300_000;3738export interface WhyCodeProps {
67 unmodified lines
106 );107108 const options = useMemo(109 (): FileOptions<WhyRow, undefined> => ({110 ...diffsOptions,111 lineHoverHighlight: "number",112 onLineNumberClick: ({ lineNumber }) => {113 setLine(lineNumber);114 },115 overflow: "scroll",113 preferredHighlighter: "shiki-js",114 theme: DEFAULT_THEMES,115 themeType: "system",116 tokenizeMaxLength: HIGHLIGHT_LIMIT,117 }),118 []119 );
35 unmodified lines
modified:apps/web/src/styles.css+202 added-24 removed
18 unmodified lines
19 --refused a refusal (nonconformance); the one rubric colour20 --sealed held-back checks, layers and sealed evidence21 --muted not reached, not needed, secondary text2223 Everything else is neutral: controls are ruled in --input, placeholders24 in --skeleton, code is drawn in the low-chroma --syntax-* colours, and a25 diff's added and removed lines in teal and rose (--diff-*), a family of26 their own, so a deletion never reads as a refusal or an addition as a27 landing. test/tokens.test.ts measures every pair that must hold.2829 Light and dark follow the system setting (no toggle, no script, no flash):30 shadcn's `dark:` variant is the media query, not a class.31*/32@custom-variant dark (@media (prefers-color-scheme: dark));
64 unmodified lines
97 --waiting: oklch(0.5 0.1 70);98 --refused: oklch(0.5 0.18 27);99 --sealed: oklch(0.46 0.13 305);100101 /* A control's border at 3:1 on paper (WCAG 2.2 SC 1.4.11), and the102 stroke of a placeholder that holds a row's place. */103 --input: oklch(0.62 0.01 258);104 --skeleton: oklch(0.8 0.008 255);105106 /* Code: ink carries keywords, names and calls; strings lean teal and107 constants olive, both too grey to be mistaken for a state. */108 --syntax-keyword: var(--foreground);109 --syntax-function: var(--foreground);110 --syntax-parameter: var(--foreground);111 --syntax-string: oklch(0.46 0.035 200);112 --syntax-constant: oklch(0.47 0.035 110);113 --syntax-comment: var(--muted);114 --syntax-punctuation: var(--muted);115 --syntax-link: var(--syntax-string);116117 /* A diff's lines. The sign colour draws the + and -, the bars and a118 changed line's number; the line's tint is that colour mixed into the119 paper as Pierre mixes it (12% here, 20% in the dark), so a server's120 plain-text diff can match the drawing; emphasis marks the changed121 words. */122 --diff-add-sign: oklch(0.51 0.09 195);123 --diff-add-bg: color-mix(in lab, var(--background) 88%, var(--diff-add-sign));124 --diff-add-emphasis: color-mix(125 in oklab,126 var(--diff-add-sign) 18%,127 transparent128 );129 --diff-del-sign: oklch(0.51 0.12 345);130 --diff-del-bg: color-mix(in lab, var(--background) 88%, var(--diff-del-sign));131 --diff-del-emphasis: color-mix(132 in oklab,133 var(--diff-del-sign) 18%,134 transparent135 );136137 /* shadcn's names, mapped onto the roles above. */138 --card: var(--background);139 --card-foreground: var(--foreground);140 --popover: oklch(0.995 0.002 240);
6 unmodified lines
147 --accent: var(--surface);148 --accent-foreground: var(--foreground);149 --destructive: var(--refused);150 --border: var(--rule);109 --input: var(--rule);151 --ring: var(--foreground);152 --radius: 0.125rem;153}154
11 unmodified lines
166 --waiting: oklch(0.82 0.12 78);167 --refused: oklch(0.73 0.15 25);168 --sealed: oklch(0.76 0.11 305);169170 --input: oklch(0.55 0.01 258);171 --skeleton: oklch(0.36 0.01 258);172173 --syntax-string: oklch(0.8 0.035 200);174 --syntax-constant: oklch(0.82 0.035 110);175176 --diff-add-sign: oklch(0.74 0.08 195);177 --diff-add-bg: color-mix(178 in lab,179 var(--background) 80%,180 var(--diff-add-sign)181 );182 --diff-add-emphasis: color-mix(183 in oklab,184 var(--diff-add-sign) 26%,185 transparent186 );187 --diff-del-sign: oklch(0.72 0.1 345);188 --diff-del-bg: color-mix(189 in lab,190 var(--background) 80%,191 var(--diff-del-sign)192 );193 --diff-del-emphasis: color-mix(194 in oklab,195 var(--diff-del-sign) 26%,196 transparent197 );198199 --popover: oklch(0.235 0.009 258);200 }201}202
4 unmodified lines
207 --font-mono:208 "JetBrains Mono", ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo,209 monospace;210141 /* A fixed scale, ratio about 1.2: product type does not float. */211 /*212 The type scale, by role: a fixed rem scale, nothing fluid, and nothing213 under 13 px. Mono is only for what a terminal prints or takes; its214 three lines are inline (the token's own), a transcript215 (`leading-terminal`) and code (`leading-code`, Pierre's 20 px).216 */217 --text-headline: 1.5rem;218 --text-headline--line-height: 2rem;219 --text-headline--letter-spacing: -0.015em;220 --text-headline--font-weight: 600;221 --text-title: 1.1875rem;222 --text-title--line-height: 1.6rem;223 --text-title--letter-spacing: -0.01em;224 --text-title--font-weight: 600;225 --text-want: 1rem;226 --text-want--line-height: 1.5rem;227 --text-body: 1rem;228 --text-body--line-height: 1.55rem;229 --text-ui: 0.875rem;230 --text-ui--line-height: 1.3rem;231 --text-label: 0.8125rem;232 --text-label--line-height: 1.15rem;233 --text-label--font-weight: 500;234 --text-mono: 0.8125rem;235 --text-mono--line-height: 1.25rem;236 --leading-terminal: 1.5rem;237 --leading-code: 20px;238239 /* The earlier scale, which pages written before the one above still use. */240 --text-xs: 0.75rem;241 --text-xs--line-height: 1.1rem;242 --text-sm: 0.875rem;243 --text-sm--line-height: 1.35rem;
15 unmodified lines
259 --color-checking: var(--checking);260 --color-waiting: var(--waiting);261 --color-refused: var(--refused);262 --color-sealed: var(--sealed);263 --color-skeleton: var(--skeleton);264 --color-diff-add-sign: var(--diff-add-sign);265 --color-diff-add-bg: var(--diff-add-bg);266 --color-diff-add-emphasis: var(--diff-add-emphasis);267 --color-diff-del-sign: var(--diff-del-sign);268 --color-diff-del-bg: var(--diff-del-bg);269 --color-diff-del-emphasis: var(--diff-del-emphasis);270 --color-muted: var(--surface);271 --color-muted-foreground: var(--muted-foreground);272273 --color-card: var(--card);
61 unmodified lines
335 outline: 2px solid var(--ring);336 outline-offset: 2px;337 }338339 /* Code shows what was typed: `=>` stays two characters. */340 code,341 kbd,342 samp,343 pre {238 font-feature-settings: "calt" 0;344 font-feature-settings:345 "calt" 0,346 "liga" 0;347 }348349 time,350 td,
4 unmodified lines
355 /*356 Pierre draws code inside shadow roots: `diffs-container` (@pierre/diffs)357 and `file-tree-container` (@pierre/trees). Each reads these variables358 from its host, so setting them here maps both onto the tokens above,251 and both follow the media-query dark mode with them.359 and both follow the media-query dark mode with them. Nothing outside360 them reaches in: the `code` rule above stops at the shadow root, so the361 ligatures are switched off again here.362 */363 diffs-container {364 /* Metrics: the mono token on Pierre's 20 px line. */365 --diffs-font-family: var(--font-mono);255 --diffs-addition-color-override: var(--landed);256 --diffs-deletion-color-override: var(--refused);257 --diffs-modified-color-override: var(--waiting);258 --diffs-selection-color-override: var(--checking);366 --diffs-font-size: 0.8125rem;367 --diffs-line-height: 20px;368 --diffs-font-features: "calt" 0, "liga" 0;369 --diffs-tab-size: 2;370 --diffs-header-font-family: var(--font-sans);371372 /* The ground: code sits on the paper, gutter and all. */373 --diffs-background: var(--background);374 --diffs-foreground: var(--foreground);375 --diffs-bg-context-override: var(--background);376 --diffs-bg-context-gutter-override: var(--background);377 --diffs-bg-separator-override: var(--surface);378 --diffs-fg-number-override: var(--muted);379 /* Pierre mixes a few percent of this into a hovered line, which lands380 on the surface's tone in both schemes. */381 --diffs-bg-hover-override: var(--foreground);382 /* The viewer's own selection, checking's hue, as text selection is;383 Pierre mixes it into the line at about a fifth. */384 --diffs-bg-selection-override: var(--checking);385 --diffs-bg-selection-number-override: var(--checking);386387 /* The token theme (features/code/pierre.ts) reads these. */388 --diffs-token-keyword: var(--syntax-keyword);389 --diffs-token-function: var(--syntax-function);390 --diffs-token-parameter: var(--syntax-parameter);391 --diffs-token-string: var(--syntax-string);392 --diffs-token-string-expression: var(--syntax-string);393 --diffs-token-constant: var(--syntax-constant);394 --diffs-token-comment: var(--syntax-comment);395 --diffs-token-punctuation: var(--syntax-punctuation);396 --diffs-token-link: var(--syntax-link);397398 /* A diff's lines, in its own tints (Pierre mixes the line's from the399 sign, as --diff-add-bg says). */400 --diffs-addition-color-override: var(--diff-add-sign);401 --diffs-bg-addition-override: var(--diff-add-sign);402 --diffs-bg-addition-number-override: var(--diff-add-sign);403 --diffs-bg-addition-emphasis-override: var(--diff-add-emphasis);404 --diffs-deletion-color-override: var(--diff-del-sign);405 --diffs-bg-deletion-override: var(--diff-del-sign);406 --diffs-bg-deletion-number-override: var(--diff-del-sign);407 --diffs-bg-deletion-emphasis-override: var(--diff-del-emphasis);408 --diffs-modified-color-override: var(--muted);409 }410411 file-tree-container {412 /* A tree is read like a list, in the UI's own face and size. */262 --trees-font-family-override: var(--font-mono);413 --trees-font-family-override: var(--font-sans);414 --trees-font-size-override: 0.875rem;415 --trees-bg-override: var(--background);416 --trees-bg-muted-override: var(--surface);417 --trees-fg-override: var(--foreground);418 --trees-fg-muted-override: var(--muted);419 --trees-input-bg-override: var(--background);267 --trees-border-color-override: var(--rule);420 --trees-border-color-override: var(--input);421 --trees-border-radius-override: var(--radius);269 --trees-accent-override: var(--checking);422 --trees-accent-override: var(--foreground);423 --trees-focus-ring-color-override: var(--ring);271 --trees-selected-bg-override: color-mix(272 in oklch,273 var(--checking) 14%,274 transparent275 );424 --trees-selected-bg-override: var(--surface);425 --trees-selected-fg-override: var(--foreground);426 /* One colour for every file's icon: a file's kind is not a state. */427 --trees-file-icon-color: var(--muted);428 /* A commit's changes, in the diff's tints; a change in place is muted. */277 --trees-status-added-override: var(--landed);278 --trees-status-deleted-override: var(--refused);279 --trees-status-modified-override: var(--waiting);280 --trees-status-renamed-override: var(--checking);429 --trees-status-added-override: var(--diff-add-sign);430 --trees-status-deleted-override: var(--diff-del-sign);431 --trees-status-modified-override: var(--muted);432 --trees-status-renamed-override: var(--muted);433 --trees-status-untracked-override: var(--muted);434 --trees-status-ignored-override: var(--muted);283 --trees-git-added-color-override: var(--landed);284 --trees-git-deleted-color-override: var(--refused);285 --trees-git-modified-color-override: var(--waiting);286 --trees-git-renamed-color-override: var(--checking);435 --trees-git-added-color-override: var(--diff-add-sign);436 --trees-git-deleted-color-override: var(--diff-del-sign);437 --trees-git-modified-color-override: var(--muted);438 --trees-git-renamed-color-override: var(--muted);439 --trees-git-untracked-color-override: var(--muted);440 --trees-git-ignored-color-override: var(--muted);441 }442
6 unmodified lines
449 transition-duration: 0.01ms !important;450 }451 }452}453454/*455 Rendered Markdown (a README, a `.md` file) in the page's colours: the456 typography plugin's palette, every role mapped to a token, so one set of457 classes serves both schemes (features/markdown/markdown.tsx).458*/459@utility prose-tokens {460 --tw-prose-body: var(--foreground);461 --tw-prose-headings: var(--foreground);462 --tw-prose-lead: var(--muted);463 --tw-prose-links: var(--foreground);464 --tw-prose-bold: var(--foreground);465 --tw-prose-counters: var(--muted);466 --tw-prose-bullets: var(--muted);467 --tw-prose-hr: var(--rule);468 --tw-prose-quotes: var(--muted);469 --tw-prose-quote-borders: var(--rule);470 --tw-prose-captions: var(--muted);471 --tw-prose-kbd: var(--foreground);472 --tw-prose-kbd-shadows: var(--rule);473 --tw-prose-code: var(--foreground);474 --tw-prose-pre-code: var(--foreground);475 --tw-prose-pre-bg: var(--surface);476 --tw-prose-th-borders: var(--input);477 --tw-prose-td-borders: var(--rule);478}
modified:apps/web/test/markdown.test.tsx+45 added
276 unmodified lines
277 expect(rendered("hi")).toMatch(/class="[^"]*\bprose\b[^"]*"/u);278 });279});280281/** The classes on the prose wrapper of a README with code and a title. */282const proseClasses = () => {283 const markup = rendered(284 "# datekit\n\nCall `format()` first.\n\n```ts\nconst a = () => 1;\n```"285 );286287 return new Set(288 /<div class="(?<classes>[^"]*\bprose\b[^"]*)"/u289 .exec(markup)290 ?.groups?.classes?.split(" ")291 );292};293294describe("a README drawn in the page's own type", () => {295 it("shows inline code without the backticks around it", () => {296 const classes = proseClasses();297298 expect(classes.has("prose-code:before:content-none")).toBeTruthy();299 expect(classes.has("prose-code:after:content-none")).toBeTruthy();300 });301302 it("sets a code block on the surface, ruled in a hairline, in the mono size", () => {303 const classes = proseClasses();304305 expect(classes.has("prose-pre:bg-surface")).toBeTruthy();306 expect(classes.has("prose-pre:border-rule")).toBeTruthy();307 expect(classes.has("prose-pre:text-mono")).toBeTruthy();308 });309310 it("keeps lines to 70 characters", () => {311 expect(proseClasses().has("max-w-[70ch]")).toBeTruthy();312 });313314 it("sets its h1 at the title size, under the page's own headline", () => {315 expect(proseClasses().has("prose-h1:text-title")).toBeTruthy();316 });317318 it("colours it from the tokens, so both schemes come from one set of classes", () => {319 const classes = proseClasses();320321 expect(classes.has("prose-tokens")).toBeTruthy();322 expect(classes.has("dark:prose-invert")).toBeFalsy();323 });324});325326describe("a README that is not Markdown", () => {327 it.each([328 ["README.md", true],329 ["docs/readme.markdown", true],
14 unmodified lines
added:apps/web/test/pierre.test.ts+101 added
1/**2 * Every drawing of code takes its options from one module: the theme that3 * reads the web's tokens (so code sits on the paper and follows the scheme4 * with the page), the highlighter, and the limits past which a minified5 * file or a lockfile is drawn as plain text instead of stalling the page.6 * The module touches no DOM and no React, so it loads here, in Node.7 */8import { describe, expect, it, vi } from "@effect/vitest";9import { DEFAULT_TOKENIZE_MAX_LENGTH, resolveTheme } from "@pierre/diffs";10import { Effect } from "effect";1112import {13 CODE_THEME,14 diffsOptions,15 registerCodeTheme,16 treesOptions,17} from "../src/features/code/pierre.ts";1819describe("the options every drawing of code shares", () => {20 it("name the token theme for both schemes, so the page's scheme decides", () => {21 expect(diffsOptions.theme).toStrictEqual({22 dark: CODE_THEME,23 light: CODE_THEME,24 });25 expect(diffsOptions.themeType).toBe("system");26 expect(diffsOptions.preferredHighlighter).toBe("shiki-js");27 });2829 it("carry the library's own limits, written out", () => {30 expect(diffsOptions.tokenizeMaxLength).toBe(100_000);31 expect(diffsOptions.tokenizeMaxLength).toBe(DEFAULT_TOKENIZE_MAX_LENGTH);32 expect(diffsOptions.tokenizeMaxLineLength).toBe(1000);33 expect(diffsOptions.maxLineDiffLength).toBe(1000);34 });3536 it("draw a file tree compact, with plain icons", () => {37 expect(treesOptions).toStrictEqual({38 density: "compact",39 icons: "minimal",40 });41 });42});4344describe("the token theme", () => {45 it.effect("colours code from the web's variables", () =>46 Effect.gen(function* () {47 registerCodeTheme();4849 const theme = yield* Effect.promise(() => resolveTheme(CODE_THEME));50 const colours = JSON.stringify(theme);5152 for (const token of ["keyword", "string", "comment", "constant"]) {53 expect(colours).toContain(`var(--diffs-token-${token}`);54 }5556 expect(colours).toContain("var(--diffs-background");57 })58 );5960 it("is registered once, however many drawings ask for it", () => {61 const complaints = vi.spyOn(console, "error").mockImplementation(() => {62 // Pierre says so on the console when a theme name is taken twice.63 });6465 registerCodeTheme();66 registerCodeTheme();6768 expect(complaints).not.toHaveBeenCalled();69 complaints.mockRestore();70 });71});7273describe("the drawings of code", () => {74 const sources: Readonly<Record<string, string>> = import.meta.glob(75 "../src/**/*.tsx",76 { eager: true, import: "default", query: "?raw" }77 );7879 const drawing = /from\s+["']@pierre\/(?:diffs|trees)\/react["']/u;80 const shared = /from\s+["'](?:\.\.?\/)+(?:code\/)?pierre\.ts["']/u;8182 const drawings = Object.entries(sources).filter(([, source]) =>83 drawing.test(source)84 );8586 it("each take their options from the one module", () => {87 expect(drawings.length).toBeGreaterThanOrEqual(6);8889 expect(90 drawings.flatMap(([path, source]) => (shared.test(source) ? [] : [path]))91 ).toStrictEqual([]);92 });9394 it("never fall back to Pierre's own colours", () => {95 expect(96 Object.entries(sources).flatMap(([path, source]) =>97 source.includes("DEFAULT_THEMES") ? [path] : []98 )99 ).toStrictEqual([]);100 });101});
added:apps/web/test/tokens.test.ts+373 added
1/**2 * The web's tokens, read from `styles.css` as text and measured the way3 * WCAG 2.2 measures them: each colour converted to sRGB (oklch through4 * oklab, by Björn Ottosson's published matrices; hex directly), then5 * compared by relative luminance. Light is `:root`; dark is `:root` with6 * the `prefers-color-scheme: dark` block laid over it, as a browser7 * resolves it.8 *9 * What holds: text at 4.5:1 and state colours at 5:1 on paper and on the10 * surface; control borders at 3:1 (SC 1.4.11); a skeleton's stroke that can11 * be seen; diff signs readable apart from the state colours; code coloured12 * with low chroma, far from every state hue; the kit's controls never under13 * 13 px; and Pierre's shadow roots fed from the tokens, never from the14 * state colours (bar the viewer's own selection).15 */16import { describe, expect, it } from "@effect/vitest";17import { createElement } from "react";18import { renderToStaticMarkup } from "react-dom/server";1920import { Input } from "../src/components/ui/input.tsx";21import { Textarea } from "../src/components/ui/textarea.tsx";2223import styles from "../src/styles.css?raw";2425/** The stylesheet with its comments gone, so a comment never reads as a rule. */26const css = styles.replaceAll(/\/\*[\s\S]*?\*\//gu, "");2728/** The text between the brace at `open` and the one that closes it. */29const blockFrom = (open: number): string => {30 let depth = 0;3132 for (let index = open; index < css.length; index += 1) {33 if (css[index] === "{") {34 depth += 1;35 } else if (css[index] === "}") {36 depth -= 1;3738 if (depth === 0) {39 return css.slice(open + 1, index);40 }41 }42 }4344 return "";45};4647/** The block a selector opens, searched from `from`; empty when there is none. */48const blockOf = (selector: string, from = 0): string => {49 const at = css.indexOf(`${selector} {`, from);5051 return at === -1 ? "" : blockFrom(css.indexOf("{", at));52};5354/** Each `--name: value;` a block declares. */55const declarations = (block: string): ReadonlyMap<string, string> =>56 new Map(57 [...block.matchAll(/--(?<name>[\w-]+):\s*(?<value>[^;]+);/gu)].map(58 ({ groups }) => [59 groups?.name ?? "",60 (groups?.value ?? "").replaceAll(/\s+/gu, " ").trim(),61 ]62 )63 );6465const lightTokens = declarations(blockOf(":root"));6667const darkTokens = new Map([68 ...lightTokens,69 ...declarations(70 blockOf(":root", css.indexOf("@media (prefers-color-scheme: dark)"))71 ),72]);7374type Scheme = "dark" | "light";7576const tokensOf = (scheme: Scheme) =>77 scheme === "light" ? lightTokens : darkTokens;7879/** A colour as oklch, the form the tokens are written in. */80interface Oklch {81 readonly chroma: number;82 readonly hue: number;83 readonly lightness: number;84}8586/** A token's value with every `var(--x)` alias followed. */87const valueOf = (scheme: Scheme, name: string): string => {88 const value = tokensOf(scheme).get(name);8990 if (value === undefined) {91 throw new Error(`--${name} is not declared for ${scheme}`);92 }9394 const alias = /^var\(--(?<name>[\w-]+)\)$/u.exec(value)?.groups?.name;9596 return alias === undefined ? value : valueOf(scheme, alias);97};9899/** A token as oklch; fails when it is written in any other form. */100const oklchOf = (scheme: Scheme, name: string): Oklch => {101 const value = valueOf(scheme, name);102103 const parts =104 /^oklch\((?<lightness>[\d.]+) (?<chroma>[\d.]+) (?<hue>[\d.]+)\)$/u.exec(105 value106 )?.groups;107108 if (parts === undefined) {109 throw new Error(`--${name} is ${value} for ${scheme}, not an oklch()`);110 }111112 return {113 chroma: Number(parts.chroma),114 hue: Number(parts.hue),115 lightness: Number(parts.lightness),116 };117};118119/** One sRGB channel, 0–1, made linear. */120const linear = (channel: number) =>121 channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;122123const clamp = (channel: number) => Math.min(1, Math.max(0, channel));124125/** Linear sRGB of an oklch colour, clipped into the gamut. */126const linearOfOklch = ({ chroma, hue, lightness }: Oklch) => {127 const a = chroma * Math.cos((hue * Math.PI) / 180);128 const b = chroma * Math.sin((hue * Math.PI) / 180);129 const l = (lightness + 0.3963377774 * a + 0.2158037573 * b) ** 3;130 const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;131 const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;132133 return [134 clamp(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),135 clamp(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),136 clamp(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),137 ] as const;138};139140/** Relative luminance of a token, written as oklch or as `#rrggbb`. */141const luminanceOf = (scheme: Scheme, name: string) => {142 const value = valueOf(scheme, name);143144 const [red, green, blue] = /^#[\da-f]{6}$/iu.test(value)145 ? ([1, 3, 5] as const).map((at) =>146 linear(Number.parseInt(value.slice(at, at + 2), 16) / 255)147 )148 : linearOfOklch(oklchOf(scheme, name));149150 return 0.2126 * (red ?? 0) + 0.7152 * (green ?? 0) + 0.0722 * (blue ?? 0);151};152153/** WCAG's contrast ratio between two tokens. */154const contrast = (scheme: Scheme, one: string, other: string) => {155 const [lighter, darker] = [156 luminanceOf(scheme, one),157 luminanceOf(scheme, other),158 ].toSorted((a, b) => b - a);159160 return ((lighter ?? 0) + 0.05) / ((darker ?? 0) + 0.05);161};162163/** The colours that mean a state, and nothing else may borrow. */164const STATES = ["landed", "checking", "waiting", "refused", "sealed"] as const;165166/** The syntax colours code is drawn in. */167const SYNTAX = [168 "syntax-keyword",169 "syntax-function",170 "syntax-parameter",171 "syntax-string",172 "syntax-constant",173 "syntax-comment",174 "syntax-punctuation",175 "syntax-link",176] as const;177178/** The degrees between two hues, the short way round. */179const hueDistance = (one: number, other: number) => {180 const apart = Math.abs(one - other) % 360;181182 return Math.min(apart, 360 - apart);183};184185/**186 * Under this chroma a colour reads as grey, and its hue as nothing: ink and187 * muted carry a trace of blue that no one sees as checking's.188 */189const NEUTRAL_CHROMA = 0.02;190191/** The states whose hue sits within 30° of `hue`. */192const statesNear = (scheme: Scheme, hue: number) =>193 STATES.filter((state) => hueDistance(hue, oklchOf(scheme, state).hue) < 30);194195describe.each(["light", "dark"] as const)("the %s scheme", (scheme) => {196 it.each(["foreground", "muted"])(197 "keeps --%s at 4.5:1 on paper and on the surface",198 (text) => {199 expect(contrast(scheme, text, "background")).toBeGreaterThanOrEqual(4.5);200 expect(contrast(scheme, text, "surface")).toBeGreaterThanOrEqual(4.5);201 }202 );203204 it.each(STATES)("keeps --%s at 5:1 on paper and on the surface", (state) => {205 expect(contrast(scheme, state, "background")).toBeGreaterThanOrEqual(5);206 expect(contrast(scheme, state, "surface")).toBeGreaterThanOrEqual(5);207 });208209 it("draws a control's border at 3:1 on paper and on the surface", () => {210 expect(contrast(scheme, "input", "background")).toBeGreaterThanOrEqual(3);211 expect(contrast(scheme, "input", "surface")).toBeGreaterThanOrEqual(3);212 });213214 it("strokes a skeleton at 1.5:1 on paper, so a placeholder can be seen", () => {215 expect(contrast(scheme, "skeleton", "background")).toBeGreaterThanOrEqual(216 1.5217 );218 });219220 // A changed line's number takes the sign's colour, so it is held as text.221 it.each(["diff-add-sign", "diff-del-sign"])(222 "draws --%s at 4.5:1 on paper",223 (sign) => {224 expect(contrast(scheme, sign, "background")).toBeGreaterThanOrEqual(4.5);225 }226 );227228 it.each(["diff-add-sign", "diff-del-sign"])(229 "keeps --%s's hue 30° from every state colour's",230 (sign) => {231 expect(statesNear(scheme, oklchOf(scheme, sign).hue)).toStrictEqual([]);232 }233 );234235 it.each(SYNTAX)("keeps --%s low in chroma, away from the states", (token) => {236 const { chroma, hue } = oklchOf(scheme, token);237238 expect(chroma).toBeLessThanOrEqual(0.035);239 expect(240 chroma < NEUTRAL_CHROMA ? [] : statesNear(scheme, hue)241 ).toStrictEqual([]);242 });243244 it.each(SYNTAX)("keeps --%s at 4.5:1 on paper", (token) => {245 expect(contrast(scheme, token, "background")).toBeGreaterThanOrEqual(4.5);246 });247248 it.each([249 "diff-add-bg",250 "diff-add-emphasis",251 "diff-del-bg",252 "diff-del-emphasis",253 ])("declares --%s", (tint) => {254 expect(valueOf(scheme, tint)).not.toBe("");255 });256});257258describe("Pierre's shadow roots", () => {259 const diffs = blockOf("diffs-container");260 const trees = blockOf("file-tree-container");261262 const roles = new RegExp(`var\\(--(?:${STATES.join("|")})\\)`, "u");263264 it("draw code without ligatures, so `=>` stays two characters", () => {265 expect(declarations(diffs).get("diffs-font-features")).toBe(266 '"calt" 0, "liga" 0'267 );268 });269270 it("set no variable the installed diffs never reads", () => {271 expect(272 declarations(diffs).has("diffs-selection-color-override")273 ).toBeFalsy();274 });275276 it("take a diff's colours from its own tints, never from landed or refused", () => {277 const mapped = declarations(diffs);278279 const elsewhere = [280 "diffs-addition-color-override",281 "diffs-deletion-color-override",282 "diffs-bg-addition-override",283 "diffs-bg-deletion-override",284 ].filter(285 (name) => !/^var\(--diff-(?:add|del)-/u.test(mapped.get(name) ?? "")286 );287288 expect(elsewhere).toStrictEqual([]);289290 // Only the viewer's own selection borrows a state's hue: checking's.291 const borrowing = [...mapped].flatMap(([name, value]) =>292 roles.test(value) ? [name] : []293 );294295 expect(borrowing.toSorted()).toStrictEqual([296 "diffs-bg-selection-number-override",297 "diffs-bg-selection-override",298 ]);299 });300301 it("mark a file tree's changes in the diff tints, and spend no state colour", () => {302 const mapped = declarations(trees);303304 expect(mapped.get("trees-git-added-color-override")).toBe(305 "var(--diff-add-sign)"306 );307 expect(mapped.get("trees-git-deleted-color-override")).toBe(308 "var(--diff-del-sign)"309 );310 expect([...mapped].filter(([, value]) => roles.test(value))).toStrictEqual(311 []312 );313 });314});315316describe("the kit's controls", () => {317 const kit: Readonly<Record<string, string>> = import.meta.glob(318 "../src/components/ui/*.tsx",319 { eager: true, import: "default", query: "?raw" }320 );321322 it("set nothing under 13 px", () => {323 expect(Object.keys(kit).length).toBeGreaterThan(20);324325 const small =326 /(?<![\w-])text-(?:xs|\[(?:0\.6875|0\.75)rem\]|\[1[0-2]px\])(?![\w-])/u;327328 const under = Object.entries(kit).flatMap(([path, source]) =>329 small.test(source) ? [path] : []330 );331332 expect(under).toStrictEqual([]);333 });334335 // iOS zooms the page when a field under 16 px takes focus.336 it.each([337 ["an input", createElement(Input)],338 ["a textarea", createElement(Textarea)],339 ])("type %s at 16 px on a phone and 14 px from 640 px", (_, element) => {340 const classes = new Set(341 /class="(?<classes>[^"]*)"/u342 .exec(renderToStaticMarkup(element))343 ?.groups?.classes?.split(" ")344 );345346 expect(classes.has("text-base")).toBeTruthy();347 expect(classes.has("sm:text-ui")).toBeTruthy();348 expect(classes.has("border-input")).toBeTruthy();349 });350});351352describe("the type scale", () => {353 const theme = declarations(blockOf("@theme inline"));354355 // Each role's size and line, as the design names them.356 it.each([357 ["headline", "1.5rem", "2rem"],358 ["title", "1.1875rem", "1.6rem"],359 ["want", "1rem", "1.5rem"],360 ["body", "1rem", "1.55rem"],361 ["ui", "0.875rem", "1.3rem"],362 ["label", "0.8125rem", "1.15rem"],363 ["mono", "0.8125rem", "1.25rem"],364 ])("sets text-%s at %s on a %s line", (role, size, line) => {365 expect(theme.get(`text-${role}`)).toBe(size);366 expect(theme.get(`text-${role}--line-height`)).toBe(line);367 });368369 it("gives mono a terminal's line and a code line", () => {370 expect(theme.get("leading-terminal")).toBe("1.5rem");371 expect(theme.get("leading-code")).toBe("20px");372 });373});