Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: added slider component
dev_wandry78e18544c63c
diff --git a/components/docs/examples/index.tsx b/components/docs/examples/index.tsxindex 87deb089..6f980d2e 100644--- a/components/docs/examples/index.tsx+++ b/components/docs/examples/index.tsx@@ -40,6 +40,10 @@ import {SkeletonExampleScene,skeletonExampleCode,} from "./skeleton-example";+import {+ SliderExampleScene,+ sliderExampleCode,+} from "./slider-example";export interface ExampleEntry {Component: ComponentType;@@ -218,4 +222,13 @@ export const examples: Record<string, ExampleEntry> = {width: W,height: H,},+ "slider-example": {+ Component: SliderExampleScene,+ code: sliderExampleCode,+ // Drag completes at 100; thumb releases at 108; a short settle then loop.+ durationInFrames: 120,+ fps: FPS,+ width: W,+ height: H,+ },};diff --git a/components/docs/examples/slider-example.tsx b/components/docs/examples/slider-example.tsxnew file mode 100644index 00000000..69365d95--- /dev/null+++ b/components/docs/examples/slider-example.tsx@@ -0,0 +1,101 @@+"use client";++import { Cursor } from "@/registry/remocn-ui/cursor";+import { useCursorPath } from "@/registry/remocn-ui/cursor/use-cursor-path";+import { Slider } from "@/registry/remocn-ui/slider";+import { useSliderTransition } from "@/registry/remocn-ui/slider/use-slider-transition";++// Track is 320px wide, centered on the 1280×720 canvas.+// Track left edge: (1280 - 320) / 2 = 480px. Track vertical center: 360px.+// Value 20% → thumb x: 480 + 0.20 × 320 = 544. Value 80% → thumb x: 480 + 0.80 × 320 = 736.+const THUMB_START_X = 544; // canvas x at value 20+const THUMB_END_X = 736; // canvas x at value 80+const THUMB_Y = 360; // canvas y of track center++export const SliderExampleScene = () => {+ // Cursor: park top-left → ease to thumb (arrives frame 30) → drag to end (arrives frame 100) → release.+ const cursorStyle = useCursorPath([+ { at: 0, x: 80, y: 60, },+ { at: 30, x: THUMB_START_X, y: THUMB_Y, duration: 26 },+ { at: 44, x: THUMB_START_X, y: THUMB_Y, press: true, duration: 0 },+ { at: 100, x: THUMB_END_X, y: THUMB_Y, press: true, duration: 56 },+ { at: 108, x: THUMB_END_X, y: THUMB_Y, duration: 0 },+ ]);++ // Slider: dual-channel — value eases 20 → 80 during the drag; thumb idles → hover → press → idle.+ const sliderStyle = useSliderTransition([+ { at: 0, value: 20, thumbState: "idle" },+ { at: 30, thumbState: "hover", duration: 8 },+ { at: 44, thumbState: "press", duration: 6 },+ { at: 44, value: 20 },+ // Match the cursor's default inOut easing so the thumb tracks the cursor exactly.+ { at: 100, value: 80, duration: 56, easing: "inOut" },+ { at: 108, thumbState: "idle", duration: 8 },+ ]);++ return (+ <div style={{ position: "relative", width: "100%", height: "100%" }}>+ <div+ style={{+ position: "absolute",+ left: "50%",+ top: "50%",+ transform: "translate(-50%, -50%)",+ }}+ >+ <Slider style={sliderStyle} width={320} showValue />+ </div>+ <Cursor style={cursorStyle} variant="pointer" />+ </div>+ );+};++export const sliderExampleCode = `import { Cursor } from "@/components/remocn/cursor";+import { useCursorPath } from "@/components/remocn/use-cursor-path";+import { Slider } from "@/components/remocn/slider";+import { useSliderTransition } from "@/components/remocn/use-slider-transition";++// Track is 320px wide, centered on the canvas.+// Adjust these to match your canvas dimensions and slider position.+const THUMB_START_X = 544; // canvas x at value 20+const THUMB_END_X = 736; // canvas x at value 80+const THUMB_Y = 360; // canvas y of track center++export const Scene = () => {+ // Cursor eases to the thumb, holds press, drags to the right, then releases.+ const cursorStyle = useCursorPath([+ { at: 0, x: 80, y: 60 },+ { at: 30, x: THUMB_START_X, y: THUMB_Y, duration: 26 },+ { at: 44, x: THUMB_START_X, y: THUMB_Y, press: true, duration: 0 },+ { at: 100, x: THUMB_END_X, y: THUMB_Y, press: true, duration: 56 },+ { at: 108, x: THUMB_END_X, y: THUMB_Y, duration: 0 },+ ]);++ // Slider dual-channel: value eases 20 → 80 in sync with the cursor drag;+ // thumb visual transitions idle → hover → press → idle.+ const sliderStyle = useSliderTransition([+ { at: 0, value: 20, thumbState: "idle" },+ { at: 30, thumbState: "hover", duration: 8 },+ { at: 44, thumbState: "press", duration: 6 },+ { at: 44, value: 20 },+ // Match the cursor's default inOut easing so the thumb tracks the cursor exactly.+ { at: 100, value: 80, duration: 56, easing: "inOut" },+ { at: 108, thumbState: "idle", duration: 8 },+ ]);++ return (+ <div style={{ position: "relative", width: "100%", height: "100%" }}>+ <div+ style={{+ position: "absolute",+ left: "50%",+ top: "50%",+ transform: "translate(-50%, -50%)",+ }}+ >+ <Slider style={sliderStyle} width={320} showValue />+ </div>+ <Cursor style={cursorStyle} variant="pointer" />+ </div>+ );+};`;diff --git a/content/docs/ui/components/meta.json b/content/docs/ui/components/meta.jsonindex 6b22f420..69fb0a9d 100644--- a/content/docs/ui/components/meta.json+++ b/content/docs/ui/components/meta.json@@ -1,5 +1,5 @@{"title": "Components","collapsible": false,- "pages": ["accordion", "alert-dialog", "button", "checkbox", "command-menu", "cursor", "dialog", "drawer", "sheet", "dropdown-menu", "input", "progress", "radio", "select", "skeleton", "spinner", "switch", "tabs", "toast", "tooltip"]+ "pages": ["accordion", "alert-dialog", "button", "checkbox", "command-menu", "cursor", "dialog", "drawer", "sheet", "dropdown-menu", "input", "progress", "radio", "select", "skeleton", "slider", "spinner", "switch", "tabs", "toast", "tooltip"]}diff --git a/content/docs/ui/components/slider.mdx b/content/docs/ui/components/slider.mdxnew file mode 100644index 00000000..2763d4bd--- /dev/null+++ b/content/docs/ui/components/slider.mdx@@ -0,0 +1,192 @@+---+title: Slider+description: A range slider with a draggable thumb driven by a scripted value and thumb-state timeline+---++<ComponentPreview name="slider" />++A dual-channel value atom whose fill (`0`–`100`) and thumb appearance (`idle`, `hover`, `press`) are a pure function of the props it receives. The component reads no frame. This is a **dual-channel** variant of the value-channel pattern: `useSliderTransition` drives a numeric fill channel and a thumb-state channel independently through one `SliderStyle`, so cursor-synced drag scenes compose naturally.++## Installation++<InstallBlock name="slider" />++<Note>+Installing `slider` automatically installs the shared `remocn-ui` core (`lib/remocn-ui/`) via `registryDependencies` (`["remocn-ui"]`). You do not need to install it separately. Both `slider` (the renderer) and `use-slider-transition` (the hook) are copied into your project.+</Note>++## Example++<LiveExample name="slider-example" />++## Value & thumb++`useSliderTransition` takes an array of `SliderStep` objects. Each step can advance the **value channel**, the **thumb channel**, or both in the same keyframe:++```ts+interface SliderStep {+ at: number; // LOCAL (Sequence-relative) authored frame this keyframe is reached+ value?: number; // Target fill percentage 0–100 (moves the value channel)+ thumbState?: SliderThumbState; // Target thumb visual (moves the thumb channel)+ duration?: number; // Frames the move INTO this step takes. Omitted → DEFAULT_DURATION (18)+ easing?: EasingName; // Override easing. Default "out"+}+```++`SliderThumbState` presets:++```ts+type SliderThumbState =+ | "idle" // thumbScale 1, ringOpacity 0 — resting+ | "hover" // thumbScale 1.1, ringOpacity 1 — pointer over thumb+ | "press" // thumbScale 1.15, ringOpacity 1 — thumb held down+```++### Dual-channel deviation++`Slider` extends the value-channel pattern (like `Progress`) with a second channel: the thumb visual. The two channels are folded independently — value-bearing steps only affect the fill; thumb-bearing steps only affect the thumb scale and grab ring. A single step may carry both fields to advance both channels at the same frame. This lets you compose a cursor drag scene by keeping cursor `x` and slider `value` on the same frame budget without coupling the thumb-state transitions to the fill easing.++## Snap usage++Pass `value` and `thumbState` directly — the component snaps instantly to that visual. Useful for static previews:++```tsx+import { Slider } from "@/components/remocn/slider";++export const Scene = () => (+ <div style={{ position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center" }}>+ <Slider value={60} thumbState="hover" width={320} showValue />+ </div>+);+```++## Smooth transitions++Value and thumb changes via the snap props are instant. For animated fill and thumb interactions, use `useSliderTransition` from the copied `use-slider-transition.ts` file. It reads the frame, folds the two channels independently, and returns a resolved `SliderStyle` — pass it to the `style` prop:++```tsx+import { Slider } from "@/components/remocn/slider";+import { useSliderTransition } from "@/components/remocn/use-slider-transition";++export const Scene = () => {+ const style = useSliderTransition([+ { at: 0, value: 20, thumbState: "idle" },+ { at: 30, thumbState: "hover", duration: 8 },+ { at: 44, thumbState: "press", duration: 6 },+ { at: 44, value: 20 },+ { at: 100, value: 80, duration: 56 },+ { at: 108, thumbState: "idle", duration: 8 },+ ]);++ return (+ <div style={{ position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center" }}>+ <Slider style={style} width={320} showValue />+ </div>+ );+};+```++The `duration` field on each step overrides the file's `DEFAULT_DURATION` (= `18`) for that specific move. To globally tune timing and easing, edit `use-slider-transition.ts` directly in your project — that file is yours (shadcn "own your code" philosophy).++`style` takes precedence over `value` and `thumbState` when provided.++### Frame-syncing with Cursor++To animate a cursor dragging the thumb, keep the cursor's `x` position and the slider's `value` steps on the same frame budget. The cursor travels from the thumb's starting canvas position to its ending position over the same number of frames that `value` eases from its start to its target:++```tsx+import { Cursor } from "@/components/remocn/cursor";+import { useCursorPath } from "@/components/remocn/use-cursor-path";+import { Slider } from "@/components/remocn/slider";+import { useSliderTransition } from "@/components/remocn/use-slider-transition";++// Track is 320px wide, centered on a 1280×720 canvas.+// Track left edge: (1280 - 320) / 2 = 480px.+// Value 20% → thumb at canvas x = 480 + 0.20 × 320 = 544.+// Value 80% → thumb at canvas x = 480 + 0.80 × 320 = 736.+const THUMB_START_X = 544;+const THUMB_END_X = 736;+const THUMB_Y = 360;++export const Scene = () => {+ const cursorStyle = useCursorPath([+ { at: 0, x: 80, y: 60 },+ { at: 30, x: THUMB_START_X, y: THUMB_Y, duration: 26 },+ { at: 44, x: THUMB_START_X, y: THUMB_Y, press: true, duration: 0 },+ { at: 100, x: THUMB_END_X, y: THUMB_Y, press: true, duration: 56 },+ { at: 108, x: THUMB_END_X, y: THUMB_Y, duration: 0 },+ ]);++ const sliderStyle = useSliderTransition([+ { at: 0, value: 20, thumbState: "idle" },+ { at: 30, thumbState: "hover", duration: 8 },+ { at: 44, thumbState: "press", duration: 6 },+ { at: 44, value: 20 },+ { at: 100, value: 80, duration: 56 },+ { at: 108, thumbState: "idle", duration: 8 },+ ]);++ return (+ <div style={{ position: "relative", width: "100%", height: "100%" }}>+ <div style={{ position: "absolute", left: "50%", top: "50%", transform: "translate(-50%, -50%)" }}>+ <Slider style={sliderStyle} width={320} showValue />+ </div>+ <Cursor style={cursorStyle} variant="pointer" />+ </div>+ );+};+```++The cursor's drag frames (`at: 44` → `at: 100`, duration 56) match the value-channel move exactly. The thumb-state transitions (`hover` at 30, `press` at 44, `idle` at 108) are independent — they run on their own mini-durations without disturbing the fill easing.++## Props++<PropsTable+ rows={[+ {+ name: "value",+ type: "number",+ default: "0",+ description: "Fill percentage 0–100 (snap path). Clamped to [0, 100]. Ignored when style is provided.",+ },+ {+ name: "thumbState",+ type: "\"idle\" | \"hover\" | \"press\"",+ default: "\"idle\"",+ description: "Thumb visual state (snap path). Sets thumbScale and ringOpacity from the preset. Ignored when style is provided.",+ },+ {+ name: "style",+ type: "SliderStyle",+ description: "Resolved animated visual (smooth path). Pass an interpolated SliderStyle from useSliderTransition. Takes precedence over value and thumbState when provided.",+ },+ {+ name: "width",+ type: "number",+ default: "320",+ description: "Track width in px.",+ },+ {+ name: "showValue",+ type: "boolean",+ default: "false",+ description: "When true, renders the rounded current value above the thumb.",+ },+ {+ name: "theme",+ type: "Partial<RemocnTheme>",+ description: "Per-component theme override. Merges with the active RemocnUIProvider theme and the mode defaults. Must be concrete oklch/hex/rgb values — not CSS custom properties.",+ },+ {+ name: "mode",+ type: "\"light\" | \"dark\"",+ default: "\"light\"",+ description: "Sets the base palette. Overrides the mode on RemocnUIProvider when both are present.",+ },+ {+ name: "className",+ type: "string",+ description: "Optional className applied to the outer wrapper element.",+ },+ ]}+/>diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex e3c1f1ce..20318f46 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -153,6 +153,8 @@ import { SkeletonBlockPreview } from "@/registry/remocn-ui/skeleton-block/previeimport { skeletonBlockConfig } from "@/registry/remocn-ui/skeleton-block/config";import { SkeletonPreview } from "@/registry/remocn-ui/skeleton/preview";import { skeletonConfig } from "@/registry/remocn-ui/skeleton/config";+import { SliderPreview } from "@/registry/remocn-ui/slider/preview";+import { sliderConfig } from "@/registry/remocn-ui/slider/config";import { ZoomThroughTransition } from "@/registry/remocn/zoom-through-transition";import { zoomThroughTransitionConfig } from "@/registry/remocn/zoom-through-transition/config";@@ -372,6 +374,9 @@ const registry: Record<string, RegistryEntry> = {config: skeletonBlockConfig,},"skeleton": { Component: SkeletonPreview, config: skeletonConfig },+ // slider's customizer Component is the preview-only SliderPreview wrapper: a+ // bare inline bar would sit top-left, so the wrapper centers it on a stage.+ "slider": { Component: SliderPreview, config: sliderConfig },"spinner": { Component: Spinner, config: spinnerConfig },};diff --git a/registry/remocn-ui/registry.json b/registry/remocn-ui/registry.jsonindex 356db77e..0ffe958e 100644--- a/registry/remocn-ui/registry.json+++ b/registry/remocn-ui/registry.json@@ -511,6 +511,26 @@"target": "components/remocn/use-skeleton-transition.ts"}]+ },+ {+ "name": "slider",+ "type": "registry:component",+ "title": "UI Slider",+ "description": "A slider whose fill is a numeric value channel plus a thumb idle/hover/press channel (dual-channel value-channel deviation). The Slider renderer is pure (clamped 0–100 value, thumb scale, grab-ring opacity); useSliderTransition reads the frame and eases both channels — value as a numeric lerp, the thumb visual from its state presets. Muted track + primary range + bordered thumb with a derived grab ring.",+ "dependencies": ["remotion"],+ "registryDependencies": ["remocn-ui"],+ "files": [+ {+ "path": "slider/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/slider.tsx"+ },+ {+ "path": "slider/use-slider-transition.ts",+ "type": "registry:component",+ "target": "components/remocn/use-slider-transition.ts"+ }+ ]}]}diff --git a/registry/remocn-ui/slider/__tests__/README.md b/registry/remocn-ui/slider/__tests__/README.mdnew file mode 100644index 00000000..253be6a3--- /dev/null+++ b/registry/remocn-ui/slider/__tests__/README.md@@ -0,0 +1,173 @@+# `slider` — verification tests++Pure / deterministic verification for the `slider` component+(`registry/remocn-ui/slider/`). The render path (`index.tsx`) imports+`useRemocnTheme` which requires React context and cannot run headlessly — it+is NOT exercised here. This suite covers everything that IS pure:+`clampValue` semantics, `sliderThumbStyle` presets, `sliderStyleContext`+color derivation, `tweenSliderStyle` interpolation, the `sliderStyleAt`+dual-channel pure core (directly exported), and `sliderConfig` controls+wiring + snippet codegen.++## Animation model — dual-channel value atom++Slider follows the **dual-channel value-channel deviation** (STYLE-GUIDE §0):+both the numeric fill (`value`) and the thumb interaction state+(`thumbScale`, `ringOpacity`) are animated and live in one `SliderStyle`.++**Snap path** (`value?: number` + `thumbState?: SliderThumbState` props):+`<Slider>` is a frame-free pure renderer. `value` drives the fill width+(clamped to [0,100]), and `thumbState` selects a thumb preset via+`sliderThumbStyle`. Changes snap — no tweening inside the component.++**Smooth path** (`style?: SliderStyle` prop):+Callers opt in to smooth animation by passing a pre-interpolated `SliderStyle`+to the `style` prop. The caller — typically `useSliderTransition` — reads+`useCurrentFrame()` and delegates to the exported pure function+`sliderStyleAt(steps, raw, opts)`.++**Dual-channel fold:** `sliderStyleAt` filters the step list into two+independent sub-timelines and folds them separately:+- **Value channel**: only steps with `value !== undefined` (numeric easing)+- **Thumb channel**: only steps with `thumbState !== undefined` (tweens+ between `sliderThumbStyle` presets)++Both channels are merged into one `SliderStyle` result. A step may move+both channels simultaneously.++**`sliderStyleAt` is directly exported** — like `progressValueAt`, its pure+core is a named export and tests call it directly with `raw` injected.++**No color tween:** `SliderStyle` has only numeric fields (`value`,+`thumbScale`, `ringOpacity`), so `tweenSliderStyle` is a simple three-field+lerp with no `mixOklch` call. Color derivation (`sliderStyleContext`) uses+`mixOklch` once to compute the grab ring but is static per render.++## Thumb state presets++| `thumbState` | `thumbScale` | `ringOpacity` |+|-------------|-------------|---------------|+| `idle` | 1 | 0 |+| `hover` | 1.1 | 1 |+| `press` | 1.15 | 1 |++Ordering invariant: `press.thumbScale > hover.thumbScale > idle.thumbScale`.+Both `hover` and `press` have `ringOpacity = 1`.++## How to run++The repo uses **Bun**, which has a built-in test runner — runs TypeScript+natively, no test-framework dep.++```bash+bun install+bun test registry/remocn-ui/slider/__tests__+```++`slider.test.ts` imports `bun:test` (not `vitest`/`jest`), so no test+script or framework dep is added to `package.json`.++## What is covered++- **`DEFAULT_DURATION`** — asserts the constant is 18 frames.++- **`clampValue` semantics** — mirrored from `index.tsx` lines 53-55.+ Below-range clamps to 0; above-range clamps to 100; in-range passes through.++- **`showValue` label** — `Math.round(pct)` (index.tsx line 218). Asserts+ 62.4→62, 62.5→63 (rounds up), 99.9→100, 0→0.++- **`sliderThumbStyle`** — exported pure `(thumbState) => {thumbScale,+ ringOpacity}`. Asserts all three presets (idle: 1/0, hover: 1.1/1,+ press: 1.15/1); ordering invariant (press > hover > idle); hover and press+ have identical ringOpacity=1; all fields numeric for every state.++- **`sliderStyleContext`** — exported pure `(theme) => SliderStyleContext`+ (post-shadcn retheme). Field set: `track` (mixOklch of input+background,+ bg-input/90, differs light/dark), `range` (theme.primary), `thumbBg`+ (literal `"oklch(1 0 0)"` — shadcn white thumb, theme-independent),+ `thumbRing` (literal `"rgba(0, 0, 0, 0.1)"` — resting hairline,+ theme-independent), `ring` (mixOklch of theme.ring+background at 0.7,+ ring-ring/30, differs light/dark), `valueText` (theme.foreground). Asserts:+ thumbBg and thumbRing are exact literals in both light and dark; track and+ ring differ between themes; all 6 fields are non-empty strings. Note:+ `thumbBorder` was removed in the retheme; the hairline is now `thumbRing`.++- **`tweenSliderStyle`** — exported pure `(a, b, t) => SliderStyle`.+ Three-field lerp (value + thumbScale + ringOpacity). Asserts: t=0/1+ endpoints, t=0.5 midpoints (value 0→100 gives 50, thumbScale 1→1.1 gives+ 1.05, ringOpacity 0→1 gives 0.5), identity case, idle→press thumb channel+ (thumbScale midpoint = 1.075).++- **`sliderStyleAt`** — exported pure dual-channel core of+ `useSliderTransition`. `useSliderTransition` is exactly+ `sliderStyleAt(steps, useCurrentFrame() * speed, opts)`. Asserts:+ - Empty steps → `{value:0, thumbScale:1(idle), ringOpacity:0(idle)}`.+ - Before first value step (raw ≤ first.at) → holds at `first.value`.+ - Before first thumb step → holds at `first.thumbState` preset.+ - Past last value step → rests at `last.value`.+ - Value channel mid-window: `[{at:0,v:0},{at:18,v:100}]` at raw=9 →+ linear=0.5, `out(0.5)=0.875` → value=87.5 (not linear 50).+ - Thumb channel mid-window: `[{at:0,idle},{at:18,hover}]` at raw=9 →+ thumbScale=1.0875, ringOpacity=0.875.+ - Dual-channel steps fold independently — both channels active in same+ step list; value-only steps leave thumb at idle; thumb-only steps leave+ value at 0.+ - Past last with both channels → rests at last step's values.++- **`sliderConfig.controls`** — control wiring: value (number, default=40,+ min=0, max=100), thumbState (select, options=["idle","hover","press"],+ default="idle"), width (number, default=320), showValue (boolean,+ default=true), mode (select, default="light").++- **`sliderConfig.snippet`** — pure JSX string builder. Asserts: `import {+ Slider }` from correct path; `<Slider` + closing `/>`; value always emitted+ (including 0 fallback); default thumbState="idle"/width=320/mode="light"+ omitted; showValue omitted when false/undefined; non-defaults emitted;+ showValue as boolean shorthand (not `showValue={true}`); thumbState and+ value numeric round-trips.++**Slider render** is a pure `(value | style, thumbState) => visual` observable+only via Remotion render; it is not unit-tested here.++## Import strategy++`slider.test.ts` imports via **relative paths** and the `@/lib/remocn-ui`+alias:++- `../index` — relative, for `sliderThumbStyle`, `sliderStyleContext`,+ `SliderThumbState`+- `../use-slider-transition` — relative, for `tweenSliderStyle`,+ `sliderStyleAt`, `DEFAULT_DURATION`, `SliderStep`+- `../config` — relative, for `sliderConfig`+- `@/lib/remocn-ui` — alias, for `defaultLightTheme`, `defaultDarkTheme`,+ `easings`, `clamp01`++`useSliderTransition` is NOT imported — it calls `useCurrentFrame()`. Its+pure body is the named export `sliderStyleAt`, which is called directly.+`bun test` resolves tsconfig `paths`, so the alias works without additional+config.++## Determinism grep checklist (run manually; must print NOTHING)++`slider/index.tsx` is a pure renderer — the component must contain **none**+of the following:++```bash+grep -nE "useState|useEffect|useCurrentFrame|onClick|onChange|addEventListener|Date\.now|Math\.random|requestAnimationFrame" \+ registry/remocn-ui/slider/index.tsx+```++Expected: **no output**. Any match is a determinism violation.++`use-slider-transition.ts` intentionally reads `useCurrentFrame()` (in+`useSliderTransition`). That is correct and expected; the smooth-path design+isolates all frame-reading to the hook, keeping `<Slider>` pure. The exported+`sliderStyleAt` is frame-free and testable directly.++Tier-wide sweep for `index.tsx`:++```bash+grep -nE "useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \+ registry/remocn-ui/slider/index.tsx registry/remocn-ui/core/*.ts+```diff --git a/registry/remocn-ui/slider/__tests__/slider.test.ts b/registry/remocn-ui/slider/__tests__/slider.test.tsnew file mode 100644index 00000000..270e3fa3--- /dev/null+++ b/registry/remocn-ui/slider/__tests__/slider.test.ts@@ -0,0 +1,661 @@+/**+ * Verification tests for the PURE / DETERMINISTIC parts of `slider`.+ *+ * Scope:+ * - registry/remocn-ui/slider/index.tsx+ * clampValue (internal) — exercised via SliderStyle semantics+ * sliderThumbStyle(thumbState) — pure thumb-channel preset map+ * sliderStyleContext(theme) — pure theme → color derivation+ * - registry/remocn-ui/slider/use-slider-transition.ts+ * tweenSliderStyle(a, b, t) — pure lerp across all three fields+ * sliderStyleAt(steps, raw, opts) — pure exported dual-channel core+ * DEFAULT_DURATION constant+ * - registry/remocn-ui/slider/config.ts+ * sliderConfig.controls wiring + sliderConfig.snippet codegen+ *+ * The render path (index.tsx) imports `useRemocnTheme` which requires React+ * context — it is NOT exercised here. `useSliderTransition` IS a hook (calls+ * `useCurrentFrame()`) and is NOT imported; its pure body is the exported+ * `sliderStyleAt` which we call directly.+ *+ * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).+ * bun test registry/remocn-ui/slider/__tests__+ *+ * --------------------------------------------------------------------------+ * IMPORT STRATEGY+ * --------------------------------------------------------------------------+ * Relative imports from component source; `@/lib/remocn-ui` alias for core.+ * `sliderThumbStyle`, `sliderStyleContext`, and `tweenSliderStyle` / `sliderStyleAt`+ * are pure value functions. `useSliderTransition` IS a hook and is NOT imported;+ * we call `sliderStyleAt` directly (the exported pure core).+ * --------------------------------------------------------------------------+ */++import { describe, expect, it } from "bun:test";+import {+ sliderThumbStyle,+ sliderStyleContext,+ type SliderThumbState,+} from "../index";+import {+ tweenSliderStyle,+ sliderStyleAt,+ DEFAULT_DURATION,+ type SliderStep,+} from "../use-slider-transition";+import { sliderConfig } from "../config";+import { defaultLightTheme, defaultDarkTheme, easings, clamp01 } from "@/lib/remocn-ui";++// ===========================================================================+// Shared fixtures+// ===========================================================================++const VALID_THUMB_STATES: readonly SliderThumbState[] = ["idle", "hover", "press"];++/** Convenience wrapper for snippet(). */+type SnippetValues = {+ value?: number;+ thumbState?: string;+ width?: number;+ showValue?: boolean;+ mode?: string;+};+const snippet = (values: SnippetValues): string =>+ sliderConfig.snippet(values as Record<string, unknown>);++// ===========================================================================+// 1. DEFAULT_DURATION constant+// ===========================================================================++describe("DEFAULT_DURATION", () => {+ it("is 18 frames", () => {+ expect(DEFAULT_DURATION).toBe(18);+ });+});++// ===========================================================================+// 2. clampValue semantics — the component applies clamp01(value/100)*100+// MIRROR of index.tsx lines 53-55 (clampValue function).+// ===========================================================================++/** MIRROR of index.tsx:clampValue */+function clampValue(value: number): number {+ return clamp01(value / 100) * 100;+}++describe("clampValue: below-range values clamp to 0", () => {+ it("value=-5 clamps to 0", () => {+ expect(clampValue(-5)).toBe(0);+ });++ it("value=-0.001 clamps to 0", () => {+ expect(clampValue(-0.001)).toBe(0);+ });+});++describe("clampValue: above-range values clamp to 100", () => {+ it("value=150 clamps to 100", () => {+ expect(clampValue(150)).toBe(100);+ });++ it("value=100.001 clamps to 100", () => {+ expect(clampValue(100.001)).toBe(100);+ });+});++describe("clampValue: in-range values pass through unchanged", () => {+ it("value=0 returns 0", () => {+ expect(clampValue(0)).toBe(0);+ });++ it("value=50 returns 50", () => {+ expect(clampValue(50)).toBe(50);+ });++ it("value=100 returns 100", () => {+ expect(clampValue(100)).toBe(100);+ });++ it("value=40 (the config default) returns 40", () => {+ expect(clampValue(40)).toBe(40);+ });+});++// ===========================================================================+// 3. showValue label — renders Math.round(pct)+// MIRROR of index.tsx line 218: {Math.round(pct)}+// ===========================================================================++describe("showValue label: Math.round applied to clamped value", () => {+ it("Math.round(62.4) = 62", () => {+ expect(Math.round(clampValue(62.4))).toBe(62);+ });++ it("Math.round(62.5) = 63 (rounds up at .5)", () => {+ expect(Math.round(clampValue(62.5))).toBe(63);+ });++ it("Math.round(99.9) = 100 (rounds up near max)", () => {+ expect(Math.round(clampValue(99.9))).toBe(100);+ });++ it("Math.round(0) = 0", () => {+ expect(Math.round(clampValue(0))).toBe(0);+ });+});++// ===========================================================================+// 4. sliderThumbStyle — pure (thumbState) => {thumbScale, ringOpacity} map+// MIRROR of index.tsx lines 62-74+// ===========================================================================++describe("sliderThumbStyle: idle state — default thumb", () => {+ const s = sliderThumbStyle("idle");++ it("thumbScale is 1 (no zoom)", () => {+ expect(s.thumbScale).toBe(1);+ });++ it("ringOpacity is 0 (ring hidden)", () => {+ expect(s.ringOpacity).toBe(0);+ });+});++describe("sliderThumbStyle: hover state — grown thumb + visible ring", () => {+ const s = sliderThumbStyle("hover");++ it("thumbScale is 1.1", () => {+ expect(s.thumbScale).toBeCloseTo(1.1, 10);+ });++ it("ringOpacity is 1 (ring fully visible)", () => {+ expect(s.ringOpacity).toBe(1);+ });+});++describe("sliderThumbStyle: press state — larger thumb + visible ring", () => {+ const s = sliderThumbStyle("press");++ it("thumbScale is 1.15 (larger than hover)", () => {+ expect(s.thumbScale).toBeCloseTo(1.15, 10);+ });++ it("ringOpacity is 1 (ring fully visible)", () => {+ expect(s.ringOpacity).toBe(1);+ });+});++describe("sliderThumbStyle: press thumbScale > hover thumbScale > idle", () => {+ it("press > hover > idle thumbScale ordering", () => {+ expect(sliderThumbStyle("press").thumbScale).toBeGreaterThan(sliderThumbStyle("hover").thumbScale);+ expect(sliderThumbStyle("hover").thumbScale).toBeGreaterThan(sliderThumbStyle("idle").thumbScale);+ });+});++describe("sliderThumbStyle: hover and press have identical ringOpacity", () => {+ it("hover.ringOpacity === press.ringOpacity === 1", () => {+ expect(sliderThumbStyle("hover").ringOpacity).toBe(1);+ expect(sliderThumbStyle("press").ringOpacity).toBe(1);+ });+});++describe("sliderThumbStyle: every state returns numeric fields", () => {+ it("every thumbState produces numeric thumbScale and ringOpacity", () => {+ for (const state of VALID_THUMB_STATES) {+ const s = sliderThumbStyle(state);+ expect(typeof s.thumbScale).toBe("number");+ expect(typeof s.ringOpacity).toBe("number");+ }+ });+});++// ===========================================================================+// 5. sliderStyleContext — pure theme → SliderStyleContext+// MIRROR of index.tsx lines 100-113 (post-shadcn retheme)+//+// Field changes vs original:+// track: was theme.muted, now mixOklch(theme.input, theme.background, 0.1)+// range: unchanged — theme.primary+// thumbBorder: REMOVED (no longer a field)+// thumbBg: was theme.background, now literal "oklch(1 0 0)" (white, theme-independent)+// thumbRing: NEW — literal "rgba(0, 0, 0, 0.1)" (resting hairline, theme-independent)+// ring: was mixOklch(primary,bg,0.55), now mixOklch(theme.ring, theme.background, 0.7)+// valueText: unchanged — theme.foreground+// ===========================================================================++describe("sliderStyleContext: light theme", () => {+ const ctx = sliderStyleContext(defaultLightTheme);++ it("track is a non-empty string (mixOklch of theme.input + theme.background, bg-input/90)", () => {+ expect(typeof ctx.track).toBe("string");+ expect(ctx.track.length).toBeGreaterThan(0);+ });++ it("range equals theme.primary", () => {+ expect(ctx.range).toBe(defaultLightTheme.primary);+ });++ it("thumbBg is the literal white 'oklch(1 0 0)' (shadcn white thumb, theme-independent)", () => {+ expect(ctx.thumbBg).toBe("oklch(1 0 0)");+ });++ it("thumbRing is the literal hairline 'rgba(0, 0, 0, 0.1)' (theme-independent)", () => {+ expect(ctx.thumbRing).toBe("rgba(0, 0, 0, 0.1)");+ });++ it("ring is a non-empty string (mixOklch blend of theme.ring+background, ring-ring/30)", () => {+ expect(typeof ctx.ring).toBe("string");+ expect(ctx.ring.length).toBeGreaterThan(0);+ });++ it("valueText equals theme.foreground", () => {+ expect(ctx.valueText).toBe(defaultLightTheme.foreground);+ });+});++describe("sliderStyleContext: thumbBg and thumbRing are theme-independent (always white/black)", () => {+ const ctxLight = sliderStyleContext(defaultLightTheme);+ const ctxDark = sliderStyleContext(defaultDarkTheme);++ it("thumbBg is 'oklch(1 0 0)' in both light and dark themes", () => {+ expect(ctxLight.thumbBg).toBe("oklch(1 0 0)");+ expect(ctxDark.thumbBg).toBe("oklch(1 0 0)");+ });++ it("thumbRing is 'rgba(0, 0, 0, 0.1)' in both light and dark themes", () => {+ expect(ctxLight.thumbRing).toBe("rgba(0, 0, 0, 0.1)");+ expect(ctxDark.thumbRing).toBe("rgba(0, 0, 0, 0.1)");+ });+});++describe("sliderStyleContext: dark theme differs from light on theme-derived fields", () => {+ const ctxLight = sliderStyleContext(defaultLightTheme);+ const ctxDark = sliderStyleContext(defaultDarkTheme);++ it("ring color differs between light and dark themes (uses theme.ring token)", () => {+ expect(ctxLight.ring).not.toBe(ctxDark.ring);+ });++ it("track differs between light and dark themes (uses theme.input token)", () => {+ expect(ctxLight.track).not.toBe(ctxDark.track);+ });+});++describe("sliderStyleContext: all fields are non-empty strings", () => {+ it("every SliderStyleContext field is a non-empty string for light theme", () => {+ const ctx = sliderStyleContext(defaultLightTheme);+ for (const key of ["track", "range", "thumbBg", "thumbRing", "ring", "valueText"] as const) {+ expect(typeof ctx[key]).toBe("string");+ expect(ctx[key].length).toBeGreaterThan(0);+ }+ });+});++// ===========================================================================+// 6. tweenSliderStyle — pure lerp across all three fields+// MIRROR of use-slider-transition.ts lines 42-52+// Both channels (value + thumb) are covered in one tween.+// ===========================================================================++describe("tweenSliderStyle: t=0 returns values equal to `a`", () => {+ const a = { value: 0, thumbScale: 1, ringOpacity: 0 };+ const b = { value: 100, thumbScale: 1.1, ringOpacity: 1 };+ const r = tweenSliderStyle(a, b, 0);++ it("value equals a.value at t=0", () => {+ expect(r.value).toBeCloseTo(a.value, 10);+ });+ it("thumbScale equals a.thumbScale at t=0", () => {+ expect(r.thumbScale).toBeCloseTo(a.thumbScale, 10);+ });+ it("ringOpacity equals a.ringOpacity at t=0", () => {+ expect(r.ringOpacity).toBeCloseTo(a.ringOpacity, 10);+ });+});++describe("tweenSliderStyle: t=1 returns values equal to `b`", () => {+ const a = { value: 0, thumbScale: 1, ringOpacity: 0 };+ const b = { value: 100, thumbScale: 1.1, ringOpacity: 1 };+ const r = tweenSliderStyle(a, b, 1);++ it("value equals b.value at t=1", () => {+ expect(r.value).toBeCloseTo(b.value, 10);+ });+ it("thumbScale equals b.thumbScale at t=1", () => {+ expect(r.thumbScale).toBeCloseTo(b.thumbScale, 10);+ });+ it("ringOpacity equals b.ringOpacity at t=1", () => {+ expect(r.ringOpacity).toBeCloseTo(b.ringOpacity, 10);+ });+});++describe("tweenSliderStyle: t=0.5 midpoint", () => {+ // a: value=0, thumbScale=1(idle), ringOpacity=0+ // b: value=100, thumbScale=1.1(hover), ringOpacity=1+ // midpoints: value=50, thumbScale=1.05, ringOpacity=0.5+ const a = { value: 0, thumbScale: 1, ringOpacity: 0 };+ const b = { value: 100, thumbScale: 1.1, ringOpacity: 1 };+ const r = tweenSliderStyle(a, b, 0.5);++ it("value midpoint: 0→100 gives 50", () => {+ expect(r.value).toBeCloseTo(50, 10);+ });+ it("thumbScale midpoint: 1→1.1 gives 1.05", () => {+ expect(r.thumbScale).toBeCloseTo(1.05, 10);+ });+ it("ringOpacity midpoint: 0→1 gives 0.5", () => {+ expect(r.ringOpacity).toBeCloseTo(0.5, 10);+ });+});++describe("tweenSliderStyle: identity (a === b, any t)", () => {+ const s = { value: 62, thumbScale: 1, ringOpacity: 0 };++ it("all fields unchanged when both endpoints are the same", () => {+ const r = tweenSliderStyle(s, s, 0.5);+ expect(r.value).toBeCloseTo(s.value, 10);+ expect(r.thumbScale).toBeCloseTo(s.thumbScale, 10);+ expect(r.ringOpacity).toBeCloseTo(s.ringOpacity, 10);+ });+});++describe("tweenSliderStyle: idle → press thumb channel", () => {+ // idle: thumbScale=1, ringOpacity=0+ // press: thumbScale=1.15, ringOpacity=1+ // t=0.5: thumbScale=1.075, ringOpacity=0.5+ const a = { value: 0, ...sliderThumbStyle("idle") };+ const b = { value: 0, ...sliderThumbStyle("press") };+ const r = tweenSliderStyle(a, b, 0.5);++ it("thumbScale midpoint idle→press: (1+1.15)/2 = 1.075", () => {+ expect(r.thumbScale).toBeCloseTo(1.075, 10);+ });+ it("ringOpacity midpoint idle→press: 0.5", () => {+ expect(r.ringOpacity).toBeCloseTo(0.5, 10);+ });+});++// ===========================================================================+// 7. sliderStyleAt — pure exported dual-channel core+// MIRROR of use-slider-transition.ts lines 148-161.+// useSliderTransition is exactly sliderStyleAt(steps, useCurrentFrame()*speed, opts).+// We call sliderStyleAt directly with the frame injected as `raw`.+//+// The two channels (value + thumb) are folded INDEPENDENTLY from the same+// step list, filtering to value-bearing and thumb-bearing steps respectively.+//+// MAINTENANCE CONTRACT: if use-slider-transition.ts lines 69-161 change,+// update these tests in lockstep. Annotated source lines below.+// ===========================================================================++describe("sliderStyleAt: empty steps → value=0, thumb=idle", () => {+ // source lines 78/112: empty value/thumb steps → return 0 / sliderThumbStyle('idle')+ it("empty steps returns {value:0, thumbScale:1, ringOpacity:0}", () => {+ const r = sliderStyleAt([], 0);+ expect(r.value).toBe(0);+ expect(r.thumbScale).toBe(sliderThumbStyle("idle").thumbScale);+ expect(r.ringOpacity).toBe(sliderThumbStyle("idle").ringOpacity);+ });+});++describe("sliderStyleAt: before first value step — holds at first.value", () => {+ // source line 80: if (raw <= first.at) return first.value+ const steps: SliderStep[] = [{ at: 10, value: 60 }];++ it("raw=5 < first.at=10 → holds at first.value=60", () => {+ expect(sliderStyleAt(steps, 5).value).toBe(60);+ });++ it("raw=10 = first.at → holds at first.value=60 (raw <= first.at)", () => {+ expect(sliderStyleAt(steps, 10).value).toBe(60);+ });+});++describe("sliderStyleAt: before first thumb step — holds at first.thumbState preset", () => {+ // source line 114: if (raw <= first.at) return sliderThumbStyle(first.thumbState)+ const steps: SliderStep[] = [{ at: 10, thumbState: "hover" }];++ it("raw=5 holds at hover preset (thumbScale=1.1)", () => {+ expect(sliderStyleAt(steps, 5).thumbScale).toBeCloseTo(1.1, 10);+ });+});++describe("sliderStyleAt: past last value step — rests at last.value", () => {+ // source lines 89-92: pastLast → to=from=last, t=1+ const steps: SliderStep[] = [{ at: 0, value: 0 }, { at: 18, value: 75 }];++ it("raw=50 → value=75 (rests at last)", () => {+ expect(sliderStyleAt(steps, 50).value).toBeCloseTo(75, 10);+ });+});++describe("sliderStyleAt: value channel mid-window uses easings.out", () => {+ // [{at:0,value:0},{at:18,value:100}], raw=9 → start=0, linear=0.5, t=out(0.5)=0.875+ // value = 0 + 100*0.875 = 87.5+ const steps: SliderStep[] = [{ at: 0, value: 0 }, { at: 18, value: 100 }];++ it("value at raw=9 is 87.5 (out-eased, not linear 50)", () => {+ expect(sliderStyleAt(steps, 9).value).toBeCloseTo(87.5, 8);+ });++ it("value is NOT linear at midpoint (87.5 ≠ 50)", () => {+ const r = sliderStyleAt(steps, 9);+ expect(r.value).not.toBeCloseTo(50, 1);+ });+});++describe("sliderStyleAt: thumb channel mid-window uses easings.out", () => {+ // [{at:0,thumbState:'idle'},{at:18,thumbState:'hover'}], raw=9+ // t=out(0.5)=0.875; idle={1,0}, hover={1.1,1}+ // thumbScale: 1 + 0.1*0.875 = 1.0875, ringOpacity: 0 + 1*0.875 = 0.875+ const steps: SliderStep[] = [{ at: 0, thumbState: "idle" }, { at: 18, thumbState: "hover" }];++ it("thumbScale at raw=9 is 1.0875 (out-eased)", () => {+ expect(sliderStyleAt(steps, 9).thumbScale).toBeCloseTo(1.0875, 8);+ });++ it("ringOpacity at raw=9 is 0.875 (out-eased, not linear 0.5)", () => {+ expect(sliderStyleAt(steps, 9).ringOpacity).toBeCloseTo(0.875, 8);+ });+});++describe("sliderStyleAt: dual-channel steps fold independently", () => {+ // value steps: [{at:0,value:0},{at:18,value:100}]+ // thumb steps: [{at:0,thumbState:'idle'},{at:18,thumbState:'hover'}]+ // Both in same step list via combined steps+ const steps: SliderStep[] = [+ { at: 0, value: 0, thumbState: "idle" },+ { at: 18, value: 100, thumbState: "hover" },+ ];++ it("both channels are active at raw=9", () => {+ const r = sliderStyleAt(steps, 9);+ expect(r.value).toBeCloseTo(87.5, 8);+ expect(r.ringOpacity).toBeCloseTo(0.875, 8);+ });++ it("value channel at raw=18 (past last) → value=100", () => {+ expect(sliderStyleAt(steps, 18).value).toBeCloseTo(100, 10);+ });+});++describe("sliderStyleAt: channels can have different step counts", () => {+ // Only value steps, no thumb steps → thumb stays idle+ const valueOnlySteps: SliderStep[] = [{ at: 0, value: 0 }, { at: 18, value: 100 }];++ it("thumb is idle when no thumb steps are present", () => {+ const r = sliderStyleAt(valueOnlySteps, 9);+ expect(r.thumbScale).toBe(sliderThumbStyle("idle").thumbScale);+ expect(r.ringOpacity).toBe(sliderThumbStyle("idle").ringOpacity);+ });++ // Only thumb steps, no value steps → value stays 0+ const thumbOnlySteps: SliderStep[] = [{ at: 0, thumbState: "idle" }, { at: 18, thumbState: "hover" }];++ it("value is 0 when no value steps are present", () => {+ expect(sliderStyleAt(thumbOnlySteps, 9).value).toBe(0);+ });+});++describe("sliderStyleAt: past last with both channels", () => {+ const steps: SliderStep[] = [{ at: 18, value: 75, thumbState: "press" }];++ it("raw=50 → value=75, thumbScale=press.thumbScale, ringOpacity=press.ringOpacity", () => {+ const r = sliderStyleAt(steps, 50);+ expect(r.value).toBeCloseTo(75, 10);+ expect(r.thumbScale).toBeCloseTo(sliderThumbStyle("press").thumbScale, 10);+ expect(r.ringOpacity).toBeCloseTo(sliderThumbStyle("press").ringOpacity, 10);+ });+});++// ===========================================================================+// 8. sliderConfig.controls — customizer control wiring+// ===========================================================================++describe("sliderConfig.controls: value", () => {+ it("value is a number control", () => {+ expect(sliderConfig.controls.value.type).toBe("number");+ });+ it("value default is 40", () => {+ expect(sliderConfig.controls.value.default).toBe(40);+ });+ it("value min=0, max=100", () => {+ const ctrl = sliderConfig.controls.value;+ if (ctrl.type !== "number") throw new Error("expected number");+ expect(ctrl.min).toBe(0);+ expect(ctrl.max).toBe(100);+ });+});++describe("sliderConfig.controls: thumbState", () => {+ it("thumbState is a select control", () => {+ expect(sliderConfig.controls.thumbState.type).toBe("select");+ });+ it("thumbState options are ['idle', 'hover', 'press']", () => {+ const ctrl = sliderConfig.controls.thumbState;+ if (ctrl.type !== "select") throw new Error("expected select");+ expect(ctrl.options).toEqual(["idle", "hover", "press"]);+ });+ it("thumbState default is 'idle'", () => {+ expect(sliderConfig.controls.thumbState.default).toBe("idle");+ });+ it("every thumbState option is a valid SliderThumbState", () => {+ const ctrl = sliderConfig.controls.thumbState;+ if (ctrl.type !== "select") throw new Error("expected select");+ for (const opt of ctrl.options) {+ expect(VALID_THUMB_STATES).toContain(opt as SliderThumbState);+ }+ });+});++describe("sliderConfig.controls: width", () => {+ it("width is a number control with default=320", () => {+ expect(sliderConfig.controls.width.type).toBe("number");+ expect(sliderConfig.controls.width.default).toBe(320);+ });+});++describe("sliderConfig.controls: showValue", () => {+ it("showValue is a boolean control with default=true", () => {+ expect(sliderConfig.controls.showValue.type).toBe("boolean");+ expect(sliderConfig.controls.showValue.default).toBe(true);+ });+});++describe("sliderConfig.controls: mode", () => {+ it("mode is a select with options ['light','dark'] and default 'light'", () => {+ const ctrl = sliderConfig.controls.mode;+ if (ctrl.type !== "select") throw new Error("expected select");+ expect(ctrl.options).toEqual(["light", "dark"]);+ expect(ctrl.default).toBe("light");+ });+});++// ===========================================================================+// 9. sliderConfig.snippet — pure JSX string builder+// ===========================================================================++describe("sliderConfig.snippet: import line", () => {+ it("includes 'import { Slider }' from the correct path", () => {+ const out = snippet({ value: 40 });+ expect(out).toContain("import { Slider }");+ expect(out).toContain('from "@/components/remocn/slider"');+ });+});++describe("sliderConfig.snippet: structural invariants", () => {+ it("contains a <Slider JSX element", () => {+ expect(snippet({ value: 40 })).toContain("<Slider");+ });+ it("ends with a self-closing />", () => {+ expect(snippet({ value: 40 }).trimEnd().endsWith("/>")).toBe(true);+ });+ it("value prop is always emitted", () => {+ expect(snippet({ value: 40 })).toContain("value={40}");+ expect(snippet({ value: 0 })).toContain("value={0}");+ });+ it("value is emitted as {0} when omitted from values (falls back to 0)", () => {+ expect(snippet({})).toContain("value={0}");+ });+});++describe("sliderConfig.snippet: default props are omitted", () => {+ it("omits thumbState when it equals the default 'idle'", () => {+ const out = snippet({ value: 40, thumbState: "idle" });+ expect(out).not.toContain("thumbState=");+ });+ it("omits width when it equals the default 320", () => {+ const out = snippet({ value: 40, width: 320 });+ expect(out).not.toContain("width=");+ });+ it("omits mode when it equals the default 'light'", () => {+ const out = snippet({ value: 40, mode: "light" });+ expect(out).not.toContain("mode=");+ });+ it("omits showValue when it is false", () => {+ const out = snippet({ value: 40, showValue: false });+ expect(out).not.toContain("showValue");+ });+ it("omits showValue when undefined", () => {+ expect(snippet({ value: 40 })).not.toContain("showValue");+ });+});++describe("sliderConfig.snippet: non-default props are emitted", () => {+ it("emits thumbState='hover' when non-default", () => {+ expect(snippet({ value: 40, thumbState: "hover" })).toContain('thumbState="hover"');+ });+ it("emits thumbState='press' when non-default", () => {+ expect(snippet({ value: 40, thumbState: "press" })).toContain('thumbState="press"');+ });+ it("emits width={480} when non-default", () => {+ expect(snippet({ value: 40, width: 480 })).toContain("width={480}");+ });+ it("emits mode='dark' when non-default", () => {+ expect(snippet({ value: 40, mode: "dark" })).toContain('mode="dark"');+ });+ it("emits showValue (boolean shorthand) when true", () => {+ const out = snippet({ value: 40, showValue: true });+ expect(out).toContain("showValue");+ expect(out).not.toContain("showValue={true}");+ });+});++describe("sliderConfig.snippet: thumbState options round-trip", () => {+ it("emits correct thumbState for every non-default option", () => {+ const ctrl = sliderConfig.controls.thumbState;+ if (ctrl.type !== "select") throw new Error("expected select");+ const nonDefault = ctrl.options.filter((o) => o !== "idle");+ for (const thumbState of nonDefault) {+ expect(snippet({ value: 40, thumbState })).toContain(`thumbState="${thumbState}"`);+ }+ });+});++describe("sliderConfig.snippet: value numeric round-trip", () => {+ it("emits the correct value for various inputs", () => {+ for (const v of [0, 25, 40, 75, 100]) {+ expect(snippet({ value: v })).toContain(`value={${v}}`);+ }+ });+});diff --git a/registry/remocn-ui/slider/config.ts b/registry/remocn-ui/slider/config.tsnew file mode 100644index 00000000..5adcf109--- /dev/null+++ b/registry/remocn-ui/slider/config.ts@@ -0,0 +1,55 @@+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";+import type { SliderThumbState } from "@/registry/remocn-ui/slider";++export const sliderConfig: ComponentConfig = {+ componentName: "Slider",+ importPath: "@/components/remocn/slider",+ controls: {+ value: { type: "number", default: 40, min: 0, max: 100, step: 1, label: "Value" },+ thumbState: {+ type: "select",+ default: "idle",+ options: ["idle", "hover", "press"],+ label: "Thumb State",+ },+ width: {+ type: "number",+ default: 320,+ min: 120,+ max: 640,+ step: 20,+ label: "Width",+ },+ showValue: { type: "boolean", default: true, label: "Show Value" },+ mode: {+ type: "select",+ default: "light",+ options: ["light", "dark"],+ label: "Mode",+ },+ },+ durationInFrames: 120,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ snippet: (values) => {+ const value = values.value as number | undefined;+ const thumbState = values.thumbState as SliderThumbState | undefined;+ const width = values.width as number | undefined;+ const showValue = values.showValue as boolean | undefined;+ const mode = values.mode as string | undefined;++ const props: string[] = [` value={${value ?? 0}}`];+ if (thumbState !== undefined && thumbState !== "idle")+ props.push(` thumbState="${thumbState}"`);+ if (width !== undefined && width !== 320) props.push(` width={${width}}`);+ if (showValue) props.push(` showValue`);+ if (mode !== undefined && mode !== "light") props.push(` mode="${mode}"`);++ return `import { Slider } from "@/components/remocn/slider";++<Slider+${props.join("\n")}+/>`;+ },+};diff --git a/registry/remocn-ui/slider/index.tsx b/registry/remocn-ui/slider/index.tsxnew file mode 100644index 00000000..d0a3cb4f--- /dev/null+++ b/registry/remocn-ui/slider/index.tsx@@ -0,0 +1,235 @@+"use client";++import { clamp01, mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";++export type SliderThumbState = "idle" | "hover" | "press";++// ===========================================================================+// Slider visual — the COMPLETE animated look for a moment in time. This is a+// DUAL-channel atom (value-channel deviation §0): the numeric `value` animates+// as a lerp while the thumb visuals (`thumbScale`, `ringOpacity`) come from a+// `thumbState` preset. Both live in one `SliderStyle`; `useSliderTransition`+// feeds an interpolated one through the `style` prop. The component never reads+// the frame.+// ===========================================================================++export interface SliderStyle {+ /** Fill percentage 0–100 (clamped by the renderer). */+ value: number;+ /** Thumb zoom: 1 idle, grows on hover/press. */+ thumbScale: number;+ /** Grab-ring opacity 0 (idle) → 1 (hover/press). */+ ringOpacity: number;+}++export interface SliderProps {+ /** Fill percentage 0–100 (snap path). Clamped. Ignored when `style` is set. */+ value?: number;+ /** Thumb visual state (snap path). Ignored when `style` is set. */+ thumbState?: SliderThumbState;+ /**+ * Resolved animated visual (smooth path). When provided, takes precedence over+ * `value`/`thumbState` — feed it an interpolated `SliderStyle` from+ * `useSliderTransition`.+ */+ style?: SliderStyle;+ /** Track width in px. */+ width?: number;+ /** Show the current value above the thumb. */+ showValue?: boolean;+ theme?: Partial<RemocnTheme>;+ mode?: "light" | "dark";+ className?: string;+}++/** Track height (px) — shadcn `h-2`. */+const TRACK_HEIGHT = 8;+/** Thumb pill — shadcn `h-4 w-6` (16×24), `rounded-full` → radius = height/2. */+const THUMB_HEIGHT = 16;+const THUMB_WIDTH = 24;+const THUMB_RADIUS = THUMB_HEIGHT / 2;+/** Grab-ring width (px) at full opacity — shadcn `ring-4`. */+const RING_WIDTH = 4;++/** Clamp a 0–100 value to [0,100]. Reuses core clamp01 on the normalized value. */+function clampValue(value: number): number {+ return clamp01(value / 100) * 100;+}++/**+ * The thumb-channel preset for a state — pure `(thumbState) => {thumbScale,+ * ringOpacity}`. Hover and press both grow the thumb and show the grab ring;+ * press grows it a touch more. The `value` channel is independent of this.+ */+export function sliderThumbStyle(thumbState: SliderThumbState): {+ thumbScale: number;+ ringOpacity: number;+} {+ switch (thumbState) {+ case "hover":+ return { thumbScale: 1.1, ringOpacity: 1 };+ case "press":+ return { thumbScale: 1.15, ringOpacity: 1 };+ default:+ return { thumbScale: 1, ringOpacity: 0 };+ }+}++/** Concrete colors for the active theme, resolved once per render. */+export interface SliderStyleContext {+ /** Track rail — shadcn `bg-input/90`. */+ track: string;+ /** Range fill — shadcn `bg-primary`. */+ range: string;+ /** Thumb fill — shadcn white in both themes. */+ thumbBg: string;+ /** Resting 1px ring on the thumb — shadcn `ring-1 ring-black/10`. */+ thumbRing: string;+ /** Grab ring — shadcn `ring-ring/30` (baked to ~30% via a mix toward bg). */+ ring: string;+ /** showValue label color. */+ valueText: string;+}++/**+ * Derive the concrete colors for a theme. Pure. Matches the current shadcn+ * slider: an `input` track, a white thumb, and a `ring`-token grab ring baked to+ * ~30% (a mix toward the background) so it reads as a soft but visible halo in+ * both light and dark.+ */+export function sliderStyleContext(theme: RemocnTheme): SliderStyleContext {+ return {+ // bg-input/90 — nudge the input token 10% toward background for the /90.+ track: mixOklch(theme.input, theme.background, 0.1),+ range: theme.primary,+ // shadcn thumb is white in both themes.+ thumbBg: "oklch(1 0 0)",+ // ring-black/10 resting hairline.+ thumbRing: "rgba(0, 0, 0, 0.1)",+ // ring-ring/30 → ~30% of the ring token: 70% toward background.+ ring: mixOklch(theme.ring, theme.background, 0.7),+ valueText: theme.foreground,+ };+}++/**+ * A deterministic slider. Pure renderer of whatever it receives — it reads no+ * frame, holds no state, runs no effects. Snap (`value` + `thumbState`) and+ * smooth (`style`) share one render path. Placement is the caller's job; the+ * slider renders inline.+ */+export function Slider({+ value = 0,+ thumbState = "idle",+ style,+ width = 320,+ showValue = false,+ theme: themeOverride,+ mode,+ className,+}: SliderProps) {+ const theme = useRemocnTheme(themeOverride, mode);+ const ctx = sliderStyleContext(theme);++ const thumb = sliderThumbStyle(thumbState);+ const v: SliderStyle = style ?? {+ value,+ thumbScale: thumb.thumbScale,+ ringOpacity: thumb.ringOpacity,+ };+ const pct = clampValue(v.value);++ return (+ <div+ className={className}+ style={{+ position: "relative",+ display: "inline-flex",+ alignItems: "center",+ width,+ height: THUMB_HEIGHT,+ fontFamily:+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",+ }}+ >+ {/* Track — muted rail. */}+ <div+ style={{+ position: "relative",+ width: "100%",+ height: TRACK_HEIGHT,+ borderRadius: TRACK_HEIGHT / 2,+ background: ctx.track,+ }}+ >+ {/* Range — primary fill from the left to `value%`. */}+ <div+ style={{+ position: "absolute",+ left: 0,+ top: 0,+ bottom: 0,+ width: `${pct}%`,+ borderRadius: TRACK_HEIGHT / 2,+ background: ctx.range,+ }}+ />+ </div>+ {/* Thumb — positioned at value%, centered via translateX(-50%). The grab+ ring sits behind it, fading in on hover/press. */}+ <div+ style={{+ position: "absolute",+ left: `${pct}%`,+ top: "50%",+ transform: `translate(-50%, -50%) scale(${v.thumbScale})`,+ }}+ >+ {/* Grab ring — a rounded-rect halo hugging the pill, fading in on+ hover/press (shadcn ring-4 ring-ring/30). */}+ <div+ style={{+ position: "absolute",+ left: "50%",+ top: "50%",+ width: THUMB_WIDTH + RING_WIDTH * 2,+ height: THUMB_HEIGHT + RING_WIDTH * 2,+ transform: "translate(-50%, -50%)",+ borderRadius: THUMB_RADIUS + RING_WIDTH,+ background: ctx.ring,+ opacity: v.ringOpacity,+ }}+ />+ {/* Thumb — white 16×24 pill with shadow-md and a resting ring-1+ ring-black/10 hairline (inset box-shadow). */}+ <div+ style={{+ position: "relative",+ width: THUMB_WIDTH,+ height: THUMB_HEIGHT,+ borderRadius: THUMB_RADIUS,+ background: ctx.thumbBg,+ boxShadow: `0 0 0 1px ${ctx.thumbRing}, 0 2px 4px rgba(0,0,0,0.18)`,+ }}+ />+ {showValue && (+ <span+ style={{+ position: "absolute",+ left: "50%",+ bottom: "100%",+ marginBottom: 8,+ transform: "translateX(-50%)",+ fontSize: 12,+ fontWeight: 500,+ fontVariantNumeric: "tabular-nums",+ color: ctx.valueText,+ }}+ >+ {Math.round(pct)}+ </span>+ )}+ </div>+ </div>+ );+}diff --git a/registry/remocn-ui/slider/preview.tsx b/registry/remocn-ui/slider/preview.tsxnew file mode 100644index 00000000..e2171846--- /dev/null+++ b/registry/remocn-ui/slider/preview.tsx@@ -0,0 +1,49 @@+"use client";++import { useRemocnTheme } from "@/lib/remocn-ui";+import { Slider, type SliderThumbState } from "@/registry/remocn-ui/slider";++export interface SliderPreviewProps {+ value?: number;+ thumbState?: SliderThumbState;+ width?: number;+ showValue?: boolean;+ mode?: "light" | "dark";+}++/**+ * Preview-only wrapper for the customizer. The shipped `Slider` is a+ * placement-agnostic inline bar; the customizer Player renders its `component`+ * as the composition root, so this thin wrapper centers it on a theme-background+ * stage just for the preview. NOT shipped: not listed in registry.json files.+ */+export function SliderPreview({+ value = 40,+ thumbState = "idle",+ width = 320,+ showValue = true,+ mode,+}: SliderPreviewProps) {+ const theme = useRemocnTheme(undefined, mode);++ return (+ <div+ style={{+ position: "absolute",+ inset: 0,+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ background: theme.background,+ }}+ >+ <Slider+ value={value}+ thumbState={thumbState}+ width={width}+ showValue={showValue}+ mode={mode}+ />+ </div>+ );+}diff --git a/registry/remocn-ui/slider/use-slider-transition.ts b/registry/remocn-ui/slider/use-slider-transition.tsnew file mode 100644index 00000000..a546313b--- /dev/null+++ b/registry/remocn-ui/slider/use-slider-transition.ts@@ -0,0 +1,161 @@+"use client";++import { useCurrentFrame } from "remotion";+import { clamp01, type EasingName, easings } from "@/lib/remocn-ui";+import {+ sliderThumbStyle,+ type SliderStyle,+ type SliderThumbState,+} from "@/components/remocn/slider";+// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.++/**+ * One scripted slider keyframe. A step may move the `value` channel, the+ * `thumbState` channel, or both. The value eases from the previous value-bearing+ * step to this one; the thumb visual tweens from the previous thumb-bearing+ * step's preset to this one.+ */+export interface SliderStep {+ /** LOCAL (Sequence-relative) authored frame this keyframe is reached. */+ at: number;+ /** Target fill percentage 0–100 (this step moves the value channel). */+ value?: number;+ /** Target thumb state (this step moves the thumb channel). */+ thumbState?: SliderThumbState;+ /** Frames the move INTO this step takes. Omitted → DEFAULT_DURATION. */+ duration?: number;+ /** Override the easing for the move into this step. Default `out`. */+ easing?: EasingName;+}++/** Default frames for a move into a step when it omits `duration`. */+export const DEFAULT_DURATION = 18;++export interface SliderTransitionOptions {+ /** Playhead scale (effectiveFrame = useCurrentFrame() * speed). */+ speed?: number;+ /** Move duration (frames) when a step omits `duration`. */+ defaultDuration?: number;+}++/** Blend two slider visuals: all three fields lerp (value + thumb channels). */+export function tweenSliderStyle(+ a: SliderStyle,+ b: SliderStyle,+ t: number,+): SliderStyle {+ return {+ value: a.value + (b.value - a.value) * t,+ thumbScale: a.thumbScale + (b.thumbScale - a.thumbScale) * t,+ ringOpacity: a.ringOpacity + (b.ringOpacity - a.ringOpacity) * t,+ };+}++/**+ * Resolve the slider's `SliderStyle` for a dual-channel timeline. THIS is the+ * only frame-reading file — `<Slider>` itself stays pure. The fold is a pure+ * function of `raw = useCurrentFrame() * speed`; tests replicate+ * `sliderStyleAt(steps, raw, opts)` with the frame injected.+ */+export function useSliderTransition(+ steps: SliderStep[],+ opts: SliderTransitionOptions = {},+): SliderStyle {+ const { speed = 1 } = opts;+ const raw = useCurrentFrame() * speed;+ return sliderStyleAt(steps, raw, opts);+}++/** Eased value at `raw` over the value-bearing steps (numeric channel). */+function valueAt(+ steps: SliderStep[],+ raw: number,+ defaultDuration: number,+): number {+ const valueSteps = steps.filter(+ (s): s is SliderStep & { value: number } => s.value !== undefined,+ );+ if (valueSteps.length === 0) return 0;+ const first = valueSteps[0];+ if (raw <= first.at) return first.value;++ let toIndex = valueSteps.length - 1;+ for (let i = 1; i < valueSteps.length; i++) {+ if (valueSteps[i].at > raw) {+ toIndex = i;+ break;+ }+ }+ const pastLast = raw >= valueSteps[valueSteps.length - 1].at;+ const to = pastLast ? valueSteps[valueSteps.length - 1] : valueSteps[toIndex];+ const from = pastLast+ ? valueSteps[valueSteps.length - 1]+ : valueSteps[toIndex - 1];++ const dur = to.duration ?? defaultDuration;+ const ease = easings[to.easing ?? "out"];+ const start = to.at - dur;+ const t = pastLast || dur <= 0 ? 1 : ease(clamp01((raw - start) / dur));+ return from.value + (to.value - from.value) * t;+}++/** Eased thumb visual at `raw` over the thumb-bearing steps (state channel). */+function thumbAt(+ steps: SliderStep[],+ raw: number,+ defaultDuration: number,+): { thumbScale: number; ringOpacity: number } {+ const thumbSteps = steps.filter(+ (s): s is SliderStep & { thumbState: SliderThumbState } =>+ s.thumbState !== undefined,+ );+ if (thumbSteps.length === 0) return sliderThumbStyle("idle");+ const first = thumbSteps[0];+ if (raw <= first.at) return sliderThumbStyle(first.thumbState);++ let toIndex = thumbSteps.length - 1;+ for (let i = 1; i < thumbSteps.length; i++) {+ if (thumbSteps[i].at > raw) {+ toIndex = i;+ break;+ }+ }+ const pastLast = raw >= thumbSteps[thumbSteps.length - 1].at;+ const to = pastLast ? thumbSteps[thumbSteps.length - 1] : thumbSteps[toIndex];+ const from = pastLast+ ? thumbSteps[thumbSteps.length - 1]+ : thumbSteps[toIndex - 1];++ const dur = to.duration ?? defaultDuration;+ const ease = easings[to.easing ?? "out"];+ const start = to.at - dur;+ const t = pastLast || dur <= 0 ? 1 : ease(clamp01((raw - start) / dur));++ const a = sliderThumbStyle(from.thumbState);+ const b = sliderThumbStyle(to.thumbState);+ return {+ thumbScale: a.thumbScale + (b.thumbScale - a.thumbScale) * t,+ ringOpacity: a.ringOpacity + (b.ringOpacity - a.ringOpacity) * t,+ };+}++/**+ * Pure core of `useSliderTransition` with the effective frame injected as `raw`.+ * The two channels are folded independently and merged: `value` eases over the+ * value-bearing steps, the thumb visual tweens over the thumb-bearing steps.+ * Kept separate so it can be unit-tested without a Remotion render.+ */+export function sliderStyleAt(+ steps: SliderStep[],+ raw: number,+ opts: SliderTransitionOptions = {},+): SliderStyle {+ const { defaultDuration = DEFAULT_DURATION } = opts;+ const value = valueAt(steps, raw, defaultDuration);+ const thumb = thumbAt(steps, raw, defaultDuration);+ return {+ value,+ thumbScale: thumb.thumbScale,+ ringOpacity: thumb.ringOpacity,+ };+}