"use client"; import Link from "next/link"; import { useEffect, useRef, useState } from "react"; import { featured, projectById, projects } from "@/content/projects"; import { Segment } from "./Segment"; const ROOT = featured[0]; export function FeaturedNodes() { const [active, setActive] = useState(null); const nodes = featured.map((f) => ({ ...f, project: projectById(f.id)! })); const stageRef = useRef(null); const [size, setSize] = useState<{ w: number; h: number } | null>(null); // Lines are drawn in px so they stay 1px crisp at any stage size. useEffect(() => { const el = stageRef.current; if (!el) return; const ro = new ResizeObserver(([e]) => setSize({ w: e.contentRect.width, h: e.contentRect.height })); ro.observe(el); return () => ro.disconnect(); }, []); return (
setActive(null)} > {size && ( )} {nodes.map((n) => { const on = active === n.id; const root = n.project.root; return ( setActive(n.id)} onFocus={() => setActive(n.id)} onBlur={() => setActive(null)} className="group relative block min-h-12 outline-none md:absolute md:top-(--y) md:left-(--x) md:min-h-0" style={{ "--x": `${n.x}%`, "--y": `${n.y}%` } as React.CSSProperties} >
); }