Shelf
A pile of tilted library cards that slide in on their own cues, plus Twice: a button, the same button again, and a vermilion cross drawn over the second.
Loading preview…
Install
npx shadcn@latest add @jbm/shelfNeeds the @jbm entry in components.json; see Install once.
Also installs @jbm/tokens, @jbm/motion-hooks, @jbm/pop, @jbm/paper, @jbm/ui-bits.
Needs Remotion: render inside a Remotion <Composition> or <Player>, not a plain React tree. Timing values are in seconds.
Usage
import { Shelf, Twice } from "@/jbm/motion/shelf"<Shelf w={936} items={[ { text: "shadcn/ui", at: 0.2 }, { text: "Material UI", at: 0.6 }, { text: "jbm-ui", at: 1.0, tone: "accent" },]} /><Twice w={936} at={2} second={2.8} strike={3.6} />// Render inside a Remotion <Composition> or <Player>.API
- Stage
fluidShelf is w wide and grows with its items: n × cardH + (n − 1) × gap, with cardH = round(0.16 × w) by default (three cards at w = 936 are 494px tall). Twice is w wide and bh + 52 tall (about 211px at w = 936). SceneFromSpec gives both min(W, 1100) and min(W, 1000) in landscape and the full safe-area width in vertical. Card tilt, the left slide, and the cross strokes reach past these boxes.
Shelfcomponent
Column of wide Paper cards, each sliding in from the left (60px) with a spring at its own at, tilted −1.2°, 1°, −0.8° in turn. Each card shows its name in mono type and three tiny pieces (card, input without cursor, button). The button is accent on paper and ink cards, paper on an accent card.
| Prop | Type | Default | Description |
|---|---|---|---|
w | number | required | Width of every card in stage pixels. |
items | { text: string; at: number; tone?: PaperTone }[] | required | Cards from top to bottom: text (mono label, one line, not truncated), at (entrance in seconds), and optional tone (paper default, accent for the one that is yours, or ink). |
cardH | number | none | Card height in stage pixels; defaults to round(0.16 × w). Label size, padding, radius, and piece size follow it. |
gap | number | 22 | Vertical space between cards in stage pixels. |
Twicecomponent
Closing gag: an ink button scales in at at, an identical one beside it at second, then two vermilion strokes draw a cross over the second (each 0.25 s, the second stroke 0.2 s after the first).
| Prop | Type | Default | Description |
|---|---|---|---|
w | number | required | Row width in stage pixels; the buttons are centred with a gap of 5% of w. |
at | number | required | Seconds when the first button scales in. |
second | number | required | Seconds when the second, identical button scales in. |
strike | number | none | Seconds when the cross starts drawing; defaults to second + 0.5. |
bw | number | none | Button width in stage pixels; defaults to min(420, half the row minus the gap). |
bh | number | none | Button height in stage pixels; defaults to round(0.34 × button width). |
QA checks
- Step through each card cue: cards slide in from the left in order and settle at alternating tilts; the accent card's button turns paper.
- Try a long label at narrow w: the mono label does not wrap or truncate and can collide with the three pieces.
- For Twice, inspect first button, second button, mid-strike, and final frame: both strokes fully drawn tail to head and the cross stays within the row's 26px padding.
- Check the full stack height (items plus Twice) fits the safe area in both orientations.