diff --git a/README.md b/README.md index 895fc0a..8c300f0 100644 --- a/README.md +++ b/README.md @@ -166,8 +166,17 @@ committing it. MusicBrainz core data is CC0 1.0; genre associations are user-contributed tag data under CC BY-NC-SA 3.0. The snapshot retains that distinction and the MusicBrainz release-group IDs for attribution and reproducibility. See [MusicBrainz Data License](https://musicbrainz.org/doc/About/Data_License) -and [MusicBrainz API](https://musicbrainz.org/doc/MusicBrainz_API). Album covers -remain out of scope for this issue. +and [MusicBrainz API](https://musicbrainz.org/doc/MusicBrainz_API). + +Album artwork is loaded externally from Cover Art Archive using the existing +MusicBrainz release-group IDs, rather than bundled into the application. Cover +availability is optional; albums without an ID or available artwork use the +existing vinyl placeholder. The artwork attribution on the album detail page +links to the corresponding MusicBrainz release-group page. Artwork rights remain +with their respective rights holders. + +See [Lighthouse results](docs/lighthouse-results.md) for local production-preview +scores, artwork audit findings and the JavaScript bundle budget verified for #23. ### Catalog quality (#64) @@ -271,9 +280,9 @@ We consider sustainability through design choices that reduce unnecessary data t | `AlbumDetailPage-*.css` | 1.94 kB | 0.71 kB | | `index.html` | 0.51 kB | 0.31 kB | -The two `AlbumDetailPage` rows represent the separate chunks for the album detail route and are not part of the search page payload. Opening an album uses normal page navigation, while previously downloaded assets may be reused by the browser. +The two `AlbumDetailPage` rows represent the separate chunks for the album detail route and are not part of the search page payload. Opening an album uses normal page navigation, while previously downloaded assets may be reused by the browser. Artwork is fetched separately from Cover Art Archive and is not included in these bundle sizes. Browser-native responsive images (`srcSet`/`sizes`) let the browser select an appropriate image size; card images load lazily, while detail artwork loads eagerly. -**Requests for a typical search:** An uncached search initially fetches up to 20 albums in one `searchAlbums` request. Infinite scroll loads up to two additional pages automatically, while further pages are loaded using the Load more button. Previously fetched pages are reused from Apollo's cache without new requests. No search requests are sent while the user types. +**Requests for a typical search:** An uncached search initially fetches up to 20 albums in one `searchAlbums` request. Infinite scroll loads up to two additional pages automatically, while further pages are loaded using the Load more button. Previously fetched pages are reused from Apollo's cache without new GraphQL requests. No search requests are sent while the user types. Album artwork adds separate external image requests as cards approach the viewport. ## Project status @@ -301,6 +310,8 @@ The two `AlbumDetailPage` rows represent the separate chunks for the album detai **Album details and reviews:** Album pages display tracks, average ratings and reviews. Users can write, edit and delete their own reviews. +**Album artwork:** Discover, My Crate and AlbumDetailPage display Cover Art Archive images when available, with the vinyl placeholder as a fallback. + **Personal crate:** Users can add or remove albums from their crate on both search results and album detail pages, and a crate page lists everything they have saved, newest first, with paging. The API returns only the requesting user's items. User identity is simulated using a locally stored ID rather than a login system. **Planned for M4:** Playwright end-to-end tests, and browsing albums without entering a search term. diff --git a/client/src/App.css b/client/src/App.css index 9ea730d..0287df9 100644 --- a/client/src/App.css +++ b/client/src/App.css @@ -1,3 +1,10 @@ +/* Keep the footer below the viewport through both detail loading phases. + Only placeholders reserve this space; loaded and error pages size naturally. */ +.album-detail-loading { + min-block-size: 100vh; + min-block-size: 100svh; + padding-block: 2rem 3rem; +} .skip-link { position: absolute; left: -9999px; diff --git a/client/src/App.test.tsx b/client/src/App.test.tsx index 2375df5..dce7943 100644 --- a/client/src/App.test.tsx +++ b/client/src/App.test.tsx @@ -18,6 +18,7 @@ const album: AlbumSummary = { title: 'Abbey Road', artists: [{ id: '1', name: 'The Beatles' }], releaseYear: 1969, + musicBrainzReleaseGroupId: null, genres: [{ id: '1', name: 'Rock' }], averageRating: 4.8, reviewCount: 1240, diff --git a/client/src/App.tsx b/client/src/App.tsx index 487bbe5..d7c1a45 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -37,7 +37,12 @@ export default function App() { {detailId ? ( +

Loading album…

} diff --git a/client/src/a11y.test.tsx b/client/src/a11y.test.tsx index 15bff44..f9263cc 100644 --- a/client/src/a11y.test.tsx +++ b/client/src/a11y.test.tsx @@ -19,6 +19,7 @@ const album: AlbumSummary = { title: 'Abbey Road', artists: [{ id: '1', name: 'The Beatles' }], releaseYear: 1969, + musicBrainzReleaseGroupId: null, genres: [{ id: '1', name: 'Rock' }], averageRating: 4.8, reviewCount: 1240, diff --git a/client/src/api/albumDetail.ts b/client/src/api/albumDetail.ts index 8aa6308..415d064 100644 --- a/client/src/api/albumDetail.ts +++ b/client/src/api/albumDetail.ts @@ -13,6 +13,7 @@ export const ALBUM_DETAIL = graphql(` id title releaseYear + musicBrainzReleaseGroupId artists { id name diff --git a/client/src/api/client.test.ts b/client/src/api/client.test.ts index 7353d02..cdb07ef 100644 --- a/client/src/api/client.test.ts +++ b/client/src/api/client.test.ts @@ -26,6 +26,7 @@ function result(ids: string[], endCursor: string, hasNextPage = true): SearchAlb artists: [], genres: [], releaseYear: null, + musicBrainzReleaseGroupId: null, averageRating: null, reviewCount: 0, isInCrate: false, diff --git a/client/src/api/crate.ts b/client/src/api/crate.ts index 60656e8..e82a965 100644 --- a/client/src/api/crate.ts +++ b/client/src/api/crate.ts @@ -53,6 +53,7 @@ export const MY_CRATE = graphql(` id title releaseYear + musicBrainzReleaseGroupId averageRating reviewCount isInCrate diff --git a/client/src/api/searchAlbums.ts b/client/src/api/searchAlbums.ts index cb95e21..6afc210 100644 --- a/client/src/api/searchAlbums.ts +++ b/client/src/api/searchAlbums.ts @@ -42,6 +42,7 @@ export const SEARCH_ALBUMS = graphql(` id title releaseYear + musicBrainzReleaseGroupId artists { id name diff --git a/client/src/components/AlbumCard.css b/client/src/components/AlbumCard.css index 486e93b..3eba9a2 100644 --- a/client/src/components/AlbumCard.css +++ b/client/src/components/AlbumCard.css @@ -1,3 +1,5 @@ +@import './AlbumCover.css'; + .album-card { position: relative; isolation: isolate; @@ -17,27 +19,12 @@ display: grid; place-items: center; } -.album-card__record { - width: 68%; - aspect-ratio: 1; - border-radius: 50%; - border: 1px solid var(--border-strong); - background: repeating-radial-gradient( - circle, - var(--surface) 0 5px, - var(--border) 6px 7px - ); - display: grid; - place-items: center; - transition: transform 400ms ease; -} -.album-card__record::after { - content: ''; - width: 25%; - aspect-ratio: 1; - border-radius: 50%; - border: 1px solid var(--border-strong); - background: var(--surface-raised); +/* Two 18rem columns plus the 1.375rem gap no longer fit below this width. */ +@container album-grid (width < 37.375rem) { + .album-card { + max-width: 26rem; + margin-inline: auto; + } } .album-card__view { position: absolute; diff --git a/client/src/components/AlbumCard.test.tsx b/client/src/components/AlbumCard.test.tsx index b83fef2..6d063b8 100644 --- a/client/src/components/AlbumCard.test.tsx +++ b/client/src/components/AlbumCard.test.tsx @@ -12,6 +12,7 @@ const album: AlbumSummary = { artists: [], genres: [], releaseYear: null, + musicBrainzReleaseGroupId: null, averageRating: null, reviewCount: 0, isInCrate: false, @@ -28,6 +29,7 @@ it('handles nullable summary fields without inventing a rating or year', () => { artists: [{ id: '1', name: 'The Beatles' }], genres: [{ id: '1', name: 'Rock' }], releaseYear: null, + musicBrainzReleaseGroupId: null, averageRating: null, reviewCount: 0, isInCrate: false, @@ -69,6 +71,22 @@ it('shows a real aggregate rating and review count', () => { expect(screen.getByText('Average rating:')).toBeInTheDocument(); }); +it('renders the album cover beneath the existing View album overlay', () => { + const releaseGroupId = '004bf1bb-df91-4724-8292-6c50b73216b8'; + const { container } = render( + + + , + ); + const cover = container.querySelector('.album-card__cover'); + expect(cover?.querySelector('img')).toHaveAttribute( + 'src', + `https://coverartarchive.org/release-group/${releaseGroupId}/front-250`, + ); + expect(cover).toContainElement(screen.getByText('View album')); + expect(screen.getByRole('link', { name: album.title })).toBeInTheDocument(); +}); + it.each([false, true])( 'keeps keyboard navigation and the crate mutation separate (saved: %s)', async (saved) => { @@ -99,7 +117,13 @@ it.each([false, true])( }, ]} > - + , ); const link = screen.getByRole('link', { name: album.title }); diff --git a/client/src/components/AlbumCard.tsx b/client/src/components/AlbumCard.tsx index d752e08..35484d4 100644 --- a/client/src/components/AlbumCard.tsx +++ b/client/src/components/AlbumCard.tsx @@ -2,6 +2,7 @@ import './AlbumCard.css'; import type { AlbumSummary } from '../api/searchAlbums.js'; import CrateButton from './CrateButton.js'; +import AlbumCover from './AlbumCover.js'; export default function AlbumCard({ album }: { album: AlbumSummary }) { const detailHref = `${import.meta.env.BASE_URL}album/${album.id}${window.location.search}`; @@ -10,7 +11,10 @@ export default function AlbumCard({ album }: { album: AlbumSummary }) { return (