fix(web): a Home row with one or two items no longer stretches them across the page
release / go (push) Successful in 1m50s
release / web (push) Successful in 1m14s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 4m9s
release / android (push) Successful in 4m13s
release / Build signed APK (push) Successful in 4m39s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 25s
release / Verify release artifacts (tag releases only) (push) Skipped

Home rows size their tiles to fill the window, and a row with fewer
items than fit split the whole width between them. One suggestion in
You might like became an album cover as wide as the page. Tiles now
grow to at most twice their minimum width; rows with enough items
still fill the window exactly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 10:01:35 -05:00
co-authored by Claude Opus 5.5
parent 6dda9ef219
commit c4eaa33e24
2 changed files with 17 additions and 7 deletions
+8 -2
View File
@@ -6,6 +6,7 @@ import {
refreshedLabel,
shelfMeta,
shelfTileWidth,
MAX_TILE_GROWTH,
songsLikeArtist,
washTone
} from './shelf.js';
@@ -148,9 +149,14 @@ describe('shelfTileWidth', () => {
expect(cols * w + (cols - 1) * 16).toBeGreaterThan(1000 - cols);
});
test('a short shelf splits the whole width between its items', () => {
expect(shelfTileWidth(1000, 2, 150, 16)).toBe(492);
test('a short shelf splits the width between its items', () => {
expect(shelfTileWidth(400, 2, 150, 16)).toBe(192);
expect(shelfTileWidth(1000, 3, 300, 16)).toBe(322);
});
test('a tile on a near-empty shelf stops growing at twice its minimum', () => {
expect(shelfTileWidth(1400, 1, 144, 16)).toBe(144 * MAX_TILE_GROWTH);
expect(shelfTileWidth(1000, 2, 150, 16)).toBe(150 * MAX_TILE_GROWTH);
});
test('a narrow window still gets one tile at the min', () => {
+9 -5
View File
@@ -123,13 +123,17 @@ function fromHsl(h: number, s: number, l: number): { r: number; g: number; b: nu
};
}
// How wide each tile on a shelf is, so the shelf's tiles always fill its
// width: as many columns as fit at `min` pixels, each grown to share the
// width. A shelf with fewer items than that splits the whole width between
// the items it has, so no shelf ends partway across the page.
// How wide each tile on a shelf is, so the shelf's tiles fill its width: as
// many columns as fit at `min` pixels, each grown to share the width. A shelf
// with fewer items than that splits the width between the items it has, but
// no tile grows past MAX_TILE_GROWTH times `min`: a lone album on a wide
// window would otherwise become a cover the size of the page.
export const MAX_TILE_GROWTH = 2;
export function shelfTileWidth(width: number, count: number, min: number, gap: number): number {
if (width <= 0) return min;
let cols = Math.max(1, Math.floor((width + gap) / (min + gap)));
if (count > 0 && count < cols) cols = count;
return Math.max(min, Math.floor((width - (cols - 1) * gap) / cols));
const shared = Math.floor((width - (cols - 1) * gap) / cols);
return Math.max(min, Math.min(shared, min * MAX_TILE_GROWTH));
}