No.77 · Cards
Ripple Rim Card
A file drop zone whose dashed rim leans in toward the file you're dragging, and sends a wave both ways round the card from the exact spot you let go.
The prompt
The design brief behind this component — reuse it to regenerate, remix, or explain it.
Build a file drop zone whose border is a live SVG path. Measure the zone with a ResizeObserver and sample its rounded rectangle (18px corners) every ~4px, keeping each point's outward normal. Draw the path from those points, filled with the surface colour and stroked as a 1.5px dash (7 6). While a file is dragged over, track the pointer (smoothed) and pull nearby rim points inward along their normals by up to 9px with a gaussian falloff (σ 80px), so the edge leans toward the file; the dashes tighten to 7 3, the stroke turns to the accent and the face tints. On drop, find the rim point nearest the drop and send a damped wave both ways round the perimeter from it: a gaussian packet times a cosine, amplitude 8px decaying with τ 0.7s, meeting on the far side after ~0.8s. Choosing a file with the picker starts the wave from where you clicked (top centre from the keyboard). The zone is a real button that opens the file input. Added files settle in underneath as rows with a type tile, the name, size and an upload bar that fills, then 'Uploaded' in green. Files over the size limit are refused with a sentence saying what to do. All animation runs in one requestAnimationFrame loop that stops when the rim is at rest.
Notes
- Interaction
- Drag a file over to make the rim lean toward it; drop it to send a wave round the card. Click or press Enter to choose a file instead.
- Motion
- Lean follows the pointer with ~70ms smoothing; the wave decays over ~1.8s; rows slide in 520ms and the upload bar fills over 1.3s.
- Accessibility
- The zone is a button described by its hint and any error; the hidden input is out of the tab order. Errors use role=alert, and a polite live region announces added and removed files. Each row has a labelled remove button that returns focus to the zone. Reduced motion keeps the rim still.
- Responsive
- Full width up to 34rem; file names truncate with an ellipsis.
- On touch
- Tap to open the file picker; the wave starts from where you tapped.