jbmui

Slip

  • UI Bits
  • adjustable

Taped paper slip of out-of-register writing that peels, lifts, and travels while registers reflow around it.

Install

npx shadcn@latest add @jbm/slip

Needs the @jbm entry in components.json; see Install once.

Also installs @jbm/tokens, @jbm/scene-geometry, @jbm/paper, @jbm/register.

Docs

Usage

A taped prose slip, flagged
import { Slip } from "@/jbm/ui/slip"<Slip kind="prose" w={240} h={72} flag />
Lift from one register, land in another
import { Register, registerGap } from "@/jbm/ui/register"import { Slip, slipGrip } from "@/jbm/ui/slip"import { Mano } from "@/jbm/motion/mano" // install @jbm/mano separatelyconst t = 0.5 // carry progress from a slider or frameconst sheet = { w: 250, h: 300, gap: 66 } as constconst src = { ...sheet, kind: "mono", n: 6, gapAt: 3 } as constconst dst = { ...sheet, kind: "prose", n: 3, gapAt: 4 } as constconst a = registerGap({ ...src, reflow: 1 })!const b = registerGap({ ...dst, reflow: 1 })!const from = { x: a.x + 30, y: a.y + 7 } // dst sheet sits 300 px to the rightconst to = { x: 300 + b.x + 30, y: b.y + 7 }const slip = { w: 190, h: 52, scale: 250 / 360, lift: 1,  offset: { x: (to.x - from.x) * t, y: (to.y - from.y) * t } }const grip = slipGrip(slip)<div style={{ position: "relative", width: 560, height: 320 }}>  <Register {...src} reflow={1 - t} style={{ position: "absolute", left: 0, top: 0 }} />  <Register {...dst} reflow={t} style={{ position: "absolute", left: 300, top: 0 }} />  <Slip {...slip} style={{ position: "absolute", left: from.x, top: from.y }} />  <svg width={560} height={320} style={{ position: "absolute", inset: 0, overflow: "visible", pointerEvents: "none" }}>    <Mano at={{ x: from.x + grip.x, y: from.y + grip.y }} pose="pinch" size={96} anchor={{ x: 6, y: 10 }} />  </svg></div>

API

Stage px
Declared at the documented defaults
Landscape
240 by 72
Vertical
240 by 72
Basis

w × h stage px at the defaults (240 × 72). The tape reaches about 7 × scale px above the top edge, and a peeled flap about 20 × scale px more; lift adds up to 10 × scale px of rise and 4% scale, and offset moves it anywhere, all without affecting layout.

Slipcomponent

A small paper strip carrying a few marks of one register (RegisterInk), with torn masking tape across its top edge. Controlled and timer-free: lift peels the tape flap (fully by 0.4), deepens the shadow, raises the slip by 10 × scale px, tilts it 3°, and scales it 4%; offset translates it from its resting place. It owns no hand and no path: place it absolutely where it rests (usually registerGap on the source sheet), drive offset along your own path, and hold it with Mano at slipGrip.

PropTypeDefaultDescription
liftnumbernone0 flat on a sheet, 1 held above it. Clamped.
offsetPtnoneTranslation in px from the resting place (default { x: 0, y: 0 }).
tapebooleannoneMasking tape across the top edge with torn ends (default true). Its right third is a flap that peels up as lift goes 0 → 0.4 and sticks again on landing; it stays hinged along its whole fold (it foreshortens as its free end rises), so no notch opens at the hinge.
flagbooleannoneFlags the slip as out of place with an ink bracket in the margin beside its left edge (default false): a spine 15 × scale px off the edge with arms reaching back toward the slip, at the shared outline, like an editor's margin mark. The slip keeps its solid edge, so it never reads as a selection marquee. Ink, not vermilion; it moves with the slip.
dashedbooleannoneDeprecated alias of flag, kept so existing callers still compile: it draws the same margin bracket, not a dashed outline. Ignored when flag is set.
kindExclude<RegisterKind, "mixed">noneRegister drawn on the slip: mono, plain, grid, or prose (default prose).
nnumbernoneCount for that register: prose source ticks (default 2), mono steps (1), plain groups or grid tables (2).
wnumbernoneSlip width in px (default 240).
hnumbernoneSlip height in px (default 72).
rotatenumbernoneResting rotation in degrees (default −2).
scalenumbernoneMark scale; pass the source sheet's scale (Register uses w / 360) so the slip's bars match the page it sits on. Default 1.
revealnumbernoneWriting drawn on the slip so far, 0–1 (default 1).
accentreadonly number[]noneCell indices whose lead mark is vermilion.
styleCSSPropertiesnoneStyles merged onto the outer box, e.g. position, left, top.

slipPointfunction

Maps a point on the slip (local px from its top-left) to the host's px after lift, rotation, and offset, relative to the slip's resting top-left.

ParamTypeDefaultDescription
propsSlipPropsrequiredThe Slip's props (lift, offset, w, h, rotate, scale).
localPtrequiredPoint on the slip in its own px.

Returns Pt in the host's px.

slipGripfunction

Where a pinch holds the slip: the middle of its bottom edge (default) or top edge, in the host's px relative to the resting top-left. Put Mano's pinch there (pose "pinch", anchor { x: 6, y: 10 }).

ParamTypeDefaultDescription
propsSlipPropsrequiredThe Slip's props.
edge"top" | "bottom""bottom""bottom" (default) or "top".

Returns Pt in the host's px.

SlipPropstype

Slip's props.

QA checks

  • Drag Lift 0 → 0.4 → 1: the tape flap peels up while staying hinged along its whole fold (no notch or wedge at the hinge), then the slip rises, tilts, and its shadow deepens; back to 0 it lies flat and the flap sticks down continuously.
  • Drag Carry 0 → 1 with Lift at Held: the slip leaves the Tutorial's gap, arcs over, and settles in the Explicación's gap; the source closes to evenly spaced steps while the destination opens exactly one slip-height of room, and no writing passes under the landed slip.
  • Toggle Tape, Out-of-place bracket, and Hand independently: each changes only its own object; the bracket is ink, stands in the margin left of the slip at the shared outline, and the slip's own edge stays solid.
  • With Hand on, check the pinch stays on the slip's bottom edge while the slip is lifted or carried, and that the hand lets go (opens and draws back from the edge) once it lies flat: at Taped + Flat and at Landed + Flat.
  • Check 2× zoom: torn tape teeth, the fold, and the outline corners join cleanly with even stroke widths.