∞ forever components

Travel

Ticket Punch

Six-journey card ticket and a sprung steel conductor’s punch. Each press swings the punch to the next box, bites a hole and drops one paper chad. Backspace patches the last hole; a seventh press deals a fresh ticket.

canvasmedium complexitysubtle motionpointer+keyboard

Open on the canvas to copy the code → Free account · 3 copies a day · membership goes unlimited

Live demo — the real component, running in a sandbox. One self-contained HTML file, zero dependencies. Open it on the canvas →
1

When to use it

A stepper or counter for a small fixed number of uses: passes, loyalty cards, credits, lesson packs.

When not to

Counts above about ten, or values that go up and down freely: the ticket reads as uses spent.

Working with an AI agent

Every component ships agent-ready metadata. An example instruction for this one:

Palette: schoolroom chart and travel desk. Graphite wall (dark) or warm stone (light), card and linen paper, aged brass, oak, slate-blue ink, ochre, one stamp-red accent. RIDES sets the number of boxes; the ticket text is drawn in printTicket(). The button announces Journey N of 6 punched, Journey N restored and New ticket; a hidden progress line keeps N of 6 journeys used.

Safe to edit

  • text in printTicket() (line name, subtitle) and the first serial number
  • colour tokens on :root and :root[data-theme="light"] (wall, card, ink, steel, brass, ring)
  • tuning table of spring constants (punch reach, jaw snap, ticket feed)

Keep intact

  • theme: ?theme= bootstrap, forever:theme listener, syncTheme() and the baked-art rebuild
  • IIFE, visibilitychange, wall-active pause, reduced motion, aria-live announcements
  • one native button: tap, Enter, Space or Right Arrow punches; Left Arrow or Backspace restores; Escape resets

Known limitations

  • Canvas drawn: object colours are tokens read by the script, so Your colours does not recolour it.
  • Six journeys per ticket; the row does not wrap.
  • The serial number hides in the compact layout.

ticketpunchsteppercounterpasschadsteelpapertravelcanvas