Build the gallery: virtualised grid, filters and a full-size viewer
The client half. The gallery now reads real captures, pages by cursor and loads thumbnails through the auth-checked route, so an image is only ever served to a request that carried a valid session. Virtualised because the gallery is the one screen that grows without bound. 5000 captures a day is past a million DOM nodes inside a year, and the browser gives up long before the database does. react-virtual virtualises a list rather than a grid, so the grid is a list of rows whose column count is computed from the measured container width - which also makes it responsive without a media-query ladder, and is why the width is observed rather than assumed. A ResizeObserver rather than a window resize listener, because the filter panel changes that element's width without the window changing at all. Filters cover what the server can answer: date range, device, kept, reviewed, pre-trigger. Taxon and tag are deliberately absent until taxa is seeded and the observation editor exists, for the same reason they are absent from the endpoint. The triage filters are tri-state selects rather than checkboxes, because "kept" has three meanings - everything, only kept, only rejected - and a checkbox expresses two of them. Filters are part of the query key, so changing one starts fresh pagination instead of appending. A cursor from the previous filter set describes a position in a list that no longer exists. The viewer is keyboard-driven on purpose. Labelling a day of captures is look-decide-next a few hundred times, and that loop is only bearable from the keyboard. It steps only through what is already loaded, and the button is disabled at the edge rather than showing a blank frame while a page arrives. Two contract details the UI has to get right, both now carried in code with the reason attached: captured_at_device is null when the camera's clock was unsynced and is rendered as "not synced" rather than as 1970 (API.md, X-Captured-At: 0), and a model-sourced observation is badged as a prediction, because that table is also the training data for any future model and a prediction shown as a human label would poison it. has_thumb is why the summary carries it: the grid shows a placeholder for a capture whose thumbnail job has not run, instead of a broken image. Conventions held: no user-facing string literal in a component - 60-odd new keys in en.ts and de.ts, and the typed catalogue makes a missing German string a build error rather than English in front of a German user. No colour literal outside tokens.css either; the one place that wanted rgba() uses color-mix against a token instead. 36 contrast pairs across three themes still pass. Verified against the real stack with 506 real captures through the Vite proxy, which is the path the browser takes: 9 pages of 60 following the cursor, all 506 seen, zero duplicates across pages that include real burst timestamp ties, 0.28s for the lot, and 12 of 12 sampled thumbnails arriving as valid WebP. Not verified: how it looks. I have no browser here, so the layout, the scroll behaviour and the virtualisation actually recycling rows are unconfirmed by eye. Typecheck, build and the data path are green; the visual pass is yours. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
51750e1644
commit
29c8cf6bfe
12 files changed
+1197
-18
No files matched your search
+28
-9
@@ -60,13 +60,30 @@ The guard here decides what to *render*. It is not access control: the server
|
||||
authorises every request on its own, and deleting `RequireAuth.tsx` would
|
||||
expose no data, it would only render pages whose requests then 401.
|
||||
|
||||
**Only `GET /health` and `/auth/*` return real data.** So the **System** page
|
||||
shows live values and the others do not yet:
|
||||
**The gallery is real.** It reads `GET /api/v1/captures`, pages by cursor,
|
||||
and loads thumbnails through the auth-checked route — so an image is only
|
||||
served to a request that carried a valid session.
|
||||
|
||||
Gallery and Devices render an honest empty state. They are deliberately not
|
||||
filled with mock rows — fake data hides exactly the layout problems that real
|
||||
data exposes. The capture and device listing endpoints are the next server
|
||||
work; the six captures already in the dev database have nothing to serve them.
|
||||
To have something to look at:
|
||||
|
||||
```bash
|
||||
cd ../server
|
||||
.venv/Scripts/poorbird seed --captures 500
|
||||
.venv/Scripts/poorbird seed --clear # when you are done
|
||||
```
|
||||
|
||||
`--clear` only ever removes seeded data. It is scoped to its own device, so a
|
||||
real camera's captures are never in scope.
|
||||
|
||||
**Devices still renders an honest empty state.** It needs a device listing
|
||||
endpoint, which is Phase 4. It is deliberately not filled with mock rows —
|
||||
fake data hides exactly the layout problems real data exposes.
|
||||
|
||||
The grid is virtualised, which matters at the scale this reaches rather than
|
||||
the scale it starts at: 5000 captures a day is past a million DOM nodes within
|
||||
a year, and the browser gives up long before the database does. Only visible
|
||||
rows exist, and the column count is computed from the measured container width
|
||||
rather than from media queries.
|
||||
|
||||
---
|
||||
|
||||
@@ -105,9 +122,11 @@ src/
|
||||
router.tsx the whole route table, one flat file
|
||||
i18n/ en.ts (source of truth), de.ts (typed against it)
|
||||
theme/ data-theme on <html>
|
||||
auth/ provider, login form, route guard (not wired yet)
|
||||
lib/api.ts the only place that calls fetch
|
||||
components/ layout and shared pieces
|
||||
auth/ provider, login form, route guard
|
||||
lib/api.ts the only place that calls fetch, and the only one
|
||||
that knows about CSRF or builds image URLs
|
||||
components/ layout, shared pieces, CaptureGrid, CaptureViewer,
|
||||
GalleryFilters
|
||||
pages/ one per route
|
||||
styles/ tokens.css (themes), global.css (everything else)
|
||||
scripts/check-contrast.mjs
|
||||
|
||||
Generated
+28
@@ -10,6 +10,7 @@
|
||||
"dependencies": {
|
||||
"@tanstack/react-query": "^5.62.0",
|
||||
"@tanstack/react-router": "^1.95.0",
|
||||
"@tanstack/react-virtual": "^3.14.13",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
},
|
||||
@@ -1291,6 +1292,23 @@
|
||||
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/react-virtual": {
|
||||
"version": "3.14.13",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.14.13.tgz",
|
||||
"integrity": "sha512-JbDTAwtzZ99aOeCrAfW5EsE5KSq5RWh6Af2dtFwyLIIk48Ja7vm6n4axu/43T3vfjFnEGJalxJ1wyYjSQD6bSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/virtual-core": "3.17.11"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/router-core": {
|
||||
"version": "1.171.32",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/router-core/-/router-core-1.171.32.tgz",
|
||||
@@ -1320,6 +1338,16 @@
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/virtual-core": {
|
||||
"version": "3.17.11",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.17.11.tgz",
|
||||
"integrity": "sha512-+ILjvtHup6Y2hzQ6YzwMgX1Q+oQpxEGOXCEsCNaPoIP0VxMbizIBTmYTDtkerkIQS8/CbP1BRuyt8V/8BCsy1g==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/babel__core": {
|
||||
"version": "7.20.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"dependencies": {
|
||||
"@tanstack/react-query": "^5.62.0",
|
||||
"@tanstack/react-router": "^1.95.0",
|
||||
"@tanstack/react-virtual": "^3.14.13",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/* The virtualised capture grid.
|
||||
*
|
||||
* Virtualised because the gallery is the one screen that grows without bound:
|
||||
* 5000 captures a day means a year is well past a million DOM nodes, and the
|
||||
* browser gives up long before the data does. Only the visible rows exist.
|
||||
*
|
||||
* react-virtual virtualises a list, not a grid, so the grid is a list of rows
|
||||
* and the column count is computed from the measured width. That keeps the
|
||||
* layout responsive without a media-query ladder, and it is why the container
|
||||
* width is observed rather than assumed.
|
||||
*/
|
||||
|
||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||
|
||||
import { useT } from "../i18n/I18nProvider";
|
||||
import type { CaptureSummary } from "../lib/api";
|
||||
import { thumbUrl } from "../lib/api";
|
||||
|
||||
/** Smallest tile that still shows a recognisable bird. */
|
||||
const MIN_TILE_PX = 200;
|
||||
const GAP_PX = 12;
|
||||
|
||||
/* Thumbnails are 400px on the long edge (SPEC 3.3) and the camera shoots 4:3,
|
||||
* so a 4:3 tile shows the whole frame without cropping. Guessing wrong here
|
||||
* only costs a reflow, because the row height is derived from it rather than
|
||||
* measured per image. */
|
||||
const TILE_ASPECT = 3 / 4;
|
||||
|
||||
/** Start the next page this many rows before the end. */
|
||||
const PREFETCH_ROWS = 3;
|
||||
|
||||
function useColumnCount(ref: React.RefObject<HTMLDivElement | null>): number {
|
||||
const [columns, setColumns] = useState(1);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const element = ref.current;
|
||||
if (element === null) return;
|
||||
|
||||
const measure = () => {
|
||||
const width = element.clientWidth;
|
||||
if (width === 0) return;
|
||||
setColumns(Math.max(1, Math.floor((width + GAP_PX) / (MIN_TILE_PX + GAP_PX))));
|
||||
};
|
||||
|
||||
measure();
|
||||
// ResizeObserver rather than a window resize listener: the sidebar and
|
||||
// the filter panel change this element's width without the window
|
||||
// changing size at all.
|
||||
const observer = new ResizeObserver(measure);
|
||||
observer.observe(element);
|
||||
return () => observer.disconnect();
|
||||
}, [ref]);
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
function Tile({
|
||||
capture,
|
||||
onOpen,
|
||||
}: {
|
||||
capture: CaptureSummary;
|
||||
onOpen: (capture: CaptureSummary) => void;
|
||||
}) {
|
||||
const t = useT();
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="tile"
|
||||
onClick={() => onOpen(capture)}
|
||||
// The received timestamp is the honest label: captured_at_device is null
|
||||
// whenever the camera's clock was unsynced.
|
||||
title={new Date(capture.received_at).toLocaleString()}
|
||||
>
|
||||
{capture.has_thumb ? (
|
||||
<img
|
||||
className="tile-image"
|
||||
src={thumbUrl(capture.id)}
|
||||
alt=""
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
// Tells the browser the shape before the bytes arrive, so a row
|
||||
// does not jump as thumbnails land.
|
||||
width={400}
|
||||
height={300}
|
||||
/>
|
||||
) : (
|
||||
<span className="tile-placeholder muted">{t("gallery.thumbPending")}</span>
|
||||
)}
|
||||
|
||||
<span className="tile-badges">
|
||||
{capture.pre_trigger && (
|
||||
<span className="badge" title={t("capture.preTrigger.hint")}>
|
||||
{t("capture.preTrigger")}
|
||||
</span>
|
||||
)}
|
||||
{!capture.kept && <span className="badge badge-danger">{t("filters.onlyRejected")}</span>}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export function CaptureGrid({
|
||||
captures,
|
||||
hasMore,
|
||||
isLoadingMore,
|
||||
onLoadMore,
|
||||
onOpen,
|
||||
}: {
|
||||
captures: CaptureSummary[];
|
||||
hasMore: boolean;
|
||||
isLoadingMore: boolean;
|
||||
onLoadMore: () => void;
|
||||
onOpen: (capture: CaptureSummary) => void;
|
||||
}) {
|
||||
const t = useT();
|
||||
const scrollRef = useRef<HTMLDivElement | null>(null);
|
||||
const columns = useColumnCount(scrollRef);
|
||||
const rowCount = Math.ceil(captures.length / columns);
|
||||
|
||||
const virtualizer = useVirtualizer({
|
||||
count: rowCount,
|
||||
getScrollElement: () => scrollRef.current,
|
||||
// Width per tile is (container - gaps) / columns; height follows the
|
||||
// aspect ratio. Close enough that rows do not need measuring.
|
||||
estimateSize: useCallback(() => {
|
||||
const width = scrollRef.current?.clientWidth ?? MIN_TILE_PX * columns;
|
||||
const tileWidth = (width - GAP_PX * (columns - 1)) / columns;
|
||||
return tileWidth / TILE_ASPECT + GAP_PX;
|
||||
}, [columns]),
|
||||
overscan: 2,
|
||||
});
|
||||
|
||||
// Re-measure when the column count changes, or every row keeps the height
|
||||
// it had at the old width and the grid overlaps itself.
|
||||
useEffect(() => {
|
||||
virtualizer.measure();
|
||||
}, [columns, virtualizer]);
|
||||
|
||||
const virtualRows = virtualizer.getVirtualItems();
|
||||
const lastVisibleRow = virtualRows.at(-1)?.index ?? 0;
|
||||
|
||||
useEffect(() => {
|
||||
if (hasMore && !isLoadingMore && lastVisibleRow >= rowCount - PREFETCH_ROWS) {
|
||||
onLoadMore();
|
||||
}
|
||||
}, [hasMore, isLoadingMore, lastVisibleRow, rowCount, onLoadMore]);
|
||||
|
||||
return (
|
||||
<div className="grid-scroll" ref={scrollRef}>
|
||||
<div className="grid-sizer" style={{ height: `${virtualizer.getTotalSize()}px` }}>
|
||||
{virtualRows.map((row) => {
|
||||
const start = row.index * columns;
|
||||
return (
|
||||
<div
|
||||
key={row.key}
|
||||
className="grid-row"
|
||||
style={{
|
||||
// Absolutely positioned by the virtualizer's offset, which is
|
||||
// what lets the scrollbar reflect all the rows while only a
|
||||
// handful exist.
|
||||
transform: `translateY(${row.start}px)`,
|
||||
height: `${row.size}px`,
|
||||
gridTemplateColumns: `repeat(${columns}, 1fr)`,
|
||||
gap: `${GAP_PX}px`,
|
||||
}}
|
||||
>
|
||||
{captures.slice(start, start + columns).map((capture) => (
|
||||
<Tile key={capture.id} capture={capture} onOpen={onOpen} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<p className="grid-footer muted" role="status">
|
||||
{isLoadingMore ? t("gallery.loadingMore") : hasMore ? "" : t("gallery.allLoaded")}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
/* Full-screen view of one capture.
|
||||
*
|
||||
* Keyboard-driven on purpose. Labelling a day of captures is a loop of
|
||||
* look-decide-next, hundreds of times, and that loop is only bearable from
|
||||
* the keyboard -- arrows to move, Escape to leave. The mouse is the fallback,
|
||||
* not the design.
|
||||
*/
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { useT } from "../i18n/I18nProvider";
|
||||
import type { Translate } from "../i18n/I18nProvider";
|
||||
import type { CaptureSummary } from "../lib/api";
|
||||
import { getCapture, imageUrl } from "../lib/api";
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(0)} KB`;
|
||||
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
||||
}
|
||||
|
||||
function triggerLabel(t: Translate, trigger: CaptureSummary["trigger"]): string {
|
||||
switch (trigger) {
|
||||
case "radar":
|
||||
return t("capture.trigger.radar");
|
||||
case "manual":
|
||||
return t("capture.trigger.manual");
|
||||
case "timer":
|
||||
return t("capture.trigger.timer");
|
||||
case "stream_grab":
|
||||
return t("capture.trigger.stream_grab");
|
||||
}
|
||||
}
|
||||
|
||||
function Row({ label, value }: { label: string; value: string }) {
|
||||
return (
|
||||
<div className="detail-row">
|
||||
<span className="detail-label muted">{label}</span>
|
||||
<span className="detail-value">{value}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function CaptureViewer({
|
||||
capture,
|
||||
onClose,
|
||||
onPrevious,
|
||||
onNext,
|
||||
}: {
|
||||
capture: CaptureSummary;
|
||||
onClose: () => void;
|
||||
onPrevious: (() => void) | null;
|
||||
onNext: (() => void) | null;
|
||||
}) {
|
||||
const t = useT();
|
||||
|
||||
// The summary is already in hand from the grid, so the detail query only
|
||||
// adds the extra fields. Showing the image immediately and filling the
|
||||
// metadata a moment later beats a spinner over the whole overlay.
|
||||
const detail = useQuery({
|
||||
queryKey: ["capture", capture.id],
|
||||
queryFn: () => getCapture(capture.id),
|
||||
staleTime: 60_000,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
function onKey(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") onClose();
|
||||
if (event.key === "ArrowLeft" && onPrevious !== null) onPrevious();
|
||||
if (event.key === "ArrowRight" && onNext !== null) onNext();
|
||||
}
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [onClose, onPrevious, onNext]);
|
||||
|
||||
const full = detail.data;
|
||||
|
||||
return (
|
||||
// eslint-disable-next-line -- the overlay is a dialog; the backdrop click
|
||||
// is a convenience and every action it offers is also a real button.
|
||||
<div className="viewer-backdrop" role="dialog" aria-modal="true" aria-label={t("capture.title")}>
|
||||
<div className="viewer">
|
||||
<header className="viewer-header">
|
||||
<span className="muted">{new Date(capture.received_at).toLocaleString()}</span>
|
||||
<div className="viewer-actions">
|
||||
<button
|
||||
className="button"
|
||||
type="button"
|
||||
onClick={onPrevious ?? undefined}
|
||||
disabled={onPrevious === null}
|
||||
>
|
||||
{t("capture.previous")}
|
||||
</button>
|
||||
<button
|
||||
className="button"
|
||||
type="button"
|
||||
onClick={onNext ?? undefined}
|
||||
disabled={onNext === null}
|
||||
>
|
||||
{t("capture.next")}
|
||||
</button>
|
||||
<button className="button button-primary" type="button" onClick={onClose}>
|
||||
{t("capture.close")}
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="viewer-body">
|
||||
<div className="viewer-image-wrap">
|
||||
<img className="viewer-image" src={imageUrl(capture.id)} alt="" />
|
||||
</div>
|
||||
|
||||
<aside className="viewer-meta">
|
||||
<Row
|
||||
label={t("capture.receivedAt")}
|
||||
value={new Date(capture.received_at).toLocaleString()}
|
||||
/>
|
||||
{/* captured_at_device is null when the camera clock was unsynced.
|
||||
API.md is explicit that X-Captured-At: 0 means "unsynced", not
|
||||
1970, so this must never render as a date. */}
|
||||
<Row
|
||||
label={t("capture.capturedAt")}
|
||||
value={
|
||||
capture.captured_at_device === null
|
||||
? t("capture.capturedAt.unsynced")
|
||||
: new Date(capture.captured_at_device).toLocaleString()
|
||||
}
|
||||
/>
|
||||
{full !== undefined && <Row label={t("capture.device")} value={full.device_name} />}
|
||||
<Row label={t("capture.trigger")} value={triggerLabel(t, capture.trigger)} />
|
||||
{capture.width !== null && capture.height !== null && (
|
||||
<Row
|
||||
label={t("capture.dimensions")}
|
||||
value={`${capture.width} × ${capture.height}`}
|
||||
/>
|
||||
)}
|
||||
<Row label={t("capture.fileSize")} value={formatBytes(capture.bytes)} />
|
||||
{capture.burst_count !== null && capture.burst_index !== null && (
|
||||
<Row
|
||||
label={t("capture.title")}
|
||||
value={t("capture.burst", {
|
||||
index: capture.burst_index + 1,
|
||||
count: capture.burst_count,
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
{capture.pre_trigger && (
|
||||
<Row label={t("capture.preTrigger")} value={t("capture.preTrigger.hint")} />
|
||||
)}
|
||||
|
||||
{full?.radar_distance_cm != null && (
|
||||
<Row label={t("capture.radarDistance")} value={`${full.radar_distance_cm} cm`} />
|
||||
)}
|
||||
{full?.radar_energy != null && (
|
||||
<Row label={t("capture.radarEnergy")} value={String(full.radar_energy)} />
|
||||
)}
|
||||
{full?.rssi != null && <Row label={t("capture.rssi")} value={`${full.rssi} dBm`} />}
|
||||
{full?.temp_c != null && (
|
||||
<Row label={t("capture.temperature")} value={`${full.temp_c} °C`} />
|
||||
)}
|
||||
|
||||
<Row
|
||||
label={t("capture.reviewed")}
|
||||
value={capture.reviewed ? t("common.yes") : t("common.no")}
|
||||
/>
|
||||
<Row
|
||||
label={t("capture.kept")}
|
||||
value={capture.kept ? t("common.yes") : t("common.no")}
|
||||
/>
|
||||
|
||||
<h3 className="detail-heading">{t("capture.observations")}</h3>
|
||||
{full === undefined || full.observations.length === 0 ? (
|
||||
<p className="muted">{t("capture.observations.none")}</p>
|
||||
) : (
|
||||
<ul className="detail-list">
|
||||
{full.observations.map((observation) => (
|
||||
<li key={observation.id}>
|
||||
{observation.taxon?.name_de ??
|
||||
observation.taxon?.scientific_name ??
|
||||
t("common.notMeasured")}
|
||||
{/* A prediction must never look like a human label: this
|
||||
table is also the training data for any future model
|
||||
(SPEC 3.2). */}
|
||||
{observation.source === "model" && (
|
||||
<span className="badge"> {t("capture.observations.model")}</span>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{full !== undefined && full.tags.length > 0 && (
|
||||
<>
|
||||
<h3 className="detail-heading">{t("capture.tags")}</h3>
|
||||
<ul className="detail-list">
|
||||
{full.tags.map((tag) => (
|
||||
<li key={tag.id}>{tag.label}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/* Gallery filters.
|
||||
*
|
||||
* Only the filters the server can actually answer. Taxon and tag filters are
|
||||
* in TODO Phase 3 and deliberately absent until there is a seeded taxa table
|
||||
* and an observation editor to fill them -- offering a control that can only
|
||||
* ever return nothing is worse than not offering it.
|
||||
*
|
||||
* The triage filters are tri-state (any / yes / no) rather than checkboxes,
|
||||
* because "kept" has three meanings here: show everything, show only kept,
|
||||
* show only rejected. A checkbox can express two of those.
|
||||
*/
|
||||
|
||||
import { useT } from "../i18n/I18nProvider";
|
||||
import type { CaptureFilters } from "../lib/api";
|
||||
|
||||
export type { CaptureFilters };
|
||||
|
||||
/** A <select> for a boolean that may also be unset. */
|
||||
function TriState({
|
||||
label,
|
||||
value,
|
||||
onChange,
|
||||
yesLabel,
|
||||
noLabel,
|
||||
}: {
|
||||
label: string;
|
||||
value: boolean | undefined;
|
||||
onChange: (next: boolean | undefined) => void;
|
||||
yesLabel: string;
|
||||
noLabel: string;
|
||||
}) {
|
||||
const t = useT();
|
||||
return (
|
||||
<label className="field field-inline">
|
||||
<span className="field-label">{label}</span>
|
||||
<select
|
||||
className="input"
|
||||
value={value === undefined ? "" : String(value)}
|
||||
onChange={(event) => {
|
||||
const raw = event.target.value;
|
||||
onChange(raw === "" ? undefined : raw === "true");
|
||||
}}
|
||||
>
|
||||
<option value="">{t("filters.any")}</option>
|
||||
<option value="true">{yesLabel}</option>
|
||||
<option value="false">{noLabel}</option>
|
||||
</select>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
/** A date input carries a local calendar day; the API wants an instant. */
|
||||
function dayStart(value: string): string | undefined {
|
||||
if (value === "") return undefined;
|
||||
return new Date(`${value}T00:00:00`).toISOString();
|
||||
}
|
||||
|
||||
function dayEnd(value: string): string | undefined {
|
||||
if (value === "") return undefined;
|
||||
// Inclusive: picking the same day for both ends should return that day,
|
||||
// which an exclusive midnight boundary would make an empty range.
|
||||
return new Date(`${value}T23:59:59.999`).toISOString();
|
||||
}
|
||||
|
||||
/** Back to what a date input can display, in local time. */
|
||||
function toDateInput(iso: string | undefined): string {
|
||||
if (iso === undefined) return "";
|
||||
const date = new Date(iso);
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(date.getDate()).padStart(2, "0");
|
||||
return `${date.getFullYear()}-${month}-${day}`;
|
||||
}
|
||||
|
||||
export function GalleryFilters({
|
||||
filters,
|
||||
onChange,
|
||||
devices,
|
||||
}: {
|
||||
filters: CaptureFilters;
|
||||
onChange: (next: CaptureFilters) => void;
|
||||
devices: { id: number; name: string }[];
|
||||
}) {
|
||||
const t = useT();
|
||||
const active = Object.values(filters).some((value) => value !== undefined);
|
||||
|
||||
return (
|
||||
<div className="filters">
|
||||
<label className="field field-inline">
|
||||
<span className="field-label">{t("filters.device")}</span>
|
||||
<select
|
||||
className="input"
|
||||
value={filters.device_id === undefined ? "" : String(filters.device_id)}
|
||||
onChange={(event) =>
|
||||
onChange({
|
||||
...filters,
|
||||
device_id: event.target.value === "" ? undefined : Number(event.target.value),
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">{t("filters.device.all")}</option>
|
||||
{devices.map((device) => (
|
||||
<option key={device.id} value={device.id}>
|
||||
{device.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label className="field field-inline">
|
||||
<span className="field-label">{t("filters.from")}</span>
|
||||
<input
|
||||
className="input"
|
||||
type="date"
|
||||
value={toDateInput(filters.received_from)}
|
||||
onChange={(event) =>
|
||||
onChange({ ...filters, received_from: dayStart(event.target.value) })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label className="field field-inline">
|
||||
<span className="field-label">{t("filters.to")}</span>
|
||||
<input
|
||||
className="input"
|
||||
type="date"
|
||||
value={toDateInput(filters.received_to)}
|
||||
onChange={(event) => onChange({ ...filters, received_to: dayEnd(event.target.value) })}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<TriState
|
||||
label={t("filters.kept")}
|
||||
value={filters.kept}
|
||||
onChange={(kept) => onChange({ ...filters, kept })}
|
||||
yesLabel={t("filters.onlyKept")}
|
||||
noLabel={t("filters.onlyRejected")}
|
||||
/>
|
||||
|
||||
<TriState
|
||||
label={t("filters.reviewed")}
|
||||
value={filters.reviewed}
|
||||
onChange={(reviewed) => onChange({ ...filters, reviewed })}
|
||||
yesLabel={t("filters.onlyReviewed")}
|
||||
noLabel={t("filters.onlyUnreviewed")}
|
||||
/>
|
||||
|
||||
<label className="field field-inline">
|
||||
<span className="field-label">{t("filters.preTrigger")}</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={filters.pre_trigger === true}
|
||||
onChange={(event) =>
|
||||
onChange({ ...filters, pre_trigger: event.target.checked ? true : undefined })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<button
|
||||
className="button"
|
||||
type="button"
|
||||
onClick={() => onChange({})}
|
||||
disabled={!active}
|
||||
>
|
||||
{t("filters.clear")}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+54
-1
@@ -43,7 +43,60 @@ export const de: Catalogue = {
|
||||
"gallery.title": "Galerie",
|
||||
"gallery.empty.title": "Noch keine Aufnahmen",
|
||||
"gallery.empty.body":
|
||||
"Die Kamera hat noch nichts hochgeladen. Der Upload kommt in Phase 2; bis dahin bleibt diese Liste leer.",
|
||||
"Die Kamera hat noch nichts hochgeladen. Zum Ausprobieren welche erzeugen: poorbird seed --captures 500",
|
||||
"gallery.empty.filtered.title": "Keine Treffer für diese Filter",
|
||||
"gallery.empty.filtered.body": "Zeitraum erweitern oder Filter zurücksetzen.",
|
||||
"gallery.count": "{shown} von {total} geladen",
|
||||
"gallery.loadingMore": "Lädt weitere…",
|
||||
"gallery.allLoaded": "Das sind alle.",
|
||||
"gallery.noThumb": "Keine Vorschau",
|
||||
"gallery.thumbPending": "Vorschau noch nicht fertig",
|
||||
|
||||
"filters.title": "Filter",
|
||||
"filters.clear": "Filter zurücksetzen",
|
||||
"filters.device": "Kamera",
|
||||
"filters.device.all": "Alle Kameras",
|
||||
"filters.from": "Von",
|
||||
"filters.to": "Bis",
|
||||
"filters.kept": "Behalten",
|
||||
"filters.reviewed": "Durchgesehen",
|
||||
"filters.preTrigger": "Nur Pre-Trigger",
|
||||
"filters.any": "Alle",
|
||||
"filters.onlyKept": "Nur behaltene",
|
||||
"filters.onlyRejected": "Nur verworfene",
|
||||
"filters.onlyReviewed": "Nur durchgesehene",
|
||||
"filters.onlyUnreviewed": "Nur nicht durchgesehene",
|
||||
|
||||
"capture.title": "Aufnahme",
|
||||
"capture.close": "Schließen",
|
||||
"capture.previous": "Zurück",
|
||||
"capture.next": "Weiter",
|
||||
"capture.openFull": "In Originalgröße öffnen",
|
||||
"capture.receivedAt": "Empfangen",
|
||||
"capture.capturedAt": "Kamerauhr",
|
||||
"capture.capturedAt.unsynced": "Nicht synchronisiert",
|
||||
"capture.device": "Kamera",
|
||||
"capture.dimensions": "Größe",
|
||||
"capture.fileSize": "Datei",
|
||||
"capture.trigger": "Auslöser",
|
||||
"capture.trigger.radar": "Radar",
|
||||
"capture.trigger.manual": "Manuell",
|
||||
"capture.trigger.timer": "Timer",
|
||||
"capture.trigger.stream_grab": "Stream-Bild",
|
||||
"capture.preTrigger": "Pre-Trigger-Bild",
|
||||
"capture.preTrigger.hint":
|
||||
"Vor dem Auslösen aufgenommen, aus dem Ringpuffer der Kamera",
|
||||
"capture.burst": "Bild {index} von {count}",
|
||||
"capture.radarDistance": "Radar-Entfernung",
|
||||
"capture.radarEnergy": "Radar-Energie",
|
||||
"capture.rssi": "WLAN-Signal",
|
||||
"capture.temperature": "Temperatur",
|
||||
"capture.reviewed": "Durchgesehen",
|
||||
"capture.kept": "Behalten",
|
||||
"capture.observations": "Beobachtungen",
|
||||
"capture.observations.none": "Noch nicht bestimmt",
|
||||
"capture.observations.model": "Modell-Vorhersage",
|
||||
"capture.tags": "Schlagwörter",
|
||||
|
||||
"devices.title": "Geräte",
|
||||
"devices.empty.title": "Keine Geräte registriert",
|
||||
|
||||
+55
-1
@@ -49,7 +49,61 @@ export const en = {
|
||||
"gallery.title": "Gallery",
|
||||
"gallery.empty.title": "No captures yet",
|
||||
"gallery.empty.body":
|
||||
"The camera has not uploaded anything. Ingest arrives in Phase 2; until then this list stays empty.",
|
||||
"The camera has not uploaded anything yet. Generate some to work with: poorbird seed --captures 500",
|
||||
"gallery.empty.filtered.title": "Nothing matches these filters",
|
||||
"gallery.empty.filtered.body": "Widen the date range, or clear the filters.",
|
||||
"gallery.count": "{shown} of {total} loaded",
|
||||
"gallery.loadingMore": "Loading more…",
|
||||
"gallery.allLoaded": "That is all of them.",
|
||||
"gallery.noThumb": "No preview",
|
||||
// The thumbnail job has not run yet. Distinct from "cannot be decoded",
|
||||
// which looks identical to a user and means something very different.
|
||||
"gallery.thumbPending": "Preview not ready",
|
||||
|
||||
"filters.title": "Filters",
|
||||
"filters.clear": "Clear filters",
|
||||
"filters.device": "Camera",
|
||||
"filters.device.all": "All cameras",
|
||||
"filters.from": "From",
|
||||
"filters.to": "To",
|
||||
"filters.kept": "Kept",
|
||||
"filters.reviewed": "Reviewed",
|
||||
"filters.preTrigger": "Pre-trigger only",
|
||||
"filters.any": "Any",
|
||||
"filters.onlyKept": "Kept only",
|
||||
"filters.onlyRejected": "Rejected only",
|
||||
"filters.onlyReviewed": "Reviewed only",
|
||||
"filters.onlyUnreviewed": "Not reviewed only",
|
||||
|
||||
"capture.title": "Capture",
|
||||
"capture.close": "Close",
|
||||
"capture.previous": "Previous",
|
||||
"capture.next": "Next",
|
||||
"capture.openFull": "Open full size",
|
||||
"capture.receivedAt": "Received",
|
||||
"capture.capturedAt": "Camera clock",
|
||||
"capture.capturedAt.unsynced": "Not synced",
|
||||
"capture.device": "Camera",
|
||||
"capture.dimensions": "Size",
|
||||
"capture.fileSize": "File",
|
||||
"capture.trigger": "Trigger",
|
||||
"capture.trigger.radar": "Radar",
|
||||
"capture.trigger.manual": "Manual",
|
||||
"capture.trigger.timer": "Timer",
|
||||
"capture.trigger.stream_grab": "Stream grab",
|
||||
"capture.preTrigger": "Pre-trigger frame",
|
||||
"capture.preTrigger.hint": "Captured before the trigger fired, from the camera's ring buffer",
|
||||
"capture.burst": "Frame {index} of {count}",
|
||||
"capture.radarDistance": "Radar distance",
|
||||
"capture.radarEnergy": "Radar energy",
|
||||
"capture.rssi": "WiFi signal",
|
||||
"capture.temperature": "Temperature",
|
||||
"capture.reviewed": "Reviewed",
|
||||
"capture.kept": "Kept",
|
||||
"capture.observations": "Observations",
|
||||
"capture.observations.none": "Not labelled yet",
|
||||
"capture.observations.model": "Model prediction",
|
||||
"capture.tags": "Tags",
|
||||
|
||||
"devices.title": "Devices",
|
||||
"devices.empty.title": "No devices enrolled",
|
||||
|
||||
@@ -137,3 +137,117 @@ export interface HealthResponse {
|
||||
export function getHealth(): Promise<HealthResponse> {
|
||||
return apiGet<HealthResponse>("/health");
|
||||
}
|
||||
|
||||
/* --- gallery ---------------------------------------------------------- */
|
||||
|
||||
export interface CaptureSummary {
|
||||
id: string;
|
||||
device_id: number;
|
||||
/** Server time, and authoritative (SPEC C7). Always present. */
|
||||
received_at: string;
|
||||
/** Null when the camera's clock was unsynced. Never render it as 1970. */
|
||||
captured_at_device: string | null;
|
||||
width: number | null;
|
||||
height: number | null;
|
||||
bytes: number;
|
||||
trigger: "radar" | "manual" | "timer" | "stream_grab";
|
||||
pre_trigger: boolean;
|
||||
burst_id: string | null;
|
||||
burst_index: number | null;
|
||||
burst_count: number | null;
|
||||
reviewed: boolean;
|
||||
kept: boolean;
|
||||
/** False while the thumbnail job is queued, or forever if it cannot decode. */
|
||||
has_thumb: boolean;
|
||||
}
|
||||
|
||||
export interface CapturePage {
|
||||
items: CaptureSummary[];
|
||||
/** Null at the end. Opaque -- pass it back, do not parse it. */
|
||||
next_cursor: string | null;
|
||||
}
|
||||
|
||||
export interface TagOut {
|
||||
id: number;
|
||||
label: string;
|
||||
colour: string | null;
|
||||
}
|
||||
|
||||
export interface TaxonOut {
|
||||
id: number;
|
||||
scientific_name: string;
|
||||
name_de: string | null;
|
||||
name_en: string | null;
|
||||
}
|
||||
|
||||
export interface ObservationOut {
|
||||
id: number;
|
||||
taxon: TaxonOut | null;
|
||||
individuals: number;
|
||||
age: string;
|
||||
sex: string;
|
||||
behaviour: string | null;
|
||||
certainty: string;
|
||||
notes: string | null;
|
||||
/** "model" is a prediction. Never present one as a human label. */
|
||||
source: "human" | "model";
|
||||
confidence: number | null;
|
||||
}
|
||||
|
||||
export interface CaptureDetail extends CaptureSummary {
|
||||
device_name: string;
|
||||
sha256: string;
|
||||
radar_state: number | null;
|
||||
radar_distance_cm: number | null;
|
||||
radar_energy: number | null;
|
||||
battery_mv: number | null;
|
||||
rssi: number | null;
|
||||
temp_c: number | null;
|
||||
frame_seq: number | null;
|
||||
observations: ObservationOut[];
|
||||
tags: TagOut[];
|
||||
}
|
||||
|
||||
export interface CaptureFilters {
|
||||
device_id?: number;
|
||||
received_from?: string;
|
||||
received_to?: string;
|
||||
kept?: boolean;
|
||||
reviewed?: boolean;
|
||||
pre_trigger?: boolean;
|
||||
trigger?: string;
|
||||
}
|
||||
|
||||
export function listCaptures(
|
||||
filters: CaptureFilters,
|
||||
cursor: string | null,
|
||||
limit = 60
|
||||
): Promise<CapturePage> {
|
||||
// URLSearchParams, not string concatenation: an ISO timestamp ends in
|
||||
// "+00:00" and a raw "+" in a query string means a space, so the server
|
||||
// would answer 422 for a date it could otherwise have parsed.
|
||||
const params = new URLSearchParams({ limit: String(limit) });
|
||||
if (cursor !== null) params.set("cursor", cursor);
|
||||
for (const [key, value] of Object.entries(filters)) {
|
||||
// A tri-state filter is absent when undefined, and `false` is a real
|
||||
// value -- so this cannot be a truthiness check.
|
||||
if (value !== undefined) params.set(key, String(value));
|
||||
}
|
||||
return apiGet<CapturePage>(`/captures?${params.toString()}`);
|
||||
}
|
||||
|
||||
export function getCapture(id: string): Promise<CaptureDetail> {
|
||||
return apiGet<CaptureDetail>(`/captures/${id}`);
|
||||
}
|
||||
|
||||
/* Image URLs are built here rather than sent by the server, because this
|
||||
* module is already the one place that knows the API prefix. They go straight
|
||||
* into <img src>, so they are paths from the site root, and the session cookie
|
||||
* rides along because it is same-origin. */
|
||||
export function thumbUrl(id: string): string {
|
||||
return `/api/v1/captures/${id}/thumb`;
|
||||
}
|
||||
|
||||
export function imageUrl(id: string): string {
|
||||
return `/api/v1/captures/${id}/image`;
|
||||
}
|
||||
@@ -1,16 +1,121 @@
|
||||
import { useInfiniteQuery } from "@tanstack/react-query";
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
import { CaptureGrid } from "../components/CaptureGrid";
|
||||
import { CaptureViewer } from "../components/CaptureViewer";
|
||||
import { GalleryFilters } from "../components/GalleryFilters";
|
||||
import type { CaptureFilters } from "../components/GalleryFilters";
|
||||
import { EmptyState } from "../components/EmptyState";
|
||||
import { useT } from "../i18n/I18nProvider";
|
||||
import { ApiError, listCaptures } from "../lib/api";
|
||||
|
||||
/* The gallery. Phase 2 gives it something to show; until /captures exists
|
||||
* there is nothing to fetch, so this is honestly empty rather than filled
|
||||
* with fake rows that would hide layout problems. */
|
||||
/* The gallery.
|
||||
*
|
||||
* Paged by cursor rather than page number, matching the server: at 5000
|
||||
* captures a day OFFSET gets slower the further back you scroll, which is the
|
||||
* direction a gallery scrolls.
|
||||
*
|
||||
* The filters are part of the query key, so changing one starts a fresh
|
||||
* pagination rather than appending to the previous result -- a cursor from the
|
||||
* old filter set describes a position in a list that no longer exists.
|
||||
*/
|
||||
export function GalleryPage() {
|
||||
const t = useT();
|
||||
const [filters, setFilters] = useState<CaptureFilters>({});
|
||||
const [openIndex, setOpenIndex] = useState<number | null>(null);
|
||||
|
||||
const query = useInfiniteQuery({
|
||||
queryKey: ["captures", filters],
|
||||
queryFn: ({ pageParam }) => listCaptures(filters, pageParam),
|
||||
initialPageParam: null as string | null,
|
||||
getNextPageParam: (lastPage) => lastPage.next_cursor,
|
||||
staleTime: 30_000,
|
||||
});
|
||||
|
||||
const captures = useMemo(
|
||||
() => query.data?.pages.flatMap((page) => page.items) ?? [],
|
||||
[query.data]
|
||||
);
|
||||
|
||||
if (query.isPending) {
|
||||
return (
|
||||
<section>
|
||||
<h1 className="page-title">{t("gallery.title")}</h1>
|
||||
<p className="muted">{t("common.loading")}</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
const error = query.error;
|
||||
const message =
|
||||
error instanceof ApiError && error.status === 0
|
||||
? t("system.unreachable.body")
|
||||
: t("common.error");
|
||||
return (
|
||||
<section>
|
||||
<h1 className="page-title">{t("gallery.title")}</h1>
|
||||
<p className="alert alert-danger" role="alert">
|
||||
{message}
|
||||
</p>
|
||||
<button className="button" type="button" onClick={() => void query.refetch()}>
|
||||
{t("common.retry")}
|
||||
</button>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
// Devices to offer in the filter come from what has actually been loaded.
|
||||
// A device list endpoint is Phase 4; until then this is honest about only
|
||||
// knowing the cameras it has seen captures from.
|
||||
const devices = [...new Set(captures.map((capture) => capture.device_id))]
|
||||
.sort((a, b) => a - b)
|
||||
.map((id) => ({ id, name: `#${id}` }));
|
||||
|
||||
const filtersActive = Object.values(filters).some((value) => value !== undefined);
|
||||
const open = openIndex === null ? null : (captures[openIndex] ?? null);
|
||||
|
||||
return (
|
||||
<section>
|
||||
<h1 className="page-title">{t("gallery.title")}</h1>
|
||||
<EmptyState title={t("gallery.empty.title")} body={t("gallery.empty.body")} />
|
||||
<section className="gallery">
|
||||
<header className="gallery-header">
|
||||
<h1 className="page-title">{t("gallery.title")}</h1>
|
||||
<span className="muted">
|
||||
{t("gallery.count", { shown: captures.length, total: captures.length })}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<GalleryFilters filters={filters} onChange={setFilters} devices={devices} />
|
||||
|
||||
{captures.length === 0 ? (
|
||||
<EmptyState
|
||||
title={
|
||||
filtersActive ? t("gallery.empty.filtered.title") : t("gallery.empty.title")
|
||||
}
|
||||
body={filtersActive ? t("gallery.empty.filtered.body") : t("gallery.empty.body")}
|
||||
/>
|
||||
) : (
|
||||
<CaptureGrid
|
||||
captures={captures}
|
||||
hasMore={query.hasNextPage}
|
||||
isLoadingMore={query.isFetchingNextPage}
|
||||
onLoadMore={() => void query.fetchNextPage()}
|
||||
onOpen={(capture) =>
|
||||
setOpenIndex(captures.findIndex((candidate) => candidate.id === capture.id))
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
{open !== null && openIndex !== null && (
|
||||
<CaptureViewer
|
||||
capture={open}
|
||||
onClose={() => setOpenIndex(null)}
|
||||
onPrevious={openIndex > 0 ? () => setOpenIndex(openIndex - 1) : null}
|
||||
// Only as far as what is loaded. Stepping past the last loaded
|
||||
// capture would show a blank frame while a page arrives, so the
|
||||
// button is simply disabled there.
|
||||
onNext={openIndex < captures.length - 1 ? () => setOpenIndex(openIndex + 1) : null}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -357,3 +357,241 @@ code,
|
||||
animation-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- gallery ---------------------------------------------------------------
|
||||
Every colour here is a token. A literal would have to be repeated for each
|
||||
of the three themes, which is the thing tokens.css exists to prevent. */
|
||||
|
||||
.gallery-header {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-4);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-3) 0 var(--space-4);
|
||||
border-bottom: 1px solid var(--border);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.field-inline {
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.field-inline .input {
|
||||
min-width: 9rem;
|
||||
}
|
||||
|
||||
/* The virtualiser needs a scrolling element with a bounded height, or every
|
||||
row is "visible" and nothing is virtualised. */
|
||||
.grid-scroll {
|
||||
overflow-y: auto;
|
||||
max-height: calc(100vh - 20rem);
|
||||
min-height: 24rem;
|
||||
/* Keeps the scrollbar from shifting the layout as rows load. */
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.grid-sizer {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.grid-row {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.grid-footer {
|
||||
min-height: 1.5rem;
|
||||
padding: var(--space-3) 0;
|
||||
text-align: center;
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
.tile {
|
||||
position: relative;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
background: var(--surface-sunken);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
transition: border-color var(--transition);
|
||||
}
|
||||
|
||||
.tile:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.tile:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.tile-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.tile-placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: var(--space-2);
|
||||
font-size: var(--text-xs);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tile-badges {
|
||||
position: absolute;
|
||||
bottom: var(--space-1);
|
||||
left: var(--space-1);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.badge {
|
||||
padding: 2px var(--space-2);
|
||||
background: var(--accent-subtle);
|
||||
color: var(--accent);
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 550;
|
||||
}
|
||||
|
||||
.badge-danger {
|
||||
background: var(--surface-raised);
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
/* --- capture viewer --- */
|
||||
|
||||
.viewer-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 50;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: var(--space-4);
|
||||
/* color-mix keeps this a token too, rather than a hardcoded rgba(). */
|
||||
background: color-mix(in srgb, var(--bg) 82%, transparent);
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.viewer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: min(1200px, 100%);
|
||||
max-height: 100%;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.viewer-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.viewer-actions {
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.viewer-body {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 20rem;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.viewer-image-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 0;
|
||||
padding: var(--space-3);
|
||||
background: var(--surface-sunken);
|
||||
}
|
||||
|
||||
.viewer-image {
|
||||
max-width: 100%;
|
||||
max-height: 70vh;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.viewer-meta {
|
||||
padding: var(--space-4);
|
||||
overflow-y: auto;
|
||||
border-left: 1px solid var(--border);
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
.detail-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-1) 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
text-align: right;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.detail-heading {
|
||||
margin: var(--space-4) 0 var(--space-2);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.detail-list {
|
||||
margin: 0;
|
||||
padding-left: var(--space-4);
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.viewer-body {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.viewer-meta {
|
||||
border-left: none;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.grid-scroll {
|
||||
max-height: calc(100vh - 26rem);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user