Slides that snap, and a dot that stretches toward the next one.
The prompt19,877 characters
Add the "Carousel" 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 Carousel, 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:
--font-ui
--ink
--ink-3
--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.
--- Carousel.tsx ---
import { useEffect, useRef, useState } from "react";
import { animate, motion, useMotionValue, useTransform } from "framer-motion";
/* ══ Carousel ═════════════════════════════════════════════
Three slides you drag between, and the dots under them.
ONE NUMBER IS THE STATE: the position, in slides, as a
motion value that is 0 on the first and 2 on the last and
anything in between while a finger has it. The track's x
is that number times the pitch, and the dots are read off
the same number, so the strip and its indicator can never
disagree about where you are — they are two readings of
one value rather than two things told to move together.
THE ACTIVE DOT STRETCHES TOWARD THE NEXT ONE. A dot that
jumps from place to place tells you where you landed and
nothing about the trip; one that reaches for the next dot
as the slide moves and gathers itself up on arrival is the
same gesture at a smaller scale. The front edge goes first
and the back edge follows, and it is symmetric in both
directions because both edges are written from the
fraction of the way between two dots — not from a
direction somebody had to track.
The rest — the source and its comments — is what you are buying.