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
12 changes: 10 additions & 2 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ main:focus {

.grid {
display: grid;
/* Never fewer than two columns, so phones still show off the artwork.
/* Two columns at the narrowest, so most phones still show off the artwork.
CARD_IMAGE_SIZES in js/constants.js mirrors these widths. */
grid-template-columns: repeat(auto-fill, minmax(min(13.5rem, calc((100% - var(--gap)) / 2)), 1fr));
gap: clamp(1.5rem, 3vw, 2.5rem) var(--gap);
Expand All @@ -521,6 +521,13 @@ main:focus {
list-style: none;
}

/* Below 400px two columns get too small to read, so each playlist gets the full width. */
@media (max-width: 24.99rem) {
.grid {
grid-template-columns: 1fr;
}
}

.card {
position: relative;
display: flex;
Expand Down Expand Up @@ -669,7 +676,8 @@ main:focus {
display: none;
}

@media (max-width: 30rem) {
/* Only the two-column phone layout (400-480px) is too tight for descriptions. */
@media (min-width: 25rem) and (max-width: 30rem) {
.card-description {
display: none;
}
Expand Down
2 changes: 1 addition & 1 deletion public/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const CACHE_KEY = 'selections:v1';
export const CACHE_ETAG_KEY = 'selections:v1:etag';

/** Approximate rendered width of a grid card's artwork; mirrors the grid in app.css. */
export const CARD_IMAGE_SIZES = '(min-width: 80rem) 14rem, (min-width: 40rem) 30vw, 50vw';
export const CARD_IMAGE_SIZES = '(min-width: 80rem) 14rem, (min-width: 40rem) 30vw, (min-width: 25rem) 50vw, 100vw';

/** Cards in the first rows load eagerly; the rest are lazy-loaded as you scroll. */
export const EAGER_CARD_COUNT = 6;
Expand Down
2 changes: 2 additions & 0 deletions test/http.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ describe('HTTP API', () => {
const html = await (await fetch(`${ctx.base}/`)).text();
assert.match(html, /rel="preload" as="image" imagesrcset="https:\/\/resources\.tidal\.com\/images\/1\/320x320\.jpg 320w"/);
assert.match(html, /rel="modulepreload" href="\/static\/dev\/js\/main\.js"/);
// The artwork is full width in the single-column phone layout.
assert.match(html, /imagesizes="[^"]*\(min-width: 25rem\) 50vw, 100vw"/);
// Searches and deep links show different first cards, so no preload then.
assert.doesNotMatch(await (await fetch(`${ctx.base}/?q=rock`)).text(), /as="image"/);
});
Expand Down
Loading