fix(web): home shelves fill the window and their text stays readable on any cover
release / web (push) Failing after 11s
release / go (push) Successful in 1m52s
release / govulncheck (push) Successful in 23s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / integration (push) Canceled after 4m12s
release / android (push) Canceled after 4m3s
release / Build signed APK (push) Canceled after 2m3s
release / web (push) Failing after 11s
release / go (push) Successful in 1m52s
release / govulncheck (push) Successful in 23s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / integration (push) Canceled after 4m12s
release / android (push) Canceled after 4m3s
release / Build signed APK (push) Canceled after 2m3s
A wide card or genre band's wash keeps its cover's hue but caps its lightness and saturation, so a pale or loud cover no longer washes the card too light for its text; the faintest text on it is 80% parchment, and a test checks 4.5:1 against the lightest wash allowed. A genre's name keeps clear of its fan of covers. Shelves size their tiles to the window: each shows a whole number of tiles that fill its width, a short shelf grows its tiles up to a cap, and the arrows page by whole tiles. On a very wide screen the page stops at 140rem and centres. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
<script lang="ts" generics="T">
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-svelte';
|
||||
import type { Snippet } from 'svelte';
|
||||
import { shelfTileWidth } from '#lib/playlists/shelf.js';
|
||||
|
||||
let {
|
||||
rows,
|
||||
item,
|
||||
title,
|
||||
meta,
|
||||
fit,
|
||||
ariaLabel
|
||||
}: {
|
||||
/** One or more visual rows of items rendered inside a single shared
|
||||
@@ -25,6 +27,11 @@
|
||||
each · refreshed today"), shown beside the title so the items need
|
||||
not repeat it. */
|
||||
meta?: string;
|
||||
/** Size items to the row instead of a fixed width: the row shows a whole
|
||||
number of items that fill its width, each at least `min` px wide (and,
|
||||
when there are fewer items than fit, at most `max` px). The width is
|
||||
set as --tile-w on the track; an item wrapper uses it as its width. */
|
||||
fit?: { min: number; max: number };
|
||||
/** Accessible label for the section as a whole. */
|
||||
ariaLabel?: string;
|
||||
} = $props();
|
||||
@@ -56,12 +63,34 @@
|
||||
|
||||
function page(direction: -1 | 1) {
|
||||
if (!scroller) return;
|
||||
const delta = direction * scroller.clientWidth * 0.85;
|
||||
// A fitted row pages by its whole visible tiles; any other by most of a
|
||||
// screen, leaving a sliver of the last page for context.
|
||||
const delta = fit && tileWidth > 0
|
||||
? direction * Math.max(1, Math.floor((clientWidth - BLEED + GAP) / (tileWidth + GAP))) * (tileWidth + GAP)
|
||||
: direction * scroller.clientWidth * 0.85;
|
||||
scroller.scrollBy({ left: delta, behavior: 'smooth' });
|
||||
setTimeout(refreshMetrics, 350);
|
||||
}
|
||||
|
||||
$effect(() => { refreshMetrics(); });
|
||||
|
||||
// The gap between items (gap-4), and the 1rem the scroller bleeds past the
|
||||
// page's right padding: whole tiles fill the width up to the page edge,
|
||||
// not into the bleed.
|
||||
const GAP = 16;
|
||||
const BLEED = 16;
|
||||
const itemCount = $derived(Math.max(0, ...rows.map((r) => r.length)));
|
||||
const tileWidth = $derived(
|
||||
fit ? shelfTileWidth(clientWidth - BLEED, itemCount, fit.min, fit.max, GAP) : 0
|
||||
);
|
||||
|
||||
// clientWidth follows the window, not just scrolling, so tiles resize live.
|
||||
$effect(() => {
|
||||
if (!scroller || typeof ResizeObserver === 'undefined') return;
|
||||
const ro = new ResizeObserver(refreshMetrics);
|
||||
ro.observe(scroller);
|
||||
return () => ro.disconnect();
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="section" aria-label={ariaLabel}>
|
||||
@@ -105,7 +134,7 @@
|
||||
data-testid="scroll-container"
|
||||
class="scroller overflow-x-auto"
|
||||
>
|
||||
<div class="track inline-flex flex-col gap-4">
|
||||
<div class="track inline-flex flex-col gap-4" style:--tile-w={fit ? `${tileWidth}px` : undefined}>
|
||||
{#each rows as row, rowIdx (rowIdx)}
|
||||
<div class="rack flex gap-4">
|
||||
{#each row as it, colIdx (colIdx)}
|
||||
|
||||
Reference in New Issue
Block a user