From e07db5a042edb4836e3650d0c98c40abfb4f5613 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Wed, 11 Nov 2026 17:40:50 +0000 Subject: [PATCH] refactor(web): controls, toggles and segments as utilities look.ts builds each control's class list from its whole state, so no two utilities fight over a property. The contextual overrides from rows, trays, page heads and the removal panel become props. Refs #280 Co-Authored-By: Claude Opus 5.5 (1M context) --- web/scripts/check-tokens.mjs | 3 +- web/src/App.tsx | 8 +- web/src/components.css | 355 +---------------------------------- web/src/detail.tsx | 13 +- web/src/icons.tsx | 18 +- web/src/look.ts | 145 ++++++++++++++ web/src/style.css | 5 + web/src/subs-panel.tsx | 9 +- web/src/ui.tsx | 81 +++++--- web/src/views/Library.tsx | 7 +- web/src/views/Movie.tsx | 8 +- web/src/views/Search.tsx | 10 +- web/src/views/Series.tsx | 12 +- web/src/views/Settings.tsx | 6 +- web/src/views/TvDeck.tsx | 5 +- 15 files changed, 277 insertions(+), 408 deletions(-) create mode 100644 web/src/look.ts diff --git a/web/scripts/check-tokens.mjs b/web/scripts/check-tokens.mjs index 63e184a..1ebd785 100644 --- a/web/scripts/check-tokens.mjs +++ b/web/scripts/check-tokens.mjs @@ -40,7 +40,8 @@ function walk(dir, out = []) { } const COLOR_LITERAL = /#[0-9a-fA-F]{3,8}\b|\b(?:oklch|oklab|lab|lch|rgba?|hsla?|hwb|color)\(/; -const RELATIVE_FROM_TOKEN = /\b(?:oklch|oklab|lab|lch|rgb|hsl|hwb|color)\(\s*from\s+var\(--/g; +// `_` is a space inside a Tailwind arbitrary value +const RELATIVE_FROM_TOKEN = /\b(?:oklch|oklab|lab|lch|rgb|hsl|hwb|color)\([\s_]*from[\s_]+var\(--/g; const SPACING_PROP = /^(?:margin|padding|gap|row-gap|column-gap|inset)(?:-[a-z-]+)?$/; const SPACING_VALUE = /^(?:var\(--[\w-]+\)|0|auto|-?[\d.]+%)$/; const FONT_SIZE_VALUE = /^var\(--text-[\w-]+\)$/; diff --git a/web/src/App.tsx b/web/src/App.tsx index 345e93c..59c798b 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -16,6 +16,7 @@ import { LAYER, LiveContext, type Nav, NavContext, type TvDeckRequest, useEscape import { type Download, fetchDownloads } from "./downloads"; import { type Probe, probeHealth } from "./health"; import { Icon, type IconName } from "./icons"; +import { control, cx } from "./look"; import { two } from "./parts"; import { currentRoute, @@ -586,7 +587,7 @@ export function App() { - diff --git a/web/src/icons.tsx b/web/src/icons.tsx index 4f30f82..52d5187 100644 --- a/web/src/icons.tsx +++ b/web/src/icons.tsx @@ -1,4 +1,5 @@ import { useEffect, useRef, useState } from "react"; +import { control, microControl } from "./look"; // The shared icon-only control block (#230), consumed by the title pages, // decks and readouts, the settings rows (#231) and the subtitle chips and @@ -64,9 +65,14 @@ const ICON_PATHS = { export type IconName = keyof typeof ICON_PATHS; /** Stroke glyph on the shared 16-grid; the control's aria-label carries the meaning. */ -export function Icon({ name }: { name: IconName }) { +export function Icon({ name, className }: { name: IconName; className?: string }) { return ( -
+
{languages.map((language) => (
@@ -859,7 +860,7 @@ export function useSubtitleSection( ); } @@ -76,13 +90,20 @@ export function Control({ export function IconControl({ glyph, label, + look, + shape = "icon", className, ...rest -}: ComponentProps<"button"> & { glyph: IconName; label: string }) { +}: ComponentProps<"button"> & { + glyph: IconName; + label: string; + look?: ControlLook["look"]; + shape?: "icon" | "chip"; +}) { return ( @@ -159,14 +183,18 @@ export function Disclosure({ return ( ); } @@ -188,6 +216,9 @@ export function ArmedDeleteWord({ text={armed ? `tap again to ${label}` : label} glyph={armed ? "check" : "trash"} quiet + fill + danger + state={armed ? "armed" : null} data-kind="delete" data-armed={armed ? "true" : undefined} disabled={spent} @@ -355,6 +386,8 @@ export interface ActionSlot { wide?: boolean; /** Shown below 40rem only — an empty cell that keeps a phone column aligned. */ narrow?: boolean; + /** A word or toggle control fills its column; an input keeps its own width. */ + fill?: boolean; } export interface RowProps { @@ -447,7 +480,8 @@ export function Row(props: RowProps) { // the column is positional: a slot is its index // biome-ignore lint/suspicious/noArrayIndexKey: see above key={index} - className="r-slot" + // a word or a toggle fills its column, so every row's plates line up + className={cx("r-slot", slot.width !== "icon" && slot.fill !== false && "*:w-full")} data-width={slot.width} data-wide={flag(slot.wide)} data-narrow={flag(slot.narrow)} @@ -695,7 +729,8 @@ export function GroupNote({ short, more }: { short: string; more?: string }) { label="more about this list" aria-expanded={open} onClick={() => setOpen(!open)} - className="size-chip-h min-w-chip-h min-h-chip-h border-transparent bg-none bg-transparent [box-shadow:none] text-ink-faint aria-expanded:border-accent aria-expanded:text-accent-bright" + look="faint" + shape="chip" />
+
@@ -444,6 +445,7 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases setMoreOpen(!moreOpen)} @@ -477,12 +479,14 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
toggle("wanted", "wanted")} /> diff --git a/web/src/views/Series.tsx b/web/src/views/Series.tsx index 16b7e13..5855fa0 100644 --- a/web/src/views/Series.tsx +++ b/web/src/views/Series.tsx @@ -6,6 +6,7 @@ import { LAYER, type TvDeckRequest, useEscape, useNav } from "../context"; import { Hero, ProviderLink, RemovePanel, type RemoveSubject, TrailerLink } from "../detail"; import { ArmedDeleteIcon } from "../icons"; import { seriesStatusChipRedundant } from "../library"; +import { control } from "../look"; import { rottenTomatoesSearch, tmdbSeriesLink, tvdbLink, youtubeLink } from "../movie"; import { audienceOf, @@ -93,15 +94,18 @@ function WritingToggle({ pressed, write, focusId, + fill, }: { label: string; pressed: boolean; write: () => Promise; focusId?: string; + fill?: boolean; }) { const [busy, setBusy] = useState(false); return ( - + {hasFiles && } } @@ -430,7 +435,7 @@ function EpisodeRow({ onDisk ? ( ) : ( - + ) ) : undefined } @@ -733,6 +738,7 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b setMoreOpen(!moreOpen)} @@ -789,7 +795,7 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b