refactor(web): move the stylesheet into Tailwind utilities (#281)
ci / web (push) Successful in 33s
e2e / e2e (push) Successful in 1m36s
ci / rust (push) Successful in 1m49s
ci / image (push) Successful in 2m36s

This commit was merged in pull request #281.
This commit is contained in:
2026-11-11 21:14:23 +00:00
parent 5528ac8aa8
commit 5a18facc4f
19 changed files with 1607 additions and 2925 deletions
+4 -2
View File
@@ -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 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_PROP = /^(?:margin|padding|gap|row-gap|column-gap|inset)(?:-[a-z-]+)?$/;
const SPACING_VALUE = /^(?:var\(--[\w-]+\)|0|auto|-?[\d.]+%)$/; const SPACING_VALUE = /^(?:var\(--[\w-]+\)|0|auto|-?[\d.]+%)$/;
const FONT_SIZE_VALUE = /^var\(--text-[\w-]+\)$/; const FONT_SIZE_VALUE = /^var\(--text-[\w-]+\)$/;
@@ -108,7 +109,8 @@ function checkCss(source, rel) {
} }
} }
const ARBITRARY = /(?:^|[\s"'`:])!?-?[a-z][\w-]*-\[([^\]\s]+)\]/g; // a value, not a variant: `data-[tone=fault]:` selects, it does not style
const ARBITRARY = /(?:^|[\s"'`:])!?-?[a-z][\w-]*-\[([^\]\s]+)\](?!:)/g;
function checkPlain(source, rel) { function checkPlain(source, rel) {
// Comments are prose, not styling — `checkCss` already ignores them, and // Comments are prose, not styling — `checkCss` already ignores them, and
+56 -26
View File
@@ -16,6 +16,7 @@ import { LAYER, LiveContext, type Nav, NavContext, type TvDeckRequest, useEscape
import { type Download, fetchDownloads } from "./downloads"; import { type Download, fetchDownloads } from "./downloads";
import { type Probe, probeHealth } from "./health"; import { type Probe, probeHealth } from "./health";
import { Icon, type IconName } from "./icons"; import { Icon, type IconName } from "./icons";
import { control, cx } from "./look";
import { two } from "./parts"; import { two } from "./parts";
import { import {
currentRoute, currentRoute,
@@ -158,6 +159,14 @@ function restoreFocus(target: HTMLElement | null) {
}); });
} }
/** A rail destination: engraved mono words, an accent rule under the current one. */
const NAV_LINK =
"inline-flex items-center gap-2 min-h-control-h py-0 px-3 font-readout text-xs font-semibold uppercase tracking-label text-ink-muted no-underline border-b-2 border-b-transparent hover:text-accent-bright aria-[current=page]:text-accent aria-[current=page]:border-b-accent";
/** A tab bar destination: glyph over word, a short accent rule on top of the current one. */
const TAB =
"relative grid place-items-center content-center gap-1 text-2xs font-semibold uppercase tracking-wide text-ink-faint no-underline aria-[current=page]:text-accent aria-[current=page]:before:absolute aria-[current=page]:before:top-0 aria-[current=page]:before:inset-x-3/10 aria-[current=page]:before:h-rule aria-[current=page]:before:bg-accent";
function TabGlyph({ name }: { name: IconName }) { function TabGlyph({ name }: { name: IconName }) {
return ( return (
<span aria-hidden="true"> <span aria-hidden="true">
@@ -466,14 +475,18 @@ export function App() {
return ( return (
<LiveContext.Provider value={live}> <LiveContext.Provider value={live}>
<NavContext.Provider value={nav}> <NavContext.Provider value={nav}>
<header className="rail" data-searching={flag(railSearching)}> <header
<div className="rail-inner"> className="group/rail sticky top-0 z-20 pt-(--safe-top) border-b border-b-line bg-panel [box-shadow:inset_0_1px_var(--highlight)]"
<div className="rail-id"> data-searching={flag(railSearching)}
>
<div className="flex items-center gap-3 w-full max-w-deck h-rail-h mx-auto px-gutter">
{/* phone search mode: the field takes the rail, the identity steps aside */}
<div className="flex flex-none items-center gap-3 mr-auto group-data-searching/rail:hidden sm:mr-0 sm:group-data-searching/rail:flex">
<span className="lamp" data-state={masterState} aria-hidden="true" /> <span className="lamp" data-state={masterState} aria-hidden="true" />
{/* §9.7: the wordmark is a link home — intercepted so it navigates {/* §9.7: the wordmark is a link home — intercepted so it navigates
the SPA instead of reloading, but still a real anchor */} the SPA instead of reloading, but still a real anchor */}
<a <a
className="wordmark" className="font-display text-xl font-bold tracking-wide leading-none text-ink no-underline hover:text-accent-bright focus-visible:text-accent-bright"
href="/" href="/"
id="wordmark" id="wordmark"
ref={wordmark} ref={wordmark}
@@ -485,11 +498,11 @@ export function App() {
arr arr
</a> </a>
</div> </div>
<nav className="rail-nav" aria-label="destinations"> <nav className="hidden sm:flex sm:items-center sm:gap-1" aria-label="destinations">
<NavLink <NavLink
destination="library" destination="library"
current={destination} current={destination}
className="nav-link" className={NAV_LINK}
href="/" href="/"
onGo={go} onGo={go}
> >
@@ -498,13 +511,13 @@ export function App() {
<NavLink <NavLink
destination="queues" destination="queues"
current={destination} current={destination}
className="nav-link" className={NAV_LINK}
href="/queues" href="/queues"
onGo={go} onGo={go}
> >
queues queues
<span <span
className="nav-count readout" className="readout text-xs text-signal-warn"
data-role="queues-count" data-role="queues-count"
hidden={badge === null} hidden={badge === null}
> >
@@ -514,21 +527,24 @@ export function App() {
<NavLink <NavLink
destination="settings" destination="settings"
current={destination} current={destination}
className="nav-link" className={NAV_LINK}
href="/settings" href="/settings"
onGo={go} onGo={go}
> >
settings settings
</NavLink> </NavLink>
</nav> </nav>
<div className="rail-search"> <div className="relative hidden flex-1 items-center min-w-0 group-data-searching/rail:flex sm:flex sm:max-w-search sm:ml-auto">
<span className="rail-search-glyph" aria-hidden="true"> <span
className="absolute left-3 text-ink-faint pointer-events-none"
aria-hidden="true"
>
<Icon name="search" /> <Icon name="search" />
</span> </span>
<input <input
ref={inputRef} ref={inputRef}
id="search" id="search"
className="search-input readout" className="readout w-full min-h-control-h py-0 px-8 text-base text-ink bg-ground border border-line rounded-panel [box-shadow:inset_0_1px_var(--lowlight)] caret-accent [transition:border-color_150ms_var(--ease-out)] placeholder:text-ink-faint placeholder:opacity-100 hover:border-line-strong focus:border-accent focus:outline-none sm:text-sm"
type="text" type="text"
spellCheck={false} spellCheck={false}
autoComplete="off" autoComplete="off"
@@ -562,12 +578,16 @@ export function App() {
} }
}} }}
/> />
<span className="search-hint readout" aria-hidden="true" hidden={inputFocused}> <span
className="readout absolute right-3 hidden py-0 px-1 text-2xs text-ink-faint border border-line rounded-panel pointer-events-none lg:inline"
aria-hidden="true"
hidden={inputFocused}
>
/ /
</span> </span>
<button <button
type="button" type="button"
className="control control-icon rail-search-close" className={cx(control({ shape: "icon" }), "flex-none ml-2 sm:hidden")}
aria-label="close search" aria-label="close search"
onClick={() => { onClick={() => {
setSearching(false); setSearching(false);
@@ -579,55 +599,65 @@ export function App() {
</div> </div>
<button <button
type="button" type="button"
className="control control-icon rail-search-open" className={cx(
control({ shape: "icon" }),
"group-data-searching/rail:hidden sm:hidden",
)}
aria-label="search" aria-label="search"
onClick={openSearch} onClick={openSearch}
> >
<Icon name="search" /> <Icon name="search" />
</button> </button>
<span className="readout dim rail-version" data-testid="version"> <span className="readout dim hidden text-xs lg:inline" data-testid="version">
{version} {version}
</span> </span>
</div> </div>
</header> </header>
<nav className="tabbar" aria-label="destinations"> <nav
<NavLink destination="library" current={destination} className="tab" href="/" onGo={go}> className="fixed inset-x-0 bottom-0 z-20 grid grid-cols-4 h-(--tabbar-space) pb-(--safe-bottom) bg-panel border-t border-t-line sm:hidden"
aria-label="destinations"
>
<NavLink destination="library" current={destination} className={TAB} href="/" onGo={go}>
<TabGlyph name="library" /> <TabGlyph name="library" />
<span className="tab-label">library</span> <span>library</span>
</NavLink> </NavLink>
<NavLink <NavLink
destination="search" destination="search"
current={destination} current={destination}
className="tab" className={TAB}
href="/search" href="/search"
onGo={go} onGo={go}
> >
<TabGlyph name="search" /> <TabGlyph name="search" />
<span className="tab-label">search</span> <span>search</span>
</NavLink> </NavLink>
<NavLink <NavLink
destination="queues" destination="queues"
current={destination} current={destination}
className="tab" className={TAB}
href="/queues" href="/queues"
onGo={go} onGo={go}
> >
<TabGlyph name="warning" /> <TabGlyph name="warning" />
<span className="tab-label">queues</span> <span>queues</span>
<span className="tab-badge readout" data-role="queues-count" hidden={badge === null}> <span
className="readout absolute top-1 left-11/20 min-w-badge h-badge py-0 px-1 rounded-pill text-2xs font-bold leading-(--spacing-badge) text-center text-ground bg-signal-warn"
data-role="queues-count"
hidden={badge === null}
>
{badge ?? ""} {badge ?? ""}
</span> </span>
</NavLink> </NavLink>
<NavLink <NavLink
destination="settings" destination="settings"
current={destination} current={destination}
className="tab" className={TAB}
href="/settings" href="/settings"
onGo={go} onGo={go}
> >
<TabGlyph name="cog" /> <TabGlyph name="cog" />
<span className="tab-label">settings</span> <span>settings</span>
</NavLink> </NavLink>
</nav> </nav>
+64 -36
View File
@@ -2,6 +2,7 @@
// and rejected collapsed to counts. Shared by the movie page and the tv deck. // and rejected collapsed to counts. Shared by the movie page and the tv deck.
import { Fragment, type ReactNode, useEffect, useRef, useState } from "react"; import { Fragment, type ReactNode, useEffect, useRef, useState } from "react";
import { CELLS, cx, ROW_RULE, score } from "./look";
import { import {
blacklistAdvice, blacklistAdvice,
blacklistClass, blacklistClass,
@@ -19,7 +20,18 @@ import {
ruleLabel, ruleLabel,
type WaiveOutcome, type WaiveOutcome,
} from "./releases"; } from "./releases";
import { Chip, Control, DeckHead, Disclosure, EmptyRow, Row, SkeletonRows, useNote } from "./ui"; import {
Chip,
Control,
DeckHead,
Disclosure,
EmptyRow,
Row,
Rows,
Section,
SkeletonRows,
useNote,
} from "./ui";
export type Bucket = "eligible" | "waived" | "rejected"; export type Bucket = "eligible" | "waived" | "rejected";
@@ -93,7 +105,7 @@ function Paged<T>({
<Fragment key={keyOf(item)}>{render(item)}</Fragment> <Fragment key={keyOf(item)}>{render(item)}</Fragment>
))} ))}
{rest > 0 && ( {rest > 0 && (
<li className="bucket-more"> <li className="pt-3">
<Control <Control
text={`show ${rest} more`} text={`show ${rest} more`}
quiet quiet
@@ -106,18 +118,26 @@ function Paged<T>({
); );
} }
const COLHEAD_LABEL = "font-readout text-2xs uppercase tracking-title text-ink-faint";
/** The column header the release cells line up under, from 46rem. */ /** The column header the release cells line up under, from 46rem. */
function Colhead() { function Colhead() {
return ( return (
<div className="colhead" aria-hidden="true"> <div
<span className="colhead-score">score</span> className={cx(
<span className="colhead-cells"> "hidden @cells:grid [grid-template-columns:var(--control-h)_minmax(0,1fr)_var(--word-w)] gap-x-3 pt-2 pb-1",
<span>res</span> ROW_RULE,
<span>source</span> )}
<span className="num">size</span> aria-hidden="true"
<span>hdr</span> >
<span>audio</span> <span className={COLHEAD_LABEL}>score</span>
<span className="num">seed</span> <span className={cx("col-start-2 grid", CELLS)}>
<span className={COLHEAD_LABEL}>res</span>
<span className={COLHEAD_LABEL}>source</span>
<span className={cx(COLHEAD_LABEL, "text-right")}>size</span>
<span className={COLHEAD_LABEL}>hdr</span>
<span className={COLHEAD_LABEL}>audio</span>
<span className={cx(COLHEAD_LABEL, "text-right")}>seed</span>
</span> </span>
</div> </div>
); );
@@ -138,13 +158,13 @@ function CollapsedBucket({
}) { }) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
return ( return (
<section className="deck-group" hidden={releases.length === 0}> <Section hidden={releases.length === 0}>
<DeckHead as="h4" label={label} count={releases.length === 0 ? "" : releases.length}> <DeckHead as="h4" label={label} count={releases.length === 0 ? "" : releases.length}>
<Disclosure count={releases.length} open={open} onToggle={() => setOpen(!open)} /> <Disclosure count={releases.length} open={open} onToggle={() => setOpen(!open)} />
</DeckHead> </DeckHead>
<div hidden={!open}> <div hidden={!open}>
<Colhead /> <Colhead />
<ul className="deck-rows"> <Rows>
<Paged <Paged
items={releases} items={releases}
keyOf={(release) => release.id} keyOf={(release) => release.id}
@@ -157,9 +177,9 @@ function CollapsedBucket({
/> />
)} )}
/> />
</ul> </Rows>
</div> </div>
</section> </Section>
); );
} }
@@ -170,18 +190,18 @@ function CollapsedBucket({
export function Buckets({ state, actions }: { state: DeckState; actions: ReleaseActions }) { export function Buckets({ state, actions }: { state: DeckState; actions: ReleaseActions }) {
if (state.kind !== "releases") { if (state.kind !== "releases") {
return ( return (
<div className="buckets"> <div className="@container">
<section className="deck-group" hidden={state.kind === "none"}> <Section hidden={state.kind === "none"}>
<DeckHead as="h4" label="eligible" count="" /> <DeckHead as="h4" label="eligible" count="" />
<Colhead /> <Colhead />
<ul className="deck-rows">{state.kind === "skeleton" && <SkeletonRows count={4} />}</ul> <Rows>{state.kind === "skeleton" && <SkeletonRows count={4} />}</Rows>
</section> </Section>
<section className="deck-group" hidden> <Section hidden>
<DeckHead as="h4" label="below policy" count="" /> <DeckHead as="h4" label="below policy" count="" />
</section> </Section>
<section className="deck-group" hidden> <Section hidden>
<DeckHead as="h4" label="rejected" count="" /> <DeckHead as="h4" label="rejected" count="" />
</section> </Section>
</div> </div>
); );
} }
@@ -205,11 +225,11 @@ function PaintedBuckets({
// forcing; a row below policy is offered already. // forcing; a row below policy is offered already.
const forceable = rejected.filter(overridable).length; const forceable = rejected.filter(overridable).length;
return ( return (
<div className="buckets"> <div className="@container">
<section className="deck-group"> <Section>
<DeckHead as="h4" label="eligible" count={eligible.length} /> <DeckHead as="h4" label="eligible" count={eligible.length} />
<Colhead /> <Colhead />
<ul className="deck-rows"> <Rows>
{eligible.length === 0 ? ( {eligible.length === 0 ? (
<EmptyRow <EmptyRow
text={ text={
@@ -232,8 +252,8 @@ function PaintedBuckets({
)} )}
/> />
)} )}
</ul> </Rows>
</section> </Section>
<CollapsedBucket <CollapsedBucket
label="below policy" label="below policy"
releases={waived} releases={waived}
@@ -361,7 +381,7 @@ function ReleaseRow({
lead={ lead={
// biome-ignore lint/a11y/useAriaPropsSupportedByRole: the score's name is read with its row, not as a control // biome-ignore lint/a11y/useAriaPropsSupportedByRole: the score's name is read with its row, not as a control
<span <span
className="score" className={score(stop)}
data-score={stop === null ? undefined : String(stop)} data-score={stop === null ? undefined : String(stop)}
aria-label={`score ${formatScore(release.score)}`} aria-label={`score ${formatScore(release.score)}`}
> >
@@ -384,7 +404,7 @@ function ReleaseRow({
</> </>
} }
beforeSub={ beforeSub={
<div className="r-cells" aria-hidden="true"> <div className={cx("hidden @cells:grid", CELLS)} aria-hidden="true">
{( {(
[ [
[values.res, false], [values.res, false],
@@ -400,11 +420,11 @@ function ReleaseRow({
// biome-ignore lint/suspicious/noArrayIndexKey: see above // biome-ignore lint/suspicious/noArrayIndexKey: see above
key={index} key={index}
title={value} title={value}
className={ className={cx(
[numeric ? "num" : "", value === "—" ? "unclaimed" : ""] "truncate font-readout text-xs tabular-nums",
.filter(Boolean) numeric && "text-right",
.join(" ") || undefined value === "—" ? "text-ink-faint" : "text-ink-muted",
} )}
> >
{value} {value}
</span> </span>
@@ -415,7 +435,15 @@ function ReleaseRow({
subExpands subExpands
afterSub={ afterSub={
blacklisted && ( blacklisted && (
<span className="r-why readout" data-blacklist={blacklisted}> <span
className={cx(
"readout text-xs",
blacklisted === "release"
? "[color:oklch(from_var(--signal-fault)_0.78_0.1_h)]"
: "text-ink-muted",
)}
data-blacklist={blacklisted}
>
{blacklistAdvice(release.blacklist_reason)} {blacklistAdvice(release.blacklist_reason)}
</span> </span>
) )
+7 -2336
View File
File diff suppressed because it is too large Load Diff
+42 -23
View File
@@ -3,6 +3,11 @@
import { type CSSProperties, type ReactNode, useEffect, useRef, useState } from "react"; import { type CSSProperties, type ReactNode, useEffect, useRef, useState } from "react";
import { Icon, ProviderMark, Star } from "./icons"; import { Icon, ProviderMark, Star } from "./icons";
import { control, NOTE, detail as page, type } from "./look";
/** each line keeps its height while empty, so the hero never grows in steps */
const HERO_LINE = "readout flex items-center gap-1 min-h-line m-0 text-xs";
import { formatMetaLine, formatRating, formatVoteCount, tmdbImage } from "./movie"; import { formatMetaLine, formatRating, formatVoteCount, tmdbImage } from "./movie";
import { type ActionOutcome, formatSize, totalSize } from "./releases"; import { type ActionOutcome, formatSize, totalSize } from "./releases";
import { cx, flag, IconControl, IconLink, type Note, NoteLine } from "./ui"; import { cx, flag, IconControl, IconLink, type Note, NoteLine } from "./ui";
@@ -61,18 +66,19 @@ export function Hero({
: ({ "--backdrop": `url("${backdropUrl}")` } as CSSProperties) : ({ "--backdrop": `url("${backdropUrl}")` } as CSSProperties)
} }
aria-label="title metadata" aria-label="title metadata"
data-bleed=""
> >
<header className="page-head"> <header className={page.pageHead}>
<IconControl glyph="back" label="back" onClick={onBack} /> <IconControl glyph="back" label="back" look="bare" onClick={onBack} />
<h2 className="page-title" tabIndex={-1} ref={heading}> <h2 className={cx(type.pageTitle, "flex-initial")} tabIndex={-1} ref={heading}>
{title === "" ? " " : title} {title === "" ? " " : title}
</h2> </h2>
<span className="page-year readout">{year === null ? "" : year}</span> <span className={page.pageMeta}>{year === null ? "" : year}</span>
</header> </header>
<div className="hero-body"> <div className="grid [grid-template-columns:6rem_minmax(0,1fr)] gap-4 [align-items:start] @row:[grid-template-columns:9rem_minmax(0,1fr)] @row:gap-6 @wide:[grid-template-columns:10.5rem_minmax(0,1fr)]">
<div className="hero-poster"> <div className="aspect-2/3 bg-panel-raised border border-line-strong rounded-panel overflow-hidden">
<img <img
className="movie-poster" className="block w-full h-full object-cover opacity-0 [transition:opacity_300ms_var(--ease-out)] data-loaded:opacity-100"
alt={posterUrl === null || posterBroken ? "" : `${title} poster`} alt={posterUrl === null || posterBroken ? "" : `${title} poster`}
src={posterUrl === null || posterBroken ? undefined : posterUrl} src={posterUrl === null || posterBroken ? undefined : posterUrl}
data-loaded={flag(posterLoaded && !posterBroken)} data-loaded={flag(posterLoaded && !posterBroken)}
@@ -80,9 +86,9 @@ export function Hero({
onError={() => setPosterBroken(true)} onError={() => setPosterBroken(true)}
/> />
</div> </div>
<div className="hero-info"> <div className="grid gap-2 content-start min-w-0">
<span className="hero-chips">{chips}</span> <span className="flex flex-wrap gap-1 min-h-chip-h">{chips}</span>
<p className="hero-rating readout"> <p className={cx(HERO_LINE, "text-ink")}>
{detail !== null && detail.vote_average !== null && ( {detail !== null && detail.vote_average !== null && (
<> <>
<Star /> <Star />
@@ -91,15 +97,15 @@ export function Hero({
</> </>
)} )}
</p> </p>
<p className="hero-meta readout"> <p className={cx(HERO_LINE, "text-ink-muted")}>
{detail === null ? "" : formatMetaLine(detail.runtime, detail.genres)} {detail === null ? "" : formatMetaLine(detail.runtime, detail.genres)}
</p> </p>
<p className="hero-tagline"> <p className="hidden @row:block m-0 font-display text-md font-semibold text-ink-muted">
{tagline !== null && tagline !== undefined && tagline !== "" ? `“${tagline}”` : ""} {tagline !== null && tagline !== undefined && tagline !== "" ? `“${tagline}”` : ""}
</p> </p>
{/* biome-ignore lint/a11y/useKeyWithClickEvents: a reading aid; the full text is in the DOM either way */} {/* biome-ignore lint/a11y/useKeyWithClickEvents: a reading aid; the full text is in the DOM either way */}
<p <p
className="hero-overview" className="line-clamp-3 min-h-overview max-w-measure m-0 text-sm text-ink cursor-pointer data-full:[-webkit-line-clamp:unset]"
data-full={flag(overviewFull)} data-full={flag(overviewFull)}
onClick={() => setOverviewFull(!overviewFull)} onClick={() => setOverviewFull(!overviewFull)}
> >
@@ -107,7 +113,7 @@ export function Hero({
</p> </p>
</div> </div>
</div> </div>
<NoteLine note={note} className="r-note hero-note readout" /> <NoteLine note={note} className={cx(NOTE, "mt-2")} />
</section> </section>
); );
} }
@@ -115,9 +121,9 @@ export function Hero({
/** The trailer: the play glyph, and the word wherever there is room for it. */ /** The trailer: the play glyph, and the word wherever there is room for it. */
export function TrailerLink({ href, title }: { href: string; title: string }) { export function TrailerLink({ href, title }: { href: string; title: string }) {
return ( return (
<IconLink className="trailer-link" label={`watch the ${title} trailer`} href={href}> <IconLink shape="trailer" label={`watch the ${title} trailer`} href={href}>
<Icon name="play" /> <Icon name="play" />
<span className="control-word">trailer</span> <span className="hidden @row:inline">trailer</span>
</IconLink> </IconLink>
); );
} }
@@ -244,29 +250,42 @@ export function RemovePanel({
return ( return (
// biome-ignore lint/a11y/useSemanticElements: a fieldset brings its own border, padding and min-width, which this group does not want // biome-ignore lint/a11y/useSemanticElements: a fieldset brings its own border, padding and min-width, which this group does not want
<div <div
className="remove-body" className={cx(
"grid gap-2 p-3 bg-panel-raised border rounded-panel",
hasFiles ? "[border-color:oklch(from_var(--signal-warn)_l_c_h/55%)]" : "border-line",
)}
role="group" role="group"
aria-label={`remove ${subject.title}`} aria-label={`remove ${subject.title}`}
data-armed={String(hasFiles)} data-armed={String(hasFiles)}
> >
<p className="remove-evidence readout dim">{evidence}</p> <p className="readout dim m-0 text-xs">{evidence}</p>
<p className="remove-path readout" hidden={path === null}> <p
className="readout m-0 text-xs text-ink-muted [overflow-wrap:anywhere] whitespace-pre-line"
hidden={path === null}
>
{path ?? ""} {path ?? ""}
</p> </p>
<p className="remove-note readout" id="remove-note" role="status" data-tone={note.tone}> <p
className="readout m-0 text-xs text-ink-muted data-[tone=warn]:text-signal-warn data-[tone=fault]:text-signal-fault"
id="remove-note"
role="status"
data-tone={note.tone}
>
{note.text} {note.text}
</p> </p>
<div className="remove-actions"> <div className="flex flex-wrap gap-2">
{/* armed: the confirm turns caution amber with the rest of the panel */}
<button <button
type="button" type="button"
className="control" className={control({ state: hasFiles ? "warn" : null })}
data-tone={hasFiles ? "warn" : undefined}
aria-describedby="remove-note" aria-describedby="remove-note"
disabled={busy} disabled={busy}
onClick={confirm} onClick={confirm}
> >
remove and delete files remove and delete files
</button> </button>
<button type="button" className="control" ref={keep} disabled={busy} onClick={onCancel}> <button type="button" className={control()} ref={keep} disabled={busy} onClick={onCancel}>
keep keep
</button> </button>
</div> </div>
+18 -5
View File
@@ -1,4 +1,5 @@
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { control, microControl } from "./look";
// The shared icon-only control block (#230), consumed by the title pages, // The shared icon-only control block (#230), consumed by the title pages,
// decks and readouts, the settings rows (#231) and the subtitle chips and // 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; export type IconName = keyof typeof ICON_PATHS;
/** Stroke glyph on the shared 16-grid; the control's aria-label carries the meaning. */ /** 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 ( return (
<svg viewBox="0 0 16 16" className="icon" aria-hidden="true" data-icon={name}> <svg
viewBox="0 0 16 16"
className={className === undefined ? "icon" : `icon ${className}`}
aria-hidden="true"
data-icon={name}
>
{ICON_PATHS[name].map((d) => ( {ICON_PATHS[name].map((d) => (
<path key={d} d={d} /> <path key={d} d={d} />
))} ))}
@@ -99,7 +105,7 @@ export function ProviderMark({ name }: { name: "tmdb" | "tvdb" | "imdb" | "rt" }
/** The drawn star before a TMDB rating — no glyph standing in for an icon. */ /** The drawn star before a TMDB rating — no glyph standing in for an icon. */
export function Star() { export function Star() {
return ( return (
<svg viewBox="0 0 12 12" className="star" aria-hidden="true"> <svg viewBox="0 0 12 12" className="size-lamp flex-none fill-ink" aria-hidden="true">
<path d="M6 0.8 L7.5 4.2 L11.2 4.6 L8.4 7.1 L9.2 10.8 L6 8.9 L2.8 10.8 L3.6 7.1 L0.8 4.6 L4.5 4.2 Z" /> <path d="M6 0.8 L7.5 4.2 L11.2 4.6 L8.4 7.1 L9.2 10.8 L6 8.9 L2.8 10.8 L3.6 7.1 L0.8 4.6 L4.5 4.2 Z" />
</svg> </svg>
); );
@@ -186,7 +192,11 @@ export function ArmedDeleteIcon({
return ( return (
<button <button
type="button" type="button"
className={compact ? "control-micro" : "control control-icon"} className={
compact
? microControl(armed)
: control({ shape: "icon", danger: true, state: armed ? "armed" : null })
}
data-kind="delete" data-kind="delete"
data-armed={armed ? "true" : undefined} data-armed={armed ? "true" : undefined}
aria-label={armed ? `confirm — ${label}` : label} aria-label={armed ? `confirm — ${label}` : label}
@@ -202,7 +212,10 @@ export function ArmedDeleteIcon({
} }
}} }}
> >
<Icon name={armed ? "check" : "trash"} /> <Icon
name={armed ? "check" : "trash"}
className={compact ? "size-3 [stroke-width:1.7]" : undefined}
/>
</button> </button>
); );
} }
+372
View File
@@ -0,0 +1,372 @@
// The control vocabulary as Tailwind class lists. Each builder takes the
// control's whole state and returns one list with no two classes fighting
// over a property: Tailwind orders its output by variant, not by the order
// classes are written, so a conflict here would be settled by accident.
export function cx(...names: (string | false | null | undefined)[]): string {
return names.filter(Boolean).join(" ");
}
const TRANSITION =
"[transition:border-color_150ms_var(--ease-out),color_150ms_var(--ease-out),background_150ms_var(--ease-out)]";
export interface ControlLook {
/**
* primary: cyan word on a raised plate, one per header or panel.
* quiet: secondary actions — cancel, add, back, retry. Never a toggle.
* bare: no plate, for a page head's back control.
* lead: a row's leading disclosure, muted.
* faint: a chip-sized info glyph beside a group's note.
*/
look?: "primary" | "quiet" | "bare" | "lead" | "faint";
/**
* word: a label. fixed: a label that changes but keeps one width.
* icon: a square glyph. trailer: a glyph that grows its word from 40rem.
* disclose: show / hide, chevron at the far end. chip: a glyph at chip height.
*/
shape?: "word" | "fixed" | "icon" | "trailer" | "disclose" | "chip";
/** Full width with the content at the start: a phone tray or a settings panel. */
fill?: boolean;
/** Destructive: rests red so delete never reads like the glyph beside it. */
danger?: boolean;
/**
* armed: the next tap fires — amber, whatever else it was (`data-armed`).
* warn: the confirm of a removal that deletes files (`data-tone="warn"`).
* busy, done and failed need no look: `data-busy` and friends carry them.
*/
state?: "armed" | "warn" | null;
}
const SHAPE = {
word: "min-h-control-h py-0 px-4",
fixed: "min-h-control-h py-0 px-4 min-w-word-w",
icon: "min-h-control-h w-control-h min-w-control-h p-0",
trailer: "min-h-control-h w-control-h min-w-control-h p-0 @row:w-auto @row:px-4",
disclose: "min-h-control-h py-0 px-4 min-w-disclose",
chip: "min-h-chip-h size-chip-h min-w-chip-h p-0",
} as const;
const LOOK = {
primary:
"text-accent bg-panel-raised border-line-strong [box-shadow:inset_0_1px_var(--highlight)]",
quiet: "text-ink bg-transparent border-line [box-shadow:none]",
bare: "text-accent bg-transparent border-transparent [box-shadow:none] flex-none",
lead: "text-ink-muted bg-transparent border-line [box-shadow:none]",
faint: "text-ink-faint bg-transparent border-transparent [box-shadow:none]",
} as const;
/** The class list for a control in one state. */
export function control({
look = "primary",
shape = "word",
fill = false,
danger = false,
state = null,
}: ControlLook = {}): string {
let tone: string;
if (state === "armed") {
tone =
"data-[armed=true]:not-disabled:text-ground data-[armed=true]:not-disabled:bg-signal-warn data-[armed=true]:not-disabled:border-signal-warn" +
// armed from the keyboard, the delete's red focus still shows on the amber
" data-[armed=true]:not-disabled:focus-visible:not-hover:text-signal-fault data-[armed=true]:not-disabled:focus-visible:not-hover:border-signal-fault";
} else if (state === "warn") {
tone =
"data-[tone=warn]:not-disabled:text-signal-warn data-[tone=warn]:not-disabled:[border-color:oklch(from_var(--signal-warn)_l_c_h/55%)]";
} else if (danger) {
tone =
"data-[kind=delete]:not-disabled:text-signal-fault data-[kind=delete]:not-disabled:hover:border-signal-fault data-[kind=delete]:not-disabled:focus-visible:border-signal-fault";
} else {
tone = cx(
"not-disabled:hover:border-accent not-disabled:hover:text-accent-bright",
// a row's lead disclosure keeps its muted plate open or closed
look !== "lead" && "aria-expanded:border-accent aria-expanded:text-accent-bright",
);
}
return cx(
"inline-flex items-center gap-2 font-readout text-xs font-semibold tabular-nums leading-none uppercase tracking-label whitespace-nowrap no-underline border rounded-panel",
fill ? "w-full justify-start" : shape === "disclose" ? "justify-between" : "justify-center",
SHAPE[shape],
LOOK[look],
TRANSITION,
"cursor-pointer disabled:text-ink-faint disabled:border-line disabled:cursor-default",
"not-disabled:active:[box-shadow:inset_0_1px_var(--lowlight)]",
// a request's outcome, read off the control's own data attributes
"data-busy:border-dashed data-busy:text-ink-faint data-busy:cursor-progress",
"data-done:text-signal-ok data-done:[border-color:oklch(from_var(--signal-ok)_l_c_h/55%)]",
"data-failed:not-hover:text-signal-fault data-failed:not-hover:[border-color:oklch(from_var(--signal-fault)_l_c_h/55%)]",
tone,
);
}
/** The chip-scale delete (#251): no plate, the armed glyph does the word's job. */
export function microControl(armed: boolean): string {
return cx(
"inline-flex items-center justify-center size-4 p-0 ms-1 [border:0] rounded-micro cursor-pointer disabled:opacity-50",
armed
? "text-ground bg-signal-warn"
: "text-ink-faint bg-transparent not-disabled:hover:text-signal-fault not-disabled:hover:[background:oklch(from_var(--signal-fault)_l_c_h/15%)] focus-visible:text-signal-fault focus-visible:[background:oklch(from_var(--signal-fault)_l_c_h/15%)]",
);
}
/** A rule that is on or off; `fill` stretches it across a tray. */
export function toggle(pressed: boolean, fill = false): string {
return cx(
"inline-flex items-center gap-2 min-h-control-h py-0 px-3 font-readout text-xs font-semibold leading-none uppercase tracking-label whitespace-nowrap bg-transparent border rounded-panel cursor-pointer [transition:border-color_150ms_var(--ease-out),color_150ms_var(--ease-out)] not-disabled:hover:border-accent disabled:cursor-progress disabled:opacity-60",
pressed ? "text-ink border-line-strong" : "text-ink-muted border-line",
fill && "w-full justify-start",
);
}
export function toggleLamp(pressed: boolean): string {
return cx(
"w-2 h-2 flex-none rounded-round [transition:background_300ms_var(--ease-out),box-shadow_300ms_var(--ease-out)]",
pressed ? "bg-accent [box-shadow:0_0_6px_oklch(from_var(--accent)_l_c_h/60%)]" : "bg-lamp-off",
);
}
export function toggleState(pressed: boolean): string {
return cx("min-w-state ml-auto text-left", pressed ? "text-accent" : "text-ink-faint");
}
/** One choice of a few, the engaged side lit; `wrap` lets a long set break lines. */
export function segmented(wrap = false): string {
return wrap
? "flex flex-wrap flex-none gap-1 min-w-0 m-0 p-0 [border:0]"
: "inline-flex flex-none min-w-0 m-0 p-0 [border:0]";
}
export function seg(pressed: boolean, icon = false): string {
return cx(
"inline-flex items-center justify-center gap-2 min-h-control-h font-readout text-xs font-semibold uppercase tracking-label border border-line cursor-pointer [transition:border-color_150ms_var(--ease-out),color_150ms_var(--ease-out)] first:rounded-l-panel last:rounded-r-panel not-first:border-l-0 hover:text-accent-bright",
icon ? "w-control-h p-0" : "py-0 px-3",
// the lit edge is drawn inside, so the joined borders never double
pressed
? "text-accent-bright bg-panel-raised [box-shadow:inset_0_0_0_1px_var(--accent)]"
: "text-ink-muted bg-transparent",
);
}
/* ---- type roles ---------------------------------------------------------- */
/** One role per job: page title, section title, group label, count. */
export const type = {
pageTitle:
"page-title m-0 min-w-0 font-display text-lg @row:text-xl font-bold tracking-title leading-tight overflow-hidden whitespace-nowrap text-ellipsis",
sectionTitle:
"m-0 font-display text-md font-semibold tracking-label uppercase leading-snug text-ink-muted",
/** The engraved micro-label: a group inside a section, never a kicker. */
label: "m-0 text-2xs font-semibold uppercase tracking-engraved",
count: "readout text-xs text-ink-faint",
} as const;
/* ---- chips --------------------------------------------------------------- */
/** What a chip says about itself, as the data attributes it carries. */
export interface ChipState {
verdict?: string;
blacklist?: string;
movieState?: string;
wanted?: string;
dlPhase?: string;
status?: string;
counts?: string;
flag?: string;
mt?: string;
tone?: string;
/** Hidden below 40rem: the phone's line keeps only what decides. */
secondary?: boolean;
/** Taps to explain itself, or opens a panel. */
interactive?: boolean;
/** Taps to explain itself: its edge lights while hovered or open. */
explain?: boolean;
/** The whole label is a glyph. */
glyph?: boolean;
/** A live download: fixed width, so 9% → 10% never moves a neighbour. */
download?: boolean;
/** A release attribute: from 46rem the aligned cells carry it instead. */
cell?: boolean;
}
const OK = "text-signal-ok [border-color:oklch(from_var(--signal-ok)_l_c_h/45%)]";
const AIRING = "text-status-airing [border-color:oklch(from_var(--status-airing)_l_c_h/45%)]";
const WARN = "text-signal-warn [border-color:oklch(from_var(--signal-warn)_l_c_h/55%)]";
const FAULT = "text-signal-fault [border-color:oklch(from_var(--signal-fault)_l_c_h/55%)]";
const ON_IT = "text-ink border-line-strong";
/**
* The chip's colour: the last of these that applies wins, in the order the
* board always resolved them — a verdict, then a blacklist, media state,
* download phase, library status, counts, a vanished flag, and a fault.
*/
function chipTone(state: ChipState): string {
let tone = "text-ink-muted border-line";
const verdict = {
eligible: "text-verdict-eligible [border-color:oklch(from_var(--verdict-eligible)_l_c_h/45%)]",
// the dashed border is the visible mark of a relaxed rule
waived: "text-verdict-waived [border-color:oklch(from_var(--verdict-waived)_l_c_h/55%)]",
rejected: "text-verdict-rejected border-line",
// a subtitle wanted and not yet on disk is the system's errand, not yours
wanted: ON_IT,
}[state.verdict ?? ""];
if (verdict) tone = verdict;
// #227: the policy's own floor (amber, act on it) or the release itself broken
if (state.blacklist === "policy") tone = WARN;
if (state.blacklist === "release") tone = FAULT;
// §4.2: green on disk, violet downloading; wanted-and-missing is the system's
if (state.movieState === "available") tone = OK;
if (state.movieState === "downloading") tone = AIRING;
const dl = { downloading: AIRING, stalled: WARN, errored: FAULT, seeding: OK }[
state.download ? (state.dlPhase ?? "") : ""
];
if (dl) tone = dl;
// violet while live, green once complete; incomplete and waiting are neutral
if (state.status === "airing") tone = AIRING;
if (state.status === "incomplete") tone = ON_IT;
if (state.status === "complete" || state.status === "ended" || state.counts === "complete") {
tone = OK;
}
if (state.counts === "partial") tone = "text-ink border-line";
// issue 122: gone upstream while its file remained — a conflict
if (state.flag === "vanished") tone = WARN;
if (state.tone === "fault") tone = FAULT;
if (state.movieState === "missing" && state.wanted === "true") tone = ON_IT;
return tone;
}
/** A label, not a target: shorter than a control, one line always. */
export function chip(state: ChipState = {}): string {
const dashed = state.verdict === "waived" || state.flag === "vanished" || state.mt === "true";
return cx(
"flex-none items-center gap-1 h-chip-h bg-panel-raised border rounded-chip font-readout text-2xs whitespace-nowrap",
state.secondary ? "hidden @row:inline-flex" : "inline-flex",
state.cell && "@cells:hidden",
state.glyph ? "min-w-chip-h justify-center py-0 px-1" : "py-0 px-2",
state.download && "min-w-dl justify-center",
// a chip that explains itself on tap: §9.6 tooltips have no touch
state.interactive
? // a button's font is the page's, then the chip's face and size on top
"[font-style:inherit] [font-weight:inherit] [font-stretch:inherit] [font-variant:inherit] [line-height:inherit] cursor-pointer [transition:color_150ms_var(--ease-out),border-color_150ms_var(--ease-out)]"
: "leading-none tabular-nums",
chipTone(state),
dashed && "border-dashed",
state.explain &&
!(state.movieState === "missing" && state.wanted === "true") &&
"hover:border-current aria-expanded:border-current",
);
}
/** A glyph inside a chip: smaller, and drawn a touch heavier to hold the size. */
export const CHIP_ICON = "size-3 [stroke-width:1.7]";
/* ---- the row ------------------------------------------------------------- */
/** A list line's hairline: the line colour, softened. */
export const ROW_RULE = "border-b [border-bottom-color:oklch(from_var(--line)_l_c_h/60%)]";
/** A row's status line, and every note written the same way. */
export const NOTE =
"readout m-0 text-xs text-ink-muted data-[tone=fault]:text-signal-fault data-[tone=warn]:text-signal-warn";
/** The secondary line: truncated, and the full string on a tap. */
export const SUB =
"readout min-w-0 truncate text-2xs leading-row text-ink-faint data-full:whitespace-normal data-full:[overflow-wrap:anywhere]";
/** Placeholder bars: the row's own geometry, no shimmer (Dead-Air). */
export const skel = {
lead: "block bg-panel-raised rounded-chip w-poster h-poster-h",
line: "block bg-panel-raised rounded-chip w-7/10 h-3",
short: "block bg-panel-raised rounded-chip w-2/5 h-3",
} as const;
/** The release's lead, on the list-relative heat scale (issue 111). */
const SCORE_TONE = [
"text-score-0 [border-color:oklch(from_var(--score-0)_l_c_h/50%)]",
"text-score-1 [border-color:oklch(from_var(--score-1)_l_c_h/50%)]",
"text-score-2 [border-color:oklch(from_var(--score-2)_l_c_h/50%)]",
"text-score-3 [border-color:oklch(from_var(--score-3)_l_c_h/50%)]",
"text-score-4 [border-color:oklch(from_var(--score-4)_l_c_h/50%)]",
"text-score-5 [border-color:oklch(from_var(--score-5)_l_c_h/50%)]",
"text-score-6 [border-color:oklch(from_var(--score-6)_l_c_h/50%)]",
] as const;
export function score(stop: number | null): string {
return cx(
"inline-grid place-items-center size-control-h font-readout text-sm font-bold tabular-nums border rounded-panel",
stop === null ? "text-ink-muted border-line" : SCORE_TONE[stop],
);
}
/** The §9.3 fixed columns release attributes line up in, from 46rem. */
export const CELLS = "[grid-template-columns:4rem_4.5rem_4.5rem_6rem_7rem_3.5rem] gap-4";
/* ---- panels -------------------------------------------------------------- */
/** An inline panel: the add flow, an edit form, the subtitle settings. */
export const PANEL =
"grid gap-3 p-3 bg-panel border border-line rounded-panel [box-shadow:inset_0_1px_var(--highlight)]";
/** A panel's save line: the controls, then what happened. */
export const PANEL_ACTIONS = "flex flex-wrap items-center gap-3";
/** A panel's note, green once the thing it describes is done. */
export const PANEL_NOTE =
"m-0 text-xs text-ink-muted data-[tone=fault]:text-signal-fault data-[tone=ok]:text-signal-ok";
/* ---- poster grid --------------------------------------------------------- */
export const card = {
grid: "grid [grid-template-columns:repeat(auto-fill,minmax(9rem,1fr))] gap-3 pt-3 px-0 pb-0",
card: "flex flex-col w-full h-full p-0 [font:inherit] text-left text-inherit bg-panel border border-line rounded-panel overflow-hidden cursor-pointer [transition:border-color_150ms_var(--ease-out)] hover:border-accent",
art: "block aspect-2/3 bg-panel-raised",
poster: "block w-full h-full object-cover",
/** Same ratio as a poster, carrying the title: the grid never has a hole. */
blank: "flex items-center justify-center w-full h-full p-3",
blankTitle: "font-display text-base font-semibold text-center text-ink-faint",
body: "grid gap-1 p-2",
name: "truncate text-sm font-semibold text-ink",
chips: "flex gap-1 min-h-chip-h overflow-hidden",
} as const;
/* ---- detail pages -------------------------------------------------------- */
export const detail = {
pageHead: "flex items-center gap-2 min-h-control-h mb-3",
pageMeta: "readout flex-none text-xs text-ink-muted",
/** one action bar: the primary word, the links as glyphs, the rest behind ⋯ */
actionbar: "flex items-center gap-2 min-h-control-h mb-3",
actionbarLinks: "flex flex-1 items-center gap-2 min-w-0",
morePanel:
"grid gap-3 mb-4 p-3 bg-panel border border-line rounded-panel [box-shadow:inset_0_1px_var(--highlight)] @row:grid-cols-2 @row:[align-items:end]",
moreLinks: "flex flex-wrap gap-2 empty:hidden @row:col-span-full",
moreToggles: "grid gap-2 @row:grid-cols-2 @row:col-span-full",
controlNote: "readout m-0 text-xs text-ink-muted @row:col-span-full",
} as const;
/* ---- forms --------------------------------------------------------------- */
const INPUT =
"min-h-control-h py-0 px-3 font-readout text-base sm:text-sm text-ink bg-ground border border-line rounded-panel [box-shadow:inset_0_1px_var(--lowlight)] caret-accent [transition:border-color_150ms_var(--ease-out)] hover:border-line-strong focus:border-accent focus:outline-none disabled:text-ink-faint disabled:border-line data-invalid:border-signal-fault";
export const form = {
grid: "grid [grid-template-columns:repeat(auto-fit,minmax(13rem,1fr))] gap-3 [align-items:end]",
field: "grid gap-1",
label: "text-2xs font-semibold uppercase tracking-engraved text-ink-muted",
input: `w-full ${INPUT}`,
/** An input that brings its own width and flex, such as a band's number. */
inputBare: INPUT,
/** A select draws its own chevron: appearance is gone, so the shape returns. */
select:
"appearance-none pr-8 bg-no-repeat [background-size:0.3rem_0.3rem] [background-position:calc(100%_-_1.1rem)_50%,calc(100%_-_0.8rem)_50%] [background-image:linear-gradient(45deg,transparent_50%,var(--ink-muted)_50%),linear-gradient(135deg,var(--ink-muted)_50%,transparent_50%)]",
} as const;
/* ---- the signal chain ---------------------------------------------------- */
export const chain = {
module: "min-w-0 border rounded-panel [box-shadow:inset_0_1px_var(--highlight)] pt-4 px-4 pb-3",
head: "flex items-center flex-wrap gap-y-1 gap-x-2",
name: "m-0 font-display font-bold uppercase tracking-engraved leading-none",
status:
"readout ml-auto pl-3 text-ink-muted data-[tone=ok]:text-signal-ok data-[tone=warn]:text-signal-warn data-[tone=fault]:text-signal-fault",
role: "mt-2 mx-0 mb-0 text-2xs font-semibold uppercase tracking-engraved text-ink-muted",
detail: "readout mt-1 mx-0 mb-0 min-h-detail text-xs text-ink-muted",
} as const;
+18 -10
View File
@@ -6,6 +6,12 @@ import { useLive } from "./context";
import { downloadChipDetail, downloadChipLabel, findDownload } from "./downloads"; import { downloadChipDetail, downloadChipLabel, findDownload } from "./downloads";
import { Icon, Star } from "./icons"; import { Icon, Star } from "./icons";
import { waiverLabel } from "./library"; import { waiverLabel } from "./library";
import { CHIP_ICON } from "./look";
/** A row's lead thumbnail at 2:3; a missing one keeps the same box. */
const POSTER =
"block w-poster aspect-2/3 flex-none object-cover bg-panel-raised border border-line rounded-chip";
import { formatRating, formatVoteCount, tmdbImage } from "./movie"; import { formatRating, formatVoteCount, tmdbImage } from "./movie";
import { Chip, type Say } from "./ui"; import { Chip, type Say } from "./ui";
@@ -38,7 +44,9 @@ export function TitleText({ title, year }: { title: string; year: number | null
return ( return (
<span> <span>
{title} {title}
{year !== null && <span className="yr">{year}</span>} {year !== null && (
<span className="ml-2 font-readout text-xs font-normal text-ink-faint">{year}</span>
)}
</span> </span>
); );
} }
@@ -54,7 +62,7 @@ export function MediaStateChip({ state, wanted }: { state: string; wanted: boole
// makes the word reachable once the glyph replaced it // makes the word reachable once the glyph replaced it
return ( return (
<Chip role="img" aria-label={state} data-movie-state={state} data-wanted={String(wanted)}> <Chip role="img" aria-label={state} data-movie-state={state} data-wanted={String(wanted)}>
<Icon name="check" /> <Icon name="check" className={CHIP_ICON} />
</Chip> </Chip>
); );
} }
@@ -78,13 +86,13 @@ export function WaiverChip({ waiver, say }: { waiver: unknown; say?: Say }) {
} }
return ( return (
<Chip <Chip
base="chip chip-glyph" glyph
data-verdict="waived" data-verdict="waived"
aria-label={label} aria-label={label}
role={say ? undefined : "img"} role={say ? undefined : "img"}
explain={say ? { text: `imported below policy — ${label}`, say, tone: "warn" } : undefined} explain={say ? { text: `imported below policy — ${label}`, say, tone: "warn" } : undefined}
> >
<Icon name="warning" /> <Icon name="warning" className={CHIP_ICON} />
</Chip> </Chip>
); );
} }
@@ -109,10 +117,10 @@ export function DownloadChip({
const { downloads } = useLive(); const { downloads } = useLive();
const download = findDownload(downloads, targetKind, targetId); const download = findDownload(downloads, targetKind, targetId);
return ( return (
<span className="dl-slot" data-dl-kind={targetKind} data-dl-id={targetId}> <span className="contents" data-dl-kind={targetKind} data-dl-id={targetId}>
{download !== null && ( {download !== null && (
<Chip <Chip
className="dl-chip" download
data-dl-phase={download.phase} data-dl-phase={download.phase}
aria-label={`download ${downloadChipDetail(download)}`} aria-label={`download ${downloadChipDetail(download)}`}
explain={say ? { text: `download ${downloadChipDetail(download)}`, say } : undefined} explain={say ? { text: `download ${downloadChipDetail(download)}`, say } : undefined}
@@ -148,7 +156,7 @@ export function CountsChip({
}) { }) {
return ( return (
<Chip data-counts={countsTone(available, total)} aria-label={ariaLabel}> <Chip data-counts={countsTone(available, total)} aria-label={ariaLabel}>
{glyph && <Icon name="disk" />} {glyph && <Icon name="disk" className={CHIP_ICON} />}
{label} {label}
</Chip> </Chip>
); );
@@ -200,11 +208,11 @@ export function RatingChip({
export function RowPoster({ posterPath, title }: { posterPath: string | null; title: string }) { export function RowPoster({ posterPath, title }: { posterPath: string | null; title: string }) {
const [broken, setBroken] = useState(false); const [broken, setBroken] = useState(false);
if (posterPath === null || broken) { if (posterPath === null || broken) {
return <span className="row-poster-blank" aria-hidden="true" />; return <span className={POSTER} aria-hidden="true" />;
} }
return ( return (
<img <img
className="row-poster" className={POSTER}
loading="lazy" loading="lazy"
src={tmdbImage(posterPath, "w92") ?? ""} src={tmdbImage(posterPath, "w92") ?? ""}
alt={`${title} poster`} alt={`${title} poster`}
@@ -217,7 +225,7 @@ export function RowPoster({ posterPath, title }: { posterPath: string | null; ti
/** The amber lamp that leads every attention-queue row. */ /** The amber lamp that leads every attention-queue row. */
export function AttentionLamp() { export function AttentionLamp() {
return ( return (
<span className="lead-lamp"> <span className="flex w-4 justify-center">
<span className="lamp" data-state="warn" aria-hidden="true" /> <span className="lamp" data-state="warn" aria-hidden="true" />
</span> </span>
); );
+9 -8
View File
@@ -3,6 +3,7 @@
import { type ReactNode, useState } from "react"; import { type ReactNode, useState } from "react";
import type { LibrarySeries } from "./library"; import type { LibrarySeries } from "./library";
import { seriesStatusChipRedundant } from "./library"; import { seriesStatusChipRedundant } from "./library";
import { card } from "./look";
import { tmdbImage } from "./movie"; import { tmdbImage } from "./movie";
import { import {
audienceOf, audienceOf,
@@ -142,15 +143,15 @@ function LibraryCard({
const [broken, setBroken] = useState(false); const [broken, setBroken] = useState(false);
return ( return (
<li> <li>
<button type="button" className="card" onClick={(event) => open(event.currentTarget)}> <button type="button" className={card.card} onClick={(event) => open(event.currentTarget)}>
<span className="card-art"> <span className={card.art}>
{posterPath === null || broken ? ( {posterPath === null || broken ? (
<span className="card-blank"> <span className={card.blank}>
<span className="card-blank-title">{title}</span> <span className={card.blankTitle}>{title}</span>
</span> </span>
) : ( ) : (
<img <img
className="card-poster" className={card.poster}
loading="lazy" loading="lazy"
src={tmdbImage(posterPath, "w342") ?? ""} src={tmdbImage(posterPath, "w342") ?? ""}
alt={`${title} poster`} alt={`${title} poster`}
@@ -159,9 +160,9 @@ function LibraryCard({
/> />
)} )}
</span> </span>
<span className="card-body"> <span className={card.body}>
<span className="card-name">{title}</span> <span className={card.name}>{title}</span>
<span className="card-chips">{chips}</span> <span className={card.chips}>{chips}</span>
</span> </span>
</button> </button>
</li> </li>
+71 -1
View File
@@ -13,6 +13,10 @@
@import "./components.css" layer(components); @import "./components.css" layer(components);
@import "tailwindcss/utilities.css" layer(utilities) source(none); @import "tailwindcss/utilities.css" layer(utilities) source(none);
/* hover as the board always had it: on any pointer, not only where the
device reports hover — Tailwind's default would drop the tap feedback */
@custom-variant hover (&:hover);
/* utilities are generated from the app's own source only, never from scripts/ */ /* utilities are generated from the app's own source only, never from scripts/ */
@source "./"; @source "./";
@@ -52,6 +56,7 @@
--color-score-6: var(--score-6); --color-score-6: var(--score-6);
--color-status-airing: var(--status-airing); --color-status-airing: var(--status-airing);
--spacing-0: 0px;
--spacing-1: var(--space-1); --spacing-1: var(--space-1);
--spacing-2: var(--space-2); --spacing-2: var(--space-2);
--spacing-3: var(--space-3); --spacing-3: var(--space-3);
@@ -59,6 +64,52 @@
--spacing-6: var(--space-6); --spacing-6: var(--space-6);
--spacing-8: var(--space-8); --spacing-8: var(--space-8);
--spacing-12: var(--space-12); --spacing-12: var(--space-12);
--spacing-control-h: var(--control-h);
--spacing-chip-h: var(--chip-h);
--spacing-row-min: var(--row-min);
--spacing-toggle-w: var(--toggle-w);
--spacing-word-w: var(--word-w);
--spacing-rail-h: var(--rail-h);
--spacing-tabbar-h: var(--tabbar-h);
--spacing-gutter: var(--gutter);
/* the 2px rule under an active destination */
--spacing-rule: 2px;
/* a count badge's round */
--spacing-badge: 1.1rem;
--spacing-disclose: 9rem;
/* a toggle's on / off word */
--spacing-state: 3ch;
/* a download chip: 100% at its widest */
--spacing-dl: 7ch;
/* a lamp's dot, and the rating star the same size */
--spacing-lamp: 0.625rem;
--spacing-chevron: 0.875rem;
/* a row's poster thumbnail, 2:3 */
--spacing-poster: 2.25rem;
--spacing-poster-h: 3.375rem;
/* a hero readout line, reserved while empty */
--spacing-line: 1.25rem;
/* three lines of overview, reserved */
--spacing-overview: 4.5em;
/* a subtitle select: its least width, and where it starts from */
--spacing-field: 9rem;
--spacing-field-basis: 12rem;
--spacing-band-label: 3.5rem;
--spacing-budget: 5.5rem;
--spacing-detail: 1.2em;
--container-deck: var(--deck-max);
--container-measure: var(--measure);
--container-search: 26rem;
--container-notice: 68ch;
--container-select: 18rem;
--container-select-narrow: 11rem;
--container-band: 4.5rem;
/* container query widths for @row, @cells and @wide: the row grows its
action column, the release cells line up, the detail hero widens */
--container-row: 40rem;
--container-cells: 46rem;
--container-wide: 64rem;
--text-2xs: var(--text-2xs); --text-2xs: var(--text-2xs);
--text-xs: var(--text-xs); --text-xs: var(--text-xs);
@@ -72,7 +123,26 @@
--font-readout: var(--font-readout); --font-readout: var(--font-readout);
--font-display: var(--font-display); --font-display: var(--font-display);
--radius-token: var(--radius); --radius-panel: var(--radius);
--radius-pill: 999px;
--radius-round: 50%;
--radius-micro: 2px;
--radius-chip: 3px;
--font-weight-normal: 400;
--font-weight-semibold: 600;
--font-weight-bold: 700;
/* tracking, by how loudly a label is engraved */
--tracking-title: 0.04em;
--tracking-label: 0.08em;
--tracking-wide: 0.1em;
--tracking-engraved: 0.12em;
--leading-none: 1;
--leading-tight: 1.1;
--leading-snug: 1.2;
--leading-row: 1.3;
--ease-out: var(--ease-out); --ease-out: var(--ease-out);
/* the board's own breakpoints: tab bar to rail, column header, dense pointer */ /* the board's own breakpoints: tab bar to rail, column header, dense pointer */
+70 -37
View File
@@ -4,6 +4,7 @@
import { type ReactNode, useEffect, useRef, useState } from "react"; import { type ReactNode, useEffect, useRef, useState } from "react";
import { ArmedDeleteIcon, Icon } from "./icons"; import { ArmedDeleteIcon, Icon } from "./icons";
import { CHIP_ICON, chip as chipLook, control, cx, form, seg, segmented } from "./look";
import { fileName } from "./movie"; import { fileName } from "./movie";
import { import {
cachedSubtitleOptions, cachedSubtitleOptions,
@@ -45,10 +46,15 @@ import {
type Note, type Note,
NoteLine, NoteLine,
Row, Row,
Rows,
type Say, type Say,
Section,
useNote, useNote,
} from "./ui"; } from "./ui";
/** One sentence of a lane's state, in the deck's own voice. */
const SUBS_NOTE = "readout m-0 mt-2 text-xs text-ink-muted data-[tone=fault]:text-signal-fault";
/** How often an open title re-reads a running translation's status. */ /** How often an open title re-reads a running translation's status. */
const TRANSLATION_POLL_MS = 5000; const TRANSLATION_POLL_MS = 5000;
@@ -150,12 +156,12 @@ function LanguagePicker({
}) { }) {
return ( return (
// biome-ignore lint/a11y/useSemanticElements: a fieldset brings its own border, padding and min-width, which this group does not want // biome-ignore lint/a11y/useSemanticElements: a fieldset brings its own border, padding and min-width, which this group does not want
<div className="segmented subs-langs" role="group" aria-label={label}> <div className={segmented(true)} role="group" aria-label={label}>
{languages.map((language) => ( {languages.map((language) => (
<button <button
key={language} key={language}
type="button" type="button"
className="seg" className={seg(language === choice)}
data-language={language} data-language={language}
aria-pressed={language === choice} aria-pressed={language === choice}
disabled={language === barred} disabled={language === barred}
@@ -192,8 +198,14 @@ function SubtitleField({
}) { }) {
return ( return (
// biome-ignore lint/a11y/noLabelWithoutControl: the select is the child // biome-ignore lint/a11y/noLabelWithoutControl: the select is the child
<label className={narrow ? "field subs-field subs-field-narrow" : "field subs-field"}> <label
<span className="field-label readout dim">{label}</span> className={cx(
form.field,
"shrink min-w-field",
narrow ? "grow-0 basis-field max-w-select-narrow" : "grow basis-field-basis max-w-select",
)}
>
<span className={cx("readout dim", form.label)}>{label}</span>
{children} {children}
</label> </label>
); );
@@ -325,10 +337,10 @@ function CandidateBuckets({
const eligible = results.candidates.filter((c) => c.verdict === "eligible"); const eligible = results.candidates.filter((c) => c.verdict === "eligible");
const rejected = results.candidates.filter((c) => c.verdict !== "eligible"); const rejected = results.candidates.filter((c) => c.verdict !== "eligible");
return ( return (
<div className="subs-buckets"> <div className="mt-3">
<section className="deck-group"> <Section spacing="mb-3">
<DeckHead as="h4" label="eligible" count={eligible.length} /> <DeckHead as="h4" label="eligible" count={eligible.length} />
<ul className="deck-rows"> <Rows>
{eligible.length === 0 && ( {eligible.length === 0 && (
<EmptyRow text="none — every candidate names the rule that rejected it below" /> <EmptyRow text="none — every candidate names the rule that rejected it below" />
)} )}
@@ -340,14 +352,14 @@ function CandidateBuckets({
fetchCandidate={fetchCandidate} fetchCandidate={fetchCandidate}
/> />
))} ))}
</ul> </Rows>
</section> </Section>
<section className="deck-group" hidden={rejected.length === 0}> <Section spacing="mb-3" hidden={rejected.length === 0}>
<DeckHead as="h4" label="rejected" count={rejected.length}> <DeckHead as="h4" label="rejected" count={rejected.length}>
<Disclosure count={rejected.length} open={open} onToggle={() => setOpen(!open)} /> <Disclosure count={rejected.length} open={open} onToggle={() => setOpen(!open)} />
</DeckHead> </DeckHead>
<div hidden={!open}> <div hidden={!open}>
<ul className="deck-rows"> <Rows>
{rejected.map((candidate) => ( {rejected.map((candidate) => (
<CandidateRow <CandidateRow
key={`${candidate.provider}:${candidate.candidate_id}`} key={`${candidate.provider}:${candidate.candidate_id}`}
@@ -356,9 +368,9 @@ function CandidateBuckets({
fetchCandidate={fetchCandidate} fetchCandidate={fetchCandidate}
/> />
))} ))}
</ul> </Rows>
</div> </div>
</section> </Section>
</div> </div>
); );
} }
@@ -536,7 +548,13 @@ export function useSubtitleSection(
const chip = ( const chip = (
<button <button
type="button" type="button"
className="chip subs-chip" className={cx(
chipLook({
verdict: summary.satisfied ? "eligible" : "wanted",
interactive: true,
}),
"subs-chip hover:border-current focus-visible:border-current aria-expanded:border-current",
)}
aria-expanded={open} aria-expanded={open}
aria-controls={panelId} aria-controls={panelId}
data-verdict={summary.satisfied ? "eligible" : "wanted"} data-verdict={summary.satisfied ? "eligible" : "wanted"}
@@ -548,14 +566,23 @@ export function useSubtitleSection(
} }
}} }}
> >
<Icon name="captions" /> <Icon name="captions" className={cx(CHIP_ICON, "opacity-70")} />
{/* the codes read as one string — the chip's own flex gap would otherwise {/* the codes read as one string — the chip's own flex gap would otherwise
open a space in front of every comma. The run is as wide as the wanted open a space in front of every comma. The run is as wide as the wanted
set can ever need, so the chips after it stay in column. */} set can ever need, so the chips after it stay in column. */}
<span className="subs-chip-langs" style={{ width: `${summaryWidth(wanted)}ch` }}> <span
className="inline-flex items-baseline flex-none overflow-hidden whitespace-nowrap"
style={{ width: `${summaryWidth(wanted)}ch` }}
>
{summary.languages.length === 0 && <span className="dim">none</span>} {summary.languages.length === 0 && <span className="dim">none</span>}
{summary.languages.map((entry, index) => ( {summary.languages.map((entry, index) => (
<span key={entry.language} data-mt={entry.translated ? "true" : undefined}> <span
key={entry.language}
data-mt={entry.translated ? "true" : undefined}
className={
entry.translated ? "underline decoration-dotted underline-offset-2" : undefined
}
>
{index === 0 ? entry.language : `,${entry.language}`} {index === 0 ? entry.language : `,${entry.language}`}
</span> </span>
))} ))}
@@ -564,7 +591,9 @@ export function useSubtitleSection(
{/* §4.2's one glyph exemption: everything wanted is on disk, drawn as a {/* §4.2's one glyph exemption: everything wanted is on disk, drawn as a
check. The slot is there either way, so a check appearing never check. The slot is there either way, so a check appearing never
moves the row's other chips. */} moves the row's other chips. */}
<span className="subs-chip-mark">{summary.satisfied && <Icon name="check" />}</span> <span className="inline-flex flex-none justify-center w-3">
{summary.satisfied && <Icon name="check" className={cx(CHIP_ICON, "opacity-70")} />}
</span>
</button> </button>
); );
@@ -730,10 +759,14 @@ export function useSubtitleSection(
const rest = subtitles.filter((subtitle) => !asked.includes(subtitle)); const rest = subtitles.filter((subtitle) => !asked.includes(subtitle));
const panel = ( const panel = (
<div className="subs-panel" id={panelId} hidden={!open}> <div
<section className="deck-group subs-lane"> className="@container min-w-0 p-3 bg-panel border border-line rounded-panel"
id={panelId}
hidden={!open}
>
<Section spacing="mb-4 last:mb-0">
<DeckHead label="on this file" /> <DeckHead label="on this file" />
<div className="subs-present"> <div className="flex flex-wrap items-center gap-1 pt-3">
{asked.map((subtitle) => ( {asked.map((subtitle) => (
<SubtitleChip <SubtitleChip
key={subtitle.id} key={subtitle.id}
@@ -756,27 +789,27 @@ export function useSubtitleSection(
/> />
))} ))}
{subtitles.length === 0 && missing.length === 0 && ( {subtitles.length === 0 && missing.length === 0 && (
<p className="readout dim">no subtitles on this file yet.</p> <p className="readout dim m-0 text-xs">no subtitles on this file yet.</p>
)} )}
</div> </div>
<NoteLine note={presentNote} className="subs-note readout" /> <NoteLine note={presentNote} className={SUBS_NOTE} />
</section> </Section>
<section className="deck-group subs-lane"> <Section spacing="mb-4 last:mb-0">
<DeckHead label="fetch" count={fetchCount} /> <DeckHead label="fetch" count={fetchCount} />
<div className="subs-controls"> <div className="flex flex-wrap items-end gap-y-2 gap-x-3 pt-3">
<LanguagePicker <LanguagePicker
label="language to search for" label="language to search for"
languages={languages} languages={languages}
choice={searchChoice} choice={searchChoice}
onPick={setSearchLanguage} onPick={setSearchLanguage}
/> />
<button type="button" className="control" disabled={searching} onClick={search}> <button type="button" className={control()} disabled={searching} onClick={search}>
search search
</button> </button>
</div> </div>
<p <p
className="subs-note readout" className={SUBS_NOTE}
role="status" role="status"
data-tone={searchNote?.tone} data-tone={searchNote?.tone}
hidden={searchNote?.hidden} hidden={searchNote?.hidden}
@@ -790,14 +823,14 @@ export function useSubtitleSection(
fetchCandidate={fetchCandidate} fetchCandidate={fetchCandidate}
/> />
)} )}
</section> </Section>
<section className="deck-group subs-lane"> <Section spacing="mb-4 last:mb-0">
<DeckHead label="translate" /> <DeckHead label="translate" />
<div className="subs-controls"> <div className="flex flex-wrap items-end gap-y-2 gap-x-3 pt-3">
<SubtitleField label="source"> <SubtitleField label="source">
<select <select
className="form-input" className={cx(form.input, form.select)}
value={source} value={source}
disabled={empty || extracting} disabled={empty || extracting}
onChange={(event) => { onChange={(event) => {
@@ -842,7 +875,7 @@ export function useSubtitleSection(
/> />
<SubtitleField label="engine" narrow> <SubtitleField label="engine" narrow>
<select <select
className="form-input" className={cx(form.input, form.select)}
value={engineDisabled ? "" : engine} value={engineDisabled ? "" : engine}
disabled={engineDisabled} disabled={engineDisabled}
onChange={(event) => setEngine(event.target.value)} onChange={(event) => setEngine(event.target.value)}
@@ -857,7 +890,7 @@ export function useSubtitleSection(
</SubtitleField> </SubtitleField>
<button <button
type="button" type="button"
className="control" className={control()}
disabled={translateDisabled} disabled={translateDisabled}
onClick={translate} onClick={translate}
> >
@@ -865,14 +898,14 @@ export function useSubtitleSection(
</button> </button>
</div> </div>
<p <p
className="subs-note readout" className={SUBS_NOTE}
role="status" role="status"
data-tone={empty ? undefined : hintFault === null ? undefined : "fault"} data-tone={empty ? undefined : hintFault === null ? undefined : "fault"}
> >
{options === null ? "" : hint} {options === null ? "" : hint}
</p> </p>
<NoteLine note={translateNote} className="subs-note readout" /> <NoteLine note={translateNote} className={SUBS_NOTE} />
</section> </Section>
</div> </div>
); );
+397 -77
View File
@@ -5,21 +5,36 @@
import { import {
type ComponentProps, type ComponentProps,
createContext,
type HTMLAttributes, type HTMLAttributes,
type KeyboardEvent, type KeyboardEvent,
type MouseEvent, type MouseEvent,
type ReactNode, type ReactNode,
type Ref,
useCallback, useCallback,
useContext,
useState, useState,
} from "react"; } from "react";
import { Icon, type IconName, useArmed } from "./icons"; import { Icon, type IconName, useArmed } from "./icons";
import {
type ControlLook,
card,
chip,
control,
cx,
NOTE,
ROW_RULE,
SUB,
skel,
toggle,
toggleLamp,
toggleState,
type,
} from "./look";
export type Tone = "fault" | "warn"; export type Tone = "fault" | "warn";
/** Joins class names, dropping the falsy ones. */ export { cx } from "./look";
export function cx(...names: (string | false | null | undefined)[]): string {
return names.filter(Boolean).join(" ");
}
/** A boolean data attribute: present (empty) or absent. */ /** A boolean data attribute: present (empty) or absent. */
export function flag(on: boolean | undefined): "" | undefined { export function flag(on: boolean | undefined): "" | undefined {
@@ -37,6 +52,10 @@ export interface ControlProps extends ComponentProps<"button"> {
glyph?: IconName; glyph?: IconName;
/** Fixed width, so a label that changes (GRAB → SENDING → SENT) never moves the row. */ /** Fixed width, so a label that changes (GRAB → SENDING → SENT) never moves the row. */
fixed?: boolean; fixed?: boolean;
/** Full width, content at the start: a phone tray or a settings panel. */
fill?: boolean;
danger?: boolean;
state?: ControlLook["state"];
busy?: boolean; busy?: boolean;
done?: boolean; done?: boolean;
failed?: boolean; failed?: boolean;
@@ -48,6 +67,9 @@ export function Control({
quiet, quiet,
glyph, glyph,
fixed, fixed,
fill,
danger,
state,
busy, busy,
done, done,
failed, failed,
@@ -57,14 +79,23 @@ export function Control({
return ( return (
<button <button
type="button" type="button"
className={cx("control", quiet && "control-quiet", fixed && "control-fixed", className)} className={cx(
control({
look: quiet ? "quiet" : "primary",
shape: fixed ? "fixed" : "word",
fill,
danger,
state,
}),
className,
)}
data-busy={flag(busy)} data-busy={flag(busy)}
data-done={flag(done)} data-done={flag(done)}
data-failed={flag(failed)} data-failed={flag(failed)}
{...rest} {...rest}
> >
{glyph && <Icon name={glyph} />} {glyph && <Icon name={glyph} className={fill ? "mr-1" : undefined} />}
<span className="control-word">{text}</span> <span>{text}</span>
</button> </button>
); );
} }
@@ -73,17 +104,27 @@ export function Control({
export function IconControl({ export function IconControl({
glyph, glyph,
label, label,
look,
shape = "icon",
className, className,
iconClassName,
...rest ...rest
}: ComponentProps<"button"> & { glyph: IconName; label: string }) { }: ComponentProps<"button"> & {
glyph: IconName;
label: string;
/** The glyph's own classes, e.g. a disclosure's turn. */
iconClassName?: string;
look?: ControlLook["look"];
shape?: "icon" | "chip";
}) {
return ( return (
<button <button
type="button" type="button"
className={cx("control control-icon", className)} className={cx(control({ look, shape }), className)}
aria-label={label} aria-label={label}
{...rest} {...rest}
> >
<Icon name={glyph} /> <Icon name={glyph} className={iconClassName} />
</button> </button>
); );
} }
@@ -92,17 +133,17 @@ export function IconControl({
export function IconLink({ export function IconLink({
label, label,
href, href,
className, shape = "icon",
children, children,
}: { }: {
label: string; label: string;
href: string; href: string;
className?: string; shape?: "icon" | "trailer";
children: ReactNode; children: ReactNode;
}) { }) {
return ( return (
<a <a
className={cx("control control-icon", className)} className={control({ shape })}
href={href} href={href}
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
@@ -121,17 +162,20 @@ export function IconLink({
export function LampToggle({ export function LampToggle({
label, label,
pressed, pressed,
fill = false,
...rest ...rest
}: ComponentProps<"button"> & { }: ComponentProps<"button"> & {
label: string; label: string;
pressed: boolean; pressed: boolean;
/** Full width, content at the start: a phone tray or a settings panel. */
fill?: boolean;
"data-focus-id"?: string; "data-focus-id"?: string;
}) { }) {
return ( return (
<button type="button" className="toggle" aria-pressed={pressed} {...rest}> <button type="button" className={toggle(pressed, fill)} aria-pressed={pressed} {...rest}>
<span className="toggle-lamp" aria-hidden="true" /> <span className={toggleLamp(pressed)} aria-hidden="true" />
<span className="toggle-label">{label}</span> <span>{label}</span>
<span className="toggle-state" aria-hidden="true"> <span className={toggleState(pressed)} aria-hidden="true">
{pressed ? "on" : "off"} {pressed ? "on" : "off"}
</span> </span>
</button> </button>
@@ -156,14 +200,18 @@ export function Disclosure({
return ( return (
<button <button
type="button" type="button"
className="control control-quiet disclose" className={cx(control({ look: "quiet", shape: "disclose" }), "ml-auto")}
aria-expanded={open} aria-expanded={open}
onClick={onToggle} onClick={onToggle}
> >
<span className="control-word"> <span>{`${open ? "hide" : "show"} ${count}${noun === "" ? "" : ` ${noun}`}`}</span>
{`${open ? "hide" : "show"} ${count}${noun === "" ? "" : ` ${noun}`}`} <Icon
</span> name="chevronDown"
<Icon name="chevronDown" /> className={cx(
"[transition:transform_200ms_var(--ease-out)]",
open && "[transform:rotate(180deg)]",
)}
/>
</button> </button>
); );
} }
@@ -185,6 +233,9 @@ export function ArmedDeleteWord({
text={armed ? `tap again to ${label}` : label} text={armed ? `tap again to ${label}` : label}
glyph={armed ? "check" : "trash"} glyph={armed ? "check" : "trash"}
quiet quiet
fill
danger
state={armed ? "armed" : null}
data-kind="delete" data-kind="delete"
data-armed={armed ? "true" : undefined} data-armed={armed ? "true" : undefined}
disabled={spent} disabled={spent}
@@ -212,16 +263,34 @@ export interface Status {
* A status slot. The slot is always laid out — an empty one keeps its line — * A status slot. The slot is always laid out — an empty one keeps its line —
* so a message arriving or leaving never pushes the content below it. * so a message arriving or leaving never pushes the content below it.
*/ */
export function StatusSlot({ status, className }: { status: Status | null; className: string }) { const SLOT = {
// a page bar's one line, ellipsised: a message never pushes the page down
head: "flex-1 min-w-0 m-0 overflow-hidden whitespace-nowrap text-ellipsis",
// a section's line: reserved, and wraps only when the sentence must
deck: "flex items-center flex-wrap gap-y-2 gap-x-3 min-h-chip-h mb-3",
} as const;
export function StatusSlot({
status,
variant,
}: {
status: Status | null;
variant: keyof typeof SLOT;
}) {
return ( return (
<p <p
className={className} className={cx(
"readout text-xs text-ink-muted data-[tone=fault]:text-signal-fault",
SLOT[variant],
)}
role="status" role="status"
data-empty={String(status === null)} data-empty={String(status === null)}
data-tone={status?.tone} data-tone={status?.tone}
data-action={flag(status?.action !== undefined)} data-action={flag(status?.action !== undefined)}
> >
{status?.busy && <span className="lamp" data-state="probing" aria-hidden="true" />} {status?.busy && (
<span className="lamp inline-block mr-2" data-state="probing" aria-hidden="true" />
)}
{status?.text ?? ""} {status?.text ?? ""}
{status?.action && <Control text={status.action.label} quiet onClick={status.action.run} />} {status?.action && <Control text={status.action.label} quiet onClick={status.action.run} />}
</p> </p>
@@ -307,17 +376,43 @@ function useExplain(explain: Explain | undefined) {
} }
export interface ChipProps extends HTMLAttributes<HTMLSpanElement> { export interface ChipProps extends HTMLAttributes<HTMLSpanElement> {
/** `chip readout` by default; a glyph chip drops the readout face. */ /** The whole label is a glyph. */
base?: string; glyph?: boolean;
/** A live download's chip. */
download?: boolean;
explain?: Explain; explain?: Explain;
[data: `data-${string}`]: string | undefined; [data: `data-${string}`]: string | undefined;
} }
/** A chip, the §9.3 column unit. */ /** A chip, the §9.3 column unit. Its look is read off its own data attributes. */
export function Chip({ base = "chip readout", className, explain, children, ...rest }: ChipProps) { export function Chip({ glyph, download, className, explain, children, ...rest }: ChipProps) {
const explainProps = useExplain(explain); const explainProps = useExplain(explain);
return ( return (
<span className={cx(base, className)} {...rest} {...explainProps}> <span
className={cx(
chip({
verdict: rest["data-verdict"],
blacklist: rest["data-blacklist"],
movieState: rest["data-movie-state"],
wanted: rest["data-wanted"],
dlPhase: rest["data-dl-phase"],
status: rest["data-status"],
counts: rest["data-counts"],
flag: rest["data-flag"],
mt: rest["data-mt"],
tone: rest["data-tone"],
secondary: rest["data-pri"] === "2",
interactive: explain !== undefined || rest.role === "button",
explain: explain !== undefined,
glyph,
download,
cell: rest["data-cell"] !== undefined,
}),
className,
)}
{...rest}
{...explainProps}
>
{children} {children}
</span> </span>
); );
@@ -334,14 +429,17 @@ export interface ActionSlot {
wide?: boolean; wide?: boolean;
/** Shown below 40rem only — an empty cell that keeps a phone column aligned. */ /** Shown below 40rem only — an empty cell that keeps a phone column aligned. */
narrow?: boolean; narrow?: boolean;
/** A word or toggle control fills its column; an input keeps its own width. */
fill?: boolean;
} }
export interface RowProps { export interface RowProps {
/** `data-row`: which kind of row, for the few rules that differ by kind. */ /** `data-row`: which kind of row. */
kind: string; kind: string;
lead?: ReactNode; lead?: ReactNode;
title?: ReactNode; title?: ReactNode;
titleClassName?: string; /** readout: a path or a key in the mono face. season: an engraved display name. */
titleStyle?: "plain" | "readout" | "season";
/** The chip line. */ /** The chip line. */
meta?: ReactNode; meta?: ReactNode;
sub?: ReactNode; sub?: ReactNode;
@@ -351,7 +449,7 @@ export interface RowProps {
beforeSub?: ReactNode; beforeSub?: ReactNode;
/** Body content after the sub line. */ /** Body content after the sub line. */
afterSub?: ReactNode; afterSub?: ReactNode;
bodyClassName?: string; /** The body as a whole toggles something, e.g. a season's episodes. */
onBodyClick?: (event: MouseEvent<HTMLDivElement>) => void; onBodyClick?: (event: MouseEvent<HTMLDivElement>) => void;
actions?: ActionSlot[]; actions?: ActionSlot[];
/** The phone tray: labelled, full-width versions of the wide-only actions. */ /** The phone tray: labelled, full-width versions of the wide-only actions. */
@@ -382,6 +480,18 @@ export function Expandable({ className, children }: { className: string; childre
); );
} }
const TITLE = {
plain: "text-sm @row:text-base font-semibold",
readout: "readout text-sm @row:text-base font-semibold",
season: "font-display text-base font-bold tracking-label uppercase",
} as const;
const SLOT_WIDTH = {
icon: "w-control-h",
toggle: "w-toggle-w",
word: "min-w-word-w",
} as const;
/** /**
* The one row: `lead | body | actions`, plus a full-width tray. The body is * The one row: `lead | body | actions`, plus a full-width tray. The body is
* `minmax(0, 1fr)`, so a long title or a run of chips is clipped inside it * `minmax(0, 1fr)`, so a long title or a run of chips is clipped inside it
@@ -390,52 +500,93 @@ export function Expandable({ className, children }: { className: string; childre
export function Row(props: RowProps) { export function Row(props: RowProps) {
const [moreOpen, setMoreOpen] = useState(false); const [moreOpen, setMoreOpen] = useState(false);
const { open, actions = [] } = props; const { open, actions = [] } = props;
// the row as a link: a stretched button under everything; real controls
// sit above it, everything else lets the tap through
const above = open ? "relative z-1 pointer-events-none" : undefined;
return ( return (
<li className="r" data-row={props.kind} data-nolead={flag(!props.lead)}> <li
className={cx(
"relative grid items-center gap-x-3 min-h-row-min py-2",
ROW_RULE,
props.lead
? "[grid-template-columns:auto_minmax(0,1fr)_auto] [grid-template-areas:'lead_body_act'_'tray_tray_tray']"
: "[grid-template-columns:minmax(0,1fr)_auto] [grid-template-areas:'body_act'_'tray_tray']",
open && "[&_:is(button,a,select,input,[role=button])]:pointer-events-auto",
)}
data-row={props.kind}
>
{open && ( {open && (
<button <button
type="button" type="button"
className={cx("r-link", open.className)} className={cx(
"r-link absolute inset-0 z-0 p-0 bg-transparent [border:0] cursor-pointer [transition:background_150ms_var(--ease-out)] hover:bg-highlight focus-visible:[outline-offset:-2px]",
open.className,
)}
aria-label={open.label} aria-label={open.label}
aria-expanded={open.expanded} aria-expanded={open.expanded}
aria-disabled={open.disabled ? "true" : undefined} aria-disabled={open.disabled ? "true" : undefined}
onClick={(event) => open.run(event.currentTarget)} onClick={(event) => open.run(event.currentTarget)}
/> />
)} )}
{props.lead && <div className="r-lead">{props.lead}</div>} {props.lead && (
<div className={cx("[grid-area:lead] flex items-center justify-center", above)}>
{props.lead}
</div>
)}
{/* biome-ignore lint/a11y/noStaticElementInteractions: the season name expands it too — the chevron stays the accessible control */} {/* biome-ignore lint/a11y/noStaticElementInteractions: the season name expands it too — the chevron stays the accessible control */}
{/* biome-ignore lint/a11y/useKeyWithClickEvents: same */} {/* biome-ignore lint/a11y/useKeyWithClickEvents: same */}
<div className={cx("r-body", props.bodyClassName)} onClick={props.onBodyClick}> <div
className={cx("[grid-area:body] grid content-center gap-1 min-w-0", above)}
onClick={props.onBodyClick}
>
{props.title !== undefined && props.title !== null && ( {props.title !== undefined && props.title !== null && (
<div className={cx("r-title", props.titleClassName)}>{props.title}</div> <div
className={cx(
"min-w-0 truncate leading-row text-ink",
TITLE[props.titleStyle ?? "plain"],
)}
>
{props.title}
</div>
)} )}
<div className="r-meta">{props.meta}</div> {/* one line of chips; what does not fit fades out at the edge rather
than being cut through a word */}
<div className="flex items-center flex-nowrap gap-1 min-w-0 overflow-hidden [mask-image:linear-gradient(to_right,var(--ink)_calc(100%_-_1.5rem),transparent)] empty:hidden">
{props.meta}
</div>
{props.beforeSub} {props.beforeSub}
{props.sub !== undefined && {props.sub !== undefined &&
props.sub !== null && props.sub !== null &&
(props.subExpands ? ( (props.subExpands ? (
<Expandable className="r-sub readout">{props.sub}</Expandable> <Expandable className={SUB}>{props.sub}</Expandable>
) : ( ) : (
<div className="r-sub readout">{props.sub}</div> <div className={SUB}>{props.sub}</div>
))} ))}
{props.afterSub} {props.afterSub}
</div> </div>
<div className="r-act"> {/* every slot has its width whether or not it holds a control, so a row
of a kind keeps one action column */}
<div className={cx("[grid-area:act] flex items-center justify-end gap-1", above)}>
{actions.map((slot, index) => ( {actions.map((slot, index) => (
<span <span
// the column is positional: a slot is its index // the column is positional: a slot is its index
// biome-ignore lint/suspicious/noArrayIndexKey: see above // biome-ignore lint/suspicious/noArrayIndexKey: see above
key={index} key={index}
className="r-slot" className={cx(
"flex-none items-center justify-center",
slot.wide ? "hidden @row:flex" : "flex",
slot.narrow && "@row:hidden",
SLOT_WIDTH[slot.width],
// a word or a toggle fills its column, so every row's plates line up
slot.width !== "icon" && slot.fill !== false && "*:w-full",
)}
data-width={slot.width} data-width={slot.width}
data-wide={flag(slot.wide)}
data-narrow={flag(slot.narrow)}
> >
{slot.node} {slot.node}
</span> </span>
))} ))}
{props.more && ( {props.more && (
<span className="r-slot" data-width="icon" data-narrow=""> <span className="flex flex-none items-center justify-center w-control-h @row:hidden">
<IconControl <IconControl
glyph="more" glyph="more"
label="more actions" label="more actions"
@@ -445,15 +596,23 @@ export function Row(props: RowProps) {
</span> </span>
)} )}
{open && open.chevron !== false && actions.length === 0 && ( {open && open.chevron !== false && actions.length === 0 && (
<span className="r-slot r-chevron" data-width="icon" aria-hidden="true"> <span
<Icon name="chevronRight" /> className="flex flex-none items-center justify-center w-control-h text-ink-faint"
aria-hidden="true"
>
<Icon name="chevronRight" className="size-chevron" />
</span> </span>
)} )}
</div> </div>
<div className="r-tray"> <div
<NoteLine note={props.note ?? null} className="r-note readout" /> className={cx(
"[grid-area:tray] grid gap-2 min-w-0 pt-2 [&:not(:has(>:not([hidden])))]:hidden",
open && "relative z-1",
)}
>
<NoteLine note={props.note ?? null} className={NOTE} />
{props.more && ( {props.more && (
<div className="r-morepanel" hidden={!moreOpen}> <div className="grid gap-2 @row:hidden" hidden={!moreOpen}>
{props.more} {props.more}
</div> </div>
)} )}
@@ -466,18 +625,28 @@ export function Row(props: RowProps) {
/** A row-shaped placeholder: same height and columns as the row it stands for. */ /** A row-shaped placeholder: same height and columns as the row it stands for. */
export function SkeletonRows({ count, withLead = true }: { count: number; withLead?: boolean }) { export function SkeletonRows({ count, withLead = true }: { count: number; withLead?: boolean }) {
return Array.from({ length: count }, (_, index) => ( return Array.from({ length: count }, (_, index) => (
// biome-ignore lint/suspicious/noArrayIndexKey: placeholders have no identity <li
<li key={index} className="r r-skel" aria-hidden="true" data-nolead={flag(!withLead)}> // biome-ignore lint/suspicious/noArrayIndexKey: placeholders have no identity
key={index}
className={cx(
"relative grid items-center gap-x-3 min-h-row-min py-2 pointer-events-none",
ROW_RULE,
withLead
? "[grid-template-columns:auto_minmax(0,1fr)_auto] [grid-template-areas:'lead_body_act'_'tray_tray_tray']"
: "[grid-template-columns:minmax(0,1fr)_auto] [grid-template-areas:'body_act'_'tray_tray']",
)}
aria-hidden="true"
>
{withLead && ( {withLead && (
<div className="r-lead"> <div className="[grid-area:lead] flex items-center justify-center">
<span className="skel skel-lead" /> <span className={skel.lead} />
</div> </div>
)} )}
<div className="r-body"> <div className="[grid-area:body] grid content-center gap-1 min-w-0">
<span className="skel skel-line" /> <span className={skel.line} />
<span className="skel skel-line skel-short" /> <span className={skel.short} />
</div> </div>
<div className="r-act" /> <div className="[grid-area:act] flex items-center justify-end gap-1" />
</li> </li>
)); ));
} }
@@ -486,62 +655,213 @@ export function SkeletonRows({ count, withLead = true }: { count: number; withLe
export function EmptyRow({ export function EmptyRow({
text, text,
tone, tone,
lead,
children, children,
}: { }: {
text: string; text: string;
tone?: "fault"; tone?: "fault";
/** Before the text, such as a probing lamp. */
lead?: ReactNode;
children?: ReactNode; children?: ReactNode;
}) { }) {
return ( return (
<li className="r-empty readout" data-tone={tone}> <li
className={cx(
"readout flex items-center gap-2 min-h-row-min py-2 text-xs text-ink-muted data-[tone=fault]:text-signal-fault",
ROW_RULE,
)}
data-tone={tone}
>
{lead}
{text} {text}
{children} {children}
</li> </li>
); );
} }
/* ---- page skeleton ------------------------------------------------------- */
/**
* A page: the one centred column, and a container, so a row answers to the
* page's width rather than the window's. The gutter belongs to the content;
* a child marked `data-bleed` (the detail hero) reaches both edges.
*/
export function Deck({
label,
detail = false,
hidden,
id,
ref,
onKeyDown,
children,
}: {
label: string;
/** A detail page opens on its hero, so the page drops its top padding. */
detail?: boolean;
hidden?: boolean;
id?: string;
ref?: Ref<HTMLElement>;
onKeyDown?: (event: KeyboardEvent<HTMLElement>) => void;
children: ReactNode;
}) {
return (
<main
className={cx(
"@container w-full max-w-deck mx-auto pb-12 flex-1 *:not-data-bleed:mx-gutter",
detail ? "pt-0" : "pt-4",
)}
aria-label={label}
hidden={hidden}
id={id}
ref={ref}
onKeyDown={onKeyDown}
>
{children}
</main>
);
}
/** A page's line: title, count, a one-line status slot, the page's controls. */
export function PageBar({
title,
count,
status,
children,
}: {
title: string;
/** Absent leaves the count's slot out entirely. */
count?: string;
status: Status | null;
children?: ReactNode;
}) {
return (
<header className="flex items-center gap-3 min-h-control-h mb-4">
<h2 className={cx(type.pageTitle, "capitalize")}>{title}</h2>
{count !== undefined && <span className={cx(type.count, "flex-none")}>{count}</span>}
<StatusSlot status={status} variant="head" />
{children}
</header>
);
}
/** Whether a section sits inside another: its head is then a quieter group label. */
const Nested = createContext(false);
const InnerSection = createContext(false);
/** A section of a page; `spacing` replaces the default gap after it. */
export function Section({
spacing = "mb-8",
hidden,
labelledBy,
ref,
className,
children,
}: {
spacing?: string;
hidden?: boolean;
labelledBy?: string;
ref?: Ref<HTMLElement>;
/** A marker other rules still key on, such as `subs-lane`. */
className?: string;
children: ReactNode;
}) {
const outer = useContext(Nested);
return (
<section
className={cx(spacing, className)}
hidden={hidden}
aria-labelledby={labelledBy}
ref={ref}
>
<InnerSection.Provider value={outer}>
<Nested.Provider value={true}>{children}</Nested.Provider>
</InnerSection.Provider>
</section>
);
}
/** A section head: the engraved label, a count, then whatever acts on it. */ /** A section head: the engraved label, a count, then whatever acts on it. */
export function DeckHead({ export function DeckHead({
label, label,
labelId, labelId,
as: Heading = "h3", as: Heading = "h3",
labelClass = "deck-label", titled = "label",
count, count,
children, children,
}: { }: {
label: string; label: string;
labelId?: string; labelId?: string;
as?: "h3" | "h4"; as?: "h3" | "h4";
labelClass?: string; /** A page's section title, or a group's engraved label. */
titled?: "section" | "label";
count?: string | number | null; count?: string | number | null;
children?: ReactNode; children?: ReactNode;
}) { }) {
// nested heads inside a section are group labels, one step quieter
const nested = useContext(InnerSection);
return ( return (
<header className="deck-head"> <header
<Heading className={labelClass} id={labelId}> className={cx(
"flex items-center gap-3 pb-1 border-b border-b-line",
nested ? "min-h-chip-h pt-3" : "min-h-control-h",
)}
>
<Heading
className={titled === "section" ? type.sectionTitle : cx(type.label, "text-ink-muted")}
id={labelId}
>
{label} {label}
</Heading> </Heading>
{count !== undefined && <span className="deck-count readout">{count ?? ""}</span>} {count !== undefined && <span className={type.count}>{count ?? ""}</span>}
{children} {children}
</header> </header>
); );
} }
/** A list of rows, or of poster cards. */
export function Rows({
grid = false,
className,
hidden,
children,
}: {
grid?: boolean;
/** A marker other rules still key on, such as `seasons`. */
className?: string;
hidden?: boolean;
children?: ReactNode;
}) {
return (
<ul className={cx("m-0 list-none", grid ? card.grid : "p-0", className)} aria-hidden={hidden}>
{children}
</ul>
);
}
/** A group's one plain sentence, which opens to the long form on a tap. */ /** A group's one plain sentence, which opens to the long form on a tap. */
export function GroupNote({ short, more }: { short: string; more: string }) { export function GroupNote({ short, more }: { short: string; more?: string }) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
return ( return (
<div className="group-note" data-explain-group=""> <div
<p>{short}</p> className="flex flex-wrap items-center gap-y-1 gap-x-2 pt-2 text-sm text-ink-muted"
<IconControl data-explain-group={more === undefined ? undefined : ""}
glyph="info" >
label="more about this list" <p className="m-0">{short}</p>
aria-expanded={open} {more !== undefined && (
onClick={() => setOpen(!open)} <>
/> <IconControl
<p className="group-note-more" hidden={!open}> glyph="info"
{more} label="more about this list"
</p> aria-expanded={open}
onClick={() => setOpen(!open)}
look="faint"
shape="chip"
/>
<p className="m-0 basis-full max-w-measure text-xs" hidden={!open}>
{more}
</p>
</>
)}
</div> </div>
); );
} }
+36 -38
View File
@@ -10,9 +10,10 @@ import {
movieNeedsAttention, movieNeedsAttention,
seriesNeedsAttention, seriesNeedsAttention,
} from "../library"; } from "../library";
import { card, seg, segmented, skel } from "../look";
import { MovieCard, MovieRow, SeriesCard, SeriesRow } from "../rows"; import { MovieCard, MovieRow, SeriesCard, SeriesRow } from "../rows";
import { allRoots, type LibraryMovie, type Root } from "../search"; import { allRoots, type LibraryMovie, type Root } from "../search";
import { DeckHead, SkeletonRows, StatusSlot, useStatus } from "../ui"; import { Deck, DeckHead, PageBar, Rows, Section, SkeletonRows, useStatus } from "../ui";
type LibraryShape = "grid" | "list"; type LibraryShape = "grid" | "list";
@@ -49,20 +50,20 @@ let cached: LibraryData | null = null;
function GridSkeleton() { function GridSkeleton() {
return ( return (
<ul className="deck-rows grid-rows" aria-hidden="true"> <Rows grid hidden>
{Array.from({ length: 6 }, (_, index) => ( {Array.from({ length: 6 }, (_, index) => (
// biome-ignore lint/suspicious/noArrayIndexKey: placeholders have no identity // biome-ignore lint/suspicious/noArrayIndexKey: placeholders have no identity
<li key={index}> <li key={index}>
<span className="card card-skel"> <span className={card.card}>
<span className="card-art" /> <span className={card.art} />
<span className="card-body"> <span className={card.body}>
<span className="skel skel-line" /> <span className={skel.line} />
<span className="skel skel-line skel-short" /> <span className={skel.short} />
</span> </span>
</span> </span>
</li> </li>
))} ))}
</ul> </Rows>
); );
} }
@@ -162,17 +163,16 @@ export function LibraryView({ hidden }: { hidden: boolean }) {
} }
return ( return (
<main className="deck" aria-label="library" hidden={hidden}> <Deck label="library" hidden={hidden}>
<header className="page-bar"> <PageBar
<h2 className="page-title">library</h2> title="library"
<span className="deck-count readout"> count={total === 0 ? "" : `${total} ${total === 1 ? "title" : "titles"}`}
{total === 0 ? "" : `${total} ${total === 1 ? "title" : "titles"}`} status={status}
</span> >
<StatusSlot status={status} className="head-status readout" /> <fieldset className={segmented()} aria-label="layout">
<fieldset className="segmented" aria-label="layout">
<button <button
type="button" type="button"
className="seg seg-icon" className={seg(shape === "grid", true)}
aria-pressed={shape === "grid"} aria-pressed={shape === "grid"}
aria-label="poster grid" aria-label="poster grid"
onClick={() => setShape("grid")} onClick={() => setShape("grid")}
@@ -181,7 +181,7 @@ export function LibraryView({ hidden }: { hidden: boolean }) {
</button> </button>
<button <button
type="button" type="button"
className="seg seg-icon" className={seg(shape === "list", true)}
aria-pressed={shape === "list"} aria-pressed={shape === "list"}
aria-label="list" aria-label="list"
onClick={() => setShape("list")} onClick={() => setShape("list")}
@@ -189,58 +189,56 @@ export function LibraryView({ hidden }: { hidden: boolean }) {
<Icon name="list" /> <Icon name="list" />
</button> </button>
</fieldset> </fieldset>
</header> </PageBar>
<div hidden={shown !== null && (shape === "list" || grid.length === 0)}> <div hidden={shown !== null && (shape === "list" || grid.length === 0)}>
{data === null && !failed && (shape === "grid" ? <GridSkeleton /> : <ListSkeleton />)} {data === null && !failed && (shape === "grid" ? <GridSkeleton /> : <ListSkeleton />)}
{shown !== null && {shown !== null &&
grid.map((section) => ( grid.map((section) => (
<section key={section.id} className="deck-group library-grid-group"> <Section key={section.id}>
<DeckHead label={section.label} count={section.items.length} /> <DeckHead label={section.label} count={section.items.length} />
<ul className="deck-rows grid-rows"> <Rows grid>
{section.items.map((item) => ( {section.items.map((item) => (
<Fragment key={item.key}>{item.node}</Fragment> <Fragment key={item.key}>{item.node}</Fragment>
))} ))}
</ul> </Rows>
</section> </Section>
))} ))}
</div> </div>
<section <Section
className="deck-group"
hidden={shown === null || shape === "grid" || seriesShown.length === 0} hidden={shown === null || shape === "grid" || seriesShown.length === 0}
aria-labelledby="label-lib-series" labelledBy="label-lib-series"
> >
<DeckHead label="series" labelId="label-lib-series" count={seriesShown.length} /> <DeckHead label="series" labelId="label-lib-series" count={seriesShown.length} />
<ul className="deck-rows"> <Rows>
{shape === "list" && {shape === "list" &&
seriesShown.map((series) => ( seriesShown.map((series) => (
<SeriesRow key={series.id} series={series} roots={roots} open={nav.openSeries} /> <SeriesRow key={series.id} series={series} roots={roots} open={nav.openSeries} />
))} ))}
</ul> </Rows>
</section> </Section>
<section <Section
className="deck-group"
hidden={shown === null || shape === "grid" || moviesShown.length === 0} hidden={shown === null || shape === "grid" || moviesShown.length === 0}
aria-labelledby="label-lib-movies" labelledBy="label-lib-movies"
> >
<DeckHead label="movies" labelId="label-lib-movies" count={moviesShown.length} /> <DeckHead label="movies" labelId="label-lib-movies" count={moviesShown.length} />
<ul className="deck-rows"> <Rows>
{shape === "list" && {shape === "list" &&
moviesShown.map((movie) => ( moviesShown.map((movie) => (
<MovieRow key={movie.id} movie={movie} roots={roots} open={nav.openMovie} /> <MovieRow key={movie.id} movie={movie} roots={roots} open={nav.openMovie} />
))} ))}
</ul> </Rows>
</section> </Section>
</main> </Deck>
); );
} }
function ListSkeleton() { function ListSkeleton() {
return ( return (
<ul className="deck-rows"> <Rows>
<SkeletonRows count={6} /> <SkeletonRows count={6} />
</ul> </Rows>
); );
} }
+33 -26
View File
@@ -5,6 +5,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
import { Buckets, type DeckState, type ReleaseActions } from "../buckets"; import { Buckets, type DeckState, type ReleaseActions } from "../buckets";
import { LAYER, useEscape, useNav } from "../context"; import { LAYER, useEscape, useNav } from "../context";
import { Hero, ProviderLink, RemovePanel, type RemoveSubject, TrailerLink } from "../detail"; import { Hero, ProviderLink, RemovePanel, type RemoveSubject, TrailerLink } from "../detail";
import { control, cx, detail, form, SUB } from "../look";
import { import {
fileName, fileName,
imdbLink, imdbLink,
@@ -45,12 +46,15 @@ import { useSubtitleSection } from "../subs-panel";
import { movieSubtitleStatus, type SubtitleStatus } from "../subtitles"; import { movieSubtitleStatus, type SubtitleStatus } from "../subtitles";
import { import {
Chip, Chip,
Deck,
DeckHead, DeckHead,
EmptyRow, EmptyRow,
Expandable, Expandable,
IconControl, IconControl,
LampToggle, LampToggle,
Row, Row,
Rows,
Section,
SkeletonRows, SkeletonRows,
StatusSlot, StatusSlot,
useNote, useNote,
@@ -80,7 +84,7 @@ function FileRow({
<Row <Row
kind="file" kind="file"
title={fileName(file.path)} title={fileName(file.path)}
titleClassName="readout" titleStyle="readout"
meta={ meta={
<> <>
<WaiverChip waiver={file.waiver} say={say} /> <WaiverChip waiver={file.waiver} say={say} />
@@ -92,7 +96,7 @@ function FileRow({
</> </>
} }
// the full path is evidence, a tap away rather than a hover away // the full path is evidence, a tap away rather than a hover away
afterSub={<Expandable className="r-sub readout">{file.path}</Expandable>} afterSub={<Expandable className={SUB}>{file.path}</Expandable>}
note={note} note={note}
tray={subs.panel} tray={subs.panel}
/> />
@@ -405,7 +409,7 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
const rootListed = movie !== null && movieRoots.some((root) => root.id === movie.root_id); const rootListed = movie !== null && movieRoots.some((root) => root.id === movie.root_id);
return ( return (
<main className="deck detail" aria-label="movie detail"> <Deck detail label="movie detail">
<Hero <Hero
title={movie?.title ?? ""} title={movie?.title ?? ""}
year={movie?.year ?? null} year={movie?.year ?? null}
@@ -427,11 +431,11 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
} }
/> />
<div className="actionbar"> <div className={detail.actionbar}>
<button type="button" className="control" disabled={sweeping} onClick={sweep}> <button type="button" className={control()} disabled={sweeping} onClick={sweep}>
search indexers search indexers
</button> </button>
<span className="actionbar-links"> <span className={detail.actionbarLinks}>
{/* the trailer resolves from the metadata's own key — no second call. {/* the trailer resolves from the metadata's own key — no second call.
Hidden when absent rather than shown dead (§9.6). */} Hidden when absent rather than shown dead (§9.6). */}
{metadata?.trailer && ( {metadata?.trailer && (
@@ -441,13 +445,14 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
<IconControl <IconControl
glyph="more" glyph="more"
label="library settings for this title" label="library settings for this title"
className="ml-auto"
aria-expanded={moreOpen} aria-expanded={moreOpen}
aria-controls="movie-more-panel" aria-controls="movie-more-panel"
onClick={() => setMoreOpen(!moreOpen)} onClick={() => setMoreOpen(!moreOpen)}
/> />
</div> </div>
<div className="more-panel" id="movie-more-panel" hidden={!moreOpen}> <div className={detail.morePanel} id="movie-more-panel" hidden={!moreOpen}>
<div className="more-links"> <div className={detail.moreLinks}>
{metadata !== null && ( {metadata !== null && (
<> <>
<ProviderLink <ProviderLink
@@ -472,14 +477,16 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
</> </>
)} )}
</div> </div>
<div className="more-toggles"> <div className={detail.moreToggles}>
<LampToggle <LampToggle
fill
label="wanted" label="wanted"
pressed={movie?.wanted ?? false} pressed={movie?.wanted ?? false}
disabled={busy === "wanted"} disabled={busy === "wanted"}
onClick={() => toggle("wanted", "wanted")} onClick={() => toggle("wanted", "wanted")}
/> />
<LampToggle <LampToggle
fill
label="targeted search" label="targeted search"
pressed={!(movie?.blocked ?? false)} pressed={!(movie?.blocked ?? false)}
// the accessible name carries what the label cannot, at rest and on // the accessible name carries what the label cannot, at rest and on
@@ -491,15 +498,15 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
{/* §6.3 is the whole point of the flag and a bare toggle hides it: the {/* §6.3 is the whole point of the flag and a bare toggle hides it: the
note appears when the flag is on, which is when the RSS half is the note appears when the flag is on, which is when the RSS half is the
thing that surprises. At rest the label and the title carry it. */} thing that surprises. At rest the label and the title carry it. */}
<p className="control-note readout" hidden={!movie?.blocked}> <p className={detail.controlNote} hidden={!movie?.blocked}>
Targeted search is off. RSS still matches this title, so a release can still arrive. Targeted search is off. RSS still matches this title, so a release can still arrive.
</p> </p>
<label className="field more-field"> <label className={form.field}>
<span className="field-label" id="movie-root-label"> <span className={form.label} id="movie-root-label">
root root
</span> </span>
<select <select
className="form-input" className={cx(form.input, form.select)}
aria-labelledby="movie-root-label" aria-labelledby="movie-root-label"
value={movie === null ? "" : String(movie.root_id)} value={movie === null ? "" : String(movie.root_id)}
disabled={busy === "root"} disabled={busy === "root"}
@@ -520,7 +527,7 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
</label> </label>
<button <button
type="button" type="button"
className="control control-quiet" className={control({ look: "quiet", fill: true, danger: true })}
data-kind="delete" data-kind="delete"
ref={removeButton} ref={removeButton}
aria-expanded={removeOpen} aria-expanded={removeOpen}
@@ -530,7 +537,7 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
> >
remove from library remove from library
</button> </button>
<div className="remove-panel" id="remove-panel" hidden={!removeOpen}> <div className="@row:col-span-full" id="remove-panel" hidden={!removeOpen}>
{removeOpen && subject.current !== null && ( {removeOpen && subject.current !== null && (
<RemovePanel <RemovePanel
subject={subject.current} subject={subject.current}
@@ -543,16 +550,16 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
)} )}
</div> </div>
</div> </div>
<StatusSlot status={status} className="deck-status readout" /> <StatusSlot status={status} variant="deck" />
<section className="deck-group" aria-labelledby="label-disk"> <Section labelledBy="label-disk">
<DeckHead <DeckHead
label="on disk" label="on disk"
labelId="label-disk" labelId="label-disk"
labelClass="section-title" titled="section"
count={files?.kind === "files" ? files.files.length : ""} count={files?.kind === "files" ? files.files.length : ""}
/> />
<ul className="deck-rows"> <Rows>
{files === null && <SkeletonRows count={1} withLead={false} />} {files === null && <SkeletonRows count={1} withLead={false} />}
{files?.kind === "error" && ( {files?.kind === "error" && (
<EmptyRow text={`files unreadable — ${files.detail}`} tone="fault" /> <EmptyRow text={`files unreadable — ${files.detail}`} tone="fault" />
@@ -569,14 +576,14 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
refresh={refreshSubtitles} refresh={refreshSubtitles}
/> />
))} ))}
</ul> </Rows>
</section> </Section>
<section className="deck-group" aria-labelledby="label-releases" ref={releasesSection}> <Section labelledBy="label-releases" ref={releasesSection}>
<DeckHead label="releases" labelId="label-releases" labelClass="section-title" /> <DeckHead label="releases" labelId="label-releases" titled="section" />
<StatusSlot status={releaseStatus} className="deck-status readout" /> <StatusSlot status={releaseStatus} variant="deck" />
<Buckets state={deck} actions={actions} /> <Buckets state={deck} actions={actions} />
</section> </Section>
</main> </Deck>
); );
} }
+14 -13
View File
@@ -25,12 +25,15 @@ import { missingChipLabel } from "../subtitles";
import { import {
Chip, Chip,
Control, Control,
Deck,
DeckHead, DeckHead,
EmptyRow, EmptyRow,
GroupNote, GroupNote,
PageBar,
Row, Row,
Rows,
Section,
SkeletonRows, SkeletonRows,
StatusSlot,
useNote, useNote,
useStatus, useStatus,
} from "../ui"; } from "../ui";
@@ -208,11 +211,11 @@ function QueueGroup({
hidden: boolean; hidden: boolean;
}) { }) {
return ( return (
<section className="deck-group" hidden={hidden} aria-labelledby={`label-${id}`}> <Section hidden={hidden} labelledBy={`label-${id}`}>
<DeckHead label={label} labelId={`label-${id}`} count={count ?? ""} /> <DeckHead label={label} labelId={`label-${id}`} count={count ?? ""} />
{note} {note}
<ul className="deck-rows">{rows}</ul> <Rows>{rows}</Rows>
</section> </Section>
); );
} }
@@ -294,14 +297,12 @@ export function QueuesView({ hidden }: { hidden: boolean }) {
); );
return ( return (
<main className="deck" aria-label="attention queues" hidden={hidden}> <Deck label="attention queues" hidden={hidden}>
<header className="page-bar"> <PageBar
<h2 className="page-title">queues</h2> title="queues"
<span className="deck-count readout"> count={loaded === null || total === 0 ? "" : `${total} waiting`}
{loaded === null || total === 0 ? "" : `${total} waiting`} status={status}
</span> />
<StatusSlot status={status} className="head-status readout" />
</header>
<QueueGroup <QueueGroup
id="no-pt" id="no-pt"
@@ -387,6 +388,6 @@ export function QueuesView({ hidden }: { hidden: boolean }) {
</>, </>,
)} )}
/> />
</main> </Deck>
); );
} }
+64 -45
View File
@@ -5,6 +5,11 @@
import { type KeyboardEvent, useEffect, useRef, useState } from "react"; import { type KeyboardEvent, useEffect, useRef, useState } from "react";
import { useNav } from "../context"; import { useNav } from "../context";
import { Icon } from "../icons"; import { Icon } from "../icons";
import { chain, cx, PANEL, PANEL_ACTIONS, PANEL_NOTE, seg, segmented } from "../look";
/** a pasted link or hash is evidence: it wraps rather than overflowing */
const INTAKE = "[overflow-wrap:anywhere]";
import { RatingChip, RowPoster, TitleText } from "../parts"; import { RatingChip, RowPoster, TitleText } from "../parts";
import { MovieRow, SeriesHitRow } from "../rows"; import { MovieRow, SeriesHitRow } from "../rows";
import { import {
@@ -18,7 +23,19 @@ import {
type TmdbMovie, type TmdbMovie,
type TmdbSeries, type TmdbSeries,
} from "../search"; } from "../search";
import { Chip, Control, DeckHead, flag, LampToggle, Row, StatusSlot, useStatus } from "../ui"; import {
Chip,
Control,
Deck,
DeckHead,
flag,
LampToggle,
PageBar,
Row,
Rows,
Section,
useStatus,
} from "../ui";
/** Which kind the deck is showing. `all` is both, and the default. */ /** Which kind the deck is showing. `all` is both, and the default. */
type KindFilter = "all" | "movie" | "series"; type KindFilter = "all" | "movie" | "series";
@@ -103,38 +120,44 @@ function AddPanel({
const done = state === "done"; const done = state === "done";
return ( return (
<div className="add-panel" ref={panel}> <div className={PANEL} ref={panel}>
{/* biome-ignore lint/a11y/useSemanticElements: a fieldset brings its own border, padding and min-width, which this group does not want */} {/* biome-ignore lint/a11y/useSemanticElements: a fieldset brings its own border, padding and min-width, which this group does not want */}
<div className="add-roots" role="group" aria-label="root folder"> <div
className="grid [grid-template-columns:repeat(auto-fit,minmax(12rem,1fr))] gap-2"
role="group"
aria-label="root folder"
>
{roots.map((root) => ( {roots.map((root) => (
<button <button
key={root.id} key={root.id}
type="button" type="button"
className="root-option" className="grid gap-1 min-h-control-h py-2 px-3 [font:inherit] text-left text-ink bg-panel-raised border border-line rounded-panel cursor-pointer [transition:border-color_150ms_var(--ease-out)] not-disabled:hover:border-line-strong aria-pressed:border-accent disabled:cursor-default disabled:opacity-60"
aria-pressed={root === selected} aria-pressed={root === selected}
disabled={done} disabled={done}
onClick={() => setSelected(root)} onClick={() => setSelected(root)}
> >
<span className="root-audience">{root.audience}</span> <span className="font-display text-md font-bold uppercase tracking-engraved leading-none">
<span className="root-policy readout dim">{root.policy_name}</span> {root.audience}
<span className="root-path readout dim">{root.path}</span> </span>
<span className="readout dim text-xs">{root.policy_name}</span>
<span className="readout dim text-xs">{root.path}</span>
</button> </button>
))} ))}
</div> </div>
{isSeries && ( {isSeries && (
<div className="add-autotrack"> <div className="grid justify-items-start gap-1">
<LampToggle <LampToggle
label="track future seasons" label="track future seasons"
pressed={autoTrack} pressed={autoTrack}
disabled={done} disabled={done}
onClick={() => setAutoTrack(!autoTrack)} onClick={() => setAutoTrack(!autoTrack)}
/> />
<p className="add-note"> <p className="m-0 text-xs text-ink-muted">
Seasons that air later are wanted automatically. Past seasons are not. Seasons that air later are wanted automatically. Past seasons are not.
</p> </p>
</div> </div>
)} )}
<div className="add-actions"> <div className={PANEL_ACTIONS}>
<Control <Control
text={ text={
state === "busy" state === "busy"
@@ -152,7 +175,7 @@ function AddPanel({
onClick={confirm} onClick={confirm}
/> />
<p <p
className="add-note readout" className={cx("readout", PANEL_NOTE)}
role="status" role="status"
data-tone={note?.tone} data-tone={note?.tone}
ref={noteRef} ref={noteRef}
@@ -210,8 +233,8 @@ function TmdbRow({
actions={[ actions={[
{ {
node: ( node: (
<span className="r-chevron" aria-hidden="true" data-done={flag(added)}> <span className="text-ink-faint" aria-hidden="true" data-done={flag(added)}>
<Icon name={added ? "check" : "plus"} /> <Icon name={added ? "check" : "plus"} className="size-chevron" />
</span> </span>
), ),
width: "icon", width: "icon",
@@ -235,14 +258,16 @@ function TmdbRow({
function ManualIntake({ kind, raw }: { kind: "magnet" | "torrent_url"; raw: string }) { function ManualIntake({ kind, raw }: { kind: "magnet" | "torrent_url"; raw: string }) {
const parsed = parseManualInput(kind, raw); const parsed = parseManualInput(kind, raw);
return ( return (
<article className="module intake"> <article className={cx(chain.module, "bg-panel border-line")}>
<header className="module-head"> <header className={chain.head}>
<h3 className="module-name">{kind === "magnet" ? "magnet" : "torrent"}</h3> <h3 className={cx(chain.name, "text-md")}>{kind === "magnet" ? "magnet" : "torrent"}</h3>
<span className="module-status readout">recognized</span> <span className={chain.status}>recognized</span>
</header> </header>
<p className="module-detail readout">{parsed.name ?? parsed.raw}</p> <p className={cx(chain.detail, INTAKE)}>{parsed.name ?? parsed.raw}</p>
{parsed.infohash && <p className="module-detail readout dim">{`btih ${parsed.infohash}`}</p>} {parsed.infohash && (
<p className="module-detail readout dim"> <p className={cx(chain.detail, INTAKE, "dim")}>{`btih ${parsed.infohash}`}</p>
)}
<p className={cx(chain.detail, INTAKE, "dim")}>
manual grab lands with the release buckets — nothing sent yet manual grab lands with the release buckets — nothing sent yet
</p> </p>
</article> </article>
@@ -395,20 +420,11 @@ export function SearchView({
all.filter((hit) => filter === "all" || hit.kind === filter).length; all.filter((hit) => filter === "all" || hit.kind === filter).length;
return ( return (
<main <Deck id="deck" label="search results" hidden={hidden} onKeyDown={onKeyDown}>
className="deck" <PageBar title="search" status={status} />
id="deck"
aria-label="search results"
hidden={hidden}
onKeyDown={onKeyDown}
>
<header className="page-bar">
<h2 className="page-title">search</h2>
<StatusSlot status={status} className="head-status readout" />
</header>
<div <div
className="segmented deck-filter" className={cx(segmented(), "deck-filter")}
role="toolbar" role="toolbar"
aria-label="show only one kind" aria-label="show only one kind"
hidden={!listed} hidden={!listed}
@@ -423,22 +439,25 @@ export function SearchView({
<button <button
key={value} key={value}
type="button" type="button"
className="seg" className={seg(kind === value)}
data-kind={value} data-kind={value}
aria-pressed={kind === value} aria-pressed={kind === value}
onClick={() => setKind(value)} onClick={() => setKind(value)}
> >
{label} {label}
<span className="filter-count" data-role="count"> <span
className={cx("tabular-nums", kind === value ? "text-ink-muted" : "text-ink-faint")}
data-role="count"
>
{listed ? countOf(value) : ""} {listed ? countOf(value) : ""}
</span> </span>
</button> </button>
))} ))}
</div> </div>
<section className="deck-group" hidden={library.length === 0} aria-labelledby="label-library"> <Section hidden={library.length === 0} labelledBy="label-library">
<DeckHead label="in library" labelId="label-library" count={library.length || ""} /> <DeckHead label="in library" labelId="label-library" count={library.length || ""} />
<ul className="deck-rows"> <Rows>
{/* §9.2: in-library hits read as whatever they are — a movie or a {/* §9.2: in-library hits read as whatever they are — a movie or a
series — and hold the order the API ranked them in. */} series — and hold the order the API ranked them in. */}
{library.map((hit) => {library.map((hit) =>
@@ -448,22 +467,22 @@ export function SearchView({
<SeriesHitRow key={`s${hit.id}`} series={hit} roots={roots} open={nav.openSeries} /> <SeriesHitRow key={`s${hit.id}`} series={hit} roots={roots} open={nav.openSeries} />
), ),
)} )}
</ul> </Rows>
</section> </Section>
<section className="deck-group" hidden={tmdbHits.length === 0} aria-labelledby="label-tmdb"> <Section hidden={tmdbHits.length === 0} labelledBy="label-tmdb">
<DeckHead label="on tmdb" labelId="label-tmdb" count={tmdbHits.length || ""} /> <DeckHead label="on tmdb" labelId="label-tmdb" count={tmdbHits.length || ""} />
<ul className="deck-rows"> <Rows>
{tmdbHits.map((hit) => ( {tmdbHits.map((hit) => (
<TmdbRow key={`${hit.kind}${hit.tmdb_id}`} hit={hit} fetchRoots={fetchRoots} /> <TmdbRow key={`${hit.kind}${hit.tmdb_id}`} hit={hit} fetchRoots={fetchRoots} />
))} ))}
</ul> </Rows>
</section> </Section>
<section className="deck-group" hidden={manual === null} aria-labelledby="label-manual"> <Section hidden={manual === null} labelledBy="label-manual">
<DeckHead label="manual grab" labelId="label-manual" /> <DeckHead label="manual grab" labelId="label-manual" />
{manual !== null && <ManualIntake kind={manual.kind} raw={manual.raw} />} {manual !== null && <ManualIntake kind={manual.kind} raw={manual.raw} />}
</section> </Section>
</main> </Deck>
); );
} }
+47 -27
View File
@@ -6,6 +6,7 @@ import { LAYER, type TvDeckRequest, useEscape, useNav } from "../context";
import { Hero, ProviderLink, RemovePanel, type RemoveSubject, TrailerLink } from "../detail"; import { Hero, ProviderLink, RemovePanel, type RemoveSubject, TrailerLink } from "../detail";
import { ArmedDeleteIcon } from "../icons"; import { ArmedDeleteIcon } from "../icons";
import { seriesStatusChipRedundant } from "../library"; import { seriesStatusChipRedundant } from "../library";
import { control, cx, detail, form } from "../look";
import { rottenTomatoesSearch, tmdbSeriesLink, tvdbLink, youtubeLink } from "../movie"; import { rottenTomatoesSearch, tmdbSeriesLink, tvdbLink, youtubeLink } from "../movie";
import { import {
audienceOf, audienceOf,
@@ -52,11 +53,14 @@ import {
ArmedDeleteWord, ArmedDeleteWord,
Chip, Chip,
Control, Control,
Deck,
DeckHead, DeckHead,
EmptyRow, EmptyRow,
IconControl, IconControl,
LampToggle, LampToggle,
Row, Row,
Rows,
Section,
SkeletonRows, SkeletonRows,
StatusSlot, StatusSlot,
useNote, useNote,
@@ -90,15 +94,18 @@ function WritingToggle({
pressed, pressed,
write, write,
focusId, focusId,
fill,
}: { }: {
label: string; label: string;
pressed: boolean; pressed: boolean;
write: () => Promise<boolean>; write: () => Promise<boolean>;
focusId?: string; focusId?: string;
fill?: boolean;
}) { }) {
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
return ( return (
<LampToggle <LampToggle
fill={fill}
label={label} label={label}
pressed={pressed} pressed={pressed}
disabled={busy} disabled={busy}
@@ -175,15 +182,19 @@ function SeasonRow({
<IconControl <IconControl
glyph="chevronRight" glyph="chevronRight"
label={`${short} episodes`} label={`${short} episodes`}
className="disclose-lead" look="lead"
iconClassName={cx(
"[transition:transform_200ms_var(--ease-out)]",
open && "[transform:rotate(90deg)]",
)}
aria-expanded={open} aria-expanded={open}
aria-controls={`episodes-${season.number}`} aria-controls={`episodes-${season.number}`}
onClick={onToggleOpen} onClick={onToggleOpen}
/> />
} }
title={name} title={name}
titleStyle="season"
// the season's name expands it too — the chevron stays the accessible control // the season's name expands it too — the chevron stays the accessible control
bodyClassName="r-toggle-body"
onBodyClick={(event) => { onBodyClick={(event) => {
if (event.target instanceof Element && event.target.closest("button, [role=button]")) { if (event.target instanceof Element && event.target.closest("button, [role=button]")) {
return; return;
@@ -270,13 +281,17 @@ function SeasonRow({
]} ]}
more={ more={
<> <>
<WritingToggle label="tracked" pressed={season.tracked} write={track} /> <WritingToggle fill label="tracked" pressed={season.tracked} write={track} />
{hasFiles && <ArmedDeleteWord label={deleteLabel} execute={removeFiles} />} {hasFiles && <ArmedDeleteWord label={deleteLabel} execute={removeFiles} />}
</> </>
} }
note={note} note={note}
tray={ tray={
<ul className="episodes" id={`episodes-${season.number}`} hidden={!open}> <ul
className="m-0 p-0 list-none [background:oklch(from_var(--panel)_l_c_h/50%)]"
id={`episodes-${season.number}`}
hidden={!open}
>
{season.episodes.map((episode) => ( {season.episodes.map((episode) => (
<EpisodeRow <EpisodeRow
key={episode.id} key={episode.id}
@@ -397,7 +412,11 @@ function EpisodeRow({
return ( return (
<Row <Row
kind="episode" kind="episode"
lead={<span className="lead-tag readout">{`E${two(episode.number)}`}</span>} lead={
<span className="readout w-control-h text-center text-xs font-semibold text-ink-faint">
{`E${two(episode.number)}`}
</span>
}
title={episode.title === "" ? "—" : episode.title} title={episode.title === "" ? "—" : episode.title}
meta={ meta={
<> <>
@@ -427,7 +446,7 @@ function EpisodeRow({
onDisk ? ( onDisk ? (
<ArmedDeleteWord label={deleteLabel} execute={removeFile} /> <ArmedDeleteWord label={deleteLabel} execute={removeFile} />
) : ( ) : (
<WritingToggle label="wanted" pressed={episode.wanted} write={want} /> <WritingToggle fill label="wanted" pressed={episode.wanted} write={want} />
) )
) : undefined ) : undefined
} }
@@ -681,10 +700,10 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b
<Control text="retry" quiet disabled={retrying} onClick={() => void retryRefresh()} /> <Control text="retry" quiet disabled={retrying} onClick={() => void retryRefresh()} />
</EmptyRow> </EmptyRow>
) : ( ) : (
<li className="r-empty readout"> <EmptyRow
<span className="lamp" data-state="probing" /> lead={<span className="lamp" data-state="probing" />}
{" refreshing metadata — seasons will appear here"} text=" refreshing metadata — seasons will appear here"
</li> />
) )
) : ( ) : (
<EmptyRow text="no seasons listed upstream" /> <EmptyRow text="no seasons listed upstream" />
@@ -695,7 +714,7 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b
const rootListed = series !== null && tvRoots.some((root) => root.id === series.root_id); const rootListed = series !== null && tvRoots.some((root) => root.id === series.root_id);
return ( return (
<main className="deck detail" aria-label="series detail" hidden={covered} ref={view}> <Deck detail label="series detail" hidden={covered} ref={view}>
<Hero <Hero
title={series?.title ?? ""} title={series?.title ?? ""}
year={series?.year ?? null} year={series?.year ?? null}
@@ -721,8 +740,8 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b
} }
/> />
<div className="actionbar"> <div className={detail.actionbar}>
<span className="actionbar-links"> <span className={detail.actionbarLinks}>
{metadata?.trailer && ( {metadata?.trailer && (
<TrailerLink href={youtubeLink(metadata.trailer.youtube_key)} title={title} /> <TrailerLink href={youtubeLink(metadata.trailer.youtube_key)} title={title} />
)} )}
@@ -730,13 +749,14 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b
<IconControl <IconControl
glyph="more" glyph="more"
label="library settings for this title" label="library settings for this title"
className="ml-auto"
aria-expanded={moreOpen} aria-expanded={moreOpen}
aria-controls="series-more-panel" aria-controls="series-more-panel"
onClick={() => setMoreOpen(!moreOpen)} onClick={() => setMoreOpen(!moreOpen)}
/> />
</div> </div>
<div className="more-panel" id="series-more-panel" hidden={!moreOpen}> <div className={detail.morePanel} id="series-more-panel" hidden={!moreOpen}>
<div className="more-links"> <div className={detail.moreLinks}>
{metadata !== null && ( {metadata !== null && (
<> <>
<ProviderLink <ProviderLink
@@ -762,12 +782,12 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b
</> </>
)} )}
</div> </div>
<label className="field more-field"> <label className={form.field}>
<span className="field-label" id="series-root-label"> <span className={form.label} id="series-root-label">
root root
</span> </span>
<select <select
className="form-input" className={cx(form.input, form.select)}
data-focus-id="series-root" data-focus-id="series-root"
aria-labelledby="series-root-label" aria-labelledby="series-root-label"
value={series === null ? "" : String(series.root_id)} value={series === null ? "" : String(series.root_id)}
@@ -786,7 +806,7 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b
</label> </label>
<button <button
type="button" type="button"
className="control control-quiet" className={control({ look: "quiet", fill: true, danger: true })}
data-kind="delete" data-kind="delete"
ref={removeButton} ref={removeButton}
aria-expanded={removeOpen} aria-expanded={removeOpen}
@@ -796,7 +816,7 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b
> >
remove from library remove from library
</button> </button>
<div className="remove-panel" id="series-remove-panel" hidden={!removeOpen}> <div className="@row:col-span-full" id="series-remove-panel" hidden={!removeOpen}>
{removeOpen && subject.current !== null && ( {removeOpen && subject.current !== null && (
<RemovePanel <RemovePanel
subject={subject.current} subject={subject.current}
@@ -809,11 +829,11 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b
)} )}
</div> </div>
</div> </div>
<StatusSlot status={status} className="deck-status readout" /> <StatusSlot status={status} variant="deck" />
<section className="deck-group" aria-labelledby="label-seasons"> <Section labelledBy="label-seasons">
<DeckHead label="seasons" labelId="label-seasons" labelClass="section-title" /> <DeckHead label="seasons" labelId="label-seasons" titled="section" />
<ul className="deck-rows seasons"> <Rows className="seasons">
{seasons === null && <SkeletonRows count={4} />} {seasons === null && <SkeletonRows count={4} />}
{seasons?.map((season) => ( {seasons?.map((season) => (
<SeasonRow <SeasonRow
@@ -833,8 +853,8 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b
/> />
))} ))}
{seasons !== null && seasons.length === 0 && seasonsEmpty} {seasons !== null && seasons.length === 0 && seasonsEmpty}
</ul> </Rows>
</section> </Section>
</main> </Deck>
); );
} }
+240 -198
View File
@@ -3,8 +3,10 @@
import { import {
type CSSProperties, type CSSProperties,
createContext,
type ReactNode, type ReactNode,
useCallback, useCallback,
useContext,
useEffect, useEffect,
useRef, useRef,
useState, useState,
@@ -12,6 +14,7 @@ import {
import { LAYER, useEscape, useLive, useNav } from "../context"; import { LAYER, useEscape, useLive, useNav } from "../context";
import type { Check, CheckStatus } from "../health"; import type { Check, CheckStatus } from "../health";
import { ArmedDeleteIcon, type IconName } from "../icons"; import { ArmedDeleteIcon, type IconName } from "../icons";
import { chain, control, form, PANEL, PANEL_ACTIONS, PANEL_NOTE } from "../look";
import type { Root } from "../search"; import type { Root } from "../search";
import { import {
deleteRow, deleteRow,
@@ -34,13 +37,16 @@ import {
Chip, Chip,
Control, Control,
cx, cx,
Deck,
DeckHead, DeckHead,
GroupNote, GroupNote,
IconControl, IconControl,
type Note, type Note,
NoteLine, NoteLine,
PageBar,
Row, Row,
StatusSlot, Rows,
Section,
useNote, useNote,
useStatus, useStatus,
} from "../ui"; } from "../ui";
@@ -81,37 +87,57 @@ function ChainModule({
master?: boolean; master?: boolean;
}) { }) {
return ( return (
<article className={cx("module", master && "module-master", area)}> <article
<header className="module-head"> className={cx(
chain.module,
area,
master
? "bg-panel-raised border-line-strong @cells:pt-6 @cells:px-4 @cells:pb-4"
: "bg-panel border-line",
)}
>
<header className={chain.head}>
<span <span
className={cx("lamp", master && "lamp-big")} className={cx("lamp", master && "lamp-big")}
data-state={module.state} data-state={module.state}
aria-hidden="true" aria-hidden="true"
style={{ "--strike": String(strike) } as CSSProperties} style={{ "--strike": String(strike) } as CSSProperties}
/> />
<h4 className="module-name">{name}</h4> <h4 className={cx(chain.name, master ? "text-lg" : "text-md")}>{name}</h4>
<span className="module-status readout" data-tone={module.tone}> <span className={chain.status} data-tone={module.tone}>
{module.word} {module.word}
</span> </span>
</header> </header>
<p className="module-role">{duty}</p> <p className={chain.role}>{duty}</p>
<p className="module-detail readout">{module.detail ?? defaultDetail}</p> <p className={chain.detail}>{module.detail ?? defaultDetail}</p>
</article> </article>
); );
} }
const TRACE = {
idle: { stroke: "stroke-line-strong", fill: "fill-line-strong" },
ok: { stroke: "stroke-signal-ok", fill: "fill-signal-ok" },
warn: { stroke: "stroke-signal-warn", fill: "fill-signal-warn" },
fault: { stroke: "stroke-signal-fault", fill: "fill-signal-fault" },
} as const;
function Bus({ area, tone }: { area: string; tone: Tone | null }) { function Bus({ area, tone }: { area: string; tone: Tone | null }) {
const trace = tone === null ? "idle" : tone;
return ( return (
<div className={cx("bus", area)} aria-hidden="true"> <div
className={cx("grid content-center justify-items-center h-8 @cells:h-auto", area)}
aria-hidden="true"
>
{/* the phone stacks the chain, so the trace turns to run downwards */}
<svg <svg
viewBox="0 0 40 8" viewBox="0 0 40 8"
preserveAspectRatio="none" preserveAspectRatio="none"
className="bus-trace" className="block w-8 h-2 [transform:rotate(90deg)] [transition:filter_300ms_var(--ease-out)] @cells:w-full @cells:[transform:none]"
data-tone={tone === null || tone === "idle" ? undefined : tone} data-tone={tone === null || tone === "idle" ? undefined : tone}
aria-hidden="true" aria-hidden="true"
> >
<line x1="0" y1="4" x2="32" y2="4" /> <line x1="0" y1="4" x2="32" y2="4" className={cx("stroke-1", TRACE[trace].stroke)} />
<path d="M32 0.5 39 4 32 7.5 Z" className="bus-arrow" /> <path d="M32 0.5 39 4 32 7.5 Z" className={TRACE[trace].fill} />
</svg> </svg>
</div> </div>
); );
@@ -120,16 +146,16 @@ function Bus({ area, tone }: { area: string; tone: Tone | null }) {
/** One lamp of the subtitle lane (#200): same module shape as the chain. */ /** One lamp of the subtitle lane (#200): same module shape as the chain. */
function SubtitleModule({ name, duty, check }: { name: string; duty: string; check: Check }) { function SubtitleModule({ name, duty, check }: { name: string; duty: string; check: Check }) {
return ( return (
<article className="module"> <article className={cx(chain.module, "bg-panel border-line")}>
<header className="module-head"> <header className={chain.head}>
<span className="lamp" data-state={check.status} /> <span className="lamp" data-state={check.status} />
<h2 className="module-name">{name}</h2> <h2 className={cx(chain.name, "text-md")}>{name}</h2>
<span className="module-status readout" data-tone={TONE_BY_STATUS[check.status]}> <span className={chain.status} data-tone={TONE_BY_STATUS[check.status]}>
{check.status} {check.status}
</span> </span>
</header> </header>
<p className="module-role">{duty}</p> <p className={chain.role}>{duty}</p>
<p className="module-detail readout">{check.detail ?? ""}</p> <p className={chain.detail}>{check.detail ?? ""}</p>
</article> </article>
); );
} }
@@ -191,39 +217,45 @@ function Chain() {
return ( return (
<> <>
<section className="chain-wrap" aria-label="signal chain"> <section className="@container pt-4" aria-label="signal chain">
<div className={cx("chain", probe !== null && "powered")}> {/* `chain powered` keys the lamps' one power-up flicker in components.css */}
<div
className={cx(
"chain w-full grid items-center gap-y-3 [grid-template-columns:1fr] [grid-template-areas:'tmdb'_'prow'_'t1'_'master'_'out'_'sink'] @cells:gap-y-6 @cells:[grid-template-columns:1fr_2.5rem_1.2fr_2.5rem_1fr] @cells:[grid-template-areas:'tmdb_t1_master_out_sink'_'prow_t2_master_out_sink']",
probe !== null && "powered",
)}
>
<ChainModule <ChainModule
name="tmdb" name="tmdb"
area="area-tmdb" area="[grid-area:tmdb]"
duty="metadata in" duty="metadata in"
defaultDetail="titles, languages, release dates" defaultDetail="titles, languages, release dates"
module={checks.tmdb} module={checks.tmdb}
strike={0} strike={0}
/> />
<Bus area="area-t1" tone={traces.tmdb} /> <Bus area="[grid-area:t1]" tone={traces.tmdb} />
<ChainModule <ChainModule
name="prowlarr" name="prowlarr"
area="area-prowlarr" area="[grid-area:prow]"
duty="indexers in" duty="indexers in"
defaultDetail="torznab search and rss" defaultDetail="torznab search and rss"
module={checks.prowlarr} module={checks.prowlarr}
strike={1} strike={1}
/> />
<Bus area="area-t2" tone={traces.prowlarr} /> <Bus area="@cells:[grid-area:t2]" tone={traces.prowlarr} />
<ChainModule <ChainModule
name="arr" name="arr"
area="area-master" area="[grid-area:master]"
duty="reconcile core" duty="reconcile core"
defaultDetail="decide · find · fetch · import" defaultDetail="decide · find · fetch · import"
module={master} module={master}
strike={2} strike={2}
master master
/> />
<Bus area="area-out" tone={traces.master} /> <Bus area="[grid-area:out]" tone={traces.master} />
<ChainModule <ChainModule
name="qbittorrent" name="qbittorrent"
area="area-qbittorrent" area="[grid-area:sink]"
duty="torrents out" duty="torrents out"
defaultDetail="webui · grab and seed" defaultDetail="webui · grab and seed"
module={checks.qbit} module={checks.qbit}
@@ -231,7 +263,11 @@ function Chain() {
/> />
</div> </div>
</section> </section>
<section className="chain-lane" aria-label="subtitle lane" hidden={lane === null}> <section
className="mt-4 grid [grid-template-columns:repeat(auto-fit,minmax(12rem,1fr))] gap-3 [align-items:stretch]"
aria-label="subtitle lane"
hidden={lane === null}
>
{lane?.map((entry) => ( {lane?.map((entry) => (
<SubtitleModule <SubtitleModule
key={entry.name} key={entry.name}
@@ -247,10 +283,18 @@ function Chain() {
/* ---- form primitives ---------------------------------------------------- */ /* ---- form primitives ---------------------------------------------------- */
/** The subtitle panel spaces its labels out: they head groups there, not just fields. */
const SpacedLabels = createContext(false);
function labelClass(spaced: boolean): string {
return cx("readout dim", form.label, spaced && "block mt-4 mx-0 mb-2");
}
function Field({ label, children }: { label: string; children: ReactNode }) { function Field({ label, children }: { label: string; children: ReactNode }) {
const spaced = useContext(SpacedLabels);
return ( return (
<div className="field"> <div className={form.field}>
<span className="field-label readout dim">{label}</span> <span className={labelClass(spaced)}>{label}</span>
{children} {children}
</div> </div>
); );
@@ -283,7 +327,7 @@ function TextInput({
<input <input
ref={ref} ref={ref}
type="text" type="text"
className="form-input readout" className={cx("readout", form.input)}
value={value} value={value}
placeholder={placeholder} placeholder={placeholder}
spellCheck={false} spellCheck={false}
@@ -299,12 +343,13 @@ function TextInput({
function NumberInput({ function NumberInput({
value, value,
onChange, onChange,
className, className = "w-full",
placeholder, placeholder,
...rest ...rest
}: { }: {
value: string; value: string;
onChange: (value: string) => void; onChange: (value: string) => void;
/** Width and flex: the full field by default. */
className?: string; className?: string;
placeholder?: string; placeholder?: string;
"aria-label"?: string; "aria-label"?: string;
@@ -312,7 +357,7 @@ function NumberInput({
return ( return (
<input <input
type="number" type="number"
className={cx("form-input readout form-num", className)} className={cx("readout", form.inputBare, className)}
value={value} value={value}
placeholder={placeholder} placeholder={placeholder}
onChange={(event) => onChange(event.target.value)} onChange={(event) => onChange(event.target.value)}
@@ -343,7 +388,7 @@ function Select({
return ( return (
<select <select
ref={ref} ref={ref}
className="form-input readout" className={cx("readout", form.input, form.select)}
value={value} value={value}
disabled={disabled} disabled={disabled}
onChange={(event) => onChange(event.target.value)} onChange={(event) => onChange(event.target.value)}
@@ -389,10 +434,10 @@ function PanelActions({
onCancel?: () => void; onCancel?: () => void;
}) { }) {
return ( return (
<div className="add-actions"> <div className={PANEL_ACTIONS}>
<Control text={saveLabel} disabled={busy} onClick={save} /> <Control text={saveLabel} disabled={busy} onClick={save} />
{onCancel && <Control text="cancel" quiet onClick={onCancel} />} {onCancel && <Control text="cancel" quiet onClick={onCancel} />}
<NoteLine note={note} className="add-note readout" /> <NoteLine note={note} className={cx("readout", PANEL_NOTE)} />
</div> </div>
); );
} }
@@ -432,8 +477,8 @@ function RootPanel({
}; };
return ( return (
<div className="edit-panel add-panel"> <div className={PANEL}>
<div className="form-grid"> <div className={form.grid}>
<Field label="kind"> <Field label="kind">
<Select <Select
options={["movie", "tv"]} options={["movie", "tv"]}
@@ -486,6 +531,10 @@ type SourceKey = (typeof SOURCES)[number];
const DV_PROFILES = ["5", "7", "8"] as const; const DV_PROFILES = ["5", "7", "8"] as const;
/** four numbers and a label share a phone's width, so the inputs shrink
* rather than push the line past the gutter */
const BAND_NUM = "w-full grow shrink basis-0 min-w-0 max-w-band";
function newPolicyDoc(): Omit<PolicyDoc, "id"> { function newPolicyDoc(): Omit<PolicyDoc, "id"> {
return { return {
name: "", name: "",
@@ -628,8 +677,8 @@ function PolicyPanel({
}; };
return ( return (
<div className="edit-panel add-panel"> <div className={PANEL}>
<div className="form-grid"> <div className={form.grid}>
<Field label="name"> <Field label="name">
<TextInput value={name} onChange={setName} placeholder="policy name" autoFocus /> <TextInput value={name} onChange={setName} placeholder="policy name" autoFocus />
</Field> </Field>
@@ -664,28 +713,28 @@ function PolicyPanel({
const set = (key: keyof BandFields) => (value: string) => const set = (key: keyof BandFields) => (value: string) =>
setBands({ ...bands, [resolution]: { ...band, [key]: value } }); setBands({ ...bands, [resolution]: { ...band, [key]: value } });
return ( return (
<div key={resolution} className="band-line" data-resolution={resolution}> <div key={resolution} className="flex items-center gap-2" data-resolution={resolution}>
<span className="field-label readout dim">{resolution}</span> <span className={cx(labelClass(false), "w-band-label")}>{resolution}</span>
<NumberInput <NumberInput
className="band-num" className={BAND_NUM}
value={band.floor} value={band.floor}
onChange={set("floor")} onChange={set("floor")}
aria-label={`${resolution} floor GiB`} aria-label={`${resolution} floor GiB`}
/> />
<NumberInput <NumberInput
className="band-num" className={BAND_NUM}
value={band.target} value={band.target}
onChange={set("target")} onChange={set("target")}
aria-label={`${resolution} target GiB`} aria-label={`${resolution} target GiB`}
/> />
<NumberInput <NumberInput
className="band-num" className={BAND_NUM}
value={band.penalty} value={band.penalty}
onChange={set("penalty")} onChange={set("penalty")}
aria-label={`${resolution} penalty points per GiB over`} aria-label={`${resolution} penalty points per GiB over`}
/> />
<NumberInput <NumberInput
className="band-num" className={BAND_NUM}
value={band.ceiling} value={band.ceiling}
onChange={set("ceiling")} onChange={set("ceiling")}
placeholder="∞" placeholder="∞"
@@ -763,7 +812,7 @@ function SettingsRow({
<Row <Row
kind="setting" kind="setting"
title={title} title={title}
titleClassName="readout" titleStyle="readout"
meta={chips.map((text) => <Chip key={text}>{text}</Chip>)} meta={chips.map((text) => <Chip key={text}>{text}</Chip>)}
actions={[ actions={[
{ {
@@ -935,129 +984,130 @@ function SubtitlesPanel({
}; };
return ( return (
<div className="add-panel subtitle-panel"> <SpacedLabels.Provider value={true}>
<div className="form-grid"> <div className={PANEL}>
<Field label="wanted languages"> <div className={form.grid}>
<TextInput value={wanted} onChange={setWanted} placeholder="pt-PT, en" /> <Field label="wanted languages">
</Field> <TextInput value={wanted} onChange={setWanted} placeholder="pt-PT, en" />
<Field label="translation engine"> </Field>
<Select <Field label="translation engine">
options={["none", ...settings.available_engines]} <Select
value={engine} options={["none", ...settings.available_engines]}
onChange={setEngine} value={engine}
disabled={!hasEngines} onChange={setEngine}
/> disabled={!hasEngines}
</Field> />
<Field label="remote command timeout (s)"> </Field>
<NumberInput value={timeout} onChange={setTimeoutValue} /> <Field label="remote command timeout (s)">
</Field> <NumberInput value={timeout} onChange={setTimeoutValue} />
</div> </Field>
{!hasEngines && ( </div>
<p className="add-note readout dim"> {!hasEngines && (
no translation engine is compiled into this binary — pick is unavailable <p className={cx("readout dim", PANEL_NOTE)}>
</p> no translation engine is compiled into this binary — pick is unavailable
)}
{/* Their own labelled row rather than two more cells in the grid above:
paired, they belong to one engine, and a base URL needs the width. */}
{hasOpenAi && (
<>
<p className="field-label readout dim">
openai-compatible endpoint — blank means its default
</p> </p>
<div className="form-grid"> )}
<Field label="base url"> {/* Their own labelled row rather than two more cells in the grid above:
<TextInput paired, they belong to one engine, and a base URL needs the width. */}
value={baseUrl} {hasOpenAi && (
onChange={setBaseUrl} <>
placeholder="optional — e.g. http://127.0.0.1:8080/v1" <p className={labelClass(true)}>openai-compatible endpoint — blank means its default</p>
aria-label="openai base url" <div className={form.grid}>
/> <Field label="base url">
</Field> <TextInput
<Field label="model"> value={baseUrl}
<TextInput onChange={setBaseUrl}
value={model} placeholder="optional — e.g. http://127.0.0.1:8080/v1"
onChange={setModel} aria-label="openai base url"
placeholder="optional — e.g. gpt-4o-mini"
aria-label="openai model"
/>
</Field>
</div>
</>
)}
{hasEngines && (
<>
<p className="field-label readout dim">translator daily budgets</p>
<div className="form-grid">
{settings.available_engines.map((name) => (
<Field key={name} label={name}>
<NumberInput
value={translators[name] ?? ""}
onChange={(value) => setTranslators({ ...translators, [name]: value })}
aria-label={`${name} daily budget`}
/> />
</Field> </Field>
))} <Field label="model">
</div> <TextInput
</> value={model}
)} onChange={setModel}
<p className="field-label readout dim">providers — enabled, and in priority order</p> placeholder="optional — e.g. gpt-4o-mini"
<ul className="provider-list"> aria-label="openai model"
{providers.map((entry, index) => (
<Row
key={entry.provider}
kind="provider"
lead={
<label className="provider-check">
<input
type="checkbox"
className="provider-toggle"
checked={entry.enabled}
aria-label={`enable ${entry.provider}`}
onChange={(event) => updateProvider(index, { enabled: event.target.checked })}
/> />
</label> </Field>
} </div>
title={entry.provider} </>
actions={[ )}
{ {hasEngines && (
node: ( <>
<p className={labelClass(true)}>translator daily budgets</p>
<div className={form.grid}>
{settings.available_engines.map((name) => (
<Field key={name} label={name}>
<NumberInput <NumberInput
className="provider-budget" value={translators[name] ?? ""}
value={entry.budget} onChange={(value) => setTranslators({ ...translators, [name]: value })}
onChange={(value) => updateProvider(index, { budget: value })} aria-label={`${name} daily budget`}
aria-label={`${entry.provider} daily budget`}
/> />
), </Field>
width: "word", ))}
}, </div>
{ </>
node: ( )}
<MoveButton <p className={labelClass(true)}>providers — enabled, and in priority order</p>
direction="up" <ul className="mt-0 mx-0 mb-3 p-0 list-none">
label={`move ${entry.provider} up`} {providers.map((entry, index) => (
disabled={index === 0} <Row
onClick={() => move(index, -1)} key={entry.provider}
kind="provider"
lead={
<label className="provider-check">
<input
type="checkbox"
className="size-line m-0 accent-accent"
checked={entry.enabled}
aria-label={`enable ${entry.provider}`}
onChange={(event) => updateProvider(index, { enabled: event.target.checked })}
/> />
), </label>
width: "icon", }
}, title={entry.provider}
{ actions={[
node: ( {
<MoveButton node: (
direction="down" <NumberInput
label={`move ${entry.provider} down`} className="w-budget"
disabled={index === providers.length - 1} value={entry.budget}
onClick={() => move(index, 1)} onChange={(value) => updateProvider(index, { budget: value })}
/> aria-label={`${entry.provider} daily budget`}
), />
width: "icon", ),
}, width: "word",
]} fill: false,
/> },
))} {
</ul> node: (
<PanelActions save={save} saveLabel="save subtitles" busy={busy} note={note} /> <MoveButton
</div> direction="up"
label={`move ${entry.provider} up`}
disabled={index === 0}
onClick={() => move(index, -1)}
/>
),
width: "icon",
},
{
node: (
<MoveButton
direction="down"
label={`move ${entry.provider} down`}
disabled={index === providers.length - 1}
onClick={() => move(index, 1)}
/>
),
width: "icon",
},
]}
/>
))}
</ul>
<PanelActions save={save} saveLabel="save subtitles" busy={busy} note={note} />
</div>
</SpacedLabels.Provider>
); );
} }
@@ -1116,33 +1166,31 @@ export function SettingsView({ hidden }: { hidden: boolean }) {
const reload = () => void load(); const reload = () => void load();
return ( return (
<main className="deck" aria-label="settings" hidden={hidden}> <Deck label="settings" hidden={hidden}>
<header className="page-bar"> <PageBar
<h2 className="page-title">settings</h2> title="settings"
<span className="deck-count readout"> count={
{loaded === null loaded === null ? "" : `${loaded.roots.length} roots · ${loaded.policies.length} policies`
? "" }
: `${loaded.roots.length} roots · ${loaded.policies.length} policies`} status={status}
</span> />
<StatusSlot status={status} className="head-status readout" />
</header>
<section className="deck-group" aria-labelledby="label-chain"> <Section labelledBy="label-chain">
<DeckHead label="signal chain" labelId="label-chain" labelClass="section-title" /> <DeckHead label="signal chain" labelId="label-chain" titled="section" />
<Chain /> <Chain />
</section> </Section>
<section className="deck-group" hidden={loaded === null} aria-labelledby="label-roots"> <Section hidden={loaded === null} labelledBy="label-roots">
<DeckHead label="roots" labelId="label-roots" labelClass="section-title"> <DeckHead label="roots" labelId="label-roots" titled="section">
<button <button
type="button" type="button"
className="control control-quiet head-action" className={cx(control({ look: "quiet" }), "ml-auto")}
onClick={() => setAddingRoot(true)} onClick={() => setAddingRoot(true)}
> >
add root add root
</button> </button>
</DeckHead> </DeckHead>
<ul className="deck-rows" key={loaded?.paint}> <Rows key={loaded?.paint}>
{loaded?.roots.map((root) => ( {loaded?.roots.map((root) => (
<SettingsRow <SettingsRow
key={root.id} key={root.id}
@@ -1161,7 +1209,7 @@ export function SettingsView({ hidden }: { hidden: boolean }) {
)} )}
/> />
))} ))}
</ul> </Rows>
{addingRoot && loaded !== null && ( {addingRoot && loaded !== null && (
<RootPanel <RootPanel
root={null} root={null}
@@ -1173,22 +1221,20 @@ export function SettingsView({ hidden }: { hidden: boolean }) {
onCancel={() => setAddingRoot(false)} onCancel={() => setAddingRoot(false)}
/> />
)} )}
</section> </Section>
<section className="deck-group" hidden={loaded === null} aria-labelledby="label-policies"> <Section hidden={loaded === null} labelledBy="label-policies">
<DeckHead label="policies" labelId="label-policies" labelClass="section-title"> <DeckHead label="policies" labelId="label-policies" titled="section">
<button <button
type="button" type="button"
className="control control-quiet head-action" className={cx(control({ look: "quiet" }), "ml-auto")}
onClick={() => setAddingPolicy(true)} onClick={() => setAddingPolicy(true)}
> >
add policy add policy
</button> </button>
</DeckHead> </DeckHead>
<div className="group-note"> <GroupNote short="Editing a policy rescores every title's releases straight away." />
<p>Editing a policy rescores every title's releases straight away.</p> <Rows key={loaded?.paint}>
</div>
<ul className="deck-rows" key={loaded?.paint}>
{loaded?.policies.map((policy) => { {loaded?.policies.map((policy) => {
const bandCount = Object.keys(policy.size_bands).length; const bandCount = Object.keys(policy.size_bands).length;
return ( return (
@@ -1207,7 +1253,7 @@ export function SettingsView({ hidden }: { hidden: boolean }) {
/> />
); );
})} })}
</ul> </Rows>
{addingPolicy && ( {addingPolicy && (
<PolicyPanel <PolicyPanel
policy={null} policy={null}
@@ -1218,14 +1264,10 @@ export function SettingsView({ hidden }: { hidden: boolean }) {
onCancel={() => setAddingPolicy(false)} onCancel={() => setAddingPolicy(false)}
/> />
)} )}
</section> </Section>
<section <Section hidden={loaded === null} labelledBy="label-settings-subtitles">
className="deck-group" <DeckHead label="subtitles" labelId="label-settings-subtitles" titled="section" />
hidden={loaded === null}
aria-labelledby="label-settings-subtitles"
>
<DeckHead label="subtitles" labelId="label-settings-subtitles" labelClass="section-title" />
<GroupNote <GroupNote
short="Provider logins and translator keys are not shown here." short="Provider logins and translator keys are not shown here."
more="They live in the daemon's config and environment (§10), along with the remote-command template." more="They live in the daemon's config and environment (§10), along with the remote-command template."
@@ -1235,7 +1277,7 @@ export function SettingsView({ hidden }: { hidden: boolean }) {
<SubtitlesPanel key={loaded.paint} settings={loaded.subtitles} onSaved={reload} /> <SubtitlesPanel key={loaded.paint} settings={loaded.subtitles} onSaved={reload} />
)} )}
</div> </div>
</section> </Section>
</main> </Deck>
); );
} }
+45 -17
View File
@@ -4,6 +4,7 @@
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { Buckets, type DeckState, type ReleaseActions } from "../buckets"; import { Buckets, type DeckState, type ReleaseActions } from "../buckets";
import { LAYER, type TvDeckRequest, useEscape, useNav } from "../context"; import { LAYER, type TvDeckRequest, useEscape, useNav } from "../context";
import { control, cx, detail, type } from "../look";
import { import {
blacklistAdvice, blacklistAdvice,
blacklistClass, blacklistClass,
@@ -16,7 +17,9 @@ import {
type SeasonPackState, type SeasonPackState,
} from "../releases"; } from "../releases";
import { waiveAndGrabTv } from "../series"; import { waiveAndGrabTv } from "../series";
import { IconControl, type Status, StatusSlot } from "../ui"; import { Deck, IconControl, type Status, StatusSlot } from "../ui";
const NOTICE_LINE = "m-0 max-w-notice text-sm text-ink-muted";
/** §6.2: the sweep runs on the daemon's cadence. Poll modestly, give up softly. */ /** §6.2: the sweep runs on the daemon's cadence. Poll modestly, give up softly. */
const TV_SWEEP_POLL_MS = 5000; const TV_SWEEP_POLL_MS = 5000;
@@ -358,51 +361,76 @@ export function TvDeckView({ request }: { request: TvDeckRequest }) {
} }
return ( return (
<main className="deck detail" aria-label="season and episode releases"> <Deck detail label="season and episode releases">
<header className="page-head"> {/* a detail page without a hero still gives its head room under the rail */}
<IconControl glyph="back" label="back" ref={back} onClick={nav.close} /> <header className={cx(detail.pageHead, "pt-2")}>
<div className="page-id"> <IconControl glyph="back" label="back" look="bare" ref={back} onClick={nav.close} />
<h2 className="page-title">{request.title}</h2> <div className="grid min-w-0">
<span className="page-sub readout">{request.sub ?? ""}</span> <h2 className={cx(type.pageTitle, "flex-initial")}>{request.title}</h2>
<span className={cx(detail.pageMeta, "truncate")}>{request.sub ?? ""}</span>
</div> </div>
</header> </header>
<div className="actionbar"> <div className={detail.actionbar}>
<button <button
type="button" type="button"
className="control" className={control()}
disabled={sweeping} disabled={sweeping}
onClick={() => void startSweep()} onClick={() => void startSweep()}
> >
search indexers search indexers
</button> </button>
</div> </div>
<StatusSlot status={status} className="deck-status readout" /> <StatusSlot status={status} variant="deck" />
<section <section
className="deck-notice" className={cx(
"mb-6 pt-3 px-4 pb-4 border rounded-panel",
failure === null
? "bg-panel border-line"
: {
policy:
"[background:oklch(from_var(--signal-warn)_l_c_h/7%)] [border-color:oklch(from_var(--signal-warn)_l_c_h/40%)]",
release:
"[background:oklch(from_var(--signal-fault)_l_c_h/7%)] [border-color:oklch(from_var(--signal-fault)_l_c_h/40%)]",
unknown: "bg-panel border-line",
}[blacklistClass(failure.reason)],
)}
hidden={failure === null} hidden={failure === null}
data-blacklist={failure === null ? undefined : blacklistClass(failure.reason)} data-blacklist={failure === null ? undefined : blacklistClass(failure.reason)}
aria-labelledby="tv-failure-label" aria-labelledby="tv-failure-label"
> >
<h3 className="deck-label" id="tv-failure-label"> <h3
className={cx(
type.label,
"mb-2",
failure === null
? "text-ink-muted"
: {
policy: "text-signal-warn",
release: "text-signal-fault",
unknown: "text-ink-muted",
}[blacklistClass(failure.reason)],
)}
id="tv-failure-label"
>
pack abandoned at import pack abandoned at import
</h3> </h3>
<p className="notice-release readout"> <p className="readout mt-0 mx-0 mb-2 [overflow-wrap:anywhere] text-xs text-ink">
{failure === null {failure === null
? "" ? ""
: failure.failed_at === null : failure.failed_at === null
? failure.release ? failure.release
: `${failure.release} · ${formatSweepAge(failure.failed_at)}`} : `${failure.release} · ${formatSweepAge(failure.failed_at)}`}
</p> </p>
<p className="notice-line">{failureWhat}</p> <p className={NOTICE_LINE}>{failureWhat}</p>
<p className="notice-line"> <p className={cx(NOTICE_LINE, "mt-2")}>
{failure === null ? "" : `${blacklistAdvice(failure.reason)}.`} {failure === null ? "" : `${blacklistAdvice(failure.reason)}.`}
</p> </p>
<p className="notice-line dim"> <p className={cx(NOTICE_LINE, "mt-2 dim")}>
Nothing was imported, and the torrent was left where it is: nothing is deleted early to Nothing was imported, and the torrent was left where it is: nothing is deleted early to
satisfy the library (§7.3). satisfy the library (§7.3).
</p> </p>
</section> </section>
<Buckets state={deck} actions={actions} /> <Buckets state={deck} actions={actions} />
</main> </Deck>
); );
} }