Add Dockerfile, add raw view

This commit is contained in:
2025-12-21 13:27:12 +01:00
parent 9bb649c9e2
commit b1541f8777
35 changed files with 2811 additions and 78 deletions

View File

@ -0,0 +1,203 @@
"use client";
import { cn } from "@/lib/utils";
import Image from "next/image";
import Link from "next/link";
import React from "react";
type ArtworkGalleryItem = {
id: string;
name: string;
altText: string | null;
okLabL: number | null;
file: { fileKey: string };
metadata: { width: number; height: number } | null;
tags: { id: string; name: string }[];
};
type FitMode =
| { mode: "fixedWidth"; width: number } // height varies
| { mode: "fixedHeight"; height: number }; // width varies
function getOverlayTextClass(okLabL: number | null | undefined) {
// if okLabL is 0..100, change threshold to ~65
// if (typeof okLabL === "number") return okLabL >= 0.65 ? "text-black" : "text-white";
return "text-white";
}
function getOverlayBgClass(okLabL: number | null | undefined) {
// if (typeof okLabL === "number") return okLabL >= 0.65 ? "bg-white/60" : "bg-black/45";
return "bg-black/45";
}
type OpenSheet = "alt" | "tags" | null;
const BUTTON_BAR_HEIGHT = 36;
export default function ArtworkThumbGallery({
items,
hrefBase = "/artworks",
fit = { mode: "fixedWidth", width: 400 },
}: {
items: ArtworkGalleryItem[];
hrefBase?: string;
fit?: FitMode;
}) {
const [openSheet, setOpenSheet] = React.useState<Record<string, OpenSheet>>({});
const toggleSheet = (id: string, which: Exclude<OpenSheet, null>) => {
setOpenSheet((prev) => {
const current = prev[id] ?? null;
// toggle off if same, switch if different
return { ...prev, [id]: current === which ? null : which };
});
};
if (items.length === 0) {
return <p className="text-muted-foreground italic">No artworks found.</p>;
}
return (
<div className="flex flex-wrap gap-4">
{items.map((a) => {
const textClass = getOverlayTextClass(a.okLabL);
const bgClass = getOverlayBgClass(a.okLabL);
const w = a.metadata?.width ?? 4;
const h = a.metadata?.height ?? 3;
const tileStyle: React.CSSProperties =
fit.mode === "fixedWidth"
? { width: fit.width, aspectRatio: `${w} / ${h}` }
: { height: fit.height, aspectRatio: `${w} / ${h}` };
const sheet = openSheet[a.id] ?? null;
return (
<div key={a.id} style={tileStyle}>
<div className="relative h-full w-full overflow-hidden rounded-md border">
<Link href={`${hrefBase}/single/${a.id}`} className="block h-full w-full">
<Image
src={`/api/image/thumbnail/${a.file.fileKey}.webp`}
alt={a.altText ?? a.name ?? "Artwork"}
fill
className="object-cover"
loading="lazy"
sizes={fit.mode === "fixedWidth" ? `${fit.width}px` : undefined}
/>
</Link>
{/* Title overlay */}
<div
className={cn(
"absolute left-0 right-0 top-0 px-3 py-2",
bgClass,
"backdrop-blur-[1px]"
)}
>
<div className={cn("truncate text-sm font-medium", textClass)}>
{a.name}
</div>
</div>
{/* Bottom button bar (reserved space) */}
<div
className="absolute left-0 right-0 bottom-0 z-20 flex items-center justify-between px-2"
style={{ height: BUTTON_BAR_HEIGHT }}
>
{/* Tags button */}
{/* <button
type="button"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
toggleSheet(a.id, "tags");
}}
className={cn(
"rounded px-2 py-1 text-xs font-medium",
bgClass,
textClass,
"hover:opacity-90"
)}
>
Tags
</button> */}
{/* Alt button */}
{/* <button
type="button"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
toggleSheet(a.id, "alt");
}}
className={cn(
"rounded px-2 py-1 text-xs font-medium",
bgClass,
textClass,
"hover:opacity-90"
)}
>
Alt
</button> */}
</div>
{/* Bottom sheet — stops ABOVE button bar */}
{/* <div
className={cn(
"absolute left-0 right-0 z-10",
"transition-transform duration-200 ease-out",
sheet ? "translate-y-0" : "translate-y-full"
)}
style={{ bottom: BUTTON_BAR_HEIGHT }}
>
<div className="rounded-t-md px-3 py-3 backdrop-blur-[2px]">
{sheet === "alt" ? (
<div className="space-y-2">
<div className="text-sm text-white">
{a.altText?.trim() ? a.altText : "No alt text set."}
</div>
</div>
) : null}
{sheet === "tags" ? (
<div className="space-y-2">
<div className="flex flex-wrap gap-2">
{a.tags.length > 0 ? (
a.tags.map((t) => (
<span
key={t.id}
className="rounded bg-white/15 px-2 py-1 text-xs text-white"
>
{t.name}
</span>
))
) : (
<span className="text-sm text-white/90">No tags set.</span>
)}
</div>
</div>
) : null}
</div>
</div> */}
{/* Optional click-away close */}
{/* {sheet ? (
<button
type="button"
aria-label="Close overlay"
className="absolute inset-0 z-5 cursor-default"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setOpenSheet((prev) => ({ ...prev, [a.id]: null }));
}}
/>
) : null} */}
</div>
</div>
);
})}
</div>
);
}