FolderContents
Folder that opens to reveal a sheet and a fan of nested folders whose documents extract independently.
Install
npx shadcn@latest add @jbm/folder-contentsNeeds the @jbm entry in components.json; see Install once.
Also installs @jbm/tokens, @jbm/scene-geometry, @jbm/folder.
Usage
import { FolderContents } from "@/jbm/ui/folder-contents"<FolderContents label="proyecto" open={1} sheet="README.md" entries={[ { id: "scripts", label: "scripts/" }, { id: "assets", label: "assets/", document: "notas.md", documentReveal: 1 }, ]} width={320} style={{ overflow: "visible" }}/>API
- Stage px
- Declared at the documented defaults
- Landscape
260 by 220- Vertical
260 by 220- Basis
Renders Folder's fixed 260×220 viewBox at 260×220 stage pixels; entry count, reveals, and lift never change the box. Pass width (or style.width) to scale with height auto, and it shrinks to maxWidth 100%. The gallery uses width={320} with overflow visible so the opened sheet above the viewBox stays visible.
FolderContentscomponent
Fills Folder's children slot with a front sheet and nested folders, each with an optional document. Every part is a rigid object that translates into view; nothing stretches. Pure React: open, per-entry reveal and documentReveal, and lift are independent 0–1 controls with no internal timer. Other SVG props pass through to the Folder svg.
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | none | Mono label for the outer folder; also names the image for assistive technology. On the front panel (accent and ink) it follows Folder's fitLine rule (compressed to 0.8, then an ellipsis); on the tab (card tone default, or labelOn "tab") it is a Geist 800 tab name drawn whole. |
tone | FolderTone | none | Outer folder fill: vermilion accent, ink, or plain cream card. |
open | number | none | Outer folder opening from 0 (closed, contents hidden) to 1 (contents shown). Clamped. Defaults to 1 here, unlike Folder's 0; every reveal is multiplied by it. |
sublabel | string | none | Short line printed on the front panel: under the label, or near the panel top when the label is on the tab. |
labelOn | "front" | "tab" | none | Where the label prints while the folder is closed. Defaults to the tab for the card tone, the front panel otherwise. Once open is above 0 the sheet stands in front of the tab, so the label prints on the front panel. |
entries | FolderEntry[] | [] | Nested folders, back to front. Their tabs pack between y 24 and 72 of the folder space, so more entries overlap more tightly instead of growing the folder. Empty by default. |
sheet | string | "README.md" | Label printed on the front sheet (first 15 characters). An empty string removes the sheet. |
lift | number | 0 | Raises all contents together by up to 240 folder units (0–1), clipped at the folder's top, for handing the whole group out. |
Also accepts Omit<ComponentProps<typeof Folder>, "children">.
FolderEntrytype
One nested folder: id (React key), label (truncated after 15 characters), reveal 0–1 (default 1; rises from the folder bottom), optional document label (12 characters shown), and documentReveal 0–1 (default 0; lifts the document 45 units out of its folder).
QA checks
- Drag Open folder through 0, 0.5, and 1: the sheet and nested folders slide up as rigid shapes and never cut through the front panel.
- Drag Extract documents and Lift contents independently; each moves only its own objects.
- Set Nested folders to 0 and 8: zero entries with an empty sheet reads as an empty folder; eight entries pack tighter without resizing the folder.
- Toggle Reveal nested folders: hidden folders sit fully below the rim with complete outlines, clipped only at the container bottom.
- Uncertain: at open 1 the sheet and front folders extend above the 220-unit viewBox, so they rely on overflow visible; check clipping when overflow is left hidden.