Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/settings-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ accent as stored. A stored value that is not a `#rgb` or
the web app manifest use it too. The branding document has no default theme
or light-theme logo URLs, and the API has no theme overrides or theme catalog.

Text in the accent color (`text-primary`) doesn't use the stored value as is.
The web client lightens the accent just enough to read at 4.5:1 on Cinema
Dark's lightest surface and on the accent's own 20% tint, with a paler variant
for high contrast. Fills and borders keep the stored color, as does the focus
ring outside high contrast.

### Retired theme settings

Manifest revision 12 deprecates `ui.theme`, `ui.custom_theme_vars` and
Expand Down
1 change: 1 addition & 0 deletions web/docs/design-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Colors are organized as semantic layers. `app.css` provides the actual values; c

- `--primary`: primary action color
- `--primary-foreground`: text on primary elements
- `--primary-text`: the primary color as text, which `text-primary` uses. An admin accent sets it to the accent, lightened only as far as needed to read at 4.5:1 on Cinema Dark's surfaces; without one it is `--primary`. Draw accent-colored text with `text-primary`, never `var(--primary)`
- `--secondary`: secondary element backgrounds
- `--accent`: highlighted and active backgrounds
- `--destructive`: danger and error text, icons, borders, and status dots
Expand Down
4 changes: 4 additions & 0 deletions web/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
/* ── Interactive ─────────────────────────────────────────── */
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
/* Text in the primary color. An admin accent sets --primary-text to a
variant that reads on Cinema Dark's surfaces (lib/accentColor.ts); fills,
borders, and rings keep the accent itself. */
--text-color-primary: var(--primary-text, var(--primary));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S2 (medium): ratings can lose contrast over bright detail artwork. --primary-text assumes a dark surface, but ScoreRow (ScoreRow.tsx:18) draws text-primary directly over the hero artwork. With a custom black accent and a bright backdrop in a mobile fixture, the rating text measured 13.76:1 before, 1.87:1 after, and 1.05:1 after with high contrast on. The ratio depends on the artwork and layout.

Suggested repair: give the ratings a dark backing, or make sure the hero scrim keeps their whole text area dark.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change here. ScoreRow sits in the detail hero beside the title and overview, which use --foreground (#e8e8ec), lighter than any --primary-text. Wherever a backdrop is bright enough to drop the lightened rating below 4.5:1, the title and overview fail first, so the hero's dark scrim already has to keep that area dark; this PR follows the same contract. On the scrim as designed, a black accent read about 1.1:1 before this change and about 6:1 after. 🤖 Claude Code (claude-opus-5-5)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 2 measured this with a black accent and high contrast on, over mid-gray artwork behind the scrim: 4.50:1 before, 2.90:1 after, while white text on the same pixel reads 4.66:1. So my earlier point that the title fails first doesn't hold for that case; I was wrong there. The regression needs a near-black accent: it read well before only because black is dark and the art behind it was light. Every shipped preset gains on the same pixel (indigo goes from about 1.6:1 to above 4.5:1), and on the scrim as designed all accents now pass. Backing the ratings, or strengthening the scrim behind them, would change the hero's design for an edge case, so I'm leaving this PR as is and flagging the decision to the maintainer. 🤖 Claude Code (claude-opus-5-5)

--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/admin/libraries/LibraryFormSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ function ProviderLevelSection({
type="button"
onClick={() => setCollapsed(!collapsed)}
aria-expanded={!collapsed}
className="text-primary hover:text-primary/80 mb-1.5 flex min-h-11 items-center gap-1.5 text-start text-xs font-semibold tracking-wider uppercase sm:min-h-0"
className="text-primary mb-1.5 flex min-h-11 items-center gap-1.5 text-start text-xs font-semibold tracking-wider uppercase hover:underline sm:min-h-0"
>
{collapsed ? <ChevronRight className="h-3 w-3" /> : <ChevronDown className="h-3 w-3" />}
{contentLevelLabel(level)}
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/watchlist/WatchlistTitlesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default function WatchlistTitlesTab({
<p className="text-muted-foreground text-sm">{watchlistTitlesHint(watchlistRequests)}</p>
<ViewTransitionLink
to={DISCOVER_HREF}
className="text-primary hover:text-primary/80 shrink-0 text-sm font-medium"
className="text-primary shrink-0 text-sm font-medium hover:underline"
>
{t("web.library.watchlist.findMore")}
</ViewTransitionLink>
Expand Down
7 changes: 5 additions & 2 deletions web/src/contexts/BrandingProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,18 @@ const ACCENT_STYLE_ID = "silo-accent";
* to <head>, so it wins over the theme's layered tokens. That would also beat
* high contrast's boosted focus ring, so a second unlayered rule restores it:
* a dark accent must not hide keyboard focus for someone who asked for high
* contrast.
* contrast. The same rule swaps accent text to the variant that reads on high
* contrast's lighter surfaces.
*/
function applyAccent(hex: string | null) {
if (typeof document === "undefined") return;
const declarations = hex ? accentDeclarations(hex) : null;
const css = declarations
? `:root {\n${Object.entries(declarations)
.map(([token, value]) => ` --${token}: ${value};`)
.join("\n")}\n}\nhtml[data-high-contrast="true"] {\n --ring: var(--contrast-boost);\n}`
.join(
"\n",
)}\n}\nhtml[data-high-contrast="true"] {\n --ring: var(--contrast-boost);\n --primary-text: var(--primary-text-high-contrast);\n}`
: "";
let style = document.getElementById(ACCENT_STYLE_ID) as HTMLStyleElement | null;
if (!css) {
Expand Down
31 changes: 31 additions & 0 deletions web/src/lib/accentColor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { accentDeclarations } from "./accentColor";
/** Cinema Dark's labels on primary surfaces, drawn when the accent keeps the dark label. */
const THEME_LABEL = "#141417";
const THEME_SIDEBAR_LABEL = "#0f0f12";
/** Cinema Dark's lightest surface under text (--surface-raised), and the same under high contrast. */
const LIGHTEST_SURFACE = "#28282e";
const LIGHTEST_SURFACE_HIGH_CONTRAST = "#535358";

function luminance(hex: string): number {
const value = parseInt(hex.slice(1), 16);
Expand All @@ -14,6 +17,17 @@ function luminance(hex: string): number {
return 0.2126 * channel(16) + 0.7152 * channel(8) + 0.0722 * channel(0);
}

/** `bg-primary/20` over `surface`: the strongest accent tint text sits on. */
function tint(accent: string, surface: string): string {
const a = parseInt(accent.slice(1), 16);
const b = parseInt(surface.slice(1), 16);
const channel = (shift: number) =>
Math.round(((a >> shift) & 0xff) * 0.2 + ((b >> shift) & 0xff) * 0.8)
.toString(16)
.padStart(2, "0");
return `#${channel(16)}${channel(8)}${channel(0)}`;
}

function contrast(a: string, b: string): number {
const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x);
return (light! + 0.05) / (dark! + 0.05);
Expand All @@ -34,4 +48,21 @@ describe("accentDeclarations", () => {
expect(contrast(accent, sidebarLabel)).toBeGreaterThanOrEqual(4.5);
},
);

// Dark presets that fail as text, one that already reads, and the extremes.
it.each(["#4f46e5", "#8b5cf6", "#f59e0b", "#000000", "#ffffff"])(
"draws %s as text at 4.5:1 or more on Cinema Dark",
(accent) => {
const declarations = accentDeclarations(accent)!;
const variants: [string | undefined, string][] = [
[declarations["primary-text"], LIGHTEST_SURFACE],
[declarations["primary-text-high-contrast"], LIGHTEST_SURFACE_HIGH_CONTRAST],
];
for (const [text, surface] of variants) {
expect(text).toBeDefined();
expect(contrast(text!, surface)).toBeGreaterThanOrEqual(4.5);
expect(contrast(text!, tint(accent, surface))).toBeGreaterThanOrEqual(4.5);
}
},
);
});
63 changes: 50 additions & 13 deletions web/src/lib/accentColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,29 @@ function contrastRatio(a: string, b: string): number {
return (light! + 0.05) / (dark! + 0.05);
}

function mixWithWhite(hex: string, amount: number): string {
const value = parseInt(hex.slice(1), 16);
/** Moves `hex` toward `target` by `amount` (0 keeps `hex`, 1 gives `target`). */
function mixToward(hex: string, target: string, amount: number): string {
const from = parseInt(hex.slice(1), 16);
const to = parseInt(target.slice(1), 16);
const channel = (shift: number) => {
const c = (value >> shift) & 0xff;
return Math.round(c + (255 - c) * amount)
const a = (from >> shift) & 0xff;
const b = (to >> shift) & 0xff;
return Math.round(a + (b - a) * amount)
.toString(16)
.padStart(2, "0");
};
return `#${channel(16)}${channel(8)}${channel(0)}`;
}

/** The accent mixed toward white in twentieths until `reads` accepts it, or white. */
function lightenUntil(hex: string, reads: (candidate: string) => boolean): string {
for (let step = 0; step <= 20; step++) {
const candidate = mixToward(hex, WHITE_LABEL, step / 20);
if (reads(candidate)) return candidate;
}
return WHITE_LABEL;
}

/** The label drawn on an accent: white or Cinema Dark's dark label, whichever reads better. */
function labelOn(hex: string): string {
return prefersWhiteLabel(hex) ? WHITE_LABEL : DARK_LABEL;
Expand All @@ -83,16 +95,37 @@ function primaryLabelOn(hex: string): string {
* badge) still reads.
*/
function accentOnDark(hex: string): string {
for (let step = 0; step <= 20; step++) {
const candidate = mixWithWhite(hex, step / 20);
if (
return lightenUntil(
hex,
(candidate) =>
contrastRatio(candidate, PLAYER_PANEL) >= MIN_PLAYER_CONTRAST &&
contrastRatio(candidate, labelOn(candidate)) >= MIN_PLAYER_CONTRAST
) {
return candidate;
}
}
return WHITE_LABEL;
contrastRatio(candidate, labelOn(candidate)) >= MIN_PLAYER_CONTRAST,
);
}

/** Cinema Dark's lightest surface under text, --surface-raised. */
const LIGHTEST_SURFACE = "#28282e";
/** High contrast mixes 20% of its white boost into --surface-raised (app.css). */
const LIGHTEST_SURFACE_HIGH_CONTRAST = mixToward(LIGHTEST_SURFACE, WHITE_LABEL, 0.2);
/** The strongest accent tint text sits on: `bg-primary/20`. */
const STRONGEST_TINT = 0.2;
/** WCAG AA for normal text. */
const MIN_TEXT_CONTRAST = 4.5;

/**
* The accent as text (`text-primary`) on Cinema Dark: unchanged when it
* already reads at 4.5:1 on `surface`, the lightest surface text sits on, and
* on the accent's own strongest tint over it; otherwise lightened just enough.
* Darker surfaces then read at least as well.
*/
function accentText(hex: string, surface: string): string {
const tint = mixToward(surface, hex, STRONGEST_TINT);
return lightenUntil(
hex,
(candidate) =>
contrastRatio(candidate, surface) >= MIN_TEXT_CONTRAST &&
contrastRatio(candidate, tint) >= MIN_TEXT_CONTRAST,
);
}

/**
Expand All @@ -113,6 +146,10 @@ export function accentDeclarations(accent: string): Record<string, string> | nul
"sidebar-primary": hex,
"accent-on-dark": onDark,
"accent-on-dark-foreground": labelOn(onDark),
// app.css maps text-primary to --primary-text; BrandingProvider swaps in
// the high contrast value under that setting.
"primary-text": accentText(hex, LIGHTEST_SURFACE),
"primary-text-high-contrast": accentText(hex, LIGHTEST_SURFACE_HIGH_CONTRAST),
Comment thread
Quick104 marked this conversation as resolved.
Resolved
};
const label = primaryLabelOn(hex);
if (label !== DARK_LABEL) {
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/upcomingEventPresentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function upcomingBadgeClass(badge: string): string {
switch (badge) {
case "series_premiere":
case "season_premiere":
return "border-primary/40 bg-primary/20 text-primary";
return "border-primary/40 bg-[color-mix(in_srgb,var(--primary)_12%,var(--background))] text-primary shadow-sm";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S3 (medium, new): watched premiere badge with a black accent over a light poster. With a black admin accent and standard contrast, a watched premiere badge over a white poster measured 5.28:1 before this change and 3.15:1 after in Chromium; a #f0f0f0 poster gave 4.80:1 before and 3.15:1 after. The watched card's opacity-60 grayscale (CalendarEventCard.tsx:40) applies to the badge as well as the artwork. Suggested repair: apply those effects to the artwork only, so the opaque badge keeps its contrast. Synthetic posters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same cause as S1's remainder: opacity-60 grayscale on the watched card covers the badge row, so no fill keeps 4.5:1 there for every accent and poster. The follow-up run for that defect moves the dimming off the badges, which fixes this case too. Tuning the fill for a black accent here would trade it against the default accent, which S1 brought back to 5.1:1. Leaving this open until that follow-up lands. 🤖 Claude Code (claude-opus-5-5)

case "finale":
return "border-orange-800/55 bg-orange-950/90 text-orange-50 shadow-sm backdrop-blur-none";
case "digital":
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/AdminPlaybackHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export default function AdminPlaybackHistory() {
</Link>
<Link
to={`/admin/logs?playback_session_id=${encodeURIComponent(row.session_id)}&focus=playback&component=ffmpeg`}
className="text-primary/80 text-sm font-medium"
className="text-primary text-sm"
>
{t("web.admin.activity.row.ffmpegLogs")}
</Link>
Expand Down
7 changes: 5 additions & 2 deletions web/src/pages/ItemDetail/components/EpisodeCardCaption.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ReactNode } from "react";
import type { EpisodeListItem } from "@/api/types";
import { useAppLanguage } from "@/i18n";
import { cn } from "@/lib/utils";
import MachineTranslatedLabel from "./MachineTranslatedLabel";
import { hasMachineTranslation } from "./machineTranslation";
import { episodeCardMetadata, episodeCardSpokenTitle, episodeCardTitle } from "./episodeCardText";
Expand Down Expand Up @@ -38,8 +39,10 @@ export default function EpisodeCardCaption({
<div className="mt-2 space-y-1">
<div className="flex items-center gap-2">
<p
className="text-foreground min-w-0 flex-1 truncate text-sm font-semibold"
style={isCurrent ? { color: "var(--primary)" } : undefined}
className={cn(
"min-w-0 flex-1 truncate text-sm font-semibold",
isCurrent ? "text-primary" : "text-foreground",
)}
>
<span aria-hidden="true">{episodeCardTitle(episode)}</span>
<span className="sr-only">{episodeCardSpokenTitle(episode)}</span>
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Recommendations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function DiscoverErrorState({ onRetry }: { onRetry: () => void }) {
<p className="text-muted-foreground text-sm">{t("web.recommendations.loadFailed")}</p>
<button
onClick={onRetry}
className="text-primary hover:text-primary/80 inline-flex items-center gap-2 text-sm font-medium"
className="text-primary inline-flex items-center gap-2 text-sm font-medium hover:underline"
>
<RefreshCw className="h-4 w-4" />
{t("common.retry")}
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/RecommendationsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function ErrorState({ onRetry }: { onRetry: () => void }) {
<p className="text-muted-foreground text-sm">{t("web.recommendations.sectionLoadFailed")}</p>
<button
onClick={onRetry}
className="text-primary hover:text-primary/80 inline-flex items-center gap-2 text-sm font-medium"
className="text-primary inline-flex items-center gap-2 text-sm font-medium hover:underline"
>
<RefreshCw className="h-4 w-4" />
{t("common.retry")}
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/RequestDiscoverSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function RequestDiscoverSection() {
<button
type="button"
onClick={() => void query.refetch()}
className="text-primary hover:text-primary/80 inline-flex items-center gap-2 text-sm font-medium"
className="text-primary inline-flex items-center gap-2 text-sm font-medium hover:underline"
>
<RefreshCw className="h-4 w-4" />
{t("common.retry")}
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/Requests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function DiscoverTab() {
<button
type="button"
onClick={() => void discovery.refetch()}
className="text-primary hover:text-primary/80 inline-flex items-center gap-2 text-sm font-medium"
className="text-primary inline-flex items-center gap-2 text-sm font-medium hover:underline"
>
<RefreshCw className="h-4 w-4" />
{t("common.retry")}
Expand Down Expand Up @@ -341,7 +341,7 @@ function YoursTab({
<button
type="button"
onClick={onRetry}
className="text-primary hover:text-primary/80 inline-flex items-center gap-2 text-sm font-medium"
className="text-primary inline-flex items-center gap-2 text-sm font-medium hover:underline"
>
<RefreshCw className="h-4 w-4" />
{t("common.retry")}
Expand Down
Loading