Escritorio
An empty desk with separate finish and optional file cabinet.
Install
npx shadcn@latest add @jbm/escritorioNeeds the @jbm entry in components.json; see Install once.
Also installs @jbm/tokens, @jbm/scene-geometry, @jbm/cajon, @jbm/file-cabinet.
Usage
import { Escritorio } from "@/jbm/motion/escritorio"<svg viewBox="0 0 820 530"> <Escritorio box={{ x: 30, y: 65, w: 760, h: 420 }} cabinet spec={{ finish: "wood", drawerSide: "end" }} folders={[{ name: "datos", accent: true }, { name: "notas" }]} open={1} /></svg>import { Escritorio, escritorioLayout } from "@/jbm/motion/escritorio"import { Mano } from "@/jbm/motion/mano" // install @jbm/mano separatelyconst desk = { box: { x: 30, y: 65, w: 760, h: 420 }, cabinet: true, folders: [{ name: "datos" }], open: 1 }const tab = escritorioLayout(desk).anchors.folders[0]<svg viewBox="0 0 820 530"> <Escritorio {...desk} /> <Mano at={tab} pose="pinch" size={120} anchor={{ x: 15, y: 5 }} /></svg>API
- Stage px
- Declared at the documented defaults
- Landscape
760 by 418- Vertical
760 by 418- Basis
Parent SVG user units for the documented box 760 × 420: width is box.w and height runs from the slab top at box.y + 2 to the floor at box.y + box.h (box.h − 2). A lifted folder in an open cabinet drawer can rise above the slab, so leave headroom when pulled is used.
Escritoriocomponent
SVG <g> of an empty desk (slab, apron, and two legs) sized to a box, with a paper or wood finish and an optional file cabinet between the legs. The cabinet body is drawn behind the desk and its drawer (Cajón) in front, so drawer folders can rise over the apron. Controlled; no internal timer. Render inside an <svg>.
| Prop | Type | Default | Description |
|---|---|---|---|
box | Box | required | Desk bounds { x, y, w, h } in the parent SVG's user units. The top slab starts at y + 2 and the legs reach the floor at y + h. |
spec | DeskSpec | none | Finish and cabinet side: finish paper (card fill, default) or wood (bg fill with grain lines); drawerSide start (left, default) or end (right). |
cabinet | boolean | none | Shows the file cabinet and its drawer under the desk. |
folders | readonly DrawerFolder[] | none | Folders in the cabinet drawer, as for Cajón: name, accent, and pulled per folder, index 0 nearest the front. |
open | number | none | Cabinet drawer opening from 0 (closed) to 1 (open). Clamped. |
escritorioLayoutfunction
Shared desk geometry: the cabinet fits between the legs (at most 250 wide, 12 units of clearance) from below the apron to the floor.
| Param | Type | Default | Description |
|---|---|---|---|
box | Box | required | Desk bounds { x, y, w, h } in the parent SVG's user units. The top slab starts at y + 2 and the legs reach the floor at y + h. |
spec | DeskSpec | {} | Only drawerSide affects the layout; finish is visual. |
cabinet | boolean | none | Accepted for parity with Escritorio's props; the layout always computes cabinet and drawer geometry. |
folders | readonly DrawerFolder[] | [] | Folders in the cabinet drawer, as for Cajón: name, accent, and pulled per folder, index 0 nearest the front. |
open | number | 0 | Cabinet drawer opening from 0 (closed) to 1 (open). Clamped. |
Returns { box, top, cabinet, drawer, plane, anchors }: top is box.y + 20; cabinet and drawer are the FileCabinet and Cajón props; plane holds innerLeft, innerRight, floor, and apronBottom; anchors.folders are the folder tab grip points, all in parent SVG units.
DeskSpectype
{ finish?: "paper" | "wood"; drawerSide?: "start" | "end" }.
QA checks
- Toggle Wood finish: only fills and grain lines change; geometry stays put.
- Toggle File cabinet and Cabinet on right: the cabinet sits between the legs with equal clearance on both sides and shares the floor line.
- With the cabinet on, drag Open and change folder count: the drawer front stays above the floor and folders draw over the apron without clipping.
- Try a narrow box: the cabinet shrinks to fit between the legs; very small widths are untested and may collapse it.
- The Mano anchor in the second example is an estimate of the pinch fingertip; verify it visually.