refactor(web): chips and type roles as utilities
A chip's look is read off the data attributes it already carries, in the order the board always resolved them. Lamps stay in CSS: the glow and the power-up are effects, not layout. Refs #280 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e07db5a042
commit
6c183c5d98
@@ -272,48 +272,6 @@ body {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
/* ---- type roles --------------------------------------------------------- */
|
||||
|
||||
/* one role per job: page title, section, group label, row title, readout */
|
||||
.page-title {
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--text-lg);
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
line-height: 1.1;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin: 0;
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--text-md);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
line-height: 1.2;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
/* the engraved micro-label: a group inside a section, never a kicker */
|
||||
.deck-label {
|
||||
margin: 0;
|
||||
font-size: var(--text-2xs);
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.12em;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.deck-count {
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-faint);
|
||||
}
|
||||
|
||||
/* ---- glyphs ---------------------------------------------------------------- */
|
||||
|
||||
.icon {
|
||||
@@ -355,188 +313,6 @@ body {
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
|
||||
/* ---- chips ---------------------------------------------------------------- */
|
||||
|
||||
/* a label, not a target: shorter than a control, one line always */
|
||||
.chip {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
height: var(--chip-h);
|
||||
padding: 0 var(--space-2);
|
||||
background: var(--panel-raised);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 3px;
|
||||
font-family: var(--font-readout);
|
||||
font-size: var(--text-2xs);
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.chip .icon {
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
stroke-width: 1.7;
|
||||
}
|
||||
|
||||
/* a chip that explains itself on tap (§9.6 tooltips have no touch) */
|
||||
.chip[data-explain],
|
||||
.chip[role="button"],
|
||||
button.chip {
|
||||
font: inherit;
|
||||
font-family: var(--font-readout);
|
||||
font-size: var(--text-2xs);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
color 150ms var(--ease-out),
|
||||
border-color 150ms var(--ease-out);
|
||||
}
|
||||
|
||||
.chip[data-explain]:hover,
|
||||
.chip[data-explain][aria-expanded="true"] {
|
||||
border-color: currentColor;
|
||||
}
|
||||
|
||||
/* release verdicts */
|
||||
.chip[data-verdict="eligible"] {
|
||||
color: var(--verdict-eligible);
|
||||
border-color: oklch(from var(--verdict-eligible) l c h / 45%);
|
||||
}
|
||||
|
||||
/* the dashed border is the visible mark of a relaxed rule */
|
||||
.chip[data-verdict="waived"] {
|
||||
color: var(--verdict-waived);
|
||||
border-style: dashed;
|
||||
border-color: oklch(from var(--verdict-waived) l c h / 55%);
|
||||
}
|
||||
|
||||
.chip[data-verdict="rejected"] {
|
||||
color: var(--verdict-rejected);
|
||||
}
|
||||
|
||||
/* a subtitle wanted and not yet on disk is the system's errand, not yours */
|
||||
.chip[data-verdict="wanted"] {
|
||||
color: var(--ink);
|
||||
border-color: var(--line-strong);
|
||||
}
|
||||
|
||||
/* #227: blacklisted at import — the policy's own floor (amber, act on it) or
|
||||
the release itself broken (fault red) */
|
||||
.chip[data-blacklist="policy"] {
|
||||
color: var(--signal-warn);
|
||||
border-color: oklch(from var(--signal-warn) l c h / 55%);
|
||||
}
|
||||
|
||||
.chip[data-blacklist="release"] {
|
||||
color: var(--signal-fault);
|
||||
border-color: oklch(from var(--signal-fault) l c h / 55%);
|
||||
}
|
||||
|
||||
/* media state (§4.2): green on disk, violet downloading; wanted-and-missing
|
||||
is ink — the system is on it, nothing needs you yet */
|
||||
.chip[data-movie-state="available"] {
|
||||
color: var(--signal-ok);
|
||||
border-color: oklch(from var(--signal-ok) l c h / 45%);
|
||||
}
|
||||
|
||||
.chip[data-movie-state="downloading"] {
|
||||
color: var(--status-airing);
|
||||
border-color: oklch(from var(--status-airing) l c h / 45%);
|
||||
}
|
||||
|
||||
.chip[data-movie-state="missing"][data-wanted="true"] {
|
||||
color: var(--ink);
|
||||
border-color: var(--line-strong);
|
||||
}
|
||||
|
||||
/* §9.8: the slot is refilled in place by the poll and takes no box itself */
|
||||
.dl-slot {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
/* §9.8: live download state, fixed width so 9% → 10% never moves a neighbour */
|
||||
.dl-chip {
|
||||
min-width: 7ch;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.dl-chip[data-dl-phase="downloading"] {
|
||||
color: var(--status-airing);
|
||||
border-color: oklch(from var(--status-airing) l c h / 45%);
|
||||
}
|
||||
|
||||
.dl-chip[data-dl-phase="stalled"] {
|
||||
color: var(--signal-warn);
|
||||
border-color: oklch(from var(--signal-warn) l c h / 55%);
|
||||
}
|
||||
|
||||
.dl-chip[data-dl-phase="errored"] {
|
||||
color: var(--signal-fault);
|
||||
border-color: oklch(from var(--signal-fault) l c h / 55%);
|
||||
}
|
||||
|
||||
.dl-chip[data-dl-phase="seeding"] {
|
||||
color: var(--signal-ok);
|
||||
border-color: oklch(from var(--signal-ok) l c h / 45%);
|
||||
}
|
||||
|
||||
/* library status (§4.2): violet while live, green once complete; incomplete
|
||||
and waiting are neutral — amber is kept for what needs you */
|
||||
.chip[data-status="airing"] {
|
||||
color: var(--status-airing);
|
||||
border-color: oklch(from var(--status-airing) l c h / 45%);
|
||||
}
|
||||
|
||||
.chip[data-status="incomplete"] {
|
||||
color: var(--ink);
|
||||
border-color: var(--line-strong);
|
||||
}
|
||||
|
||||
.chip[data-status="complete"],
|
||||
.chip[data-status="ended"],
|
||||
.chip[data-counts="complete"] {
|
||||
color: var(--signal-ok);
|
||||
border-color: oklch(from var(--signal-ok) l c h / 45%);
|
||||
}
|
||||
|
||||
.chip[data-counts="partial"] {
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
/* issue 122: gone upstream while its file remained — a conflict, amber dashed */
|
||||
.chip[data-flag="vanished"] {
|
||||
color: var(--signal-warn);
|
||||
border-style: dashed;
|
||||
border-color: oklch(from var(--signal-warn) l c h / 55%);
|
||||
}
|
||||
|
||||
/* a machine translation reads as machine-made (§15) — the relaxed-case dash */
|
||||
.chip[data-mt="true"] {
|
||||
border-style: dashed;
|
||||
}
|
||||
|
||||
.chip[data-tone="fault"] {
|
||||
color: var(--signal-fault);
|
||||
border-color: oklch(from var(--signal-fault) l c h / 55%);
|
||||
}
|
||||
|
||||
/* a chip whose whole label is its glyph */
|
||||
.chip-glyph {
|
||||
min-width: var(--chip-h);
|
||||
justify-content: center;
|
||||
padding: 0 var(--space-1);
|
||||
}
|
||||
|
||||
.star {
|
||||
width: 0.625rem;
|
||||
height: 0.625rem;
|
||||
flex: none;
|
||||
fill: var(--ink);
|
||||
}
|
||||
|
||||
/* ---- the row ------------------------------------------------------------------ */
|
||||
|
||||
/* lead | body | actions, then the tray full width. The body is minmax(0, 1fr):
|
||||
@@ -612,10 +388,6 @@ button.chip {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.r-meta [data-pri="2"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.r-sub {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
@@ -937,10 +709,6 @@ button.chip {
|
||||
}
|
||||
|
||||
@container (min-width: 40rem) {
|
||||
.r-meta [data-pri="2"] {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.r-slot[data-wide] {
|
||||
display: flex;
|
||||
}
|
||||
@@ -1198,10 +966,6 @@ button.chip {
|
||||
padding-top: var(--space-2);
|
||||
}
|
||||
|
||||
.page-head .page-title {
|
||||
flex: 0 1 auto;
|
||||
}
|
||||
|
||||
.page-id {
|
||||
display: grid;
|
||||
min-width: 0;
|
||||
@@ -1389,10 +1153,6 @@ button.chip {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: var(--text-xl);
|
||||
}
|
||||
|
||||
.more-panel {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
align-items: end;
|
||||
@@ -1492,18 +1252,6 @@ button.chip {
|
||||
border-color: oklch(from var(--signal-fault) l c h / 40%);
|
||||
}
|
||||
|
||||
.deck-notice .deck-label {
|
||||
margin-bottom: var(--space-2);
|
||||
}
|
||||
|
||||
.deck-notice[data-blacklist="policy"] .deck-label {
|
||||
color: var(--signal-warn);
|
||||
}
|
||||
|
||||
.deck-notice[data-blacklist="release"] .deck-label {
|
||||
color: var(--signal-fault);
|
||||
}
|
||||
|
||||
.notice-release {
|
||||
margin: 0 0 var(--space-2);
|
||||
overflow-wrap: anywhere;
|
||||
@@ -1533,17 +1281,6 @@ button.chip {
|
||||
|
||||
/* ---- subtitles (§15, §9.6) -------------------------------------------- */
|
||||
|
||||
/* the one subtitle chip a file's row carries: it opens the panel */
|
||||
.subs-chip .icon {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.subs-chip:hover,
|
||||
.subs-chip:focus-visible,
|
||||
.subs-chip[aria-expanded="true"] {
|
||||
border-color: currentColor;
|
||||
}
|
||||
|
||||
/* the languages read as one string, as wide as the wanted set can need */
|
||||
.subs-chip-langs {
|
||||
display: inline-flex;
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
|
||||
import { type CSSProperties, type ReactNode, useEffect, useRef, useState } from "react";
|
||||
import { Icon, ProviderMark, Star } from "./icons";
|
||||
import { control } from "./look";
|
||||
import { control, type } from "./look";
|
||||
import { formatMetaLine, formatRating, formatVoteCount, tmdbImage } from "./movie";
|
||||
import { type ActionOutcome, formatSize, totalSize } from "./releases";
|
||||
import { cx, flag, IconControl, IconLink, type Note, NoteLine } from "./ui";
|
||||
@@ -66,7 +66,7 @@ export function Hero({
|
||||
>
|
||||
<header className="page-head">
|
||||
<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}
|
||||
</h2>
|
||||
<span className="page-year readout">{year === null ? "" : year}</span>
|
||||
|
||||
+5
-2
@@ -105,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. */
|
||||
export function Star() {
|
||||
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" />
|
||||
</svg>
|
||||
);
|
||||
@@ -212,7 +212,10 @@ export function ArmedDeleteIcon({
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon name={armed ? "check" : "trash"} className={compact ? "size-3" : undefined} />
|
||||
<Icon
|
||||
name={armed ? "check" : "trash"}
|
||||
className={compact ? "size-3 [stroke-width:1.7]" : undefined}
|
||||
/>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
+112
@@ -143,3 +143,115 @@ export function seg(pressed: boolean, icon = false): string {
|
||||
: "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]";
|
||||
|
||||
+7
-6
@@ -6,6 +6,7 @@ import { useLive } from "./context";
|
||||
import { downloadChipDetail, downloadChipLabel, findDownload } from "./downloads";
|
||||
import { Icon, Star } from "./icons";
|
||||
import { waiverLabel } from "./library";
|
||||
import { CHIP_ICON } from "./look";
|
||||
import { formatRating, formatVoteCount, tmdbImage } from "./movie";
|
||||
import { Chip, type Say } from "./ui";
|
||||
|
||||
@@ -54,7 +55,7 @@ export function MediaStateChip({ state, wanted }: { state: string; wanted: boole
|
||||
// makes the word reachable once the glyph replaced it
|
||||
return (
|
||||
<Chip role="img" aria-label={state} data-movie-state={state} data-wanted={String(wanted)}>
|
||||
<Icon name="check" />
|
||||
<Icon name="check" className={CHIP_ICON} />
|
||||
</Chip>
|
||||
);
|
||||
}
|
||||
@@ -78,13 +79,13 @@ export function WaiverChip({ waiver, say }: { waiver: unknown; say?: Say }) {
|
||||
}
|
||||
return (
|
||||
<Chip
|
||||
base="chip chip-glyph"
|
||||
glyph
|
||||
data-verdict="waived"
|
||||
aria-label={label}
|
||||
role={say ? undefined : "img"}
|
||||
explain={say ? { text: `imported below policy — ${label}`, say, tone: "warn" } : undefined}
|
||||
>
|
||||
<Icon name="warning" />
|
||||
<Icon name="warning" className={CHIP_ICON} />
|
||||
</Chip>
|
||||
);
|
||||
}
|
||||
@@ -109,10 +110,10 @@ export function DownloadChip({
|
||||
const { downloads } = useLive();
|
||||
const download = findDownload(downloads, targetKind, targetId);
|
||||
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 && (
|
||||
<Chip
|
||||
className="dl-chip"
|
||||
download
|
||||
data-dl-phase={download.phase}
|
||||
aria-label={`download ${downloadChipDetail(download)}`}
|
||||
explain={say ? { text: `download ${downloadChipDetail(download)}`, say } : undefined}
|
||||
@@ -148,7 +149,7 @@ export function CountsChip({
|
||||
}) {
|
||||
return (
|
||||
<Chip data-counts={countsTone(available, total)} aria-label={ariaLabel}>
|
||||
{glyph && <Icon name="disk" />}
|
||||
{glyph && <Icon name="disk" className={CHIP_ICON} />}
|
||||
{label}
|
||||
</Chip>
|
||||
);
|
||||
|
||||
@@ -79,6 +79,10 @@
|
||||
--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;
|
||||
|
||||
--container-deck: var(--deck-max);
|
||||
--container-measure: var(--measure);
|
||||
@@ -105,6 +109,7 @@
|
||||
--radius-pill: 999px;
|
||||
--radius-round: 50%;
|
||||
--radius-micro: 2px;
|
||||
--radius-chip: 3px;
|
||||
|
||||
--font-weight-semibold: 600;
|
||||
--font-weight-bold: 700;
|
||||
|
||||
+12
-4
@@ -4,7 +4,7 @@
|
||||
|
||||
import { type ReactNode, useEffect, useRef, useState } from "react";
|
||||
import { ArmedDeleteIcon, Icon } from "./icons";
|
||||
import { control, seg, segmented } from "./look";
|
||||
import { CHIP_ICON, chip as chipLook, control, cx, seg, segmented } from "./look";
|
||||
import { fileName } from "./movie";
|
||||
import {
|
||||
cachedSubtitleOptions,
|
||||
@@ -539,7 +539,13 @@ export function useSubtitleSection(
|
||||
const chip = (
|
||||
<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-controls={panelId}
|
||||
data-verdict={summary.satisfied ? "eligible" : "wanted"}
|
||||
@@ -551,7 +557,7 @@ 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
|
||||
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. */}
|
||||
@@ -567,7 +573,9 @@ export function useSubtitleSection(
|
||||
{/* §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
|
||||
moves the row's other chips. */}
|
||||
<span className="subs-chip-mark">{summary.satisfied && <Icon name="check" />}</span>
|
||||
<span className="subs-chip-mark">
|
||||
{summary.satisfied && <Icon name="check" className={cx(CHIP_ICON, "opacity-70")} />}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
|
||||
|
||||
+42
-12
@@ -16,7 +16,7 @@ import {
|
||||
useState,
|
||||
} from "react";
|
||||
import { Icon, type IconName, useArmed } from "./icons";
|
||||
import { type ControlLook, control, cx, toggle, toggleLamp, toggleState } from "./look";
|
||||
import { type ControlLook, chip, control, cx, toggle, toggleLamp, toggleState, type } from "./look";
|
||||
|
||||
export type Tone = "fault" | "warn";
|
||||
|
||||
@@ -359,17 +359,43 @@ function useExplain(explain: Explain | undefined) {
|
||||
}
|
||||
|
||||
export interface ChipProps extends HTMLAttributes<HTMLSpanElement> {
|
||||
/** `chip readout` by default; a glyph chip drops the readout face. */
|
||||
base?: string;
|
||||
/** The whole label is a glyph. */
|
||||
glyph?: boolean;
|
||||
/** A live download's chip. */
|
||||
download?: boolean;
|
||||
explain?: Explain;
|
||||
[data: `data-${string}`]: string | undefined;
|
||||
}
|
||||
|
||||
/** A chip, the §9.3 column unit. */
|
||||
export function Chip({ base = "chip readout", className, explain, children, ...rest }: ChipProps) {
|
||||
/** A chip, the §9.3 column unit. Its look is read off its own data attributes. */
|
||||
export function Chip({ glyph, download, className, explain, children, ...rest }: ChipProps) {
|
||||
const explainProps = useExplain(explain);
|
||||
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}
|
||||
</span>
|
||||
);
|
||||
@@ -612,8 +638,8 @@ export function PageBar({
|
||||
}) {
|
||||
return (
|
||||
<header className="flex items-center gap-3 min-h-control-h mb-4">
|
||||
<h2 className="page-title capitalize">{title}</h2>
|
||||
{count !== undefined && <span className="deck-count readout flex-none">{count}</span>}
|
||||
<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>
|
||||
@@ -661,14 +687,15 @@ export function DeckHead({
|
||||
label,
|
||||
labelId,
|
||||
as: Heading = "h3",
|
||||
labelClass = "deck-label",
|
||||
titled = "label",
|
||||
count,
|
||||
children,
|
||||
}: {
|
||||
label: string;
|
||||
labelId?: string;
|
||||
as?: "h3" | "h4";
|
||||
labelClass?: string;
|
||||
/** A page's section title, or a group's engraved label. */
|
||||
titled?: "section" | "label";
|
||||
count?: string | number | null;
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
@@ -681,10 +708,13 @@ export function DeckHead({
|
||||
nested ? "min-h-chip-h pt-3" : "min-h-control-h",
|
||||
)}
|
||||
>
|
||||
<Heading className={labelClass} id={labelId}>
|
||||
<Heading
|
||||
className={titled === "section" ? type.sectionTitle : cx(type.label, "text-ink-muted")}
|
||||
id={labelId}
|
||||
>
|
||||
{label}
|
||||
</Heading>
|
||||
{count !== undefined && <span className="deck-count readout">{count ?? ""}</span>}
|
||||
{count !== undefined && <span className={type.count}>{count ?? ""}</span>}
|
||||
{children}
|
||||
</header>
|
||||
);
|
||||
|
||||
@@ -556,7 +556,7 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
|
||||
<DeckHead
|
||||
label="on disk"
|
||||
labelId="label-disk"
|
||||
labelClass="section-title"
|
||||
titled="section"
|
||||
count={files?.kind === "files" ? files.files.length : ""}
|
||||
/>
|
||||
<Rows>
|
||||
@@ -580,7 +580,7 @@ export function MovieView({ movieId, toReleases }: { movieId: number; toReleases
|
||||
</Section>
|
||||
|
||||
<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} variant="deck" />
|
||||
<Buckets state={deck} actions={actions} />
|
||||
</Section>
|
||||
|
||||
@@ -821,7 +821,7 @@ export function SeriesView({ seriesId, covered }: { seriesId: number; covered: b
|
||||
<StatusSlot status={status} variant="deck" />
|
||||
|
||||
<Section labelledBy="label-seasons">
|
||||
<DeckHead label="seasons" labelId="label-seasons" labelClass="section-title" />
|
||||
<DeckHead label="seasons" labelId="label-seasons" titled="section" />
|
||||
<Rows className="seasons">
|
||||
{seasons === null && <SkeletonRows count={4} />}
|
||||
{seasons?.map((season) => (
|
||||
|
||||
@@ -1131,12 +1131,12 @@ export function SettingsView({ hidden }: { hidden: boolean }) {
|
||||
/>
|
||||
|
||||
<Section labelledBy="label-chain">
|
||||
<DeckHead label="signal chain" labelId="label-chain" labelClass="section-title" />
|
||||
<DeckHead label="signal chain" labelId="label-chain" titled="section" />
|
||||
<Chain />
|
||||
</Section>
|
||||
|
||||
<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
|
||||
type="button"
|
||||
className={cx(control({ look: "quiet" }), "ml-auto")}
|
||||
@@ -1179,7 +1179,7 @@ export function SettingsView({ hidden }: { hidden: boolean }) {
|
||||
</Section>
|
||||
|
||||
<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
|
||||
type="button"
|
||||
className={cx(control({ look: "quiet" }), "ml-auto")}
|
||||
@@ -1222,7 +1222,7 @@ export function SettingsView({ hidden }: { hidden: boolean }) {
|
||||
</Section>
|
||||
|
||||
<Section hidden={loaded === null} labelledBy="label-settings-subtitles">
|
||||
<DeckHead label="subtitles" labelId="label-settings-subtitles" labelClass="section-title" />
|
||||
<DeckHead label="subtitles" labelId="label-settings-subtitles" titled="section" />
|
||||
<GroupNote
|
||||
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."
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Buckets, type DeckState, type ReleaseActions } from "../buckets";
|
||||
import { LAYER, type TvDeckRequest, useEscape, useNav } from "../context";
|
||||
import { control } from "../look";
|
||||
import { control, cx, type } from "../look";
|
||||
import {
|
||||
blacklistAdvice,
|
||||
blacklistClass,
|
||||
@@ -364,7 +364,7 @@ export function TvDeckView({ request }: { request: TvDeckRequest }) {
|
||||
<header className="page-head pt-2">
|
||||
<IconControl glyph="back" label="back" look="bare" ref={back} onClick={nav.close} />
|
||||
<div className="page-id">
|
||||
<h2 className="page-title">{request.title}</h2>
|
||||
<h2 className={cx(type.pageTitle, "flex-initial")}>{request.title}</h2>
|
||||
<span className="page-sub readout">{request.sub ?? ""}</span>
|
||||
</div>
|
||||
</header>
|
||||
@@ -385,7 +385,20 @@ export function TvDeckView({ request }: { request: TvDeckRequest }) {
|
||||
data-blacklist={failure === null ? undefined : blacklistClass(failure.reason)}
|
||||
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
|
||||
</h3>
|
||||
<p className="notice-release readout">
|
||||
|
||||
Reference in New Issue
Block a user