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)}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { getPlaylist, systemShuffle, refreshSystem } from '#lib/api/playlists.js';
|
||||
import { playlistTrackToRef } from '#lib/playlists/playlistTrackToRef.js';
|
||||
import { systemPlaylistRefetch } from '#lib/playlists/systemRefetch.js';
|
||||
import { refreshedLabel, songsLikeArtist } from '#lib/playlists/shelf.js';
|
||||
import { refreshedLabel, songsLikeArtist, washTone } from '#lib/playlists/shelf.js';
|
||||
import { coverUrl } from '#lib/media/covers.js';
|
||||
import { dominantColorFromUrl, rgbToCssString } from '#lib/media/dominantColor.js';
|
||||
import { errCode } from '#lib/api/errors.js';
|
||||
@@ -50,7 +50,8 @@
|
||||
const lead = $derived(coverUrls[0] ?? playlist.cover_url ?? '');
|
||||
|
||||
// The wash behind a wide card or band is the lead cover's main colour,
|
||||
// darkened so light text reads on it in either theme. Until the colour is
|
||||
// toned down (washTone) and darkened so light text reads on it in either
|
||||
// theme, whatever the cover. Until the colour is
|
||||
// known (or when there is no cover) the wash is a neutral slate.
|
||||
let washRgb = $state('rgb(44 49 58)');
|
||||
$effect(() => {
|
||||
@@ -58,7 +59,7 @@
|
||||
const url = lead;
|
||||
if (!url) return;
|
||||
dominantColorFromUrl(url).then((rgb) => {
|
||||
if (rgb && url === lead) washRgb = rgbToCssString(rgb);
|
||||
if (rgb && url === lead) washRgb = rgbToCssString(washTone(rgb));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -289,7 +290,7 @@
|
||||
<img src={url} alt="" />
|
||||
{/each}
|
||||
</div>
|
||||
<div class="relative z-10 max-w-[55%] font-display text-xl font-medium leading-tight on-wash">{playlist.name.replace(/\s+mix$/i, '')}</div>
|
||||
<div class="band-name relative z-10 font-display text-xl font-medium leading-tight on-wash">{playlist.name.replace(/\s+mix$/i, '')}</div>
|
||||
{#if showMeta}
|
||||
<div class="relative z-10 truncate text-xs on-wash-3">{plural(playlist.track_count, 'track', 'tracks')}{refreshed ? ` · ${refreshed}` : ''}</div>
|
||||
{/if}
|
||||
@@ -372,8 +373,13 @@
|
||||
);
|
||||
}
|
||||
.on-wash { color: var(--fs-parchment); }
|
||||
.on-wash-2 { color: color-mix(in srgb, var(--fs-parchment) 82%, transparent); }
|
||||
.on-wash-3 { color: color-mix(in srgb, var(--fs-parchment) 68%, transparent); }
|
||||
/* Fainter text stays at 90% and 80%: at those strengths it still clears
|
||||
4.5:1 on the lightest wash washTone allows (shelf.test.ts checks it). */
|
||||
.on-wash-2 { color: color-mix(in srgb, var(--fs-parchment) 90%, transparent); }
|
||||
.on-wash-3 { color: color-mix(in srgb, var(--fs-parchment) 80%, transparent); }
|
||||
/* The genre name keeps clear of the fan: the fan is three 3.75rem covers
|
||||
overlapping by half (7.5rem) plus its 0.75rem inset. */
|
||||
.band-name { max-width: calc(100% - 8.75rem); overflow-wrap: anywhere; }
|
||||
.fan {
|
||||
position: absolute;
|
||||
right: 0.75rem;
|
||||
@@ -382,13 +388,14 @@
|
||||
display: flex;
|
||||
}
|
||||
.fan img {
|
||||
width: 4.5rem;
|
||||
width: 3.75rem;
|
||||
aspect-ratio: 1;
|
||||
object-fit: cover;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 6px 16px rgb(0 0 0 / 0.45);
|
||||
margin-left: -2.25rem;
|
||||
margin-left: -1.875rem;
|
||||
}
|
||||
.fan img:first-child { margin-left: 0; }
|
||||
.fan img:nth-child(1) { transform: rotate(-8deg) translateY(4px); }
|
||||
.fan img:nth-child(2) { transform: translateY(-4px); z-index: 1; }
|
||||
.fan img:nth-child(3) { transform: rotate(8deg) translateY(4px); z-index: 2; }
|
||||
|
||||
Reference in New Issue
Block a user