const ROMAN = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"];
// BlurIn is shared with the gallery — see Reveal.jsx.
// One photo, in a box that already holds its shape so nothing jumps while the
// image loads. `w`/`h` come from the manifest; without them the box is left to
// the image itself.
function Frame({ frame, index, label, total, captionInset = 0 }) {
// A film takes the same place in the sequence as a photograph, so the choice
// is made here rather than at each of the four spots that lay out a row.
if (frame.youtube) return ;
const ratio = frame.w && frame.h ? `${frame.w} / ${frame.h}` : undefined;
// Without a caption in the manifest every frame in a series read the same to
// a screen reader — "Sven Ugau", forty-one times over. The position at least
// tells someone where they are. Real descriptions belong in the manifest.
const described = frame.caption || `${label} — frame ${index + 1}${total ? ` of ${total}` : ""}`;
return (
{/* Nothing under a frame that has nothing to say. The project name used to
sit under all forty-one — already the page's heading and its tab title
— and a bare number left on its own read as a stray mark. The number
returns alongside the words as soon as the manifest carries a caption. */}
{frame.caption && (
{String(index + 1).padStart(2, "0")}{frame.caption}
)}
);
}
// A film in the sequence. Nothing of YouTube's is fetched until someone asks
// for it: the player alone is about a megabyte, and on a page where every image
// is being weighed that is too much to spend on a visitor who never presses
// play. Until then this is a still with a control over it.
//
// `poster` names a frame from the project's own folder; without one, YouTube's
// thumbnail stands in — the only request made before play, and it comes from
// a cookieless host.
function FilmFrame({ frame, captionInset = 0 }) {
const [playing, setPlaying] = React.useState(false);
const [hover, setHover] = React.useState(false);
const id = frame.youtube;
const still = frame.poster || `https://i.ytimg.com/vi/${id}/maxresdefault.jpg`;
const label = frame.caption || "Film";
return (
{playing ? (
) : (
)}
{frame.caption && (
{frame.caption}
)}
);
}
// How often a frame breaks the margin when the manifest does not say. Sven's
// series marks its own moments by hand; a folder that was only ever generated
// gets the same rhythm for free.
const AUTO_FULL_EVERY = 7;
// Which frames run full-bleed. A manifest that marks any frame `full` is taken
// at its word and left alone; otherwise landscape frames are promoted on a
// steady cadence, starting with the opener. Portraits are never promoted —
// full-bleed makes them taller than the screen.
function fullBleedIndices(frames) {
if (frames.some((f) => f.full)) return null;
const picked = new Set();
for (let i = 0; i < frames.length; i += 1) {
if (i % AUTO_FULL_EVERY === 0 && !frames[i].portrait) picked.add(i);
}
return picked;
}
// Turn a flat run of frames into rows: full-bleed moments stand alone, two
// portraits in a row pair up as a diptych, everything else runs single and
// alternates side to side.
function buildRows(frames) {
const auto = fullBleedIndices(frames);
const rows = [];
let singles = 0;
let i = 0;
while (i < frames.length) {
const frame = frames[i];
if (frame.full || (auto && auto.has(i))) {
rows.push({ kind: "full", frames: [frame], start: i });
i += 1;
continue;
}
const next = frames[i + 1];
const nextIsFull = next && (next.full || (auto && auto.has(i + 1)));
if (frame.portrait && next && next.portrait && !nextIsFull) {
rows.push({ kind: "diptych", frames: [frame, next], start: i });
i += 2;
continue;
}
rows.push({ kind: "single", frames: [frame], start: i, right: singles % 2 === 1 });
singles += 1;
i += 1;
}
return rows;
}
function ChapterHeading({ number, title, note }) {
return (
{ROMAN[number] || number + 1}{title}
{note && {note}}
);
}
// A series runs long — 119 frames on the deepest project — so the way back to
// the overview stays on screen instead of waiting at the bottom. It echoes the
// menu tab: a solid block flush to the opposite edge, which also keeps it clear
// of the frame captions running down the left margin. Hidden over the hero,
// which already carries its own navigation.
function BackToOverview({ total }) {
const isMobile = window.useIsMobile();
const [shown, setShown] = React.useState(false);
const [hover, setHover] = React.useState(false);
const [progress, setProgress] = React.useState(0);
const [current, setCurrent] = React.useState(0);
React.useEffect(() => {
const onScroll = () => {
setShown(window.scrollY > window.innerHeight * 0.6);
const max = document.body.scrollHeight - window.innerHeight;
setProgress(max > 0 ? Math.min(1, window.scrollY / max) : 0);
// Which frame is in front of the reader, measured rather than derived
// from the scrollbar — a project page opens on a full-height frame and
// closes on a footer, so distance travelled is not the same as position
// in the series. The same reasoning as the gallery's counter.
const frames = document.querySelectorAll("figure");
if (!frames.length) return;
const centre = window.scrollY + window.innerHeight / 2;
let nearest = 0;
let best = Infinity;
frames.forEach((f, i) => {
const box = f.getBoundingClientRect();
const middle = box.top + window.scrollY + box.height / 2;
const d = Math.abs(middle - centre);
if (d < best) { best = d; nearest = i; }
});
setCurrent(nearest);
};
onScroll();
window.addEventListener("scroll", onScroll, { passive: true });
window.addEventListener("resize", onScroll);
return () => {
window.removeEventListener("scroll", onScroll);
window.removeEventListener("resize", onScroll);
};
}, []);
// One strip along the foot of the page: the way back, where you are, and how
// far in. A project page runs to 60,000px on the deepest series and gave no
// sense of position at all; the gallery rooms have carried this for a while,
// so it is the same hairline and the same counter here.
return (
);
}
if (row.kind === "diptych") {
const a = counter++;
const b = counter++;
return (
);
}
const index = counter++;
const frame = row.frames[0];
// A phone is too narrow to hold a frame at 42% and still show the
// photograph, so every frame runs the full column there and the
// left/right rhythm falls away.
const width = isMobile
? "100%"
: frame.portrait ? "clamp(260px, 42%, 520px)" : "clamp(280px, 74%, 1000px)";
return (