"use client"; import { useState, type ReactNode } from "react"; import { motion, useReducedMotion } from "motion/react"; type Folder = { /** Typed on the tab. */ tab: string; title: string; /** What the sheet says. */ body: ReactNode; /** Rubber stamp that lands when the folder opens. */ stamp?: string; /** Folder colour. */ color?: string; }; type FilingTabProps = { folders: Folder[]; /** Index of the folder open at the start. */ open?: number; className?: string; }; const MANILA = ["#e6cf9b", "#e8b49a", "#b9cfc6", "#d8c6a0", "#c3c8de", "#e4d27c"]; const TAB = 1.9; const HEIGHT = 22.2; const BACK = 0.8; const FRONT = 2.3; /* FilingTab: manila folders in a drawer with staggered typed tabs. Press a tab and the folders in front drop down to show its sheet. */ export function FilingTab({ folders, open = 0, className = "" }: FilingTabProps) { const reduce = useReducedMotion(); const [picked, setPicked] = useState(open); const [near, setNear] = useState(-1); const count = folders.length; const tabWidth = Math.min(11, 31.3 / count); const spring = reduce ? { duration: 0 } : { type: "spring" as const, stiffness: 190, damping: 21 }; return (
{folders.map((f, i) => { const isOpen = i === picked; const y = i <= picked ? i * BACK : HEIGHT - (count - i) * FRONT; const color = f.color ?? MANILA[i % MANILA.length]; return (

{f.title}

{f.body}
{f.stamp && isOpen && ( {f.stamp} )}
); })}
); }