{"name":"cajon","entry":"component","title":"Cajon","description":"A fixed-size filing drawer whose complete folders fan front to back, darker with depth.","category":"UI Bits","capabilities":["controls"],"needsRemotion":false,"registryDependencies":["@jbm/tokens","@jbm/scene-geometry","@jbm/folder"],"install":"npx shadcn@latest add @jbm/cajon","installName":"cajon","page":"https://jbm-ui.bns.studio/c/cajon","registryItem":"https://jbm-ui.bns.studio/r/cajon.json","sourcePath":"registry/jbm/motion/cajon.tsx","files":[{"source":"registry/jbm/motion/cajon.tsx","target":"src/jbm/motion/cajon.tsx","import":"@/jbm/motion/cajon","type":"registry:component"}],"endpoints":{"markdown":"https://jbm-ui.bns.studio/catalog/cajon.md","json":"https://jbm-ui.bns.studio/catalog/cajon.json"},"snippet":"import { Cajon } from \"@/jbm/motion/cajon\"\n\n<svg viewBox=\"0 -300 500 740\">\n  <Cajon x={40} y={10} open={1} folders={[\n    { name: \"Grove 1983\", sublabel: \"High Output Management\" },\n    { name: \"Mintzberg 1979\", sublabel: \"Structuring of Organizations\" },\n    { name: \"Simon 1947\", sublabel: \"Administrative Behavior\" },\n    { name: \"Training Within Industry 1940s\", sublabel: \"Job Instruction\", reveal: 0.5 },\n    { name: \"Taylor 1911\", sublabel: \"Principles of Scientific Management\" },\n  ]} />\n</svg>","api":[{"export":"Cajon","kind":"component","summary":"SVG <g> of a filing drawer: an interior of flat drawer shades (back wall, floor, and lighter side walls, so an empty drawer reads as an empty box), complete FolderOutline folders stepping up and narrowing toward the back, side walls, and a card front carrying a label holder near its top edge with a separate pull under it (flat rectangles at the shared outline: a cream label card and an ink bar). Each folder's light (k) darkens with depth, its name inks in with reveal, and its front flap can stand ajar. Folders are occluded by the front and by each other, never shortened. Controlled by open and per-folder values; no internal timer. Render inside an <svg>.","props":[{"name":"x","type":"number","required":false,"default":null,"description":"Left edge of the drawer in the parent SVG's user units."},{"name":"y","type":"number","required":false,"default":null,"description":"Top of the drawer's back edge reference in parent SVG units; the front and folders are placed from it."},{"name":"w","type":"number","required":false,"default":null,"description":"Drawer width in parent SVG units. The front folder is w − 52 wide (Folder's body at folderScaleForDrawer(w), so a loose Folder at that scale is the same object) and its height (and the front's) scales with it at 150:205; folders further back are narrower. Above the 420 reference the furniture grows with it: walls, margins, front travel, the front folder's rise, lift clearance, and the front's label holder and pull all scale by w / 420 (narrower drawers keep the reference sizes)."},{"name":"h","type":"number","required":false,"default":null,"description":"Nominal drawer depth, returned by cajonLayout for composites; the drawing does not use it (front height follows w)."},{"name":"folders","type":"readonly DrawerFolder[]","required":true,"default":null,"description":"Folders front to back (index 0 nearest the front, drawn last). Each is a DrawerFolder: name (drawn whole on its tab in Geist 800), accent, pulled, k, open, reveal, sublabel (Geist italic), sublabelReveal. A name wider than its folder's widest tab squeezes at most to 0.94, then ends in an ellipsis; glyphs are never visibly condensed."},{"name":"open","type":"number","required":false,"default":null,"description":"Drawer opening from 0 (closed) to 1 (front slid forward 104 units, folders raised 62 and fanned by depthSpacing; both × w / 420 above 420). Clamped; pulled and ajar folders only rise while open."},{"name":"depthSpacing","type":"number","required":false,"default":null,"description":"Rise from one folder to the next one back, in parent SVG units. Default: tab height + band + a lip of flap, so every tab and a band of back panel stay visible for up to six folders; more folders share the rise of six (five steps), so a crowded drawer packs tighter instead of growing: at 12 folders the stack is as tall as at six, names stay whole, and a sublabel whose band the folder in front covers is not printed. At labelSize 13 that is 46 (55 with sublabels). A smaller value packs folders and may hide names. A larger value is capped: the stack never rises more than the drawer front's height, and above six folders a given value packs like the default."},{"name":"tabLayout","type":"\"stair\" | \"stagger3\"","required":false,"default":null,"description":"\"stair\" (default) puts every tab at its folder's left edge, so tabs climb as back folders narrow; \"stagger3\" cycles tabs left, center, right."},{"name":"labelSize","type":"number","required":false,"default":null,"description":"Name size in parent SVG units (default 13). Tab height is 27/13 of it, the sublabel 0.8 of it. Tab widths come from sansWidth (Geist 800). Perspective does not depend on it: a folder's inset follows its depth in the drawer (its rise over the rise of eight folders), up to a fifth of the width at the back. For video at 1080 use about 24–36."}],"passthrough":["Partial<Box>"]},{"export":"cajonLayout","kind":"function","summary":"The geometry Cajon draws, for composites that attach threads, hands, or labels to folders.","params":[{"name":"x","type":"number","required":false,"default":"0","description":"Left edge of the drawer in the parent SVG's user units."},{"name":"y","type":"number","required":false,"default":"0","description":"Top of the drawer's back edge reference in parent SVG units; the front and folders are placed from it."},{"name":"w","type":"number","required":false,"default":"420","description":"Drawer width in parent SVG units. The front folder is w − 52 wide (Folder's body at folderScaleForDrawer(w), so a loose Folder at that scale is the same object) and its height (and the front's) scales with it at 150:205; folders further back are narrower. Above the 420 reference the furniture grows with it: walls, margins, front travel, the front folder's rise, lift clearance, and the front's label holder and pull all scale by w / 420 (narrower drawers keep the reference sizes)."},{"name":"h","type":"number","required":false,"default":"420","description":"Nominal drawer depth, returned by cajonLayout for composites; the drawing does not use it (front height follows w)."},{"name":"folders","type":"readonly DrawerFolder[]","required":true,"default":null,"description":"Folders front to back (index 0 nearest the front, drawn last). Each is a DrawerFolder: name (drawn whole on its tab in Geist 800), accent, pulled, k, open, reveal, sublabel (Geist italic), sublabelReveal. A name wider than its folder's widest tab squeezes at most to 0.94, then ends in an ellipsis; glyphs are never visibly condensed."},{"name":"open","type":"number","required":false,"default":"1","description":"Drawer opening from 0 (closed) to 1 (front slid forward 104 units, folders raised 62 and fanned by depthSpacing; both × w / 420 above 420). Clamped; pulled and ajar folders only rise while open."},{"name":"depthSpacing","type":"number","required":false,"default":null,"description":"Rise from one folder to the next one back, in parent SVG units. Default: tab height + band + a lip of flap, so every tab and a band of back panel stay visible for up to six folders; more folders share the rise of six (five steps), so a crowded drawer packs tighter instead of growing: at 12 folders the stack is as tall as at six, names stay whole, and a sublabel whose band the folder in front covers is not printed. At labelSize 13 that is 46 (55 with sublabels). A smaller value packs folders and may hide names. A larger value is capped: the stack never rises more than the drawer front's height, and above six folders a given value packs like the default."},{"name":"tabLayout","type":"\"stair\" | \"stagger3\"","required":false,"default":"\"stair\"","description":"\"stair\" (default) puts every tab at its folder's left edge, so tabs climb as back folders narrow; \"stagger3\" cycles tabs left, center, right."},{"name":"labelSize","type":"number","required":false,"default":"13","description":"Name size in parent SVG units (default 13). Tab height is 27/13 of it, the sublabel 0.8 of it. Tab widths come from sansWidth (Geist 800). Perspective does not depend on it: a folder's inset follows its depth in the drawer (its rise over the rise of eight folders), up to a fifth of the width at the back. For video at 1080 use about 24–36."}],"returns":"{ x, y, w, h, front, frontTop, frontHeight, hardware, scale, depthSpacing, labelSize, band, folders, anchors }. frontTop is the drawer front's top edge; hardware is { holder, pull }, the front's label holder (60 × 24, 18 below frontTop) and the pull under it (96 × 14, 14 lower), centred, as Boxes (× scale); scale is max(1, w / 420). Each folder has x, y (top of tab), w, h, tabX, tabWidth, tabHeight, tabSlope, anchor (tab grip point), label { x, y baseline, mid, end, text, scale } (text is the name as drawn, whole or ending in an ellipsis; scale is 1, or down to 0.94 when a barely-long name fits), sublabel { x, y, scale, width, visible } (visible is false whenever anything in front, a nearer folder's tab or top edge or the drawer front, covers any part of the line: a half-open drawer or a crowded one never prints a fragment), rule and flapEdge (whether, and with what ink 0–1, the closed front flap's top edge draws: side to side across the folder, like Folder's front panel, only where a tab height or more of flap shows under it clear of everything in front, fully inked from one and a half; a fan at rest shows none, since its thin lips of flap would read as seams, and a lifting folder gains its edge smoothly), flap (front flap's top edge), opening { drop, lean } (the ajar flap; lean is 0: the flap's top edge drops straight and is never wider than its folder), visible (0–1, how much of the tab shows above the drawer front; 0 inside a closed drawer), and light (effective k). anchors(i, n) returns n points on folder i's tab midline, from just before the name (clear of its first letter, where a knot sits) to the tab's straight edge; once a tab is below the drawer front's top edge the points stop at that rim, so threads never reach through the front. [] for an unknown folder or n < 1."},{"export":"drawerLight","kind":"function","summary":"Folder fill for a light value k, mixed in OKLab from the palette tokens only: k 1 is the card, lower k moves lightness toward ink by 1 − k while the hue warms toward cream; k 0 is ink.","params":[{"name":"k","type":"number","required":true,"default":null,"description":"Light from 0 to 1; clamped, non-finite values give the card."}],"returns":"An sRGB hex color."},{"export":"backLight","kind":"constant","summary":"0.72: the light of the backmost folder when k is not given (the front folder is 1)."},{"export":"drawerInside","kind":"constant","summary":"The open drawer's inside planes as hex fills { back, floor, left, right }, mixed in OKLab from Pencil Rule (the right wall, facing the light) toward Graphite (the back wall, half way), so an empty drawer reads as a box of the palette's rule tones. The side panels outside the walls are card."},{"export":"DrawerFolder","kind":"type","summary":"{ name, accent?, pulled?, k?, open?, reveal?, sublabel?, sublabelReveal? }: one folder. pulled 0–1 lifts it out and brings k to 1; k defaults to a ramp from 1 (front) to 0.72 (back); open 0–1 stands the front flap ajar: its top edge drops a fifth of the folder height, straight down and never wider than the folder, and the folder rises (by that drop plus a lip, at most as far as keeps the tab of the folder behind it in view) so at least half the shaded opening shows above whatever is in front of it (vermilion folders shade toward ink, never a new colour); reveal 0–1 inks the name in grapheme by grapheme (sublabelReveal defaults to it)."},{"export":"CajonProps","kind":"type","summary":"Box (x, y, w, h) plus folders, open, depthSpacing, tabLayout, and labelSize."}],"stage":{"mode":"declared","landscape":{"width":420,"height":382},"vertical":{"width":420,"height":382},"basis":"Parent SVG user units at the defaults w 420, open 1, and one folder: from the back edge at y + 10 to the front's bottom at y + 391 (front at y + 82, plus 32, plus a 277 front height from w). Each further folder rises depthSpacing (46 at labelSize 13, 55 with sublabels) above the one in front, from the front folder's top at y + 52: six or more folders reach y − 178 (y − 222 with sublabels). open 0 ends at y + 287. A lifted folder rises until its bottom is 14 units behind the drawer front's top edge (never floating clear of the drawer), so leave headroom (the gallery uses viewBox 0 −400 500 840)."},"examples":[{"title":"Six sources fanned by age","code":"import { Cajon } from \"@/jbm/motion/cajon\"\n\n<svg viewBox=\"0 -300 500 740\">\n  <Cajon x={40} y={10} open={1} folders={[\n    { name: \"Grove 1983\", sublabel: \"High Output Management\" },\n    { name: \"Mintzberg 1979\", sublabel: \"Structuring of Organizations\" },\n    { name: \"Simon 1947\", sublabel: \"Administrative Behavior\" },\n    { name: \"Training Within Industry 1940s\", sublabel: \"Job Instruction\", reveal: 0.5 },\n    { name: \"Taylor 1911\", sublabel: \"Principles of Scientific Management\" },\n  ]} />\n</svg>"},{"title":"Tie threads to a tab","code":"import { Cajon, cajonLayout } from \"@/jbm/motion/cajon\"\nimport { color } from \"@/jbm/lib/tokens\"\n\nconst props = { x: 40, y: 10, folders: [{ name: \"Procida 2017\" }, { name: \"Taylor 1911\" }] }\nconst ends = cajonLayout(props).anchors(0, 3)\n\n<svg viewBox=\"-200 -200 700 640\">\n  <Cajon {...props} />\n  {ends.map((p, i) => (\n    <path key={i} d={`M-180 ${i * 40}C-60 ${i * 40} ${p.x - 80} ${p.y} ${p.x} ${p.y}`} fill=\"none\" stroke={color.ink} strokeWidth={2} />\n  ))}\n</svg>"},{"title":"Point a hand at a folder tab","code":"import { Cajon, cajonLayout } from \"@/jbm/motion/cajon\"\nimport { Mano } from \"@/jbm/motion/mano\" // install @jbm/mano separately\n\nconst props = { x: 40, y: 10, open: 1, folders: [{ name: \"datos\", pulled: 0.4 }] }\nconst tab = cajonLayout(props).folders[0].anchor\n<svg viewBox=\"0 -260 500 700\">\n  <Cajon {...props} />\n  <Mano at={tab} pose=\"pinch\" size={120} anchor={{ x: 15, y: 5 }} />\n</svg>"}],"qa":["At index size the closed and open drawer read as a filing-cabinet drawer: a small cream label holder near the front's top edge and a separate ink pull under it, both centred; never one plate with a slot, and nothing floating mid-panel. The walls narrow toward the back and the front stays as tall as the folders it hides.","Drag Open through 0, 0.5, and 1: the front slides forward, folders rise and fan, and no folder shows below the front edge.","Try 0, 1, 3, and 6 folders with and without sublabels: every tab and the band under it stay visible, back folders are narrower and darker, never larger; with none, the inside reads as an empty box (back wall, floor, lighter side walls), not a dark block. At 8 and 12 folders the stair keeps the height of six: folders pack tighter, names stay whole, and sublabels the next folder would strike are not printed.","Sweep Name reveal 0 → 1: tabs start blank and names ink in from the left, one grapheme at a time; the tab never changes width.","Lift a back folder: it rises behind the folders in front and brightens to k 1; its complete outline appears as it clears them, and once a tab of its front flap shows, its flap edge inks in side to side.","With 1, 3, 5, 8, and 12 folders at Open 0, 0.5, and 1 (any Rise), no line crosses any folder body: a fan at rest shows tabs, sublabels, and stacked folder tops only, never a closed flap edge or a seam under the next tab.","Pick any folder in Target and set Flap ajar: the folder rises until its shaded opening shows above the folder (or drawer front) in front of it while the tab of the folder behind stays in view, the flap's top edge drops straight down, never wider than the folder (lifted or not), and the bottom corners stay fixed. On a vermilion folder the opening is a darker vermilion.","Tab names are bold sans (Geist 800), sublabels italic sans. Long names (\"Training Within Industry 1940s\" at Name size 36) widen the tab to the folder, then end in an ellipsis; no name is visibly condensed.","Set Name size to 24 with six folders: back folders narrow exactly as at 13; at w 900 the label holder, pull, walls, and travel grow with the drawer.","Switch Tab layout to stagger3: tabs cycle left, center, right and sublabels stay inside the folder.","The Mano anchor in the hand example is an estimate of the pinch fingertip; verify it visually for your pose."],"related":[{"name":"tokens","relation":"installs"},{"name":"scene-geometry","relation":"installs"},{"name":"folder","relation":"installs"},{"name":"escritorio","relation":"installed-by"},{"name":"file-cabinet","relation":"installed-by"},{"name":"mano","relation":"example-import"}],"family":"Folders & drawers","docs":[{"title":"Desk illustrations guide","url":"https://jbm-ui.bns.studio/docs/desk-components.md"}],"setup":{"namespace":"@jbm","componentsJson":{"registries":{"@jbm":"https://jbm-ui.bns.studio/r/{name}.json"}},"command":"npx shadcn@latest add @jbm/<name>","target":"src/jbm/","importAlias":"@/jbm/…","tsconfigPaths":{"@/*":["./src/*"]}},"rules":["Install through the @jbm namespace: each registry item JSON (/r/<name>.json) carries its files' contents and each guide is served at /docs/<slug>.md, so agents never need the source repository (it is public on GitHub for people browsing the code).","Files install to src/jbm/ and import as @/jbm/…, which needs the @/* → ./src/* path alias in tsconfig.json.","Items marked needsRemotion require the remotion package and must render inside a Remotion composition or Player; every other item works in any React page.","Use one vermilion accent per composition; accent2 is for annotations only and soft is for dark surfaces only.","Stages are 1920×1080 landscape and 1080×1920 vertical with declared safe areas; each item's stage field declares its size in stage pixels, and scenes compose from YAML-shaped specs with @jbm/scene-spec."],"links":{"catalog":"https://jbm-ui.bns.studio/catalog.json","llms":"https://jbm-ui.bns.studio/llms.txt"}}