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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ personal wantlist ("crate").

IT2810 (NTNU) Project 2. Group T19: `erikhfj`, `robertky`, `evenkkl`, `rachelks`.

**Status: M4 delivered – final polish.** See the README's
**Status: Final submission ready (hand-in 27 November).** See the README's
[feature overview](README.md#what-you-can-do-in-crate) for implemented features
and the project status section for planned work.

Expand Down
154 changes: 91 additions & 63 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="referrer" content="no-referrer" />
<meta name="description" content="Crate — search, review and collect albums." />
<link rel="icon" type="image/svg+xml" href="%BASE_URL%favicon.svg" />
<title>Crate — album catalog</title>
<script src="%BASE_URL%theme-init.js"></script>
</head>
Expand Down
6 changes: 6 additions & 0 deletions client/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 51 additions & 10 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,27 @@
background: var(--bg);
color: var(--text);
}
.search-section::before,
.search-section__backdrop,
.search-section::after {
content: '';
position: absolute;
inset: 0;
pointer-events: none;
}
.search-section::before {
.search-section__backdrop {
z-index: -2;
background: url('./assets/vinyl-hero.webp') center 22% / cover;
display: block;
overflow: hidden;
}
.search-section__backdrop-image {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
object-position: center 45%;
filter: saturate(0.5) contrast(1.03);
}
.search-section::after {
content: '';
z-index: -1;
background:
linear-gradient(
Expand Down Expand Up @@ -144,8 +152,26 @@
font-size: 1.125rem;
margin: 1.5rem 0 1.875rem;
}
.hero-footer {
margin-top: 2rem;
}
.hero-jump-link {
display: none;
align-items: center;
gap: 0.35rem;
min-height: 2.75rem;
font-size: 0.9rem;
font-weight: 700;
color: var(--accent);
text-decoration: none;
}
.hero-jump-link:hover {
color: var(--accent-hover);
text-decoration: underline;
text-underline-offset: 0.2em;
}
.hero-credit {
margin: 2rem 0 0;
margin: 0;
color: var(--muted);
font-size: 0.75rem;
}
Expand Down Expand Up @@ -183,13 +209,13 @@
.search-section {
min-height: 0;
align-items: end;
padding-block: 2.5rem 2rem;
padding-block: 1.5rem 1.25rem;
}
.search-section__content {
padding-inline: 1rem;
}
.search-section::before {
background-position: center 24%;
.search-section__backdrop-image {
object-position: center 40%;
}
.search-section::after {
background: linear-gradient(
Expand All @@ -199,11 +225,26 @@
rgba(5, 12, 8, 0.65)
);
}
.search-section .eyebrow {
margin-bottom: 0.5rem;
}
.search-section h1 {
font-size: clamp(2.5rem, 8vw, 3rem);
font-size: clamp(2rem, 8vw, 2.75rem);
}
.search-section .tagline {
font-size: 1rem;
font-size: 0.95rem;
margin: 0.75rem 0 1rem;
}
.hero-footer {
margin-top: 0.75rem;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 0.5rem 1rem;
}
.hero-jump-link {
display: inline-flex;
}
}
@media (max-width: 420px) {
Expand Down
21 changes: 21 additions & 0 deletions client/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,27 @@ describe('App search', () => {
within(hero).getByText('Search, rate and collect albums you’ll want to return to.'),
).toBeInTheDocument();
expect(within(hero).getByRole('search')).toBeInTheDocument();
const heroPicture = hero.querySelector('picture.search-section__backdrop');
const heroSource = heroPicture?.querySelector('source');
expect(heroSource).toHaveAttribute('media', '(max-width: 700px)');
expect(heroSource).toHaveAttribute('srcset');
expect(heroSource).not.toHaveAttribute('type');
const heroImage = heroPicture?.querySelector('img');
expect(heroImage).toHaveAttribute('src');
expect(heroImage).toHaveAttribute('aria-hidden', 'true');
expect(heroImage).toHaveAttribute('width', '1280');
expect(heroImage).toHaveAttribute('height', '720');
expect(heroImage).toHaveAttribute('loading', 'eager');
expect(heroImage).toHaveAttribute('fetchpriority', 'high');
expect(heroImage).toHaveAttribute('decoding', 'async');
expect(heroImage).toHaveAttribute('alt', '');
expect(heroImage).not.toHaveAttribute('srcset');
expect(heroImage).not.toHaveAttribute('sizes');
expect(within(hero).queryByRole('img')).not.toBeInTheDocument();
expect(within(hero).getByRole('link', { name: 'Browse catalog' })).toHaveAttribute(
'href',
'#catalogue',
);
expect(document.querySelector('a')).toBe(
screen.getByRole('link', { name: 'Skip to content' }),
);
Expand Down
Binary file added client/src/assets/vinyl-hero-mobile.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions client/src/assets/vinyl-hero.LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
- Photo: [Black turntable on brown wooden table](https://unsplash.com/photos/black-turntable-on-brown-wooden-table-TcSckNRL9J8)
- License: [Unsplash License](https://unsplash.com/license), permitting downloading, modification, distribution and use, including commercial use.
- Source: https://images.unsplash.com/photo-1526394931762-90052e97b376
- Local asset: vinyl-hero.webp (1800px wide WebP, quality 80).
- Used as a decorative CSS background with dark overlays. Attribution is also visible in the hero.
- Local assets:
- `vinyl-hero.webp` (1280×720 landscape crop WebP, quality 78)
- `vinyl-hero-mobile.webp` (640×360 landscape crop WebP, quality 75)
- Used as a decorative responsive hero backdrop (`<picture>` / `<img>` with `alt=""` and `aria-hidden="true"`) behind dark overlays. Attribution is also visible in the hero.
Binary file modified client/src/assets/vinyl-hero.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions client/src/components/AlbumCover.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ it('uses responsive thumbnails and native loading with decorative semantics', ()
expect(image).toHaveAttribute('loading', 'lazy');
expect(image).not.toHaveAttribute('fetchpriority');
expect(image).toHaveAttribute('decoding', 'async');
expect(image).toHaveAttribute('referrerpolicy', 'no-referrer');
expect(image).toHaveAttribute('alt', '');
expect(screen.queryByRole('img')).not.toBeInTheDocument();
});
Expand All @@ -53,6 +54,7 @@ it('loads detail artwork eagerly with 500px and 1200px thumbnails', () => {
expect(image).toHaveAttribute('loading', 'eager');
expect(image).toHaveAttribute('fetchpriority', 'high');
expect(image).toHaveAttribute('decoding', 'async');
expect(image).toHaveAttribute('referrerpolicy', 'no-referrer');
expect(image).toHaveAttribute('alt', '');
expect(screen.queryByRole('img')).not.toBeInTheDocument();
});
Expand Down
1 change: 1 addition & 0 deletions client/src/components/AlbumCover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function AlbumCover({
loading={variant === 'detail' ? 'eager' : 'lazy'}
fetchPriority={variant === 'detail' ? 'high' : undefined}
decoding="async"
referrerPolicy="no-referrer"
alt=""
onLoad={() => onLoadChange?.(true)}
onError={() => {
Expand Down
14 changes: 14 additions & 0 deletions client/src/components/SearchForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@
.search-form__icon {
display: none;
}
.search-form {
padding: 0.375rem;
gap: 0.375rem;
}
.search-form input {
min-height: 2.75rem;
padding: 0.5rem 0.75rem;
}
.search-form button {
min-height: 2.75rem;
padding: 0.5rem 1.125rem;
}
}
@media (max-width: 22.5rem) {
.search-form {
flex-direction: column;
align-items: stretch;
Expand Down
31 changes: 26 additions & 5 deletions client/src/pages/DiscoveryPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useEffect } from 'react';

import vinylHeroDesktop from '../assets/vinyl-hero.webp';
import vinylHeroMobile from '../assets/vinyl-hero-mobile.webp';
import ResultsLayout from '../components/ResultsLayout.js';
import SearchForm from '../components/SearchForm.js';
import { useAlbumSearch } from '../hooks/useAlbumSearch.js';
Expand All @@ -23,6 +25,20 @@ export default function DiscoveryPage() {
return (
<main id="main" className="discovery-main" tabIndex={-1}>
<section className="search-section" aria-labelledby="search-heading">
<picture className="search-section__backdrop">
<source media="(max-width: 700px)" srcSet={vinylHeroMobile} />
<img
className="search-section__backdrop-image"
src={vinylHeroDesktop}
width={1280}
height={720}
alt=""
aria-hidden="true"
loading="eager"
fetchPriority="high"
decoding="async"
/>
</picture>
<div className="search-section__content">
<p className="eyebrow">Your next favorite is in here</p>
<h1 id="search-heading">
Expand All @@ -33,12 +49,17 @@ export default function DiscoveryPage() {
Search, rate and collect albums you’ll want to return to.
</p>
<SearchForm query={search.query} onSearch={submitSearch} history={history} />
<p className="hero-credit">
Photo by{' '}
<a href="https://unsplash.com/photos/black-turntable-on-brown-wooden-table-TcSckNRL9J8">
Kevin McCutcheon on Unsplash
<div className="hero-footer">
<a className="hero-jump-link" href="#catalogue">
Browse catalog <span aria-hidden="true">↓</span>
</a>
</p>
<p className="hero-credit">
Photo by{' '}
<a href="https://unsplash.com/photos/black-turntable-on-brown-wooden-table-TcSckNRL9J8">
Kevin McCutcheon on Unsplash
</a>
</p>
</div>
</div>
</section>
<div id="catalogue" className="catalogue-layout">
Expand Down
3 changes: 3 additions & 0 deletions client/src/pagination.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ describe('cursor pagination', () => {
const user = userEvent.setup();
screen.getByRole('button', { name: 'Search' }).focus();

await user.tab();
expect(screen.getByRole('link', { name: 'Browse catalog' })).toHaveFocus();

await user.tab();
expect(
screen.getByRole('link', { name: 'Kevin McCutcheon on Unsplash' }),
Expand Down
Loading