diff --git a/src/app/globals.css b/src/app/globals.css index 68ac83d..87d380e 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -569,73 +569,74 @@ a { text-underline-offset: 0.2em; } -.album-contact-sheet { +/* --- Album overview: grid of cover tiles in the photo-gallery aesthetic --- + Cover images use object-fit: cover with a consistent 4/3 tile (album + summaries don't carry EXIF, so no native per-cover aspect ratio), a + persistent bottom gradient with album name + photo count, and a hover + zoom. Clicking opens the album. Mirrors the photo grid's hover language. */ +.album-gallery { display: grid; - gap: clamp(1.25rem, 2.25vw, 2.5rem); + gap: clamp(0.75rem, 1.5vw, 1.25rem); padding: 0; list-style: none; - grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); + grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); } -.contact-sheet-link { +.album-tile { display: block; color: inherit; text-decoration: none; } -.album-contact-frame { +.album-tile-frame { + position: relative; margin: 0; - background: var(--contact-sheet); - border: 1px solid var(--ink); overflow: hidden; + background: var(--contact-sheet); + aspect-ratio: 4 / 3; } -.contact-sheet-image, -.missing-contact-image { +.album-tile-image { display: block; width: 100%; - aspect-ratio: 3 / 2; - object-fit: contain; + height: 100%; + object-fit: cover; background: var(--contact-sheet); - transition: transform 150ms ease-out; + transition: transform 200ms ease-out; } -.missing-contact-image { +.album-tile-missing { display: grid; place-items: center; + width: 100%; + height: 100%; color: var(--metadata); - font-size: 0.75rem; + font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; } -.contact-sheet-link:hover .contact-sheet-image, -.contact-sheet-link:focus-visible .contact-sheet-image { - transform: scale(1.015); +.album-tile:hover .album-tile-image, +.album-tile:focus-visible .album-tile-image { + transform: scale(1.03); } -.contact-strip { +/* Persistent overlay (unlike the photo grid's hover-only overlay) — album + names need to be readable at a glance so editors can pick one. */ +.album-tile-overlay { + position: absolute; + inset: 0; display: flex; - align-items: baseline; - justify-content: space-between; - gap: 0.75rem; - min-height: 2.35rem; - margin: 0; - padding: 0.5rem 0.625rem; - border-top: 1px solid var(--ink); - background: var(--contact-sheet); - color: var(--graphite); - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; - font-size: 0.625rem; - letter-spacing: 0.035em; - line-height: 1.25; - text-transform: uppercase; -} - -.contact-strip-name { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + flex-direction: column; + justify-content: flex-end; + padding: 0.75rem; + background: linear-gradient( + to top, + rgb(0 0 0 / 85%) 0%, + rgb(0 0 0 / 30%) 55%, + rgb(0 0 0 / 0%) 85% + ); + pointer-events: none; } /* --- Photo overview: masonry grid + hover overlay + lightbox -------------- @@ -1152,7 +1153,7 @@ a { } @media (prefers-reduced-motion: reduce) { - .contact-sheet-image, + .album-tile-image, .photo-tile-image, .photo-tile-overlay { transition: none; diff --git a/src/app/redaktion/leuchtkasten/LightboxToggleButton.tsx b/src/app/redaktion/leuchtkasten/LightboxToggleButton.tsx index 1a49c15..9b132d7 100644 --- a/src/app/redaktion/leuchtkasten/LightboxToggleButton.tsx +++ b/src/app/redaktion/leuchtkasten/LightboxToggleButton.tsx @@ -23,8 +23,12 @@ export function LightboxToggleButton({ assetId, initialInLightbox }: LightboxTog try { const result = await toggleLightboxItem(assetId); setInLightbox(result.isNowInLightbox); - } catch { - // Revert on error + } catch (error) { + // Revert the optimistic toggle and surface the real cause. Server + // action errors also print to the dev server terminal — check there + // for the stack trace. Without this the button just flips back + // silently and the user can't tell why the merkzettel "doesn't work". + console.error("[merkzettel] toggleLightboxItem failed:", error); setInLightbox(inLightbox); } }); diff --git a/src/components/download/usage-dialog.tsx b/src/components/download/usage-dialog.tsx index 971be2a..43e12be 100644 --- a/src/components/download/usage-dialog.tsx +++ b/src/components/download/usage-dialog.tsx @@ -87,7 +87,11 @@ export function UsageDialog({ headers: { "content-type": "application/json" }, body: JSON.stringify(payload), }); - if (!response.ok) throw new Error("intent failed"); + if (!response.ok) { + const code = await readErrorCode(response); + setError(downloadErrorMessage(code, response.status)); + return; + } const intent = (await response.json()) as IntentResponse; if (!isLocalDownloadUrl(intent.fileUrl, intent.downloadId)) { throw new Error("invalid download url"); @@ -99,9 +103,9 @@ export function UsageDialog({ dialogRef.current?.close(); idempotencyKeyRef.current = null; } catch { - setError( - "Der Download konnte nicht vorbereitet werden. Versuchen Sie dieselbe Anfrage erneut.", - ); + // Network failure / response not JSON — the server-code cases are + // handled above; this is only a transport-level failure. + setError("Der Download konnte nicht vorbereitet werden (Netzwerkfehler). Versuchen Sie es erneut."); } finally { setPending(false); } @@ -220,3 +224,39 @@ function formatDate(value: string): string { function isLocalDownloadUrl(fileUrl: string, downloadId: string): boolean { return fileUrl === `/api/downloads/${encodeURIComponent(downloadId)}/file`; } + +async function readErrorCode(response: Response): Promise { + try { + const data = (await response.json()) as { code?: unknown }; + return typeof data.code === "string" ? data.code : null; + } catch { + return null; + } +} + +// Map the server's stable error codes (see intent-handler.ts) to specific +// German messages so the editorial sees the real reason instead of a generic +// "try again". The fallback includes the raw code so unmapped failures are +// still actionable when reported back. +function downloadErrorMessage(code: string | null, status: number): string { + switch (code) { + case "FORBIDDEN": + return "Ihr Konto ist nicht freigegeben oder gesperrt."; + case "INVALID_REQUEST": + return "Die Anfrage war unvollständig. Bitte laden Sie die Seite neu und versuchen Sie es erneut."; + case "IDEMPOTENCY_CONFLICT": + return "Dieser Download wurde bereits registriert. Bitte laden Sie die Seite neu."; + case "NOT_FOUND": + return "Das Bild ist nicht im freigegebenen Album enthalten oder wurde daraus entfernt."; + case "UPSTREAM_UNAVAILABLE": + return "Immich ist momentan nicht erreichbar. Bitte versuchen Sie es in wenigen Minuten erneut."; + case "INVALID_ASSET": + return "Dieses Asset ist kein Bild und kann nicht lizenziert werden."; + case "ACCOUNTING_UNAVAILABLE": + return "Für Ihr Konto ist noch kein Preis hinterlegt. Bitte den Admin, einen Preis festzulegen."; + case "CROSS_ORIGIN_REQUEST": + return "Die Anfrage wurde aus einer unzulässigen Herkunft gestellt."; + default: + return `Download fehlgeschlagen (Code ${code ?? status}). Bitte erneut versuchen.`; + } +} diff --git a/src/modules/albums/catalog-content.tsx b/src/modules/albums/catalog-content.tsx index 52e2695..9f6e2f3 100644 --- a/src/modules/albums/catalog-content.tsx +++ b/src/modules/albums/catalog-content.tsx @@ -8,29 +8,30 @@ import type { VisibleAlbum } from "./catalog"; export function AlbumContactSheet({ albums }: Readonly<{ albums: VisibleAlbum[] }>) { return ( -