Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

feat: added resize component

dev_wandry98eae6afa5da
diff --git a/components/docs/examples/index.tsx b/components/docs/examples/index.tsx
index 4466bfef..9cbe1c8c 100644
--- a/components/docs/examples/index.tsx
+++ b/components/docs/examples/index.tsx
@@ -64,6 +64,10 @@ import {
StepperExampleScene,
stepperExampleCode,
} from "./stepper-example";
+import {
+ ResizableExampleScene,
+ resizableExampleCode,
+} from "./resizable-example";
export interface ExampleEntry {
Component: ComponentType;
@@ -297,4 +301,13 @@ export const examples: Record<string, ExampleEntry> = {
width: W,
height: H,
},
+ "resizable-example": {
+ Component: ResizableExampleScene,
+ code: resizableExampleCode,
+ // Sweep right→left→center ends at 176; handle idle at 184+8=192; settle then loop.
+ durationInFrames: 205,
+ fps: FPS,
+ width: W,
+ height: H,
+ },
};
diff --git a/components/docs/examples/resizable-example.tsx b/components/docs/examples/resizable-example.tsx
new file mode 100644
index 00000000..af370c76
--- /dev/null
+++ b/components/docs/examples/resizable-example.tsx
@@ -0,0 +1,83 @@
+"use client";
+
+import { Cursor } from "@/registry/remocn-ui/cursor";
+import { useCursorPath } from "@/registry/remocn-ui/cursor/use-cursor-path";
+import { Resizable } from "@/registry/remocn-ui/resizable";
+import { useResizableTransition } from "@/registry/remocn-ui/resizable/use-resizable-transition";
+
+const X_CENTER = 640;
+const X_RIGHT = 750;
+const X_LEFT = 530;
+const HANDLE_Y = 360;
+
+export const ResizableExampleScene = () => {
+ const cursorStyle = useCursorPath([
+ { at: 0, x: 80, y: 60 },
+ { at: 32, x: X_CENTER, y: HANDLE_Y, duration: 28 },
+ { at: 44, x: X_CENTER, y: HANDLE_Y, press: true, duration: 0 },
+ { at: 84, x: X_RIGHT, y: HANDLE_Y, press: true, duration: 40 },
+ { at: 132, x: X_LEFT, y: HANDLE_Y, press: true, duration: 48 },
+ { at: 176, x: X_CENTER, y: HANDLE_Y, press: true, duration: 44 },
+ { at: 184, x: X_CENTER, y: HANDLE_Y, duration: 0 },
+ ]);
+
+ const resizableStyle = useResizableTransition([
+ { at: 0, ratio: 0.5, handleState: "idle" },
+ { at: 32, handleState: "hover", duration: 8 },
+ { at: 46, handleState: "press", duration: 4 },
+ { at: 44, ratio: 0.5 },
+ { at: 84, ratio: 0.75, duration: 40, easing: "inOut" },
+ { at: 132, ratio: 0.25, duration: 48, easing: "inOut" },
+ { at: 176, ratio: 0.5, duration: 44, easing: "inOut" },
+ { at: 184, handleState: "idle", duration: 8 },
+ ]);
+
+ return (
+ <div style={{ position: "relative", width: "100%", height: "100%" }}>
+ <Resizable style={resizableStyle} />
+ <Cursor style={cursorStyle} variant="pointer" />
+ </div>
+ );
+};
+
+export const resizableExampleCode = `import { Cursor } from "@/components/remocn/cursor";
+import { useCursorPath } from "@/components/remocn/use-cursor-path";
+import { Resizable } from "@/components/remocn/resizable";
+import { useResizableTransition } from "@/components/remocn/use-resizable-transition";
+
+const X_CENTER = 640;
+const X_RIGHT = 750;
+const X_LEFT = 530;
+const HANDLE_Y = 360;
+
+export const Scene = () => {
+
+ const cursorStyle = useCursorPath([
+ { at: 0, x: 80, y: 60 },
+ { at: 32, x: X_CENTER, y: HANDLE_Y, duration: 28 },
+ { at: 44, x: X_CENTER, y: HANDLE_Y, press: true, duration: 0 },
+ { at: 84, x: X_RIGHT, y: HANDLE_Y, press: true, duration: 40 },
+ { at: 132, x: X_LEFT, y: HANDLE_Y, press: true, duration: 48 },
+ { at: 176, x: X_CENTER, y: HANDLE_Y, press: true, duration: 44 },
+ { at: 184, x: X_CENTER, y: HANDLE_Y, duration: 0 },
+ ]);
+
+
+ const resizableStyle = useResizableTransition([
+ { at: 0, ratio: 0.5, handleState: "idle" },
+ { at: 32, handleState: "hover", duration: 8 },
+ { at: 46, handleState: "press", duration: 4 },
+ { at: 44, ratio: 0.5 },
+ { at: 84, ratio: 0.75, duration: 40, easing: "inOut" },
+ { at: 132, ratio: 0.25, duration: 48, easing: "inOut" },
+ { at: 176, ratio: 0.5, duration: 44, easing: "inOut" },
+ { at: 184, handleState: "idle", duration: 8 },
+ ]);
+
+ return (
+ <div style={{ position: "relative", width: "100%", height: "100%" }}>
+ <Resizable style={resizableStyle} />
+ <Cursor style={cursorStyle} variant="pointer" />
+ </div>
+ );
+};`;
diff --git a/content/docs/ui/components/meta.json b/content/docs/ui/components/meta.json
index ba02ce45..9c878de8 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", "combobox", "command-menu", "context-menu", "cursor", "dialog", "drawer", "sheet", "dropdown-menu", "input", "popover", "progress", "radio", "select", "skeleton", "slider", "spinner", "stepper", "switch", "tabs", "toast", "toggle-group", "tooltip"]
+ "pages": ["accordion", "alert-dialog", "button", "checkbox", "combobox", "command-menu", "context-menu", "cursor", "dialog", "drawer", "sheet", "dropdown-menu", "input", "popover", "progress", "radio", "resizable", "select", "skeleton", "slider", "spinner", "stepper", "switch", "tabs", "toast", "toggle-group", "tooltip"]
}
diff --git a/content/docs/ui/components/resizable.mdx b/content/docs/ui/components/resizable.mdx
new file mode 100644
index 00000000..078efbb7
--- /dev/null
+++ b/content/docs/ui/components/resizable.mdx
@@ -0,0 +1,230 @@
+---
+title: Resizable
+description: A two-panel split container whose divider ratio and handle state are driven by a scripted dual-channel timeline
+---
+
+<ComponentPreview name="resizable" />
+
+A dual-channel value atom whose panel split ratio (`0`–`1`) and handle 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: `useResizableTransition` drives a numeric ratio channel and a handle-state channel independently through one `ResizableStyle`, so cursor-synced drag scenes compose naturally — the same pattern as the Slider primitive.
+
+## Installation
+
+<InstallBlock name="resizable" />
+
+<Note>
+Installing `resizable` automatically installs the shared `remocn-ui` core (`lib/remocn-ui/`) via `registryDependencies` (`["remocn-ui"]`). You do not need to install it separately. Both `resizable` (the renderer) and `use-resizable-transition` (the hook) are copied into your project.
+</Note>
+
+## Example
+
+<LiveExample name="resizable-example" />
+
+## Ratio & handle
+
+`useResizableTransition` takes an array of `ResizableStep` objects. Each step can advance the **ratio channel**, the **handle channel**, or both in the same keyframe:
+
+```ts
+interface ResizableStep {
+ at: number; // LOCAL (Sequence-relative) authored frame this keyframe is reached
+ ratio?: number; // Target first-panel fraction 0–1 (moves the ratio channel)
+ handleState?: ResizableHandleState; // Target handle visual (moves the handle channel)
+ duration?: number; // Frames the move INTO this step takes. Omitted → DEFAULT_DURATION (18)
+ easing?: EasingName; // Override easing. Default "out"
+}
+```
+
+`ResizableHandleState` presets:
+
+```ts
+type ResizableHandleState =
+ | "idle" // handleScale 1, handleRingOpacity 0 — resting
+ | "hover" // handleScale 1.15, handleRingOpacity 1 — pointer over handle
+ | "press" // handleScale 1.25, handleRingOpacity 1 — handle held down
+```
+
+### Dual-channel deviation
+
+`Resizable` extends the value-channel pattern (like `Progress`) with a second channel: the handle visual. The two channels are folded independently — ratio-bearing steps only affect the split; handle-bearing steps only affect the grip scale and grab ring. A single step may carry both fields to advance both channels at the same frame.
+
+### Min/max clamp
+
+The ratio is clamped to `[minRatio, maxRatio]` (defaults: `0.15`–`0.85`) inside the renderer. Steps may specify values outside this range — the clamp applies at render time, not in the hook.
+
+## Snap usage
+
+Pass `ratio` and `handleState` directly — the component snaps instantly to that visual. Useful for static previews:
+
+```tsx
+import { Resizable } from "@/components/remocn/resizable";
+
+export const Scene = () => (
+ <div style={{ position: "relative", width: "100%", height: "100%" }}>
+ <Resizable ratio={0.65} handleState="hover" />
+ </div>
+);
+```
+
+## Smooth transitions
+
+Ratio and handle changes via the snap props are instant. For an animated drag interaction, use `useResizableTransition` from the copied `use-resizable-transition.ts` file. It reads the frame, folds the two channels independently, and returns a resolved `ResizableStyle` — pass it to the `style` prop:
+
+```tsx
+import { Resizable } from "@/components/remocn/resizable";
+import { useResizableTransition } from "@/components/remocn/use-resizable-transition";
+
+export const Scene = () => {
+ const style = useResizableTransition([
+ { at: 0, ratio: 0.5, handleState: "idle" },
+ { at: 32, handleState: "hover", duration: 8 },
+ { at: 46, handleState: "press", duration: 4 },
+ { at: 44, ratio: 0.5 },
+ { at: 100, ratio: 0.7, duration: 56 },
+ { at: 108, handleState: "idle", duration: 8 },
+ ]);
+
+ return (
+ <div style={{ position: "relative", width: "100%", height: "100%" }}>
+ <Resizable style={style} />
+ </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-resizable-transition.ts` directly in your project — that file is yours (shadcn "own your code" philosophy).
+
+`style` takes precedence over `ratio` and `handleState` when provided.
+
+### Frame-syncing with Cursor
+
+To animate a cursor dragging the divider, keep the cursor's `x` position and the ratio step on the **same frame budget with the same easing**. `useCursorPath` uses `inOut` easing by default — set `easing: "inOut"` on the ratio drag step so the divider tracks the cursor exactly:
+
+```tsx
+import { Cursor } from "@/components/remocn/cursor";
+import { useCursorPath } from "@/components/remocn/use-cursor-path";
+import { Resizable } from "@/components/remocn/resizable";
+import { useResizableTransition } from "@/components/remocn/use-resizable-transition";
+
+// Widget default: 440×240px, centered on a 1280×720 canvas.
+// Divider at ratio 0.50 → canvas x = 420 + 440 × 0.50 = 640.
+// Divider at ratio 0.70 → canvas x = 420 + 440 × 0.70 = 728.
+const HANDLE_START_X = 640;
+const HANDLE_END_X = 728;
+const HANDLE_Y = 360;
+
+export const Scene = () => {
+ const cursorStyle = useCursorPath([
+ { at: 0, x: 80, y: 60 },
+ { at: 32, x: HANDLE_START_X, y: HANDLE_Y, duration: 28 },
+ { at: 44, x: HANDLE_START_X, y: HANDLE_Y, press: true, duration: 0 },
+ { at: 100, x: HANDLE_END_X, y: HANDLE_Y, press: true, duration: 56 },
+ { at: 108, x: HANDLE_END_X, y: HANDLE_Y, duration: 0 },
+ ]);
+
+ const resizableStyle = useResizableTransition([
+ { at: 0, ratio: 0.5, handleState: "idle" },
+ { at: 32, handleState: "hover", duration: 8 },
+ { at: 46, handleState: "press", duration: 4 },
+ { at: 44, ratio: 0.5 },
+ // easing inOut matches the cursor's default travel easing.
+ { at: 100, ratio: 0.7, duration: 56, easing: "inOut" },
+ { at: 108, handleState: "idle", duration: 8 },
+ ]);
+
+ return (
+ <div style={{ position: "relative", width: "100%", height: "100%" }}>
+ <Resizable style={resizableStyle} />
+ <Cursor style={cursorStyle} variant="pointer" />
+ </div>
+ );
+};
+```
+
+The cursor's drag frames (`at: 44` → `at: 100`, duration 56) match the ratio-channel move exactly. The handle-state transitions (`hover` at 32, `press` at 46, `idle` at 108) are independent — they run on their own mini-durations without disturbing the ratio easing.
+
+## Direction
+
+Both `"horizontal"` (default) and `"vertical"` are implemented. Horizontal splits the container width between panels; vertical splits the height. The grip pill rotates automatically — vertical for a horizontal split, horizontal for a vertical split.
+
+```tsx
+<Resizable style={style} direction="vertical" />
+```
+
+## Props
+
+<PropsTable
+ rows={[
+ {
+ name: "first",
+ type: "ReactNode",
+ description: "First panel content. Defaults to a muted placeholder card labeled \"Panel one\".",
+ },
+ {
+ name: "second",
+ type: "ReactNode",
+ description: "Second panel content. Defaults to a muted placeholder card labeled \"Panel two\".",
+ },
+ {
+ name: "direction",
+ type: "\"horizontal\" | \"vertical\"",
+ default: "\"horizontal\"",
+ description: "Split axis. Horizontal divides width; vertical divides height.",
+ },
+ {
+ name: "ratio",
+ type: "number",
+ default: "0.5",
+ description: "First-panel fraction 0–1 (snap path). Clamped to [minRatio, maxRatio]. Ignored when style is provided.",
+ },
+ {
+ name: "handleState",
+ type: "\"idle\" | \"hover\" | \"press\"",
+ default: "\"idle\"",
+ description: "Handle visual state (snap path). Sets handleScale and handleRingOpacity from the preset. Ignored when style is provided.",
+ },
+ {
+ name: "style",
+ type: "ResizableStyle",
+ description: "Resolved animated visual (smooth path). Pass an interpolated ResizableStyle from useResizableTransition. Takes precedence over ratio and handleState when provided.",
+ },
+ {
+ name: "minRatio",
+ type: "number",
+ default: "0.15",
+ description: "Minimum first-panel fraction. The renderer clamps ratio to this floor.",
+ },
+ {
+ name: "maxRatio",
+ type: "number",
+ default: "0.85",
+ description: "Maximum first-panel fraction. The renderer clamps ratio to this ceiling.",
+ },
+ {
+ name: "width",
+ type: "number",
+ default: "440",
+ description: "Container width in px.",
+ },
+ {
+ name: "height",
+ type: "number",
+ default: "240",
+ description: "Container height in px.",
+ },
+ {
+ 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__.tsx
index aa0763ac..520969ca 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -165,6 +165,8 @@ import { ToggleGroup } from "@/registry/remocn-ui/toggle-group";
import { toggleGroupConfig } from "@/registry/remocn-ui/toggle-group/config";
import { StepperPreview } from "@/registry/remocn-ui/stepper/preview";
import { stepperConfig } from "@/registry/remocn-ui/stepper/config";
+import { Resizable } from "@/registry/remocn-ui/resizable";
+import { resizableConfig } from "@/registry/remocn-ui/resizable/config";
import { ZoomThroughTransition } from "@/registry/remocn/zoom-through-transition";
import { zoomThroughTransitionConfig } from "@/registry/remocn/zoom-through-transition/config";
@@ -403,6 +405,9 @@ const registry: Record<string, RegistryEntry> = {
// stepper's customizer Component is the preview-only StepperPreview wrapper: a
// bare wide horizontal element would sit top-left, so the wrapper centers it.
"stepper": { Component: StepperPreview, config: stepperConfig },
+ // resizable registers RAW (no preview wrapper): its index.tsx already paints
+ // an opaque inset:0 stage that centers the fixed-size bordered box, like tabs.
+ "resizable": { Component: Resizable, config: resizableConfig },
"spinner": { Component: Spinner, config: spinnerConfig },
};
diff --git a/registry/remocn-ui/registry.json b/registry/remocn-ui/registry.json
index 0b287915..ea775826 100644
--- a/registry/remocn-ui/registry.json
+++ b/registry/remocn-ui/registry.json
@@ -631,6 +631,26 @@
"target": "components/remocn/use-stepper-transition.ts"
}
]
+ },
+ {
+ "name": "resizable",
+ "type": "registry:component",
+ "title": "UI Resizable",
+ "description": "Two panels split by a draggable handle, where the split ratio is a numeric channel plus a handle idle/hover/press channel (dual-channel value-channel deviation). The Resizable renderer is pure (clamped 0–1 ratio, handle scale, grab-ring opacity); useResizableTransition reads the frame and eases both channels — ratio as a numeric lerp, the handle visual from its state presets. Horizontal and vertical splits; 1px divider + centered grip pill with a derived grab ring.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["remocn-ui"],
+ "files": [
+ {
+ "path": "resizable/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/resizable.tsx"
+ },
+ {
+ "path": "resizable/use-resizable-transition.ts",
+ "type": "registry:component",
+ "target": "components/remocn/use-resizable-transition.ts"
+ }
+ ]
}
]
}
diff --git a/registry/remocn-ui/resizable/__tests__/README.md b/registry/remocn-ui/resizable/__tests__/README.md
new file mode 100644
index 00000000..2188b59f
--- /dev/null
+++ b/registry/remocn-ui/resizable/__tests__/README.md
@@ -0,0 +1,74 @@
+# resizable — test suite
+
+`bun test registry/remocn-ui/resizable/__tests__`
+
+## What is tested
+
+Pure, deterministic functions only. Remotion hooks (`useCurrentFrame`, `useRemocnTheme`) are never imported.
+
+| Section | Subject | Source |
+|---------|---------|--------|
+| 1 | `DEFAULT_DURATION` = 18 | `use-resizable-transition.ts` |
+| 2 | `resizableHandleStyle(handleState)` presets | `index.tsx:75-87` |
+| 3 | `clampRatio(ratio, minRatio, maxRatio)` mirror | `index.tsx:66-68` |
+| 4 | `resizableStyleContext(theme)` token mapping | `index.tsx:106-116` |
+| 5 | `resizableStyle(ratio, handleState)` snap composer | `index.tsx:123-133` |
+| 6 | `tweenResizableStyle(a, b, t)` lerp | `use-resizable-transition.ts:42-53` |
+| 7 | `resizableStyleAt(steps, raw, opts)` dual-channel core | `use-resizable-transition.ts:152-165` |
+| 8 | `resizableConfig.controls` wiring | `config.ts` |
+| 9 | `resizableConfig.snippet` codegen | `config.ts` |
+
+## Animation model
+
+Resizable is a **dual-channel** atom (identical pattern to `slider`). Both channels live in a single `ResizableStyle`:
+
+| Field | Channel | Default when empty |
+|-------|---------|--------------------|
+| `ratio` | numeric, lerps from step to step | `0.5` |
+| `handleScale` | handle-visual, from `resizableHandleStyle` preset | idle = `1` |
+| `handleRingOpacity` | handle-visual, from `resizableHandleStyle` preset | idle = `0` |
+
+### Channel fold (per-channel, independent)
+
+```
+ratioSteps = steps.filter(s => s.ratio !== undefined)
+handleSteps = steps.filter(s => s.handleState !== undefined)
+```
+
+Each channel is resolved independently and merged into one `ResizableStyle`.
+
+### Easing
+
+All transitions use `easings.out` (cubic ease-out) by default:
+
+```
+out(t) = 1 - (1 - t)^3
+out(0.5) = 0.875
+```
+
+Key numeric used in mid-window tests:
+
+| Setup | raw | Window | linear t | out(t) | Expected ratio |
+|-------|-----|--------|----------|--------|----------------|
+| `[{at:0,ratio:0.3},{at:18,ratio:0.7}]` | 9 | `[0..18]` | 0.5 | 0.875 | `0.3 + 0.4*0.875 = 0.65` |
+
+### Handle presets
+
+| state | `handleScale` | `handleRingOpacity` |
+|-------|--------------|---------------------|
+| `idle` | 1 | 0 |
+| `hover` | 1.15 | 1 |
+| `press` | 1.25 | 1 |
+
+## Determinism grep checklist
+
+Before `bun test`, confirm these are true in the source:
+
+- `use-resizable-transition.ts` — `export const DEFAULT_DURATION = 18`
+- `index.tsx` — `resizableHandleStyle("hover")` returns `{ handleScale: 1.15, handleRingOpacity: 1 }`
+- `index.tsx` — `resizableHandleStyle("press")` returns `{ handleScale: 1.25, handleRingOpacity: 1 }`
+- `index.tsx` — `resizableHandleStyle("idle")` returns `{ handleScale: 1, handleRingOpacity: 0 }`
+- `index.tsx` — `resizableStyleContext` maps `containerBg=background`, `panelBg=muted`, `grip=border`, `placeholderFg=mutedForeground`
+- `use-resizable-transition.ts` — empty ratio steps → `return 0.5`; empty handle steps → `return resizableHandleStyle("idle")`
+- `config.ts` — `ratio` control `default=0.5`, `handleState` control `default='idle'`, `direction` control `default='horizontal'`
+- `config.ts` — snippet omits `handleState` when `"idle"`, omits `direction` when `"horizontal"`, omits `mode` when `"light"`
diff --git a/registry/remocn-ui/resizable/__tests__/resizable.test.ts b/registry/remocn-ui/resizable/__tests__/resizable.test.ts
new file mode 100644
index 00000000..2510dd40
--- /dev/null
+++ b/registry/remocn-ui/resizable/__tests__/resizable.test.ts
@@ -0,0 +1,814 @@
+/**
+ * Verification tests for the PURE / DETERMINISTIC parts of `resizable`.
+ *
+ * Scope:
+ * - registry/remocn-ui/resizable/index.tsx
+ * resizableHandleStyle(handleState) — pure handle-channel preset map
+ * resizableStyleContext(theme) — pure theme → color derivation
+ * resizableStyle(ratio, handleState) — pure snap-path composer
+ * - registry/remocn-ui/resizable/use-resizable-transition.ts
+ * tweenResizableStyle(a, b, t) — pure lerp across all three fields
+ * resizableStyleAt(steps, raw, opts) — pure exported dual-channel core
+ * DEFAULT_DURATION constant
+ * - registry/remocn-ui/resizable/config.ts
+ * resizableConfig.controls wiring + resizableConfig.snippet codegen
+ *
+ * The render path (index.tsx) imports `useRemocnTheme` which requires React
+ * context — it is NOT exercised here. `useResizableTransition` IS a hook (calls
+ * `useCurrentFrame()`) and is NOT imported; its pure body is the exported
+ * `resizableStyleAt` which we call directly.
+ *
+ * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
+ * bun test registry/remocn-ui/resizable/__tests__
+ *
+ * --------------------------------------------------------------------------
+ * IMPORT STRATEGY
+ * --------------------------------------------------------------------------
+ * Relative imports from component source; `@/lib/remocn-ui` alias for core.
+ * `resizableHandleStyle`, `resizableStyleContext`, `resizableStyle` are pure
+ * value functions. `useResizableTransition` IS a hook and is NOT imported;
+ * we call `resizableStyleAt` directly (the exported pure core).
+ * --------------------------------------------------------------------------
+ */
+
+import { describe, expect, it } from "bun:test";
+import {
+ resizableHandleStyle,
+ resizableStyleContext,
+ resizableStyle,
+ type ResizableHandleState,
+} from "../index";
+import {
+ tweenResizableStyle,
+ resizableStyleAt,
+ DEFAULT_DURATION,
+ type ResizableStep,
+} from "../use-resizable-transition";
+import { resizableConfig } from "../config";
+import { defaultLightTheme, defaultDarkTheme } from "@/lib/remocn-ui";
+
+// ===========================================================================
+// Shared fixtures
+// ===========================================================================
+
+const VALID_HANDLE_STATES: readonly ResizableHandleState[] = [
+ "idle",
+ "hover",
+ "press",
+];
+
+/** Convenience wrapper for snippet(). */
+type SnippetValues = {
+ ratio?: number;
+ handleState?: string;
+ direction?: string;
+ mode?: string;
+};
+const snippet = (values: SnippetValues): string =>
+ resizableConfig.snippet(values as Record<string, unknown>);
+
+// ===========================================================================
+// 1. DEFAULT_DURATION constant
+// ===========================================================================
+
+describe("DEFAULT_DURATION", () => {
+ it("is 18 frames", () => {
+ expect(DEFAULT_DURATION).toBe(18);
+ });
+});
+
+// ===========================================================================
+// 2. resizableHandleStyle — pure (handleState) => {handleScale, handleRingOpacity}
+// MIRROR of index.tsx lines 75-87
+// ===========================================================================
+
+describe("resizableHandleStyle: idle state — resting handle", () => {
+ const s = resizableHandleStyle("idle");
+
+ it("handleScale is 1 (no zoom)", () => {
+ expect(s.handleScale).toBe(1);
+ });
+
+ it("handleRingOpacity is 0 (ring hidden)", () => {
+ expect(s.handleRingOpacity).toBe(0);
+ });
+});
+
+describe("resizableHandleStyle: hover state — grown handle + visible ring", () => {
+ const s = resizableHandleStyle("hover");
+
+ it("handleScale is 1.15", () => {
+ expect(s.handleScale).toBeCloseTo(1.15, 10);
+ });
+
+ it("handleRingOpacity is 1 (ring fully visible)", () => {
+ expect(s.handleRingOpacity).toBe(1);
+ });
+});
+
+describe("resizableHandleStyle: press state — larger handle + visible ring", () => {
+ const s = resizableHandleStyle("press");
+
+ it("handleScale is 1.25 (larger than hover)", () => {
+ expect(s.handleScale).toBeCloseTo(1.25, 10);
+ });
+
+ it("handleRingOpacity is 1 (ring fully visible)", () => {
+ expect(s.handleRingOpacity).toBe(1);
+ });
+});
+
+describe("resizableHandleStyle: press > hover > idle handleScale ordering", () => {
+ it("press handleScale > hover handleScale > idle handleScale", () => {
+ expect(resizableHandleStyle("press").handleScale).toBeGreaterThan(
+ resizableHandleStyle("hover").handleScale,
+ );
+ expect(resizableHandleStyle("hover").handleScale).toBeGreaterThan(
+ resizableHandleStyle("idle").handleScale,
+ );
+ });
+});
+
+describe("resizableHandleStyle: hover and press have identical handleRingOpacity", () => {
+ it("hover.handleRingOpacity === press.handleRingOpacity === 1", () => {
+ expect(resizableHandleStyle("hover").handleRingOpacity).toBe(1);
+ expect(resizableHandleStyle("press").handleRingOpacity).toBe(1);
+ });
+});
+
+describe("resizableHandleStyle: every state returns numeric fields", () => {
+ it("every handleState produces numeric handleScale and handleRingOpacity", () => {
+ for (const state of VALID_HANDLE_STATES) {
+ const s = resizableHandleStyle(state);
+ expect(typeof s.handleScale).toBe("number");
+ expect(typeof s.handleRingOpacity).toBe("number");
+ }
+ });
+});
+
+// ===========================================================================
+// 3. clampRatio — the renderer clamps ratio to [minRatio, maxRatio]
+// MIRROR of index.tsx lines 66-68 (clampRatio function)
+//
+// Default minRatio=0.15, maxRatio=0.85 from ResizableProps.
+// The function is unexported but its semantics are contractual.
+// ===========================================================================
+
+/** MIRROR of index.tsx:clampRatio */
+function clampRatio(
+ ratio: number,
+ minRatio: number,
+ maxRatio: number,
+): number {
+ return Math.min(maxRatio, Math.max(minRatio, ratio));
+}
+
+describe("clampRatio: below-range values clamp to minRatio", () => {
+ it("ratio=0.1 clamps to minRatio=0.15", () => {
+ expect(clampRatio(0.1, 0.15, 0.85)).toBeCloseTo(0.15, 10);
+ });
+
+ it("ratio=0 clamps to minRatio=0.15", () => {
+ expect(clampRatio(0, 0.15, 0.85)).toBeCloseTo(0.15, 10);
+ });
+
+ it("ratio=-0.5 clamps to minRatio=0.15", () => {
+ expect(clampRatio(-0.5, 0.15, 0.85)).toBeCloseTo(0.15, 10);
+ });
+});
+
+describe("clampRatio: above-range values clamp to maxRatio", () => {
+ it("ratio=0.9 clamps to maxRatio=0.85", () => {
+ expect(clampRatio(0.9, 0.15, 0.85)).toBeCloseTo(0.85, 10);
+ });
+
+ it("ratio=1 clamps to maxRatio=0.85", () => {
+ expect(clampRatio(1, 0.15, 0.85)).toBeCloseTo(0.85, 10);
+ });
+
+ it("ratio=1.5 clamps to maxRatio=0.85", () => {
+ expect(clampRatio(1.5, 0.15, 0.85)).toBeCloseTo(0.85, 10);
+ });
+});
+
+describe("clampRatio: boundary values are inclusive", () => {
+ it("ratio=0.15 (exactly minRatio) passes through unchanged", () => {
+ expect(clampRatio(0.15, 0.15, 0.85)).toBeCloseTo(0.15, 10);
+ });
+
+ it("ratio=0.85 (exactly maxRatio) passes through unchanged", () => {
+ expect(clampRatio(0.85, 0.15, 0.85)).toBeCloseTo(0.85, 10);
+ });
+});
+
+describe("clampRatio: in-range values pass through unchanged", () => {
+ it("ratio=0.5 returns 0.5", () => {
+ expect(clampRatio(0.5, 0.15, 0.85)).toBeCloseTo(0.5, 10);
+ });
+
+ it("ratio=0.3 returns 0.3", () => {
+ expect(clampRatio(0.3, 0.15, 0.85)).toBeCloseTo(0.3, 10);
+ });
+
+ it("ratio=0.75 returns 0.75", () => {
+ expect(clampRatio(0.75, 0.15, 0.85)).toBeCloseTo(0.75, 10);
+ });
+});
+
+// ===========================================================================
+// 4. resizableStyleContext — pure theme → ResizableStyleContext
+// MIRROR of index.tsx lines 106-116
+// ===========================================================================
+
+describe("resizableStyleContext: light theme — token mapping", () => {
+ const ctx = resizableStyleContext(defaultLightTheme);
+
+ it("containerBg equals theme.background", () => {
+ expect(ctx.containerBg).toBe(defaultLightTheme.background);
+ });
+
+ it("border equals theme.border", () => {
+ expect(ctx.border).toBe(defaultLightTheme.border);
+ });
+
+ it("panelBg equals theme.muted", () => {
+ expect(ctx.panelBg).toBe(defaultLightTheme.muted);
+ });
+
+ it("grip equals theme.border", () => {
+ expect(ctx.grip).toBe(defaultLightTheme.border);
+ });
+
+ it("ring is a non-empty string (mixOklch blend of theme.ring + background)", () => {
+ expect(typeof ctx.ring).toBe("string");
+ expect(ctx.ring.length).toBeGreaterThan(0);
+ });
+
+ it("placeholderFg equals theme.mutedForeground", () => {
+ expect(ctx.placeholderFg).toBe(defaultLightTheme.mutedForeground);
+ });
+
+ it("radius equals theme.radius", () => {
+ expect(ctx.radius).toBe(defaultLightTheme.radius);
+ });
+});
+
+describe("resizableStyleContext: dark theme differs from light on theme-derived fields", () => {
+ const ctxLight = resizableStyleContext(defaultLightTheme);
+ const ctxDark = resizableStyleContext(defaultDarkTheme);
+
+ it("ring color differs between light and dark (uses theme.ring token)", () => {
+ expect(ctxLight.ring).not.toBe(ctxDark.ring);
+ });
+
+ it("containerBg differs between light and dark (uses theme.background)", () => {
+ expect(ctxLight.containerBg).not.toBe(ctxDark.containerBg);
+ });
+});
+
+describe("resizableStyleContext: all fields are present and correctly typed", () => {
+ it("every ResizableStyleContext field is a non-empty string or number for light theme", () => {
+ const ctx = resizableStyleContext(defaultLightTheme);
+ for (const key of [
+ "containerBg",
+ "border",
+ "panelBg",
+ "grip",
+ "ring",
+ "placeholderFg",
+ ] as const) {
+ expect(typeof ctx[key]).toBe("string");
+ expect(ctx[key].length).toBeGreaterThan(0);
+ }
+ expect(typeof ctx.radius).toBe("number");
+ });
+});
+
+// ===========================================================================
+// 5. resizableStyle — pure (ratio, handleState) => ResizableStyle
+// MIRROR of index.tsx lines 123-133
+// ===========================================================================
+
+describe("resizableStyle: idle handle preset", () => {
+ const s = resizableStyle(0.5, "idle");
+ const preset = resizableHandleStyle("idle");
+
+ it("ratio equals the input ratio", () => {
+ expect(s.ratio).toBeCloseTo(0.5, 10);
+ });
+
+ it("handleScale matches idle preset", () => {
+ expect(s.handleScale).toBeCloseTo(preset.handleScale, 10);
+ });
+
+ it("handleRingOpacity matches idle preset (0)", () => {
+ expect(s.handleRingOpacity).toBeCloseTo(preset.handleRingOpacity, 10);
+ });
+});
+
+describe("resizableStyle: hover handle preset", () => {
+ const s = resizableStyle(0.3, "hover");
+ const preset = resizableHandleStyle("hover");
+
+ it("ratio equals the input ratio", () => {
+ expect(s.ratio).toBeCloseTo(0.3, 10);
+ });
+
+ it("handleScale matches hover preset (1.15)", () => {
+ expect(s.handleScale).toBeCloseTo(preset.handleScale, 10);
+ });
+
+ it("handleRingOpacity matches hover preset (1)", () => {
+ expect(s.handleRingOpacity).toBeCloseTo(preset.handleRingOpacity, 10);
+ });
+});
+
+describe("resizableStyle: press handle preset", () => {
+ const s = resizableStyle(0.7, "press");
+ const preset = resizableHandleStyle("press");
+
+ it("ratio equals the input ratio", () => {
+ expect(s.ratio).toBeCloseTo(0.7, 10);
+ });
+
+ it("handleScale matches press preset (1.25)", () => {
+ expect(s.handleScale).toBeCloseTo(preset.handleScale, 10);
+ });
+
+ it("handleRingOpacity matches press preset (1)", () => {
+ expect(s.handleRingOpacity).toBeCloseTo(preset.handleRingOpacity, 10);
+ });
+});
+
+describe("resizableStyle: ratio is preserved regardless of handle state", () => {
+ it("ratio=0.2 is preserved with idle", () => {
+ expect(resizableStyle(0.2, "idle").ratio).toBeCloseTo(0.2, 10);
+ });
+
+ it("ratio=0.8 is preserved with press", () => {
+ expect(resizableStyle(0.8, "press").ratio).toBeCloseTo(0.8, 10);
+ });
+});
+
+describe("resizableStyle: all three ResizableStyle fields are present", () => {
+ it("returns an object with ratio, handleScale, handleRingOpacity", () => {
+ const s = resizableStyle(0.5, "idle");
+ expect("ratio" in s).toBe(true);
+ expect("handleScale" in s).toBe(true);
+ expect("handleRingOpacity" in s).toBe(true);
+ });
+});
+
+// ===========================================================================
+// 6. tweenResizableStyle — pure lerp across all three fields
+// MIRROR of use-resizable-transition.ts lines 42-53
+// Both channels (ratio + handle) are covered in one tween.
+// ===========================================================================
+
+describe("tweenResizableStyle: t=0 returns values equal to `a`", () => {
+ const a = resizableStyle(0.3, "idle"); // {ratio:0.3, handleScale:1, handleRingOpacity:0}
+ const b = resizableStyle(0.7, "hover"); // {ratio:0.7, handleScale:1.15, handleRingOpacity:1}
+ const r = tweenResizableStyle(a, b, 0);
+
+ it("ratio equals a.ratio at t=0", () => {
+ expect(r.ratio).toBeCloseTo(a.ratio, 10);
+ });
+ it("handleScale equals a.handleScale at t=0", () => {
+ expect(r.handleScale).toBeCloseTo(a.handleScale, 10);
+ });
+ it("handleRingOpacity equals a.handleRingOpacity at t=0", () => {
+ expect(r.handleRingOpacity).toBeCloseTo(a.handleRingOpacity, 10);
+ });
+});
+
+describe("tweenResizableStyle: t=1 returns values equal to `b`", () => {
+ const a = resizableStyle(0.3, "idle");
+ const b = resizableStyle(0.7, "hover");
+ const r = tweenResizableStyle(a, b, 1);
+
+ it("ratio equals b.ratio at t=1", () => {
+ expect(r.ratio).toBeCloseTo(b.ratio, 10);
+ });
+ it("handleScale equals b.handleScale at t=1", () => {
+ expect(r.handleScale).toBeCloseTo(b.handleScale, 10);
+ });
+ it("handleRingOpacity equals b.handleRingOpacity at t=1", () => {
+ expect(r.handleRingOpacity).toBeCloseTo(b.handleRingOpacity, 10);
+ });
+});
+
+describe("tweenResizableStyle: t=0.5 midpoint", () => {
+ // a: ratio=0.3, handleScale=1(idle), handleRingOpacity=0
+ // b: ratio=0.7, handleScale=1.15(hover), handleRingOpacity=1
+ // midpoints: ratio=0.5, handleScale=1.075, handleRingOpacity=0.5
+ const a = resizableStyle(0.3, "idle");
+ const b = resizableStyle(0.7, "hover");
+ const r = tweenResizableStyle(a, b, 0.5);
+
+ it("ratio midpoint: 0.3→0.7 gives 0.5", () => {
+ expect(r.ratio).toBeCloseTo(0.5, 10);
+ });
+ it("handleScale midpoint: 1→1.15 gives 1.075", () => {
+ expect(r.handleScale).toBeCloseTo(1.075, 10);
+ });
+ it("handleRingOpacity midpoint: 0→1 gives 0.5", () => {
+ expect(r.handleRingOpacity).toBeCloseTo(0.5, 10);
+ });
+});
+
+describe("tweenResizableStyle: identity (a === b, any t)", () => {
+ const s = resizableStyle(0.5, "idle");
+
+ it("all fields unchanged when both endpoints are the same", () => {
+ const r = tweenResizableStyle(s, s, 0.5);
+ expect(r.ratio).toBeCloseTo(s.ratio, 10);
+ expect(r.handleScale).toBeCloseTo(s.handleScale, 10);
+ expect(r.handleRingOpacity).toBeCloseTo(s.handleRingOpacity, 10);
+ });
+});
+
+describe("tweenResizableStyle: idle → press handle channel", () => {
+ // idle: handleScale=1, handleRingOpacity=0
+ // press: handleScale=1.25, handleRingOpacity=1
+ // t=0.5: handleScale=1.125, handleRingOpacity=0.5
+ const a = resizableStyle(0.5, "idle");
+ const b = resizableStyle(0.5, "press");
+ const r = tweenResizableStyle(a, b, 0.5);
+
+ it("handleScale midpoint idle→press: (1+1.25)/2 = 1.125", () => {
+ expect(r.handleScale).toBeCloseTo(1.125, 10);
+ });
+ it("handleRingOpacity midpoint idle→press: 0.5", () => {
+ expect(r.handleRingOpacity).toBeCloseTo(0.5, 10);
+ });
+});
+
+describe("tweenResizableStyle: hover → press handle channel", () => {
+ // hover: handleScale=1.15, handleRingOpacity=1
+ // press: handleScale=1.25, handleRingOpacity=1
+ // t=0.5: handleScale=1.2, handleRingOpacity=1 (ring stays at 1)
+ const a = resizableStyle(0.5, "hover");
+ const b = resizableStyle(0.5, "press");
+ const r = tweenResizableStyle(a, b, 0.5);
+
+ it("handleScale midpoint hover→press: (1.15+1.25)/2 = 1.2", () => {
+ expect(r.handleScale).toBeCloseTo(1.2, 10);
+ });
+ it("handleRingOpacity stays at 1 (both hover and press have full ring)", () => {
+ expect(r.handleRingOpacity).toBeCloseTo(1, 10);
+ });
+});
+
+// ===========================================================================
+// 7. resizableStyleAt — pure exported dual-channel core
+// MIRROR of use-resizable-transition.ts lines 152-165.
+// useResizableTransition is exactly resizableStyleAt(steps, useCurrentFrame()*speed, opts).
+// We call resizableStyleAt directly with the frame injected as `raw`.
+//
+// The two channels (ratio + handle) are folded INDEPENDENTLY from the same
+// step list, filtering to ratio-bearing and handle-bearing steps respectively.
+//
+// MAINTENANCE CONTRACT: if use-resizable-transition.ts lines 70-165 change,
+// update these tests in lockstep. Annotated source lines below.
+// ===========================================================================
+
+describe("resizableStyleAt: empty steps → ratio=0.5, handle=idle", () => {
+ // source lines 78/113: empty ratio/handle steps → return 0.5 / resizableHandleStyle('idle')
+ it("empty steps returns {ratio:0.5, handleScale:1, handleRingOpacity:0}", () => {
+ const r = resizableStyleAt([], 0);
+ expect(r.ratio).toBe(0.5);
+ expect(r.handleScale).toBe(resizableHandleStyle("idle").handleScale);
+ expect(r.handleRingOpacity).toBe(resizableHandleStyle("idle").handleRingOpacity);
+ });
+});
+
+describe("resizableStyleAt: before first ratio step — holds at first.ratio", () => {
+ // source line 81: if (raw <= first.at) return first.ratio
+ const steps: ResizableStep[] = [{ at: 10, ratio: 0.6 }];
+
+ it("raw=5 < first.at=10 → holds at first.ratio=0.6", () => {
+ expect(resizableStyleAt(steps, 5).ratio).toBeCloseTo(0.6, 10);
+ });
+
+ it("raw=10 = first.at → holds at first.ratio=0.6 (raw <= first.at)", () => {
+ expect(resizableStyleAt(steps, 10).ratio).toBeCloseTo(0.6, 10);
+ });
+});
+
+describe("resizableStyleAt: before first handle step — holds at first.handleState preset", () => {
+ // source line 115: if (raw <= first.at) return resizableHandleStyle(first.handleState)
+ const steps: ResizableStep[] = [{ at: 10, handleState: "hover" }];
+
+ it("raw=5 holds at hover preset (handleScale=1.15)", () => {
+ expect(resizableStyleAt(steps, 5).handleScale).toBeCloseTo(1.15, 10);
+ });
+
+ it("raw=5 holds at hover preset (handleRingOpacity=1)", () => {
+ expect(resizableStyleAt(steps, 5).handleRingOpacity).toBeCloseTo(1, 10);
+ });
+});
+
+describe("resizableStyleAt: past last ratio step — rests at last.ratio", () => {
+ // source lines 90-93: pastLast → to=from=last, t=1
+ const steps: ResizableStep[] = [
+ { at: 0, ratio: 0.3 },
+ { at: 18, ratio: 0.7 },
+ ];
+
+ it("raw=50 → ratio=0.7 (rests at last)", () => {
+ expect(resizableStyleAt(steps, 50).ratio).toBeCloseTo(0.7, 10);
+ });
+});
+
+describe("resizableStyleAt: past last handle step — rests at last.handleState preset", () => {
+ const steps: ResizableStep[] = [
+ { at: 0, handleState: "idle" },
+ { at: 18, handleState: "press" },
+ ];
+
+ it("raw=50 → handleScale=1.25 (press preset, rests at last)", () => {
+ expect(resizableStyleAt(steps, 50).handleScale).toBeCloseTo(
+ resizableHandleStyle("press").handleScale,
+ 10,
+ );
+ });
+
+ it("raw=50 → handleRingOpacity=1 (press preset)", () => {
+ expect(resizableStyleAt(steps, 50).handleRingOpacity).toBeCloseTo(1, 10);
+ });
+});
+
+describe("resizableStyleAt: ratio channel mid-window uses easings.out", () => {
+ // [{at:0,ratio:0.3},{at:18,ratio:0.7}], raw=9 → start=0, linear=0.5, t=out(0.5)=0.875
+ // ratio = 0.3 + (0.7-0.3)*0.875 = 0.3 + 0.35 = 0.65
+ const steps: ResizableStep[] = [
+ { at: 0, ratio: 0.3 },
+ { at: 18, ratio: 0.7 },
+ ];
+
+ it("ratio at raw=9 is 0.65 (out-eased, not linear 0.5)", () => {
+ expect(resizableStyleAt(steps, 9).ratio).toBeCloseTo(0.65, 8);
+ });
+
+ it("ratio is NOT linear at midpoint (0.65 ≠ 0.5)", () => {
+ const r = resizableStyleAt(steps, 9);
+ expect(r.ratio).not.toBeCloseTo(0.5, 1);
+ });
+});
+
+describe("resizableStyleAt: handle channel mid-window uses easings.out", () => {
+ // [{at:0,handleState:'idle'},{at:18,handleState:'hover'}], raw=9
+ // t=out(0.5)=0.875; idle={hs:1,hro:0}, hover={hs:1.15,hro:1}
+ // handleScale: 1 + 0.15*0.875 = 1.13125, handleRingOpacity: 0 + 1*0.875 = 0.875
+ const steps: ResizableStep[] = [
+ { at: 0, handleState: "idle" },
+ { at: 18, handleState: "hover" },
+ ];
+
+ it("handleScale at raw=9 is 1.13125 (out-eased)", () => {
+ expect(resizableStyleAt(steps, 9).handleScale).toBeCloseTo(1.13125, 8);
+ });
+
+ it("handleRingOpacity at raw=9 is 0.875 (out-eased, not linear 0.5)", () => {
+ expect(resizableStyleAt(steps, 9).handleRingOpacity).toBeCloseTo(0.875, 8);
+ });
+});
+
+describe("resizableStyleAt: dual-channel steps fold independently", () => {
+ // Combined steps — both channels active simultaneously
+ const steps: ResizableStep[] = [
+ { at: 0, ratio: 0.3, handleState: "idle" },
+ { at: 18, ratio: 0.7, handleState: "hover" },
+ ];
+
+ it("both channels are active at raw=9", () => {
+ const r = resizableStyleAt(steps, 9);
+ expect(r.ratio).toBeCloseTo(0.65, 8);
+ expect(r.handleRingOpacity).toBeCloseTo(0.875, 8);
+ });
+
+ it("ratio channel at raw=18 (past last) → ratio=0.7", () => {
+ expect(resizableStyleAt(steps, 18).ratio).toBeCloseTo(0.7, 10);
+ });
+
+ it("handle channel at raw=18 (past last) → hover preset values", () => {
+ const r = resizableStyleAt(steps, 18);
+ expect(r.handleScale).toBeCloseTo(resizableHandleStyle("hover").handleScale, 10);
+ expect(r.handleRingOpacity).toBeCloseTo(
+ resizableHandleStyle("hover").handleRingOpacity,
+ 10,
+ );
+ });
+});
+
+describe("resizableStyleAt: channels can have different step counts", () => {
+ // Only ratio steps, no handle steps → handle stays idle
+ const ratioOnlySteps: ResizableStep[] = [
+ { at: 0, ratio: 0.3 },
+ { at: 18, ratio: 0.7 },
+ ];
+
+ it("handle is idle when no handle steps are present", () => {
+ const r = resizableStyleAt(ratioOnlySteps, 9);
+ expect(r.handleScale).toBe(resizableHandleStyle("idle").handleScale);
+ expect(r.handleRingOpacity).toBe(resizableHandleStyle("idle").handleRingOpacity);
+ });
+
+ // Only handle steps, no ratio steps → ratio stays 0.5
+ const handleOnlySteps: ResizableStep[] = [
+ { at: 0, handleState: "idle" },
+ { at: 18, handleState: "hover" },
+ ];
+
+ it("ratio is 0.5 (default center) when no ratio steps are present", () => {
+ expect(resizableStyleAt(handleOnlySteps, 9).ratio).toBe(0.5);
+ });
+});
+
+describe("resizableStyleAt: past last with both channels — single-step timeline", () => {
+ const steps: ResizableStep[] = [{ at: 18, ratio: 0.75, handleState: "press" }];
+
+ it("raw=50 → ratio=0.75, handle=press preset", () => {
+ const r = resizableStyleAt(steps, 50);
+ expect(r.ratio).toBeCloseTo(0.75, 10);
+ expect(r.handleScale).toBeCloseTo(resizableHandleStyle("press").handleScale, 10);
+ expect(r.handleRingOpacity).toBeCloseTo(
+ resizableHandleStyle("press").handleRingOpacity,
+ 10,
+ );
+ });
+});
+
+describe("resizableStyleAt: before first with both channels — single-step timeline", () => {
+ const steps: ResizableStep[] = [{ at: 10, ratio: 0.6, handleState: "hover" }];
+
+ it("raw=0 → ratio=0.6 (first ratio), handleScale=1.15 (first hover)", () => {
+ const r = resizableStyleAt(steps, 0);
+ expect(r.ratio).toBeCloseTo(0.6, 10);
+ expect(r.handleScale).toBeCloseTo(1.15, 10);
+ });
+});
+
+describe("resizableStyleAt: custom defaultDuration override", () => {
+ // With defaultDuration=9, a step at=9 with no explicit duration uses a 9-frame window
+ // [0..9], raw=4.5 is mid → linear=0.5, out-eased → 0.875
+ // ratio = 0.3 + (0.7-0.3)*0.875 = 0.65
+ const steps: ResizableStep[] = [
+ { at: 0, ratio: 0.3 },
+ { at: 9, ratio: 0.7 },
+ ];
+
+ it("custom defaultDuration=9 adjusts window width correctly at raw=4.5", () => {
+ const r = resizableStyleAt(steps, 4.5, { defaultDuration: 9 });
+ expect(r.ratio).toBeCloseTo(0.65, 8);
+ });
+});
+
+// ===========================================================================
+// 8. resizableConfig.controls — customizer control wiring
+// ===========================================================================
+
+describe("resizableConfig.controls: ratio", () => {
+ it("ratio is a number control", () => {
+ expect(resizableConfig.controls.ratio.type).toBe("number");
+ });
+ it("ratio default is 0.5", () => {
+ expect(resizableConfig.controls.ratio.default).toBe(0.5);
+ });
+ it("ratio min=0, max=1", () => {
+ const ctrl = resizableConfig.controls.ratio;
+ if (ctrl.type !== "number") throw new Error("expected number");
+ expect(ctrl.min).toBe(0);
+ expect(ctrl.max).toBe(1);
+ });
+});
+
+describe("resizableConfig.controls: handleState", () => {
+ it("handleState is a select control", () => {
+ expect(resizableConfig.controls.handleState.type).toBe("select");
+ });
+ it("handleState options are ['idle', 'hover', 'press']", () => {
+ const ctrl = resizableConfig.controls.handleState;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ expect(ctrl.options).toEqual(["idle", "hover", "press"]);
+ });
+ it("handleState default is 'idle'", () => {
+ expect(resizableConfig.controls.handleState.default).toBe("idle");
+ });
+ it("every handleState option is a valid ResizableHandleState", () => {
+ const ctrl = resizableConfig.controls.handleState;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ for (const opt of ctrl.options) {
+ expect(VALID_HANDLE_STATES).toContain(opt as ResizableHandleState);
+ }
+ });
+});
+
+describe("resizableConfig.controls: direction", () => {
+ it("direction is a select control", () => {
+ expect(resizableConfig.controls.direction.type).toBe("select");
+ });
+ it("direction options include 'horizontal' and 'vertical'", () => {
+ const ctrl = resizableConfig.controls.direction;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ expect(ctrl.options).toContain("horizontal");
+ expect(ctrl.options).toContain("vertical");
+ });
+ it("direction default is 'horizontal'", () => {
+ expect(resizableConfig.controls.direction.default).toBe("horizontal");
+ });
+});
+
+describe("resizableConfig.controls: mode", () => {
+ it("mode is a select with options ['light','dark'] and default 'light'", () => {
+ const ctrl = resizableConfig.controls.mode;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ expect(ctrl.options).toEqual(["light", "dark"]);
+ expect(ctrl.default).toBe("light");
+ });
+});
+
+// ===========================================================================
+// 9. resizableConfig.snippet — pure JSX string builder
+// ===========================================================================
+
+describe("resizableConfig.snippet: import line", () => {
+ it("includes 'import { Resizable }' from the correct path", () => {
+ const out = snippet({ ratio: 0.5 });
+ expect(out).toContain("import { Resizable }");
+ expect(out).toContain('from "@/components/remocn/resizable"');
+ });
+});
+
+describe("resizableConfig.snippet: structural invariants", () => {
+ it("contains a <Resizable JSX element", () => {
+ expect(snippet({ ratio: 0.5 })).toContain("<Resizable");
+ });
+ it("ends with a self-closing />", () => {
+ expect(snippet({ ratio: 0.5 }).trimEnd().endsWith("/>")).toBe(true);
+ });
+ it("ratio prop is always emitted", () => {
+ expect(snippet({ ratio: 0.5 })).toContain("ratio={0.5}");
+ expect(snippet({ ratio: 0.3 })).toContain("ratio={0.3}");
+ });
+ it("ratio is emitted as {0.5} when omitted from values (falls back to default 0.5)", () => {
+ expect(snippet({})).toContain("ratio={0.5}");
+ });
+});
+
+describe("resizableConfig.snippet: default props are omitted", () => {
+ it("omits handleState when it equals the default 'idle'", () => {
+ const out = snippet({ ratio: 0.5, handleState: "idle" });
+ expect(out).not.toContain("handleState=");
+ });
+ it("omits direction when it equals the default 'horizontal'", () => {
+ const out = snippet({ ratio: 0.5, direction: "horizontal" });
+ expect(out).not.toContain("direction=");
+ });
+ it("omits mode when it equals the default 'light'", () => {
+ const out = snippet({ ratio: 0.5, mode: "light" });
+ expect(out).not.toContain("mode=");
+ });
+});
+
+describe("resizableConfig.snippet: non-default props are emitted", () => {
+ it("emits handleState='hover' when non-default", () => {
+ expect(snippet({ ratio: 0.5, handleState: "hover" })).toContain(
+ 'handleState="hover"',
+ );
+ });
+ it("emits handleState='press' when non-default", () => {
+ expect(snippet({ ratio: 0.5, handleState: "press" })).toContain(
+ 'handleState="press"',
+ );
+ });
+ it("emits direction='vertical' when non-default", () => {
+ expect(snippet({ ratio: 0.5, direction: "vertical" })).toContain(
+ 'direction="vertical"',
+ );
+ });
+ it("emits mode='dark' when non-default", () => {
+ expect(snippet({ ratio: 0.5, mode: "dark" })).toContain('mode="dark"');
+ });
+});
+
+describe("resizableConfig.snippet: handleState options round-trip", () => {
+ it("emits correct handleState for every non-default option", () => {
+ const ctrl = resizableConfig.controls.handleState;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ const nonDefault = ctrl.options.filter((o) => o !== "idle");
+ for (const handleState of nonDefault) {
+ expect(snippet({ ratio: 0.5, handleState })).toContain(
+ `handleState="${handleState}"`,
+ );
+ }
+ });
+});
+
+describe("resizableConfig.snippet: ratio numeric round-trip", () => {
+ it("emits the correct ratio for various inputs", () => {
+ for (const r of [0.15, 0.3, 0.5, 0.7, 0.85]) {
+ expect(snippet({ ratio: r })).toContain(`ratio={${r}}`);
+ }
+ });
+});
diff --git a/registry/remocn-ui/resizable/config.ts b/registry/remocn-ui/resizable/config.ts
new file mode 100644
index 00000000..dfcceb45
--- /dev/null
+++ b/registry/remocn-ui/resizable/config.ts
@@ -0,0 +1,61 @@
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+import type {
+ ResizableDirection,
+ ResizableHandleState,
+} from "@/registry/remocn-ui/resizable";
+
+export const resizableConfig: ComponentConfig = {
+ componentName: "Resizable",
+ importPath: "@/components/remocn/resizable",
+ controls: {
+ ratio: {
+ type: "number",
+ default: 0.5,
+ min: 0,
+ max: 1,
+ step: 0.05,
+ label: "Ratio",
+ },
+ handleState: {
+ type: "select",
+ default: "idle",
+ options: ["idle", "hover", "press"],
+ label: "Handle State",
+ },
+ direction: {
+ type: "select",
+ default: "horizontal",
+ options: ["horizontal", "vertical"],
+ label: "Direction",
+ },
+ mode: {
+ type: "select",
+ default: "light",
+ options: ["light", "dark"],
+ label: "Mode",
+ },
+ },
+ durationInFrames: 120,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+ snippet: (values) => {
+ const ratio = values.ratio as number | undefined;
+ const handleState = values.handleState as ResizableHandleState | undefined;
+ const direction = values.direction as ResizableDirection | undefined;
+ const mode = values.mode as string | undefined;
+
+ const props: string[] = [` ratio={${ratio ?? 0.5}}`];
+ if (handleState !== undefined && handleState !== "idle")
+ props.push(` handleState="${handleState}"`);
+ if (direction !== undefined && direction !== "horizontal")
+ props.push(` direction="${direction}"`);
+ if (mode !== undefined && mode !== "light") props.push(` mode="${mode}"`);
+
+ return `import { Resizable } from "@/components/remocn/resizable";
+
+<Resizable
+${props.join("\n")}
+/>`;
+ },
+};
diff --git a/registry/remocn-ui/resizable/index.tsx b/registry/remocn-ui/resizable/index.tsx
new file mode 100644
index 00000000..bab646fe
--- /dev/null
+++ b/registry/remocn-ui/resizable/index.tsx
@@ -0,0 +1,272 @@
+"use client";
+
+import type { ReactNode } from "react";
+import { clamp01, mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
+
+export type ResizableHandleState = "idle" | "hover" | "press";
+
+export type ResizableDirection = "horizontal" | "vertical";
+
+// ===========================================================================
+// Resizable visual — the COMPLETE animated look for a moment in time. This is a
+// DUAL-channel atom (value-channel deviation §0, like slider): the numeric
+// `ratio` animates as a lerp while the handle visuals (`handleScale`,
+// `handleRingOpacity`) come from a `handleState` preset. Both live in one
+// `ResizableStyle`; `useResizableTransition` feeds an interpolated one through
+// the `style` prop. The component never reads the frame.
+// ===========================================================================
+
+export interface ResizableStyle {
+ /** Fraction of the FIRST panel, 0–1 (clamped to [minRatio, maxRatio]). */
+ ratio: number;
+ /** Handle grip zoom: 1 idle, grows on hover/press. */
+ handleScale: number;
+ /** Handle grab-ring opacity 0 (idle) → 1 (hover/press). */
+ handleRingOpacity: number;
+}
+
+export interface ResizableProps {
+ /** First panel content. Defaults to a muted placeholder card. */
+ first?: ReactNode;
+ /** Second panel content. Defaults to a muted placeholder card. */
+ second?: ReactNode;
+ /** Split direction — both implemented (horizontal splits width, vertical height). */
+ direction?: ResizableDirection;
+ /** Fraction of the first panel, 0–1 (snap path). Ignored when `style` is set. */
+ ratio?: number;
+ /** Handle visual state (snap path). Ignored when `style` is set. */
+ handleState?: ResizableHandleState;
+ /**
+ * Resolved animated visual (smooth path). When provided, takes precedence over
+ * `ratio`/`handleState` — feed it an interpolated `ResizableStyle` from
+ * `useResizableTransition`.
+ */
+ style?: ResizableStyle;
+ /** Minimum first-panel fraction. Default 0.15. */
+ minRatio?: number;
+ /** Maximum first-panel fraction. Default 0.85. */
+ maxRatio?: number;
+ /** Container size in px (width for horizontal, height for vertical primary axis). */
+ width?: number;
+ height?: number;
+ theme?: Partial<RemocnTheme>;
+ mode?: "light" | "dark";
+ className?: string;
+}
+
+/** Divider thickness (px). */
+const DIVIDER = 1;
+/** Grip pill dimensions (px) — shadcn `h-6 w-1`. */
+const GRIP_LONG = 24;
+const GRIP_SHORT = 4;
+/** Grab-ring spread (px) at full opacity. */
+const RING_WIDTH = 4;
+
+/** Clamp a ratio into [minRatio, maxRatio]. */
+function clampRatio(ratio: number, minRatio: number, maxRatio: number): number {
+ return Math.min(maxRatio, Math.max(minRatio, ratio));
+}
+
+/**
+ * The handle-channel preset for a state — pure `(handleState) => {handleScale,
+ * handleRingOpacity}`. Hover and press both grow the grip and show the ring;
+ * press grows it a touch more. The `ratio` channel is independent of this.
+ */
+export function resizableHandleStyle(handleState: ResizableHandleState): {
+ handleScale: number;
+ handleRingOpacity: number;
+} {
+ switch (handleState) {
+ case "hover":
+ return { handleScale: 1.15, handleRingOpacity: 1 };
+ case "press":
+ return { handleScale: 1.25, handleRingOpacity: 1 };
+ default:
+ return { handleScale: 1, handleRingOpacity: 0 };
+ }
+}
+
+/** Concrete colors for the active theme, resolved once per render. */
+export interface ResizableStyleContext {
+ containerBg: string;
+ border: string;
+ panelBg: string;
+ grip: string;
+ /** Grab ring — a visible halo derived from the ring token (US-006 contrast). */
+ ring: string;
+ placeholderFg: string;
+ radius: number;
+}
+
+/**
+ * Derive the concrete colors for a theme. Pure. The grab ring is a real mix of
+ * the ring token toward the background (not a duplicate token), so it reads as a
+ * distinct halo in both light and dark.
+ */
+export function resizableStyleContext(theme: RemocnTheme): ResizableStyleContext {
+ return {
+ containerBg: theme.background,
+ border: theme.border,
+ panelBg: theme.muted,
+ grip: theme.border,
+ ring: mixOklch(theme.ring, theme.background, 0.6),
+ placeholderFg: theme.mutedForeground,
+ radius: theme.radius,
+ };
+}
+
+/**
+ * The COMPLETE resting visual for the snap path — a pure `(ratio, handleState)
+ * => ResizableStyle` map. The ratio is NOT clamped here (the renderer clamps
+ * with the active min/max); the handle visuals come from the preset.
+ */
+export function resizableStyle(
+ ratio: number,
+ handleState: ResizableHandleState,
+): ResizableStyle {
+ const handle = resizableHandleStyle(handleState);
+ return {
+ ratio,
+ handleScale: handle.handleScale,
+ handleRingOpacity: handle.handleRingOpacity,
+ };
+}
+
+/** Default placeholder card for a panel slot. */
+function Placeholder({ label, color }: { label: string; color: string }) {
+ return (
+ <div
+ style={{
+ width: "100%",
+ height: "100%",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ fontSize: 13,
+ fontWeight: 500,
+ letterSpacing: "-0.01em",
+ color,
+ }}
+ >
+ {label}
+ </div>
+ );
+}
+
+export function Resizable({
+ first,
+ second,
+ direction = "horizontal",
+ ratio = 0.5,
+ handleState = "idle",
+ style,
+ minRatio = 0.15,
+ maxRatio = 0.85,
+ width = 440,
+ height = 240,
+ theme: themeOverride,
+ mode,
+ className,
+}: ResizableProps) {
+ const theme = useRemocnTheme(themeOverride, mode);
+ const ctx = resizableStyleContext(theme);
+
+ const v = style ?? resizableStyle(ratio, handleState);
+ const pct = clampRatio(v.ratio, minRatio, maxRatio) * 100;
+ const isHorizontal = direction === "horizontal";
+
+ // The grip is a long pill along the divider; long axis is perpendicular to the
+ // split direction (vertical pill for a horizontal split, and vice versa).
+ const gripW = isHorizontal ? GRIP_SHORT : GRIP_LONG;
+ const gripH = isHorizontal ? GRIP_LONG : GRIP_SHORT;
+
+ return (
+ <div
+ className={className}
+ style={{
+ position: "absolute",
+ inset: 0,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ background: theme.background,
+ fontFamily:
+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
+ }}
+ >
+ <div
+ style={{
+ position: "relative",
+ width,
+ height,
+ display: "flex",
+ flexDirection: isHorizontal ? "row" : "column",
+ background: ctx.containerBg,
+ border: `1px solid ${ctx.border}`,
+ borderRadius: ctx.radius,
+ overflow: "hidden",
+ boxSizing: "border-box",
+ }}
+ >
+ {/* First panel — sized by ratio along the split axis. */}
+ <div
+ style={{
+ flex: "none",
+ [isHorizontal ? "width" : "height"]: `${pct}%`,
+ background: ctx.panelBg,
+ overflow: "hidden",
+ }}
+ >
+ {first ?? <Placeholder label="Panel one" color={ctx.placeholderFg} />}
+ </div>
+ {/* Divider — a 1px border-color line; grip pill centered on it. */}
+ <div
+ style={{
+ position: "relative",
+ flex: "none",
+ [isHorizontal ? "width" : "height"]: DIVIDER,
+ background: ctx.border,
+ }}
+ >
+ {/* Grab ring behind the grip, fading in on hover/press. */}
+ <div
+ style={{
+ position: "absolute",
+ left: "50%",
+ top: "50%",
+ width: gripW + RING_WIDTH * 2,
+ height: gripH + RING_WIDTH * 2,
+ transform: `translate(-50%, -50%) scale(${v.handleScale})`,
+ borderRadius: 999,
+ background: ctx.ring,
+ opacity: v.handleRingOpacity,
+ }}
+ />
+ {/* Grip pill — scales on grab. */}
+ <div
+ style={{
+ position: "absolute",
+ left: "50%",
+ top: "50%",
+ width: gripW,
+ height: gripH,
+ transform: `translate(-50%, -50%) scale(${v.handleScale})`,
+ borderRadius: 999,
+ background: ctx.grip,
+ }}
+ />
+ </div>
+ {/* Second panel — fills the remainder. */}
+ <div
+ style={{
+ flex: "1 1 0",
+ background: ctx.panelBg,
+ overflow: "hidden",
+ }}
+ >
+ {second ?? <Placeholder label="Panel two" color={ctx.placeholderFg} />}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/registry/remocn-ui/resizable/use-resizable-transition.ts b/registry/remocn-ui/resizable/use-resizable-transition.ts
new file mode 100644
index 00000000..fda4d557
--- /dev/null
+++ b/registry/remocn-ui/resizable/use-resizable-transition.ts
@@ -0,0 +1,165 @@
+"use client";
+
+import { useCurrentFrame } from "remotion";
+import { clamp01, type EasingName, easings } from "@/lib/remocn-ui";
+import {
+ resizableHandleStyle,
+ type ResizableHandleState,
+ type ResizableStyle,
+} from "@/components/remocn/resizable";
+// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
+
+/**
+ * One scripted resizable keyframe. A step may move the `ratio` channel, the
+ * `handleState` channel, or both. The ratio eases from the previous ratio-bearing
+ * step to this one; the handle visual tweens from the previous handle-bearing
+ * step's preset to this one.
+ */
+export interface ResizableStep {
+ /** LOCAL (Sequence-relative) authored frame this keyframe is reached. */
+ at: number;
+ /** Target first-panel fraction 0–1 (this step moves the ratio channel). */
+ ratio?: number;
+ /** Target handle state (this step moves the handle channel). */
+ handleState?: ResizableHandleState;
+ /** 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 ResizableTransitionOptions {
+ /** Playhead scale (effectiveFrame = useCurrentFrame() * speed). */
+ speed?: number;
+ /** Move duration (frames) when a step omits `duration`. */
+ defaultDuration?: number;
+}
+
+/** Blend two resizable visuals: all three fields lerp (ratio + handle channels). */
+export function tweenResizableStyle(
+ a: ResizableStyle,
+ b: ResizableStyle,
+ t: number,
+): ResizableStyle {
+ return {
+ ratio: a.ratio + (b.ratio - a.ratio) * t,
+ handleScale: a.handleScale + (b.handleScale - a.handleScale) * t,
+ handleRingOpacity:
+ a.handleRingOpacity + (b.handleRingOpacity - a.handleRingOpacity) * t,
+ };
+}
+
+/**
+ * Resolve the resizable's `ResizableStyle` for a dual-channel timeline. THIS is
+ * the only frame-reading file — `<Resizable>` itself stays pure. The fold is a
+ * pure function of `raw = useCurrentFrame() * speed`; tests replicate
+ * `resizableStyleAt(steps, raw, opts)` with the frame injected.
+ */
+export function useResizableTransition(
+ steps: ResizableStep[],
+ opts: ResizableTransitionOptions = {},
+): ResizableStyle {
+ const { speed = 1 } = opts;
+ const raw = useCurrentFrame() * speed;
+ return resizableStyleAt(steps, raw, opts);
+}
+
+/** Eased ratio at `raw` over the ratio-bearing steps (numeric channel). */
+function ratioAt(
+ steps: ResizableStep[],
+ raw: number,
+ defaultDuration: number,
+): number {
+ const ratioSteps = steps.filter(
+ (s): s is ResizableStep & { ratio: number } => s.ratio !== undefined,
+ );
+ if (ratioSteps.length === 0) return 0.5;
+ const first = ratioSteps[0];
+ if (raw <= first.at) return first.ratio;
+
+ let toIndex = ratioSteps.length - 1;
+ for (let i = 1; i < ratioSteps.length; i++) {
+ if (ratioSteps[i].at > raw) {
+ toIndex = i;
+ break;
+ }
+ }
+ const pastLast = raw >= ratioSteps[ratioSteps.length - 1].at;
+ const to = pastLast ? ratioSteps[ratioSteps.length - 1] : ratioSteps[toIndex];
+ const from = pastLast
+ ? ratioSteps[ratioSteps.length - 1]
+ : ratioSteps[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.ratio + (to.ratio - from.ratio) * t;
+}
+
+/** Eased handle visual at `raw` over the handle-bearing steps (state channel). */
+function handleAt(
+ steps: ResizableStep[],
+ raw: number,
+ defaultDuration: number,
+): { handleScale: number; handleRingOpacity: number } {
+ const handleSteps = steps.filter(
+ (s): s is ResizableStep & { handleState: ResizableHandleState } =>
+ s.handleState !== undefined,
+ );
+ if (handleSteps.length === 0) return resizableHandleStyle("idle");
+ const first = handleSteps[0];
+ if (raw <= first.at) return resizableHandleStyle(first.handleState);
+
+ let toIndex = handleSteps.length - 1;
+ for (let i = 1; i < handleSteps.length; i++) {
+ if (handleSteps[i].at > raw) {
+ toIndex = i;
+ break;
+ }
+ }
+ const pastLast = raw >= handleSteps[handleSteps.length - 1].at;
+ const to = pastLast
+ ? handleSteps[handleSteps.length - 1]
+ : handleSteps[toIndex];
+ const from = pastLast
+ ? handleSteps[handleSteps.length - 1]
+ : handleSteps[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 = resizableHandleStyle(from.handleState);
+ const b = resizableHandleStyle(to.handleState);
+ return {
+ handleScale: a.handleScale + (b.handleScale - a.handleScale) * t,
+ handleRingOpacity:
+ a.handleRingOpacity + (b.handleRingOpacity - a.handleRingOpacity) * t,
+ };
+}
+
+/**
+ * Pure core of `useResizableTransition` with the effective frame injected as
+ * `raw`. The two channels are folded independently and merged: `ratio` eases over
+ * the ratio-bearing steps, the handle visual tweens over the handle-bearing
+ * steps. Kept separate so it can be unit-tested without a Remotion render.
+ */
+export function resizableStyleAt(
+ steps: ResizableStep[],
+ raw: number,
+ opts: ResizableTransitionOptions = {},
+): ResizableStyle {
+ const { defaultDuration = DEFAULT_DURATION } = opts;
+ const ratio = ratioAt(steps, raw, defaultDuration);
+ const handle = handleAt(steps, raw, defaultDuration);
+ return {
+ ratio,
+ handleScale: handle.handleScale,
+ handleRingOpacity: handle.handleRingOpacity,
+ };
+}