feat: redesign photo overview (masonry + lightbox) and fix hoch/quer search

The album search could not distinguish portrait from landscape: the format
filter ran client-side over a single 60-item page and relied on exifInfo that
Immich never returned (no withExif flag), so the orientation guard fell
through and every photo matched every filter. Pagination links also dropped
format/jahr on the next page.

- immich/client: send withExif: true on /search/metadata so
  exifImageWidth/Height are populated for orientation filtering and masonry
  aspect ratios.
- albums/filter (new): filter + paginate across the full fetched set so total,
  page slice and has-more-pages stay consistent with active filters; both the
  album detail and the cross-album search pages use it.
- albums/photo-gallery (new client component): masonry grid with native
  EXIF aspect ratios (object-fit: cover, no more 3:2 letterboxing), hover
  overlay with filename/date + merken/lizenzieren/vergrößern, and a
  full-screen lightbox with keyboard nav (Esc/arrow keys).
- catalog-content: drop the old PhotoContactSheet; keep AlbumContactSheet and
  thread format/jahr through PhotoPagination links.
- Album detail search form restyled to the editorial design system (sharp ink
  borders) instead of the shadcn rounded card.
- Tests: filter.test.ts covers the orientation/year/pagination logic;
  catalog-content.test.tsx updated to the gallery + lightbox structure;
  immich client test expects withExif: true.

Skipped: global search form still uses shadcn styling (visually inconsistent
but functionally fixed); albums > 1000 photos lose tail items (noted with a
ponytail ceiling comment).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Leon TonhäuserandClaude committed 2026-08-11 13:36:46 +02:00
1 parent b81cd7c3e2
commit a3ec068cac
11 files changed
+949 -267

No files matched your search

+52 -47
View File
@@ -1,9 +1,10 @@
// @vitest-environment jsdom
import { cleanup, render, screen } from "@testing-library/react";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, expect, test } from "vitest";
import { AlbumContactSheet, PhotoContactSheet } from "./catalog-content";
import { AlbumContactSheet } from "./catalog-content";
import { PhotoGallery } from "./photo-gallery";
afterEach(cleanup);
@@ -30,42 +31,27 @@ test("renders granted albums as labelled contact-sheet links", () => {
);
});
test("renders a labelled photo search and descriptive contact-sheet metadata", () => {
render(
<PhotoContactSheet
albumName="Heimspiel gegen Nord"
page={{
items: [
{
id: "asset-1",
type: "IMAGE",
originalFileName: "tor-des-sieges.jpg",
originalMimeType: "image/jpeg",
localDateTime: "2026-08-08T18:42:00.000Z",
fileCreatedAt: null,
albums: [{ id: "heimspiel" }],
},
],
total: 1,
nextPage: null,
previousPage: null,
}}
query="Tor"
/>,
);
const photo = {
id: "asset-1",
type: "IMAGE" as const,
originalFileName: "tor-des-sieges.jpg",
originalMimeType: "image/jpeg",
localDateTime: "2026-08-08T18:42:00.000Z",
fileCreatedAt: null,
albums: [{ id: "heimspiel" }],
};
expect(screen.getByRole("search", { name: /fotos in heimspiel gegen nord durchsuchen/i })).not.toBeNull();
expect((screen.getByRole("searchbox", { name: /suchbegriff/i }) as HTMLInputElement).value).toBe("Tor");
test("renders the gallery list labelled by album name", () => {
render(<PhotoGallery albumName="Heimspiel gegen Nord" items={[photo]} />);
expect(screen.getByRole("list", { name: /fotos aus heimspiel gegen nord/i })).not.toBeNull();
expect(screen.getByAltText("tor-des-sieges.jpg").getAttribute("src")).toBe(
"/api/assets/asset-1/thumbnail",
);
expect(screen.getByText("tor-des-sieges.jpg")).not.toBeNull();
expect(screen.getByText(/1 foto gefunden/i)).not.toBeNull();
});
test("renders the server-scoped download choices for a catalog photo", () => {
render(
<PhotoContactSheet
<PhotoGallery
albumId="33333333-3333-4333-8333-333333333333"
albumName="Heimspiel gegen Nord"
downloadOptions={{
@@ -80,25 +66,44 @@ test("renders the server-scoped download choices for a catalog photo", () => {
],
},
}}
page={{
items: [
{
id: "22222222-2222-4222-8222-222222222222",
type: "IMAGE",
originalFileName: "tor.jpg",
originalMimeType: "image/jpeg",
localDateTime: null,
fileCreatedAt: null,
albums: [{ id: "33333333-3333-4333-8333-333333333333" }],
},
],
total: 1,
nextPage: null,
previousPage: null,
}}
query=""
items={[
{
id: "22222222-2222-4222-8222-222222222222",
type: "IMAGE",
originalFileName: "tor.jpg",
originalMimeType: "image/jpeg",
localDateTime: null,
fileCreatedAt: null,
albums: [{ id: "33333333-3333-4333-8333-333333333333" }],
},
]}
/>,
);
expect(screen.getByRole("button", { name: /original laden/i })).not.toBeNull();
});
test("opens a full-screen lightbox when a photo tile is clicked", () => {
render(
<PhotoGallery
albumName="Heimspiel gegen Nord"
items={[
{ ...photo, id: "a", originalFileName: "first.jpg" },
{ ...photo, id: "b", originalFileName: "second.jpg" },
]}
/>,
);
// No lightbox before clicking.
expect(screen.queryByRole("dialog")).toBeNull();
fireEvent.click(screen.getByRole("button", { name: /first\.jpg vergrößern/i }));
const dialog = screen.getByRole("dialog");
expect(dialog.getAttribute("aria-modal")).toBe("true");
// Lightbox image + tile image both carry the alt, so the dialog contains one.
expect(dialog.querySelector(".lightbox-image")?.getAttribute("alt")).toBe("first.jpg");
expect(screen.getByRole("button", { name: /nächstes bild/i })).not.toBeNull();
// No previous on the first photo.
expect(screen.queryByRole("button", { name: /vorheriges bild/i })).toBeNull();
});