refactor(web): release deck and subtitle panel as utilities
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
4254c1bde1
commit
8ed861448d
+3
-3
@@ -105,7 +105,7 @@ function Paged<T>({
|
||||
<Fragment key={keyOf(item)}>{render(item)}</Fragment>
|
||||
))}
|
||||
{rest > 0 && (
|
||||
<li className="bucket-more">
|
||||
<li className="pt-3">
|
||||
<Control
|
||||
text={`show ${rest} more`}
|
||||
quiet
|
||||
@@ -190,7 +190,7 @@ function CollapsedBucket({
|
||||
export function Buckets({ state, actions }: { state: DeckState; actions: ReleaseActions }) {
|
||||
if (state.kind !== "releases") {
|
||||
return (
|
||||
<div className="buckets">
|
||||
<div className="@container">
|
||||
<Section hidden={state.kind === "none"}>
|
||||
<DeckHead as="h4" label="eligible" count="" />
|
||||
<Colhead />
|
||||
@@ -225,7 +225,7 @@ function PaintedBuckets({
|
||||
// forcing; a row below policy is offered already.
|
||||
const forceable = rejected.filter(overridable).length;
|
||||
return (
|
||||
<div className="buckets">
|
||||
<div className="@container">
|
||||
<Section>
|
||||
<DeckHead as="h4" label="eligible" count={eligible.length} />
|
||||
<Colhead />
|
||||
|
||||
@@ -376,132 +376,6 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- release deck (§9.3) ------------------------------------------------- */
|
||||
|
||||
.buckets {
|
||||
container-type: inline-size;
|
||||
}
|
||||
|
||||
.bucket-more {
|
||||
padding-top: var(--space-3);
|
||||
}
|
||||
|
||||
/* #227: a pack abandoned at import, above the candidates — a quiet panel */
|
||||
.deck-notice {
|
||||
margin-bottom: var(--space-6);
|
||||
padding: var(--space-3) var(--space-4) var(--space-4);
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.deck-notice[data-blacklist="policy"] {
|
||||
background: oklch(from var(--signal-warn) l c h / 7%);
|
||||
border-color: oklch(from var(--signal-warn) l c h / 40%);
|
||||
}
|
||||
|
||||
.deck-notice[data-blacklist="release"] {
|
||||
background: oklch(from var(--signal-fault) l c h / 7%);
|
||||
border-color: oklch(from var(--signal-fault) l c h / 40%);
|
||||
}
|
||||
|
||||
.notice-release {
|
||||
margin: 0 0 var(--space-2);
|
||||
overflow-wrap: anywhere;
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
.notice-line {
|
||||
margin: 0;
|
||||
max-width: 68ch;
|
||||
font-size: var(--text-sm);
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.notice-line + .notice-line {
|
||||
margin-top: var(--space-2);
|
||||
}
|
||||
|
||||
/* ---- subtitles (§15, §9.6) -------------------------------------------- */
|
||||
|
||||
/* the languages read as one string, as wide as the wanted set can need */
|
||||
.subs-chip-langs {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
flex: none;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* the check has its slot whether or not it is drawn */
|
||||
.subs-chip-mark {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
justify-content: center;
|
||||
width: 0.75rem;
|
||||
}
|
||||
|
||||
.subs-chip-langs [data-mt="true"] {
|
||||
text-decoration: underline dotted;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
.subs-panel {
|
||||
container-type: inline-size;
|
||||
min-width: 0;
|
||||
padding: var(--space-3);
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.subs-present {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
padding-top: var(--space-3);
|
||||
}
|
||||
|
||||
.subs-present > p {
|
||||
margin: 0;
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
|
||||
.subs-controls {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: var(--space-2) var(--space-3);
|
||||
padding-top: var(--space-3);
|
||||
}
|
||||
|
||||
.subs-field {
|
||||
flex: 1 1 12rem;
|
||||
min-width: 9rem;
|
||||
max-width: 18rem;
|
||||
}
|
||||
|
||||
.subs-field-narrow {
|
||||
flex: 0 1 9rem;
|
||||
max-width: 11rem;
|
||||
}
|
||||
|
||||
.subs-note {
|
||||
margin: var(--space-2) 0 0;
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
.subs-note[data-tone="fault"] {
|
||||
color: var(--signal-fault);
|
||||
}
|
||||
|
||||
.subs-buckets {
|
||||
margin-top: var(--space-3);
|
||||
}
|
||||
|
||||
/* ---- settings (issue #116) -------------------------------------------- */
|
||||
|
||||
.form-grid {
|
||||
|
||||
@@ -91,10 +91,16 @@
|
||||
--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;
|
||||
|
||||
--container-deck: var(--deck-max);
|
||||
--container-measure: var(--measure);
|
||||
--container-search: 26rem;
|
||||
--container-notice: 68ch;
|
||||
--container-select: 18rem;
|
||||
--container-select-narrow: 11rem;
|
||||
/* 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;
|
||||
|
||||
+35
-14
@@ -52,6 +52,9 @@ import {
|
||||
useNote,
|
||||
} 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. */
|
||||
const TRANSLATION_POLL_MS = 5000;
|
||||
|
||||
@@ -195,7 +198,12 @@ function SubtitleField({
|
||||
}) {
|
||||
return (
|
||||
// biome-ignore lint/a11y/noLabelWithoutControl: the select is the child
|
||||
<label className={narrow ? "field subs-field subs-field-narrow" : "field subs-field"}>
|
||||
<label
|
||||
className={cx(
|
||||
"field shrink min-w-field",
|
||||
narrow ? "grow-0 basis-field max-w-select-narrow" : "grow basis-field-basis max-w-select",
|
||||
)}
|
||||
>
|
||||
<span className="field-label readout dim">{label}</span>
|
||||
{children}
|
||||
</label>
|
||||
@@ -328,7 +336,7 @@ function CandidateBuckets({
|
||||
const eligible = results.candidates.filter((c) => c.verdict === "eligible");
|
||||
const rejected = results.candidates.filter((c) => c.verdict !== "eligible");
|
||||
return (
|
||||
<div className="subs-buckets">
|
||||
<div className="mt-3">
|
||||
<Section spacing="mb-3">
|
||||
<DeckHead as="h4" label="eligible" count={eligible.length} />
|
||||
<Rows>
|
||||
@@ -561,10 +569,19 @@ export function useSubtitleSection(
|
||||
{/* 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. */}
|
||||
<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.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}`}
|
||||
</span>
|
||||
))}
|
||||
@@ -573,7 +590,7 @@ 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">
|
||||
<span className="inline-flex flex-none justify-center w-3">
|
||||
{summary.satisfied && <Icon name="check" className={cx(CHIP_ICON, "opacity-70")} />}
|
||||
</span>
|
||||
</button>
|
||||
@@ -741,10 +758,14 @@ export function useSubtitleSection(
|
||||
const rest = subtitles.filter((subtitle) => !asked.includes(subtitle));
|
||||
|
||||
const panel = (
|
||||
<div className="subs-panel" id={panelId} hidden={!open}>
|
||||
<div
|
||||
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" />
|
||||
<div className="subs-present">
|
||||
<div className="flex flex-wrap items-center gap-1 pt-3">
|
||||
{asked.map((subtitle) => (
|
||||
<SubtitleChip
|
||||
key={subtitle.id}
|
||||
@@ -767,15 +788,15 @@ export function useSubtitleSection(
|
||||
/>
|
||||
))}
|
||||
{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>
|
||||
<NoteLine note={presentNote} className="subs-note readout" />
|
||||
<NoteLine note={presentNote} className={SUBS_NOTE} />
|
||||
</Section>
|
||||
|
||||
<Section spacing="mb-4 last:mb-0">
|
||||
<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
|
||||
label="language to search for"
|
||||
languages={languages}
|
||||
@@ -787,7 +808,7 @@ export function useSubtitleSection(
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
className="subs-note readout"
|
||||
className={SUBS_NOTE}
|
||||
role="status"
|
||||
data-tone={searchNote?.tone}
|
||||
hidden={searchNote?.hidden}
|
||||
@@ -805,7 +826,7 @@ export function useSubtitleSection(
|
||||
|
||||
<Section spacing="mb-4 last:mb-0">
|
||||
<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">
|
||||
<select
|
||||
className="form-input"
|
||||
@@ -876,13 +897,13 @@ export function useSubtitleSection(
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
className="subs-note readout"
|
||||
className={SUBS_NOTE}
|
||||
role="status"
|
||||
data-tone={empty ? undefined : hintFault === null ? undefined : "fault"}
|
||||
>
|
||||
{options === null ? "" : hint}
|
||||
</p>
|
||||
<NoteLine note={translateNote} className="subs-note readout" />
|
||||
<NoteLine note={translateNote} className={SUBS_NOTE} />
|
||||
</Section>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -19,6 +19,8 @@ import {
|
||||
import { waiveAndGrabTv } from "../series";
|
||||
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. */
|
||||
const TV_SWEEP_POLL_MS = 5000;
|
||||
const TV_SWEEP_WAIT_MS = 150_000;
|
||||
@@ -380,7 +382,18 @@ export function TvDeckView({ request }: { request: TvDeckRequest }) {
|
||||
</div>
|
||||
<StatusSlot status={status} variant="deck" />
|
||||
<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}
|
||||
data-blacklist={failure === null ? undefined : blacklistClass(failure.reason)}
|
||||
aria-labelledby="tv-failure-label"
|
||||
@@ -401,18 +414,18 @@ export function TvDeckView({ request }: { request: TvDeckRequest }) {
|
||||
>
|
||||
pack abandoned at import
|
||||
</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.failed_at === null
|
||||
? failure.release
|
||||
: `${failure.release} · ${formatSweepAge(failure.failed_at)}`}
|
||||
</p>
|
||||
<p className="notice-line">{failureWhat}</p>
|
||||
<p className="notice-line">
|
||||
<p className={NOTICE_LINE}>{failureWhat}</p>
|
||||
<p className={cx(NOTICE_LINE, "mt-2")}>
|
||||
{failure === null ? "" : `${blacklistAdvice(failure.reason)}.`}
|
||||
</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
|
||||
satisfy the library (§7.3).
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user