refactor(web): move the stylesheet into Tailwind utilities (#281)
This commit was merged in pull request #281.
This commit is contained in:
+42
-23
@@ -3,6 +3,11 @@
|
||||
|
||||
import { type CSSProperties, type ReactNode, useEffect, useRef, useState } from "react";
|
||||
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 { type ActionOutcome, formatSize, totalSize } from "./releases";
|
||||
import { cx, flag, IconControl, IconLink, type Note, NoteLine } from "./ui";
|
||||
@@ -61,18 +66,19 @@ export function Hero({
|
||||
: ({ "--backdrop": `url("${backdropUrl}")` } as CSSProperties)
|
||||
}
|
||||
aria-label="title metadata"
|
||||
data-bleed=""
|
||||
>
|
||||
<header className="page-head">
|
||||
<IconControl glyph="back" label="back" onClick={onBack} />
|
||||
<h2 className="page-title" tabIndex={-1} ref={heading}>
|
||||
<header className={page.pageHead}>
|
||||
<IconControl glyph="back" label="back" look="bare" onClick={onBack} />
|
||||
<h2 className={cx(type.pageTitle, "flex-initial")} tabIndex={-1} ref={heading}>
|
||||
{title === "" ? " " : title}
|
||||
</h2>
|
||||
<span className="page-year readout">{year === null ? "" : year}</span>
|
||||
<span className={page.pageMeta}>{year === null ? "" : year}</span>
|
||||
</header>
|
||||
<div className="hero-body">
|
||||
<div className="hero-poster">
|
||||
<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="aspect-2/3 bg-panel-raised border border-line-strong rounded-panel overflow-hidden">
|
||||
<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`}
|
||||
src={posterUrl === null || posterBroken ? undefined : posterUrl}
|
||||
data-loaded={flag(posterLoaded && !posterBroken)}
|
||||
@@ -80,9 +86,9 @@ export function Hero({
|
||||
onError={() => setPosterBroken(true)}
|
||||
/>
|
||||
</div>
|
||||
<div className="hero-info">
|
||||
<span className="hero-chips">{chips}</span>
|
||||
<p className="hero-rating readout">
|
||||
<div className="grid gap-2 content-start min-w-0">
|
||||
<span className="flex flex-wrap gap-1 min-h-chip-h">{chips}</span>
|
||||
<p className={cx(HERO_LINE, "text-ink")}>
|
||||
{detail !== null && detail.vote_average !== null && (
|
||||
<>
|
||||
<Star />
|
||||
@@ -91,15 +97,15 @@ export function Hero({
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
<p className="hero-meta readout">
|
||||
<p className={cx(HERO_LINE, "text-ink-muted")}>
|
||||
{detail === null ? "" : formatMetaLine(detail.runtime, detail.genres)}
|
||||
</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}”` : ""}
|
||||
</p>
|
||||
{/* biome-ignore lint/a11y/useKeyWithClickEvents: a reading aid; the full text is in the DOM either way */}
|
||||
<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)}
|
||||
onClick={() => setOverviewFull(!overviewFull)}
|
||||
>
|
||||
@@ -107,7 +113,7 @@ export function Hero({
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<NoteLine note={note} className="r-note hero-note readout" />
|
||||
<NoteLine note={note} className={cx(NOTE, "mt-2")} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -115,9 +121,9 @@ export function Hero({
|
||||
/** The trailer: the play glyph, and the word wherever there is room for it. */
|
||||
export function TrailerLink({ href, title }: { href: string; title: string }) {
|
||||
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" />
|
||||
<span className="control-word">trailer</span>
|
||||
<span className="hidden @row:inline">trailer</span>
|
||||
</IconLink>
|
||||
);
|
||||
}
|
||||
@@ -244,29 +250,42 @@ export function RemovePanel({
|
||||
return (
|
||||
// biome-ignore lint/a11y/useSemanticElements: a fieldset brings its own border, padding and min-width, which this group does not want
|
||||
<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"
|
||||
aria-label={`remove ${subject.title}`}
|
||||
data-armed={String(hasFiles)}
|
||||
>
|
||||
<p className="remove-evidence readout dim">{evidence}</p>
|
||||
<p className="remove-path readout" hidden={path === null}>
|
||||
<p className="readout dim m-0 text-xs">{evidence}</p>
|
||||
<p
|
||||
className="readout m-0 text-xs text-ink-muted [overflow-wrap:anywhere] whitespace-pre-line"
|
||||
hidden={path === null}
|
||||
>
|
||||
{path ?? ""}
|
||||
</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}
|
||||
</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
|
||||
type="button"
|
||||
className="control"
|
||||
className={control({ state: hasFiles ? "warn" : null })}
|
||||
data-tone={hasFiles ? "warn" : undefined}
|
||||
aria-describedby="remove-note"
|
||||
disabled={busy}
|
||||
onClick={confirm}
|
||||
>
|
||||
remove and delete files
|
||||
</button>
|
||||
<button type="button" className="control" ref={keep} disabled={busy} onClick={onCancel}>
|
||||
<button type="button" className={control()} ref={keep} disabled={busy} onClick={onCancel}>
|
||||
keep
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user