"use client"; import { useEffect, useRef, useState, type ReactNode } from "react"; import { cn } from "@/lib/utils"; export type SectionNavItem = { id: T; label: string; }; export type SectionNavGroup = { title?: string; items: SectionNavItem[]; }; const DESKTOP_STICKY_TOP = 80; export function SectionColumns({ children }: { children: ReactNode }) { return (
{children}
); } export function SectionNav({ label, groups, activeId, onSelect, }: { label: string; groups: SectionNavGroup[]; activeId: T; onSelect: (id: T) => void; }) { const navRef = useRef(null); const [stick, setStick] = useState(false); useEffect(() => { const el = navRef.current; if (!el) return; const measure = () => { const desktop = window.matchMedia("(min-width: 640px)").matches; setStick(desktop && el.offsetHeight <= window.innerHeight - DESKTOP_STICKY_TOP); }; measure(); const observer = new ResizeObserver(measure); observer.observe(el); window.addEventListener("resize", measure); return () => { observer.disconnect(); window.removeEventListener("resize", measure); }; }, []); return ( ); } export function SectionPanel({ id, titleId, title, description, children, }: { id?: string; titleId: string; title: string; description: string; children: ReactNode; }) { return (

{title}

{description}

{children}
); }