svg-ui-moments
Make or change Moments (moments/): a monochrome specimen sheet of twenty tactile UI micro-interactions driven by real, interruptible nonlinear physics across five materials (rubber, viscous, mechanica
Files2
View on GitHubSKILL.mdskills/svg-ui-moments/SKILL.md
GitHubUI moments
Twenty monochrome UI controls that move by nonlinear physical law rather than flat CSS ease-in-out.
Read moments/notes.md first for the module map and the invariants every tile must keep.
The bar
- Monochrome exposes timing. No brand hues, no rainbow gradients, no glow crutches. Value contrast (ground, recessed well, mid ink, crisp active solid, overhead rim light, soft contact shadow) carries the entire form, so flat easing, clipped strokes, or hesitant transitions have nowhere to hide.
- Nonlinear motion is the whole craft (anti-slop laws). A bare high-damping spring from rest (
ζ ≥ 0.7) still reads as a polite linearease-out. Every tile in Moments earns its liveliness through at least one of five explicit nonlinear techniques:- Anticipation & delayed tail: wind up before launching (Jelly Pad pre-hop crouch, Squash Play pillow compression mid-morph) or delay the trailing edge 65–85 ms behind the leading edge (Stretch Toggle, Gooey Tab Bar, Worm Dots) so the silhouette elongates dramatically before snapping shut.
- True 2nd-order inertia, never 1st-order lerp: even multi-element fields (Magnet Grid's 42 dots)
run on individual
Springoscillators so elements whip inward and overshoot elastically rather than creeping asymptotically viax += (target - x) * k. - Nonlinear acceleration & threshold snap: gravity torque
∝ sin(θ)on Domino Row, exponential launchu^2.15on Paper Plane, quintic pusheaseInOutQuinton Swipe Confirm and Download Ring, and sticky tension → sudden pinch-off recoil on Merge Drops (never constant-speed linear orbits!). - Exact volume conservation outside rotation: squash/stretch computes
squash(s) = (exp(s), exp(-s))with world-aligned floor squash outside body rotation (Jelly Pad, Squash Play). - Geometry-exact polarity inversion: SVG
<mask>over the filtered metaball in Gooey Tab Bar, live sine<clipPath>in Tide Progress, wide mid-grey crossover in Stretch Toggle, and livegetComputedTextLength()strikethrough in Checklist.
- Five distinct physical materials (
MATERIALSinphysics.ts):mechanical(ω 38, ζ 0.62; detents/rocker/reels tunedζ 0.50–0.52for crisp over-center snap): Detent Dial, Domino Row, Rocker Switch, Odometer.rubber(ω 18, ζ 0.30; deep pillow squash & silicone reboundζ 0.20–0.46): Stretch Toggle, Jelly Pad, Swipe Confirm, Squash Play, Worm Dots.taut(ω 34, ζ 0.085; expressive harmonic whips & bouncy staged morphs): Paper Plane, Elastic String, Download Ring, Bell Toggle, Menu Morph, Checklist.viscous(ω 13, ζ 0.48; sticky tension, concave metaball necks, mutual recoil): Gooey Tab Bar, Merge Drops.fluid(ω 11, ζ 0.32; sloshing waves, spring dot lattices, quartic ripples): Tide Progress, Magnet Grid, Ripple Pad.
- Real interaction, not a canned video. Every tile feeds pointer press, drag, scrub, velocity-on-release,
or hover directly into the same physics state that Loop mode drives via
demo(cycleTime, dt). Callingctx.interact()grants a quiet user-ownership hold without breaking per-tile Loop clocks on resume; interrupting any control mid-flight preserves velocity and never snaps or teleports. - Quiet when still, crisp at any refresh rate. Analytical spring stepping behaves identically at
60 Hz, 120 Hz, and 144 Hz. Every
.moment-cardisolates paint withcontain: layout style paintand is culled individually byIntersectionObserverso off-screen tiles never tick. Settled tiles sleep between beats even in Loop mode (so everydemo()must callctx.wake()whenever it starts a beat or drives continuous motion), andschedule()guards re-entrantctx.wake()insideframe()so a single shared RAF never multiplies. Never read layout (getComputedTextLength,getBoundingClientRect) insidestep()/render(), skip redundant attribute writes, bypass SVG blur filters when a gooey blob sits still, and sleep the RAF loop completely when settled in Play mode. - Tactile Web Audio that actually fires on first touch.
SoundEngine(sound.ts) layers short bandpass noise bursts over resonant body oscillators through a masterDynamicsCompressorNode, awaits asyncctx.resume()rather than dropping the first click, announces itself with a subtle chime when toggled on, and stays silent during Loop auto-playback until the reader touches a tile. - Both lights earn their frame. Night is matte obsidian with porcelain solids; Day is delineate's warm
bone paper with charcoal ink — value hierarchy re-balanced per surface (
--m-dial-hi/lo,--m-rocker-*), never a CSSinvert()shortcut.
Adding a new tile (agentic DX recipe)
- Pick the matching material family file (
tiles/rubber.ts,tiles/viscous.ts,tiles/mechanical.ts,tiles/taut.ts,tiles/fluid.ts) and export aTileSpec(slug,name,material,hint,mount). - Draw inside the shared
200 × 140viewBox returned bycreateStageSvg()using only semantic CSS tokens (--m-ink,--m-paper,--m-well,--m-well-deep,--m-mid,--m-soft,--m-border,--m-border-strong,--m-card,--m-lip,--m-ink-dim,--m-shadow,--m-sheen,--m-dial-hi/lo,--m-rocker-*). - Share one physics state between user events (
stagePoint,VelocityTracker,ctx.interact(),ctx.sound()) and Loop choreography (demo(cycleTime, dt)). Always callctx.wake()insidedemo()when triggering a beat or driving continuous motion so per-tile idle-sleep wakes immediately. Gate any delayed sound insidestep()/render()on auserActiveflag so Loop mode stays silent when Sound is enabled. - For viscous tiles, create a unique filter id via
uniqueId(...)withcreateGooFilter(-30%/160%bounds) and use a synchronized SVG<mask>(not<clipPath>) whenever foreground strokes invert across the metaball. - Register the tile in
tiles/index.ts(alternating adjacent silhouettes) and inspect it magnified at?tile=<slug>in both?light=nightand?light=day.
Done means
npm run check passes and npm run moments (http://localhost:5380/) looks museum-grade in a real browser:
- Inspect full sheet in both Night and Day at desktop (
5 × 4) and narrow (2 × 10) viewports: even visual weight, zero clipped SVG strokes or filter edges, crisp contrast on every label and hardware surface, and zero console errors. - Inspect mid-motion filmstrips of the signature morphs (Stretch Toggle wide mid-pill elongation, Gooey Tab Bar continuous metaball bridge + masked icon inversion, Merge Drops sticky tension → snap recoil, Paper Plane rocket launch with trailing wake, Download Ring elastic pill-to-ring-to-check-pill, Squash Play deep pillow-squash + mid-press polygon morph, Tide Progress split-polarity waterline + calm Play meniscus, Elastic String full-height S-wave whip) and verify every beat reads nonlinearly.
- Verify direct interaction (click, drag, early-release recoil on Swipe Confirm, circular drag on Detent
Dial, bidirectional swipe on Domino Row, pointer sweep across Elastic String and Magnet Grid,
crisp audible feedback on first gesture when Sound is toggled on) and confirm the RAF loop sleeps cleanly
(
0idle DOM mutations) in Play mode even after tapping or triggering Magnet Grid.