Skip to content
Myr

Review fixes for 1203

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

- AppLink escapes a path's $ and braces (literalPath) before the router sees them: a path built whole is a name, and the router was filling routes/$project/$.tsx from the page's own params (it became routes/datekit/...) and dropping {-$x}. The router decodes them back when it reads a page's params. Test: shell.test.tsx, inside the router and with none around it. - The rail's Keys and Menu buttons take their muted colour from a wrapper (Quiet): the kit's class merger reads an unknown text-* as a colour, so a colour in a Button's className dropped text-ui and the buttons drew at 16 px. The keys dialog's caps drop their colour class for the same reason (they drew at 14 px, not the 13 px label). Tests: every rail button carries text-ui; every key cap carries text-label. - The project switcher keeps a row's open count beside its posture at the row's end (two ml-auto split the row). The sheet loses its soft shadow: flat paper and a hairline, one elevation. - One doc comment on ProjectRow (two were stacked); root.test.tsx asserts the router's pending, error and not-found components are the shell's own, not merely defined. - ASSUMPTION: the same merger collision inside the kit's own base classes (muted colour dropped beside text-ui in DialogDescription, Kbd and others) is the kit's to fix, not the shell's; recorded for 1204.

authored by oscabriel · committed by oscabriel · parent ddbd51e · Browse files · 8 files+144 added−38 removed
This commit

State

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

Diff stats

8 files+144 added−38 removed

  • tests:+83 added−3 removed
  • other:+61 added−35 removed

8 files+144 added−38 removed

modified:apps/web/src/components/ui/sheet.tsx+3 added-2 removed
modified:apps/web/src/features/shared/shell/overlays.tsx+5 added-3 removed
115 unmodified lines
116 return (117 <ComboboxItem className="h-10 gap-3" key={name} value={name}>118 <span className="min-w-0 truncate font-medium">{name}</span>119 {listing === undefined ? null : (120 <>121 <span className="text-muted-foreground text-label ml-auto tabular-nums">120 // One group at the row's end, so the count sits beside121 // the posture rather than midway along the row.122 <span className="ml-auto flex shrink-0 items-center gap-3">123 <span className="text-muted-foreground text-label tabular-nums">124 {listing.openAsks} open125 </span>126 <PostureMark posture={listing.posture} />125 </>127 </span>128 )}129 </ComboboxItem>130 );131 }}
130 unmodified lines
modified:apps/web/src/features/shared/shell/rail.tsx+40 added-27 removed
150 unmodified lines
151 </span>152 );153};154155/** A project's row: its name, and its posture once the list has it. */156/** The current project's row: in ink at 600, unfilled, so the page being read (a section under it) is the one filled row. */157const PROJECT_ROW = RAIL_BASE;158155/**156 * A project's row: its name, and its posture once the list has it. The157 * current project's is in ink at 600 but unfilled, so the page being read158 * (a section under it) is the one filled row.159 */160const ProjectRow = ({161 current,162 listing,163 project,
4 unmodified lines
168}) => (169 <AppLink170 activeOptions={EXACT}171 aria-current={current ? "true" : undefined}171 className={PROJECT_ROW}172 className={RAIL_BASE}173 data-project={project}174 to={`/${project}`}175 >176 <span className="min-w-0 truncate">{project}</span>
117 unmodified lines
294 </div>295 );296};297298/**299 * A ghost button set in muted text, ink on hover. The colour comes from300 * around the button, not through its `className`: the kit merges classes,301 * reads an unknown `text-*` as a colour, and would drop the button's302 * `text-ui` size for a colour given there.303 */304const Quiet = ({ children }: { readonly children: ReactNode }) => (305 <span className="text-muted-foreground flex shrink-0">{children}</span>306);307308/** The rail's foot: the session, and the Keys button that opens the `?` dialog. */309export const RailFoot = () => {310 const { open } = useShell();311312 return (313 <div className="border-rule flex min-h-12 shrink-0 items-center justify-between gap-2 border-t py-1.5 pr-1.5 pl-3">314 <SessionSlot layout="rail" />304 <Button305 className="text-muted-foreground shrink-0"306 onClick={() => {307 open("keys");308 }}309 size="sm"310 variant="ghost"311 >312 <Keyboard aria-hidden="true" strokeWidth={1.75} />313 Keys314 </Button>315 <Quiet>316 <Button317 onClick={() => {318 open("keys");319 }}320 size="sm"321 variant="ghost"322 >323 <Keyboard aria-hidden="true" strokeWidth={1.75} />324 Keys325 </Button>326 </Quiet>327 </div>328 );329};330
64 unmodified lines
395 >396 <div className="border-rule flex h-11 shrink-0 items-center justify-between gap-2 border-b pr-1.5 pl-4">397 <Wordmark />398 {slotted ? (387 <Button388 className="text-muted-foreground"389 onClick={() => {390 open("menu");391 }}392 size="sm"393 variant="ghost"394 >395 <Menu aria-hidden="true" strokeWidth={1.75} />396 Menu397 </Button>399 <Quiet>400 <Button401 onClick={() => {402 open("menu");403 }}404 size="sm"405 variant="ghost"406 >407 <Menu aria-hidden="true" strokeWidth={1.75} />408 Menu409 </Button>410 </Quiet>411 ) : null}412 </div>413 {slotted ? (414 <>
12 unmodified lines
modified:apps/web/src/features/shared/keys.tsx+1 added-1 removed
156 unmodified lines
157 <span className="text-muted-foreground" key={key}>158 to159 </span>160 ) : (161 <Kbd className="text-foreground font-mono" key={key}>161 <Kbd className="font-mono" key={key}>162 {key}163 </Kbd>164 )165 )}
451 unmodified lines
modified:apps/web/src/features/shared/link.tsx+12 added-2 removed
modified:apps/web/test/keys.test.tsx+8 added
159 unmodified lines
160 expect(markup).toMatch(161 /<button\b[^>]*aria-pressed="false"[^>]*>On<\/button>/u162 );163164 // Each key cap at the label size, whatever face it is set in.165 expect(166 [...markup.matchAll(/<kbd\b[^>]*class="(?<classes>[^"]*)"/gu)].filter(167 ({ groups }) =>168 groups?.classes?.split(" ").includes("text-label") !== true169 )170 ).toStrictEqual([]);171172 for (const key of ["?", "j", "k", "J", "K", "1", "9", "Esc"]) {173 expect(markup).toContain(`<kbd`);174 expect(text).toContain(key);175 }
2 unmodified lines
modified:apps/web/test/root.test.tsx+8 added-3 removed
5 unmodified lines
6 */7import { describe, expect, it } from "@effect/vitest";8import { renderToStaticMarkup } from "react-dom/server";910import {11 NotFoundPage,12 PendingPage,13 RouteError,14} from "../src/features/shared/pending.tsx";15import { themeColors } from "../src/features/shared/theme.ts";16import { getRouter } from "../src/router.tsx";17import { rootHead, ThemeColors } from "../src/routes/__root.tsx";18
77 unmodified lines
96 });9798 it("waits 300 ms before drawing a page as pending, so a quick move never flashes", () => {99 expect(options.defaultPendingMs).toBe(300);95 expect(options.defaultPendingComponent).toBeDefined();100 expect(options.defaultPendingComponent).toBe(PendingPage);101 });102103 it("draws a failure and a missing page in the shell, never the router's own", () => {99 expect(options.defaultErrorComponent).toBeDefined();100 expect(options.defaultNotFoundComponent).toBeDefined();104 expect(options.defaultErrorComponent).toBe(RouteError);105 expect(options.defaultNotFoundComponent).toBe(NotFoundPage);106 });107108 it("scrolls each new page's main pane back to its top", () => {109 expect(options.scrollRestoration).toBeTruthy();
3 unmodified lines
modified:apps/web/test/shell.test.tsx+67 added
17 unmodified lines
18import { Effect } from "effect";19import { renderToStaticMarkup } from "react-dom/server";2021import { PageShell } from "../src/features/shared/layout.tsx";22import { AppLink } from "../src/features/shared/link.tsx";23import { RouteError } from "../src/features/shared/pending.tsx";24import { AppShell } from "../src/features/shared/shell/app-shell.tsx";25import { RailSlot } from "../src/features/shared/shell/rail-slot.tsx";26import { Workspace } from "../src/features/shared/shell/workspace.tsx";
259 unmodified lines
286 })287 );288});289290describe("the shell's controls", () => {291 // A colour given to a kit button must not cost it the UI size: the292 // class merger reads an unknown `text-*` as a colour, so a colour class293 // drops `text-ui` and the button falls back to the body's 16 px.294 it.effect("set every button in the rail at the UI size", () =>295 Effect.gen(function* () {296 const rail = elementOf(297 yield* renderAt("/datekit/tree/main", ledgerPage(false), {298 rail: Tree,299 }),300 "nav",301 'aria-label="Site"'302 );303304 const buttons = [305 ...rail.matchAll(/<button\b[^>]*class="(?<classes>[^"]*)"/gu),306 ].map(({ groups }) => groups?.classes?.split(" ") ?? []);307308 expect(buttons.length).toBeGreaterThanOrEqual(2);309 expect(310 buttons.filter((classes) => !classes.includes("text-ui"))311 ).toStrictEqual([]);312 })313 );314});315316describe(AppLink, () => {317 // A path is built whole, and a file's path may hold the router's own318 // marks (`routes/$project/route.tsx`, `{-$x}`): they are the file's319 // name, never a param to fill from the page being read.320 it.effect("leads to a path holding $ or braces as written", () =>321 Effect.gen(function* () {322 const markup = yield* renderAt(323 "/datekit/ledger",324 <p>325 <AppLink to="/datekit/blob/main/src/routes/$project/$.tsx">326 route327 </AppLink>328 <AppLink to="/datekit/blob/main/src/{-$x}.ts">optional</AppLink>329 </p>330 );331332 const hrefs = linksOf(markup).map(({ href }) => href);333334 expect(hrefs.map((href) => decodeURIComponent(href ?? ""))).toStrictEqual(335 [336 "/datekit/blob/main/src/routes/$project/$.tsx",337 "/datekit/blob/main/src/{-$x}.ts",338 ]339 );340 })341 );342343 it("draws the same address with no router around it", () => {344 expect(345 renderToStaticMarkup(346 <AppLink to="/datekit/blob/main/src/routes/$project/$.tsx">347 route348 </AppLink>349 )350 ).toMatch(351 /href="\/datekit\/blob\/main\/src\/routes\/(?:\$|%24)project\/(?:\$|%24)\.tsx"/u352 );353 });354});355356describe("the shell's sources", () => {357 // Keys only: the sources as text.358 const sources: Readonly<Record<string, string>> = import.meta.glob(359 "../src/features/shared/shell/*.tsx",
70 unmodified lines