Skip to content

feat: add bookshelf component - #273

Merged
starc007 merged 5 commits into
mainfrom
feat/bookshelf
Nov 19, 2026
Merged

starc007 merged 5 commits into
mainfrom
feat/bookshelf

Conversation

@starc007

Copy link
Copy Markdown
Owner

What

A new Bookshelf component (/components/motion/bookshelf, install slug bookshelf). It shows a row of book spines. Click one and it comes off the shelf and turns in 3D to show its cover while the books beside it move apart.

  • Motion: the book pulls out first and turns a beat later; closing turns back first, then pushes in. Faces darken side-on and light up facing the viewer, and a soft shadow grows under the open book. Hover lifts and tips a spine; the open cover tilts toward the mouse (tilt prop).
  • Mobile: the shelf scales to fit. When an open book overflows, the row pans to keep it in view and can be swiped, with edge fades.
  • Sound (opt-in, sound prop): synthesized with Web Audio in lib/book-sounds.ts on the shared audio context, no audio files. A friction slide and soft landing on open, a slide and woody tock on close, quiet taps on hover. The preview has a Sound switch.
  • Accessibility: a named list of toggle buttons (aria-pressed). Arrow keys move between books and carry the open one along, Home/End jump, Escape closes. Reduced motion drops the slide, turn, tip and tilt; the cover fades in instead.
  • Controlled or uncontrolled (value, defaultValue, onValueChange), with height, coverRatio, gap, openGap and per-book thickness, color, textColor, coverImage.

Also: registry entry, SEO, About notes, dates, changelog line, preview and tests/bookshelf.a11y.test.tsx.

Notes for review

  • Each book is its own 3D scene in a flat list so paint order is controlled by z-index. A closing book stays on top only while its cover is more than half turned, so the side face of books left of centre never paints over the next spine.
  • The 3D book is picture only. A flat transparent button over its footprint (spine closed, cover open) takes clicks, hover and focus, because a browser only hit-tests the turned cover inside the spine-sized parent box. The focus outline is drawn on the book faces via group-has-[button:focus-visible].
  • The 500ms turn is longer than the usual UI budget on purpose (commented in code).

Checked

  • bun run check and bun test (220 pass).
  • In the browser: open, close, switch and mid-turn frames; pull and turn timing; hover lift, tip and cursor tilt; keyboard browsing and focus outline; full-cover hit area; mobile scale, pan, swipe and tap; light and dark mode; sound switch on and off. Sound timing and levels were checked with an offline render.
  • Not checked in the browser: reduced motion (the pane can't emulate it); reviewed in code only.

@starc007
starc007 merged commit c0a936f into main Nov 19, 2026
1 check passed
@starc007
starc007 deleted the feat/bookshelf branch November 19, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant