A track that thickens under your finger, and a value that rides the thumb.
The prompt29,254 characters
Add the "Slider" component from notboring to my project.
It is licensed for use in my projects — notboring.dev/license. Please:
1. Create the component at a sensible path for this
project, named Slider, from the source below.
2. Install what it needs: npm i framer-motion
3. Add the CSS to the project's stylesheet.
4. THE PART THAT NEEDS YOUR JUDGMENT. The CSS reads
these custom properties and does not define them:
--card
--font-ui
--ink
--ink-rgb
They are notboring's design tokens. Map each one to
whatever this project already uses for the same
job — its own ink, ground, surface and UI font —
rather than defining them as new globals. If the
project has no equivalent, define it locally on
the component's own root so nothing leaks out.
Anything ending -rgb wants three bare numbers,
because the CSS builds rgba() from it.
Keep the comments. They say why the numbers are what
they are, and they are most of what makes this worth
copying rather than rewriting.
--- Slider.tsx ---
import { useEffect, useRef, useState } from "react";
import {
animate,
motion,
useMotionValue,
useSpring,
useTransform,
useVelocity,
} from "framer-motion";
/* ══ Slider ═══════════════════════════════════════════════
A thumb on a track, and the track knows when it is held.
THE THUMB STRETCHES WITH SPEED, AND THE READING LEANS WITH
IT. A thumb that slides is a circle changing its x, and a
circle changing its x is a diagram. This one lengthens
while it is fast — the tail behind, the front where the
value is, area kept — and is a circle again the moment it
stops, which is the switch's knob doing its one trick on a
longer road. The reading above it is a tag on the thumb:
it tilts a few degrees away from the direction of travel,
the way anything hanging off a moving point does, and hangs
straight once the point is still. Both are read off the
same velocity, so neither can lean or stretch on its own.
The rest — the source and its comments — is what you are buying.