"use client"; import Image from "next/image"; import { useEffect, useRef, useState } from "react"; import { Eyebrow, TextLink } from "./ui"; import buy from "@/assets/packbook/buy.webp"; import identify from "@/assets/packbook/identify.webp"; import pack from "@/assets/packbook/pack.webp"; import share from "@/assets/packbook/share.webp"; import wall from "@/assets/packbook/wall.webp"; import { useT } from "@/components/locale-provider"; import { projects } from "@/config/site"; import { cn } from "@/lib/utils"; // In order; each screen's label and alt text live in messages/ (packbook.screens). const SCREENS = [wall, identify, pack, share, buy]; export function PackBookCard() { const { packbook: t, common: { open }, } = useT(); const screens = SCREENS.map((src, i) => ({ src, ...t.screens[i] })); const [index, setIndex] = useState(0); const [hovering, setHovering] = useState(false); const [loaded, setLoaded] = useState(1); const rootRef = useRef(null); const go = (i: number) => { setLoaded((n) => Math.max(n, i + 2)); setIndex(i); }; // Flip through the app while the card is hovered. useEffect(() => { if (!hovering) return; const id = window.setInterval( () => setIndex((i) => { const next = (i + 1) % SCREENS.length; setLoaded((n) => Math.max(n, next + 2)); return next; }), 1800, ); return () => window.clearInterval(id); }, [hovering]); return (
{ if (e.pointerType !== "touch") { setLoaded((n) => Math.max(n, 3)); setHovering(true); } }} onPointerLeave={() => setHovering(false)} >
{t.eyebrow}

PackBook

{t.pitch}

{screens.map((s, i) => ( ))}
{projects.packbook.linkLabel}
{/* On a narrow card the dots tighten up to leave room for the link. */}
{screens.map((s, i) => ( ))}
{projects.packbook.linkLabel}
); }