Stamp Collection

Three perforated stamps on a table. Press one to bring it forward.

Three stamps rest in a fanned row on a table that follows the theme. Reach for one and it lifts. Press it and the stamps gather into a pile, then the one you pressed grows out of it into focus. With a stamp in front, move the pointer: the stamp leans toward it, and the print slides under its own window. Press the stamp again, press the table, or hit Escape to put them back in the row.

How it works

  • A stamp is staged by its size, never by scaling it. Every pose is in stage pixels and the stamp animates its width and height. A scale would blow the perforated edge and the shadow up with the stamp, and the point of drawing the paper as an SVG is that its edge stays the same weight at any size.
  • The paper is an SVG, with holes punched on its edge. Half of each hole bites into the paper, so the shadow follows the scallops instead of the stamp's bounding box.
  • Every move runs in beats through a pile. Going in is fan, pile, focus. Coming out is focus, pile, fan, and the stamp that was open travels to its own slot still raised before it tucks into the row. The second beat starts on the tail of the first, so it reads as one gesture. A press during a beat is ignored.
  • The lift is a tween, not a spring, and it skips React. The stamp rises about 4% of the stage. A spring creeps the last pixel of a move that short, which reads as lag. The lift is set from the pointer event, so it starts on the frame the pointer arrives, and it only arms once the fan has stopped moving, so a stamp sliding under a still pointer doesn't lift.
  • Two springs, two speeds. The lean is stiff and the print drifts loosely behind it, so the print reads as sitting under glass rather than being dragged.
  • Reduced motion skips the beats, the lean and the parallax, and makes every move instant.

The stamps that fade behind the focused one are inert, so you can't tab to or press a stamp you can't see.

Installation

pnpm dlx shadcn@latest add @uitopia/stamp-collection

Usage

import StampCollection from "@/components/ui/stamp-collection";

<StampCollection />;

The collection draws its own stage, a 3:2 table that follows the theme and fills the width of its container, and every pose is worked out from its size. Pass className to change the stage, and imageBase to point at your own folder of three 3:4 pictures named sun.webp, wave.webp and kiku.webp. The stamps are stampsAt in index.tsx, the geometry and timings are in poses.ts, and a stamp with no src falls back to the drawn prints in motifs.tsx. The prints keep their own palette, since a postage stamp's colours are the object.

Pictures

The three stamps carry public-domain works from the Metropolitan Museum of Art's Open Access collection, released under CC0. Each is cropped to 3:4 and lightly graded, and they are hosted on this site, so the component adds no image weight to your bundle. Pass imageBase for anything you ship.