skip to content
cd/

lab

my workbench. every piece here is an experiment you can play with, and the code under each one is the control panel: drag the numbers to change them. copy the ones you like.

the toy

the drawing that stands for me, as a toy. it looks at your pointer, squashes when you press and stretches when you let go.

teaches: one spring can tilt, follow and squash, and how stiffness and damping change the creature's mood.

avatar-toy.ts
spring({ stiffness: 220, damping: 14 })
look({ tilt: 12deg })

drag the numbers, or focus and use the arrows. double-click to type.

snap together

two loose pieces: a plain button and my avatar. drag the avatar close to the button and let go. if it's inside the radius it snaps in and becomes a cartoon button. clicking it makes the avatar hop.

teaches: a generous snap radius and a spring make dragging feel magnetic, and keyboard users get a button that does the same.

combine.ts
merge({ snap: 56px, stiffness: 260 })

drag the numbers, or focus and use the arrows. double-click to type.

hold to confirm

hold the button until it fills. change the time to feel how long you need to be sure. space and enter work too.

teaches: slow where the person decides, fast where the system answers: filling is slow, letting go is 200 ms.

hold.ts
hold({ duration: 1600ms, release: 200ms })

drag the numbers, or focus and use the arrows. double-click to type.

cartoon button

from my cd-ui: thick border and a hard shadow, no blur. on press the button sinks into its own shadow and comes back on a spring curve.

teaches: three css variables change the whole mood, and pressing has to be instant while letting go can have personality.

cartoon.css
--cartoon-offset: 4px;
--press-depth: 3px;
--cartoon-border: 2px;

drag the numbers, or focus and use the arrows. double-click to type.

confetti

the cd/ui confetti, the same one that fires when you send the freelance form. the dashed cone shows where it goes. click the button or anywhere on the stage.

teaches: real physics (speed, angle, gravity) sampled at 12 points and handed to WAAPI, no canvas and no library.

or click anywhere

confetti.ts
confetti({ count: 60, spread: 70,
angle: 270, power: 900 })

drag the numbers, or focus and use the arrows. double-click to type.

easing curve

drag the yellow dots on the graph. the top ball runs on your curve and the bottom one is linear, for comparison. going past 1 on the y axis is what gives the springy overshoot.

teaches: almost everything in an interface wants ease-out: it starts fast and lands slow, so it feels instant.

cubic-bezier
linear
easing.css
transition: transform 700ms
cubic-bezier(0.23, 1, 0.32, 1);

drag the numbers, or focus and use the arrows. double-click to type.

stagger

a list that comes in one item at a time. change the delay and watch the total in the code comment: it turns red when it goes too far.

teaches: a stagger is charming until the last item takes too long. the total time is what people feel, not the per-item delay.

$ ls ~/lab
  1. 0msavatar-toy.tsx
  2. 40mscombine.tsx
  3. 80mshold-bench.tsx
  4. 120msconfetti-bench.tsx
  5. 160mseasing-bench.tsx
  6. 200msrubber-bench.tsx
stagger.ts
stagger({ delay: 40ms, duration: 300ms, y: 12px })
// total: (6 - 1) × 40ms + 300ms = 500ms

drag the numbers, or focus and use the arrows. double-click to type.

rubber band

pull the avatar away. it follows your finger with resistance (the dashed circle is where your finger is) and springs back when you let go, keeping the gesture's speed. on the keyboard, the arrows give it a push.

teaches: a limit that gives a little beats a wall: it says you've hit the end without feeling stuck.

rubber.ts
rubber(distance, { max: 120px, resistance: 0.55 })
spring({ stiffness: 300, damping: 18 })
// (1 - 1 / (d × resistance / max + 1)) × max

drag the numbers, or focus and use the arrows. double-click to type.

no-wait palette

the palette (ctrl+k) is a chunk of code that downloads the first time. the network here is simulated: open it with no preload and watch the skeleton wait, then turn on the preload the site does on its own.

teaches: downloading while idle removes the wait on first use, and a keyboard shortcut gets no animation at all.

press open

palette.ts
open({ preload: , network: 450ms })

drag the numbers, or focus and use the arrows. double-click to type.

achievement

the one from the site's easter egg, out of its hiding place. the circle pops, the pill opens from it, the text comes in, holds, and everything closes back.

teaches: one timeline with several parts at different offsets, instead of several timeouts fighting each other.

achievement.ts
circle: pop 280ms -> hold -> collapse
pill: open 200-520ms, close 4050-4400ms
text: fade 420-600ms, out 3950-4100ms

command palette

this one is already live site-wide: press the shortcut on any page to search pages, posts and actions.

Ctrl K