Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: added dialog component
dev_wandry128ddefebeb9
diff --git a/components/docs/examples/dialog-example.tsx b/components/docs/examples/dialog-example.tsxnew file mode 100644index 00000000..8ebd55cd--- /dev/null+++ b/components/docs/examples/dialog-example.tsx@@ -0,0 +1,49 @@+"use client";++import { Button } from "@/registry/remocn-ui/button";+import { useButtonTransition } from "@/registry/remocn-ui/button/use-button-transition";+import { Dialog } from "@/registry/remocn-ui/dialog";+import { useDialogTransition } from "@/registry/remocn-ui/dialog/use-dialog-transition";++export const DialogExampleScene = () => {+ // The trigger Button: idle → hover → press, the press lands just before the+ // dialog opens (the "click" that triggers it).+ const trigger = useButtonTransition([+ { at: 14, state: "hover" },+ { at: 26, state: "press" },+ ]);+ // The dialog opens right after the press, then closes near the end.+ const dialog = useDialogTransition([+ { at: 32, state: "opened", duration: 16 },+ { at: 92, state: "closed", duration: 12 },+ ]);+ return (+ <>+ <Button label="Edit profile" style={trigger} />+ <Dialog style={dialog} />+ </>+ );+};++export const dialogExampleCode = `import { Dialog } from "@/components/remocn/dialog";+import { useDialogTransition } from "@/components/remocn/use-dialog-transition";+import { Button } from "@/components/remocn/button";+import { useButtonTransition } from "@/components/remocn/use-button-transition";++export const Scene = () => {+ const trigger = useButtonTransition([+ { at: 14, state: "hover" },+ { at: 26, state: "press" },+ ]);+ const dialog = useDialogTransition([+ { at: 32, state: "opened", duration: 16 },+ { at: 92, state: "closed", duration: 12 },+ ]);++ return (+ <>+ <Button label="Edit profile" style={trigger} />+ <Dialog style={dialog} />+ </>+ );+};`;diff --git a/components/docs/examples/index.tsx b/components/docs/examples/index.tsxindex bb76eecb..97b578b1 100644--- a/components/docs/examples/index.tsx+++ b/components/docs/examples/index.tsx@@ -8,6 +8,7 @@ import {AlertDialogExampleScene,alertDialogExampleCode,} from "./alert-dialog-example";+import { DialogExampleScene, dialogExampleCode } from "./dialog-example";import { ButtonExampleScene, buttonExampleCode } from "./button-example";import {CheckboxExampleScene,@@ -58,6 +59,15 @@ export const examples: Record<string, ExampleEntry> = {width: W,height: H,},+ "dialog-example": {+ Component: DialogExampleScene,+ code: dialogExampleCode,+ // Dialog closes at 92 + dur 12 = 104; a short settle then loop.+ durationInFrames: 120,+ fps: FPS,+ width: W,+ height: H,+ },"checkbox-example": {Component: CheckboxExampleScene,code: checkboxExampleCode,diff --git a/content/docs/ui/components/dialog.mdx b/content/docs/ui/components/dialog.mdxnew file mode 100644index 00000000..7113e92d--- /dev/null+++ b/content/docs/ui/components/dialog.mdx@@ -0,0 +1,144 @@+---+title: Dialog+description: A modal dialog whose opened/closed state is a pure function of the timeline+---++<ComponentPreview name="dialog" />++A state atom whose appearance (closed, opened) is a pure function of the `state` prop. Pass a state directly or drive it from the Remotion timeline via `useCurrentState`. The component reads no frame — only the state value you give it. The wrapper is transparent by design: Dialog is a modal layer meant to compose over another scene, so it does not paint an opaque background. Unlike AlertDialog, Dialog is a generic (non-destructive) modal — its primary action uses the theme `primary` color, and it renders a close (X) button in the top-right corner of the popup card.++## Installation++<InstallBlock name="dialog" />++<Note>+Installing `dialog` automatically installs the shared `remocn-ui` core (`lib/remocn-ui/`) via `registryDependencies` (`["remocn-ui"]`). You do not need to install it separately. If you want to pair Dialog with the Button as its trigger in the canonical lifecycle example, install `button` separately.+</Note>++## States++`DialogState` is:++```ts+type DialogState =+ | "opened" // backdrop dims to 50% black, popup fades in and zooms from 0.95 → 1+ | "closed" // panel hidden, backdrop clear (overlay opacity 0, popup opacity 0, scale 0.95)+```++`opened` reveals the backdrop dim (scales up to `MAX_OVERLAY_ALPHA = 0.5`) and fades the popup card in while zooming it from `0.95` to `1` and lifting it 8 px upward. `closed` hides the backdrop and the popup entirely.++## Snap usage++Pass `state` directly — the component snaps instantly to that visual. Useful for static previews or when you drive state from your own logic:++```tsx+import { Dialog } from "@/components/remocn/dialog";++export const Scene = () => <Dialog state="opened" />;+```++To drive state from the timeline, use `useCurrentState`:++```tsx+import { useCurrentState } from "@/lib/remocn-ui";+import { Dialog } from "@/components/remocn/dialog";++export const Scene = () => {+ const state = useCurrentState(+ [+ { at: 32, state: "opened" },+ { at: 92, state: "closed" },+ ],+ "closed",+ );++ return <Dialog title="Edit profile" state={state} />;+};+```++Each `at` is a **Sequence-local authored frame**. State persists between steps: `opened` at frame 32 keeps the dialog visible until `closed` fires at frame 92. See [Concepts](/docs/ui/concepts) for the full `useCurrentState` API.++## Smooth transitions++State changes via `state` snap with no cross-fade. For animated transitions, use `useDialogTransition` from the copied `use-dialog-transition.ts` file. It reads the frame, interpolates between state presets, and returns a resolved `DialogStyle` — pass it to the `style` prop:++```tsx+import { Dialog } from "@/components/remocn/dialog";+import { useDialogTransition } from "@/components/remocn/use-dialog-transition";++export const Scene = () => {+ const style = useDialogTransition([+ { at: 32, state: "opened", duration: 16 },+ { at: 92, state: "closed", duration: 12 },+ ]);+ return <Dialog title="Edit profile" style={style} />;+};+```++The `duration` field on each step overrides the file's `DEFAULT_DURATION` (= `12`) for that specific transition. To globally tune timing and easing, edit `use-dialog-transition.ts` directly in your project — that file is yours (shadcn "own your code" philosophy).++`style` takes precedence over `state` when both are provided.++## Full lifecycle++The live example composes **Button as the trigger**: a primary Button animates through `hover` → `press` states (the "click"), and the dialog opens right after the press lands, then closes near the end. Copy the code to drop it into your own composition.++<LiveExample name="dialog-example" />++## Props++<PropsTable+ rows={[+ {+ name: "state",+ type: "\"opened\" | \"closed\"",+ default: "\"closed\"",+ description: "Current visual state (snap path). State changes snap — no automatic cross-fade.",+ },+ {+ name: "style",+ type: "DialogStyle",+ description: "Resolved animated visual (smooth path). Pass an interpolated DialogStyle from useDialogTransition. Takes precedence over state when provided.",+ },+ {+ name: "title",+ type: "string",+ default: "\"Edit profile\"",+ description: "Headline of the dialog popup.",+ },+ {+ name: "description",+ type: "string",+ default: "\"Make changes to your profile here. Click save when you're done.\"",+ description: "Body copy displayed under the title.",+ },+ {+ name: "actionLabel",+ type: "string",+ default: "\"Save changes\"",+ description: "Label of the confirming (primary) action button.",+ },+ {+ name: "cancelLabel",+ type: "string",+ default: "\"Cancel\"",+ description: "Label of the dismissing action button.",+ },+ {+ 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 popup card element.",+ },+ ]}+/>diff --git a/content/docs/ui/components/meta.json b/content/docs/ui/components/meta.jsonindex 9e9ac2a2..4271a7d6 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", "dropdown-menu", "input", "radio", "select", "spinner", "switch"]+ "pages": ["accordion", "alert-dialog", "button", "checkbox", "dialog", "dropdown-menu", "input", "radio", "select", "spinner", "switch"]}diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex f49f7cb5..fee20b8d 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -109,6 +109,8 @@ import { Accordion } from "@/registry/remocn-ui/accordion";import { accordionConfig } from "@/registry/remocn-ui/accordion/config";import { AlertDialog } from "@/registry/remocn-ui/alert-dialog";import { alertDialogConfig } from "@/registry/remocn-ui/alert-dialog/config";+import { Dialog } from "@/registry/remocn-ui/dialog";+import { dialogConfig } from "@/registry/remocn-ui/dialog/config";import { Button } from "@/registry/remocn-ui/button";import { buttonConfig } from "@/registry/remocn-ui/button/config";import { Checkbox } from "@/registry/remocn-ui/checkbox";@@ -305,6 +307,7 @@ const registry: Record<string, RegistryEntry> = {"button": { Component: Button, config: buttonConfig },"accordion": { Component: Accordion, config: accordionConfig },"alert-dialog": { Component: AlertDialog, config: alertDialogConfig },+ "dialog": { Component: Dialog, config: dialogConfig },"checkbox": { Component: Checkbox, config: checkboxConfig },"input": { Component: Input, config: inputConfig },"radio": { Component: Radio, config: radioConfig },diff --git a/registry/remocn-ui/dialog/__tests__/README.md b/registry/remocn-ui/dialog/__tests__/README.mdnew file mode 100644index 00000000..3ab80b83--- /dev/null+++ b/registry/remocn-ui/dialog/__tests__/README.md@@ -0,0 +1,130 @@+# `dialog` — verification tests++Pure / deterministic verification for the `dialog` component+(`registry/remocn-ui/dialog/`). The RENDER path needs `useRemocnTheme()`+and the Remotion render tree and cannot run headless, so the render is NOT+exercised here. This suite covers the pieces that ARE pure: `DialogState`+union membership, `dialogConfig.controls` wiring, `dialogConfig.snippet`+codegen, `dialogStyle` presets, `tweenDialogStyle` interpolation, and+`DEFAULT_DURATION`.++## Animation model — pure snap + opt-in smooth path++Dialog ships two complementary paths:++**Snap path** (`state?: DialogState` prop):+`Dialog` is a frame-free pure renderer. The `state` prop drives all visuals.+Each state maps to a complete resting visual via the exported pure function+`dialogStyle(state, ctx) => DialogStyle`. State changes snap instantly —+no tweening inside the component.++**Smooth path** (`style?: DialogStyle` prop):+Callers opt in to smooth transitions by passing a pre-interpolated+`DialogStyle` to the `style` prop. The caller — typically+`useDialogTransition` — reads `useCurrentFrame()` and calls+`useStateTransition` from `core/timeline.ts` to compute+`{ from, to, progress }`, then blends the two presets via+`tweenDialogStyle(from, to, t)`. The `Dialog` component itself remains+frame-free; it simply renders whatever `DialogStyle` it receives.++This design keeps `Dialog` pure-testable (no Remotion render context needed)+while still supporting smooth open/close transitions for production use.++## How to run++> **The user (not the agent) runs verification.** Do not run this command+> automatically — always wait for the user to run it.++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/dialog/__tests__+```++`dialog.test.ts` imports `bun:test` (not `vitest`/`jest`), so no test+script or framework dep is added to `package.json`.++## What is covered++- **`DialogState` union** — asserts the two states `["opened", "closed"]`+ are the complete set (via the real `controls.state.options` list from+ `config.ts`).+- **`dialogConfig.controls.state`** — the customizer control wiring. Asserts+ a `select` control exists with exactly those two options in order, default+ `"opened"` (so the preview showcases the popup), and that every option is a+ member of the `DialogState` union.+- **`dialogConfig.snippet`** — REAL pure string builder (high value).+ Asserts: always emits `state="<state>"` for every option; NEVER emits `steps`;+ includes `import { Dialog }` from `@/components/remocn/dialog`;+ omits default-equal props (`title="Edit profile"`, the default description+ `"Make changes to your profile here. Click save when you're done."`,+ `actionLabel="Save changes"`, `cancelLabel="Cancel"`, `mode="light"`); EMITS+ non-default `title`/`description`/`actionLabel`/`cancelLabel`/`mode`;+ structural round-trip (starts with import, contains `<Dialog`, ends `/>`).+ Note: `action=` is not checked for absence because `actionLabel=` is a+ legitimate emitted prop — only `steps` is asserted absent.+- **`dialogStyleContext`** — exported pure `(theme) => DialogStyleContext`+ (takes only `theme`, no variant — unlike accordion). Built from+ `dialogStyleContext(defaultLightTheme)`. Asserts each field+ (`popoverBg`, `popoverFg`, `mutedFg`, `border`, `actionBg`, `actionFg`,+ `cancelFg`) is a non-empty string, and `radius` is a number.+- **`dialogStyle` presets** — exported pure `(state, ctx) => DialogStyle`.+ All four fields (`overlayOpacity`, `popupOpacity`, `popupScale`,+ `popupTranslateY`) are numeric. Asserts per-state invariants: closed →+ `{ 0, 0, 0.95, 8 }`; opened → `{ 1, 1, 1, 0 }`.+- **`tweenDialogStyle`** — exported pure `(a, b, t) => DialogStyle`.+ All four fields are pure numeric lerps (no color fields). Asserts: at t=0 all+ fields equal `a`; at t=1 all equal `b`; at t=0.5 each field is the exact+ midpoint (`overlayOpacity` 0.5, `popupOpacity` 0.5, `popupScale` 0.975,+ `popupTranslateY` 4). Both directions (closed→opened and opened→closed) are+ verified.+- **`DEFAULT_DURATION`** — sanity-checks the exported constant is a positive+ number equal to 12.++**Dialog render** is a pure `(style | state) => visual` observable only via+Remotion render, not unit-tested here.++## Import strategy++`dialog.test.ts` imports via a mix of **relative paths** and the+**`@/lib/remocn-ui` tsconfig alias**:++- `../index` — relative, for `DialogState`, `dialogStyle`,+ `dialogStyleContext`+- `../use-dialog-transition` — relative, for `tweenDialogStyle`,+ `DEFAULT_DURATION`+- `../config` — relative, for `dialogConfig`+- `@/lib/remocn-ui` — alias (resolves to `registry/remocn-ui/core/index.ts`),+ for `defaultLightTheme`++Importing `index.tsx` and `use-dialog-transition.ts` pulls the `remotion`+module (and React), but neither `dialogStyle`, `dialogStyleContext`,+nor `tweenDialogStyle` call `useCurrentFrame()` at import time or at call+time — they are pure value functions. `bun test` resolves tsconfig `paths`, so+the alias works without additional config.++## Determinism grep checklist (run manually; must print NOTHING)++Dialog is a state atom and must be frame-free. The component's `index.tsx`+must contain **none** of the following:++```bash+grep -nE "useState|useEffect|useCurrentFrame|onClick|onChange|addEventListener|Date\.now|Math\.random|requestAnimationFrame" \+ registry/remocn-ui/dialog/index.tsx+```++Expected: no output. Any match is a determinism violation.++`use-dialog-transition.ts` is the CALLER hook that intentionally reads+`useCurrentFrame()` (via `useStateTransition`). It is not a render component;+the smooth-path design isolates all frame-reading to the hook, keeping+`Dialog` pure.++Tier-wide sweep:++```bash+grep -nE "useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \+ registry/remocn-ui/dialog/index.tsx registry/remocn-ui/core/*.ts+```diff --git a/registry/remocn-ui/dialog/__tests__/dialog.test.ts b/registry/remocn-ui/dialog/__tests__/dialog.test.tsnew file mode 100644index 00000000..3638d491--- /dev/null+++ b/registry/remocn-ui/dialog/__tests__/dialog.test.ts@@ -0,0 +1,474 @@+/**+ * Verification tests for the PURE / DETERMINISTIC parts of `dialog`.+ *+ * Scope:+ * - registry/remocn-ui/dialog/index.tsx — DialogState union membership,+ * dialogStyle presets, dialogStyleContext+ * - registry/remocn-ui/dialog/config.ts — dialogConfig.controls wiring+ * + dialogConfig.snippet output (the state → JSX codegen)+ * - registry/remocn-ui/dialog/use-dialog-transition.ts+ * — tweenDialogStyle interpolation, DEFAULT_DURATION+ *+ * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.+ * `<Dialog>` reads `useRemocnTheme()` internally — that hook is pure at+ * call-time in test context, but the JSX render tree is not exercised here.+ * The pure-testable surface is: the style presets + tween + customizer wiring+ * + snippet codegen.+ *+ * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).+ * bun test registry/remocn-ui/dialog/__tests__+ *+ * --------------------------------------------------------------------------+ * IMPORT STRATEGY+ * --------------------------------------------------------------------------+ * `config.ts` imports `DialogState` from `@/registry/remocn-ui/dialog`+ * and the pieces under test never CALL a Remotion runtime API at import time —+ * `dialogConfig` is a plain object; `.snippet` is a pure string builder;+ * `dialogStyle` and `tweenDialogStyle` are pure value functions.+ * We import via RELATIVE paths (matching the existing test suite pattern),+ * annotating each import with the source it corresponds to.+ * --------------------------------------------------------------------------+ */++import { describe, expect, it } from "bun:test";+import {+ type DialogState,+ dialogStyle,+ dialogStyleContext,+} from "../index";+import { tweenDialogStyle, DEFAULT_DURATION } from "../use-dialog-transition";+import { dialogConfig } from "../config";+import { defaultLightTheme } from "@/lib/remocn-ui";++// ===========================================================================+// Shared fixtures+// ===========================================================================++/**+ * The DialogState union, enumerated as a runtime list for membership checks.+ * Must stay in sync with `export type DialogState` in index.tsx.+ */+const VALID_STATES: readonly DialogState[] = ["opened", "closed"];++/** Minimal shape mirroring the customizer's value bag passed to snippet(). */+type SnippetValues = {+ state?: string;+ title?: string;+ description?: string;+ actionLabel?: string;+ cancelLabel?: string;+ mode?: string;+};++const snippet = (values: SnippetValues): string =>+ dialogConfig.snippet(values as Record<string, unknown>);++/**+ * A shared DialogStyleContext built from the default light theme.+ * `dialogStyleContext` takes only `(theme)` — no variant arg, unlike accordion.+ */+const ctx = dialogStyleContext(defaultLightTheme);++// ===========================================================================+// 1. DialogState union membership+// ===========================================================================++describe("DialogState union", () => {+ it("contains exactly the two documented states", () => {+ // We can't enumerate a TS type at runtime, but we can assert the REAL+ // controls.state options match and that all known states are members.+ const control = dialogConfig.controls.state;+ if (control.type !== "select") throw new Error("state control must be a select");+ expect(control.options).toEqual(["opened", "closed"]);+ });++ it("every VALID_STATES entry is assignable (no typos in the fixture)", () => {+ // Belt-and-suspenders: the fixture array must have exactly 2 entries and+ // match the options list from the real config.+ const control = dialogConfig.controls.state;+ if (control.type !== "select") throw new Error("state control must be a select");+ expect(VALID_STATES).toHaveLength(2);+ for (const s of VALID_STATES) {+ expect(control.options).toContain(s);+ }+ });+});++// ===========================================================================+// 2. dialogConfig.controls.state — customizer control wiring+// ===========================================================================++describe("dialogConfig.controls.state", () => {+ it("is a select control", () => {+ expect(dialogConfig.controls.state.type).toBe("select");+ });++ it("has exactly the two DialogState options in order", () => {+ const control = dialogConfig.controls.state;+ if (control.type !== "select") throw new Error("state control must be a select");+ expect(control.options).toEqual(["opened", "closed"]);+ });++ it("defaults to 'opened' so the preview showcases the popup", () => {+ const control = dialogConfig.controls.state;+ expect(control.default).toBe("opened");+ });++ it("every option is a member of the DialogState union", () => {+ const control = dialogConfig.controls.state;+ if (control.type !== "select") throw new Error("state control must be a select");+ for (const option of control.options) {+ expect(VALID_STATES).toContain(option as DialogState);+ }+ });+});++// ===========================================================================+// 3. dialogConfig.snippet — pure string builder+// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.+// It NEVER emits `steps`.+// Note on `action`: the snippet emits `actionLabel=` (a legitimate prop) but+// must never emit a bare `action=` attribute. We assert `steps` is absent and+// add a targeted check that `action=` only ever appears as `actionLabel=`.+// ===========================================================================++describe("dialogConfig.snippet: state prop emission", () => {+ it("emits state=\"opened\" for the opened option", () => {+ expect(snippet({ state: "opened" })).toContain('state="opened"');+ });++ it("emits state=\"closed\" for the closed option", () => {+ expect(snippet({ state: "closed" })).toContain('state="closed"');+ });++ it("emits the correct state for every control option", () => {+ const control = dialogConfig.controls.state;+ if (control.type !== "select") throw new Error("state control must be a select");+ for (const state of control.options) {+ const out = snippet({ state });+ expect(out).toContain(`state="${state}"`);+ }+ });+});++describe("dialogConfig.snippet: NEVER emits steps", () => {+ // `action=` is intentionally NOT checked here because `actionLabel=` is a+ // legitimate emitted prop and would cause a false positive on a naive+ // `.toContain("action")` check. Assert `steps` absence only.+ it("never emits `steps` in any state", () => {+ for (const state of VALID_STATES) {+ expect(snippet({ state })).not.toContain("steps");+ }+ });+});++describe("dialogConfig.snippet: import line", () => {+ it("includes `import { Dialog }` from the correct path", () => {+ const out = snippet({ state: "opened" });+ expect(out).toContain('import { Dialog }');+ expect(out).toContain('from "@/components/remocn/dialog"');+ });+});++describe("dialogConfig.snippet: default props are omitted", () => {+ // Defaults: title="Edit profile",+ // description="Make changes to your profile here. Click save when you're done.",+ // actionLabel="Save changes", cancelLabel="Cancel", mode="light"+ const allDefaults = snippet({+ state: "opened",+ title: "Edit profile",+ description: "Make changes to your profile here. Click save when you're done.",+ actionLabel: "Save changes",+ cancelLabel: "Cancel",+ mode: "light",+ });++ it("omits title when it equals the default 'Edit profile'", () => {+ expect(allDefaults).not.toContain("title=");+ });++ it("omits description when it equals the default text", () => {+ expect(allDefaults).not.toContain("description=");+ });++ it("omits actionLabel when it equals the default 'Save changes'", () => {+ expect(allDefaults).not.toContain("actionLabel=");+ });++ it("omits cancelLabel when it equals the default 'Cancel'", () => {+ expect(allDefaults).not.toContain("cancelLabel=");+ });++ it("omits mode when it equals the default 'light'", () => {+ expect(allDefaults).not.toContain("mode=");+ });+});++describe("dialogConfig.snippet: non-default props are emitted", () => {+ it("emits a non-default title", () => {+ expect(snippet({ state: "opened", title: "Edit workspace settings" }))+ .toContain('title="Edit workspace settings"');+ });++ it("emits a non-default description", () => {+ expect(snippet({ state: "opened", description: "Update your workspace name and settings." }))+ .toContain('description="Update your workspace name and settings."');+ });++ it("emits a non-default actionLabel", () => {+ expect(snippet({ state: "opened", actionLabel: "Confirm" }))+ .toContain('actionLabel="Confirm"');+ });++ it("emits a non-default cancelLabel", () => {+ expect(snippet({ state: "opened", cancelLabel: "Go back" }))+ .toContain('cancelLabel="Go back"');+ });++ it("emits a non-default mode", () => {+ expect(snippet({ state: "opened", mode: "dark" }))+ .toContain('mode="dark"');+ });+});++describe("dialogConfig.snippet: structural round-trip", () => {+ const out = snippet({ state: "opened" });++ it("starts with the import line", () => {+ expect(out.startsWith('import { Dialog }')).toBe(true);+ });++ it("contains a <Dialog JSX opening", () => {+ expect(out).toContain("<Dialog");+ });++ it("ends with a self-closing />", () => {+ expect(out.trimEnd().endsWith("/>")).toBe(true);+ });+});++// ===========================================================================+// 4. dialogStyleContext — derives concrete colors from the theme.+// Signature is `(theme)` — NO variant argument (unlike accordion).+// Build ctx from the default light theme and assert each field is populated.+// `radius` is a number (px); all other fields are non-empty strings.+// ===========================================================================++describe("dialogStyleContext: field types from defaultLightTheme", () => {+ it("popoverBg is a non-empty string", () => {+ expect(typeof ctx.popoverBg).toBe("string");+ expect(ctx.popoverBg.length).toBeGreaterThan(0);+ });++ it("popoverFg is a non-empty string", () => {+ expect(typeof ctx.popoverFg).toBe("string");+ expect(ctx.popoverFg.length).toBeGreaterThan(0);+ });++ it("mutedFg is a non-empty string", () => {+ expect(typeof ctx.mutedFg).toBe("string");+ expect(ctx.mutedFg.length).toBeGreaterThan(0);+ });++ it("border is a non-empty string", () => {+ expect(typeof ctx.border).toBe("string");+ expect(ctx.border.length).toBeGreaterThan(0);+ });++ it("radius is a number", () => {+ expect(typeof ctx.radius).toBe("number");+ });++ it("actionBg is a non-empty string", () => {+ expect(typeof ctx.actionBg).toBe("string");+ expect(ctx.actionBg.length).toBeGreaterThan(0);+ });++ it("actionFg is a non-empty string", () => {+ expect(typeof ctx.actionFg).toBe("string");+ expect(ctx.actionFg.length).toBeGreaterThan(0);+ });++ it("cancelFg is a non-empty string", () => {+ expect(typeof ctx.cancelFg).toBe("string");+ expect(ctx.cancelFg.length).toBeGreaterThan(0);+ });+});++// ===========================================================================+// 5. dialogStyle presets — pure (state, ctx) => DialogStyle+// dialogStyleContext and dialogStyle are exported and frame-free.+// Build one ctx from the default light theme, then assert the numeric+// invariants for every state.+// ===========================================================================++describe("dialogStyle: closed state", () => {+ const s = dialogStyle("closed", ctx);++ it("overlayOpacity is 0 (overlay fully hidden)", () => {+ expect(s.overlayOpacity).toBe(0);+ });++ it("popupOpacity is 0 (popup fully hidden)", () => {+ expect(s.popupOpacity).toBe(0);+ });++ it("popupScale is 0.95 (popup slightly shrunk)", () => {+ expect(s.popupScale).toBe(0.95);+ });++ it("popupTranslateY is 8 (popup shifted down 8px)", () => {+ expect(s.popupTranslateY).toBe(8);+ });+});++describe("dialogStyle: opened state", () => {+ const s = dialogStyle("opened", ctx);++ it("overlayOpacity is 1 (overlay fully revealed)", () => {+ expect(s.overlayOpacity).toBe(1);+ });++ it("popupOpacity is 1 (popup fully visible)", () => {+ expect(s.popupOpacity).toBe(1);+ });++ it("popupScale is 1 (popup at full size)", () => {+ expect(s.popupScale).toBe(1);+ });++ it("popupTranslateY is 0 (popup at natural position)", () => {+ expect(s.popupTranslateY).toBe(0);+ });+});++describe("dialogStyle: closed/opened invariant", () => {+ it("closed: overlayOpacity 0, popupOpacity 0, popupScale 0.95, popupTranslateY 8", () => {+ const s = dialogStyle("closed", ctx);+ expect(s.overlayOpacity).toBe(0);+ expect(s.popupOpacity).toBe(0);+ expect(s.popupScale).toBe(0.95);+ expect(s.popupTranslateY).toBe(8);+ });++ it("opened: overlayOpacity 1, popupOpacity 1, popupScale 1, popupTranslateY 0", () => {+ const s = dialogStyle("opened", ctx);+ expect(s.overlayOpacity).toBe(1);+ expect(s.popupOpacity).toBe(1);+ expect(s.popupScale).toBe(1);+ expect(s.popupTranslateY).toBe(0);+ });+});++// ===========================================================================+// 6. tweenDialogStyle — pure linear interpolation between two DialogStyles.+// All four fields are pure numeric lerps (no color fields, unlike accordion).+// Concrete expectations: closed → opened for midpoint math.+// ===========================================================================++describe("tweenDialogStyle: t=0 returns values equal to `a`", () => {+ const a = dialogStyle("closed", ctx);+ const b = dialogStyle("opened", ctx);+ const r = tweenDialogStyle(a, b, 0);++ it("overlayOpacity equals a.overlayOpacity at t=0", () => {+ expect(r.overlayOpacity).toBeCloseTo(a.overlayOpacity, 10);+ });++ it("popupOpacity equals a.popupOpacity at t=0", () => {+ expect(r.popupOpacity).toBeCloseTo(a.popupOpacity, 10);+ });++ it("popupScale equals a.popupScale at t=0", () => {+ expect(r.popupScale).toBeCloseTo(a.popupScale, 10);+ });++ it("popupTranslateY equals a.popupTranslateY at t=0", () => {+ expect(r.popupTranslateY).toBeCloseTo(a.popupTranslateY, 10);+ });+});++describe("tweenDialogStyle: t=1 returns values equal to `b`", () => {+ const a = dialogStyle("closed", ctx);+ const b = dialogStyle("opened", ctx);+ const r = tweenDialogStyle(a, b, 1);++ it("overlayOpacity equals b.overlayOpacity at t=1", () => {+ expect(r.overlayOpacity).toBeCloseTo(b.overlayOpacity, 10);+ });++ it("popupOpacity equals b.popupOpacity at t=1", () => {+ expect(r.popupOpacity).toBeCloseTo(b.popupOpacity, 10);+ });++ it("popupScale equals b.popupScale at t=1", () => {+ expect(r.popupScale).toBeCloseTo(b.popupScale, 10);+ });++ it("popupTranslateY equals b.popupTranslateY at t=1", () => {+ expect(r.popupTranslateY).toBeCloseTo(b.popupTranslateY, 10);+ });+});++describe("tweenDialogStyle: t=0.5 midpoint numeric lerp (closed → opened)", () => {+ // closed: overlayOpacity=0, popupOpacity=0, popupScale=0.95, popupTranslateY=8+ // opened: overlayOpacity=1, popupOpacity=1, popupScale=1, popupTranslateY=0+ const a = dialogStyle("closed", ctx);+ const b = dialogStyle("opened", ctx);+ const r = tweenDialogStyle(a, b, 0.5);++ it("overlayOpacity midpoint: 0 → 1 gives 0.5", () => {+ expect(r.overlayOpacity).toBeCloseTo(0.5, 10);+ });++ it("popupOpacity midpoint: 0 → 1 gives 0.5", () => {+ expect(r.popupOpacity).toBeCloseTo(0.5, 10);+ });++ it("popupScale midpoint: 0.95 → 1 gives 0.975", () => {+ expect(r.popupScale).toBeCloseTo(0.975, 10);+ });++ it("popupTranslateY midpoint: 8 → 0 gives 4", () => {+ expect(r.popupTranslateY).toBeCloseTo(4, 10);+ });+});++describe("tweenDialogStyle: t=0.5 midpoint numeric lerp (opened → closed)", () => {+ // opened: overlayOpacity=1, popupOpacity=1, popupScale=1, popupTranslateY=0+ // closed: overlayOpacity=0, popupOpacity=0, popupScale=0.95, popupTranslateY=8+ const a = dialogStyle("opened", ctx);+ const b = dialogStyle("closed", ctx);+ const r = tweenDialogStyle(a, b, 0.5);++ it("overlayOpacity midpoint: 1 → 0 gives 0.5", () => {+ expect(r.overlayOpacity).toBeCloseTo(0.5, 10);+ });++ it("popupOpacity midpoint: 1 → 0 gives 0.5", () => {+ expect(r.popupOpacity).toBeCloseTo(0.5, 10);+ });++ it("popupScale midpoint: 1 → 0.95 gives 0.975", () => {+ expect(r.popupScale).toBeCloseTo(0.975, 10);+ });++ it("popupTranslateY midpoint: 0 → 8 gives 4", () => {+ expect(r.popupTranslateY).toBeCloseTo(4, 10);+ });+});++// ===========================================================================+// 7. DEFAULT_DURATION — sanity check the exported constant+// ===========================================================================++describe("DEFAULT_DURATION", () => {+ it("is a positive number", () => {+ expect(typeof DEFAULT_DURATION).toBe("number");+ expect(DEFAULT_DURATION).toBeGreaterThan(0);+ });++ it("equals 12 (the authored value)", () => {+ expect(DEFAULT_DURATION).toBe(12);+ });+});diff --git a/registry/remocn-ui/dialog/config.ts b/registry/remocn-ui/dialog/config.tsnew file mode 100644index 00000000..b61083d1--- /dev/null+++ b/registry/remocn-ui/dialog/config.ts@@ -0,0 +1,67 @@+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";+import type { DialogState } from "@/registry/remocn-ui/dialog";++const DEFAULT_DESCRIPTION =+ "Make changes to your profile here. Click save when you're done.";++export const dialogConfig: ComponentConfig = {+ componentName: "Dialog",+ importPath: "@/components/remocn/dialog",+ controls: {+ title: { type: "text", default: "Edit profile", label: "Title" },+ description: {+ type: "text",+ default: DEFAULT_DESCRIPTION,+ label: "Description",+ },+ actionLabel: {+ type: "text",+ default: "Save changes",+ label: "Action Label",+ },+ cancelLabel: { type: "text", default: "Cancel", label: "Cancel Label" },+ state: {+ type: "select",+ // Default to `opened` so the preview shows the popup.+ default: "opened",+ options: ["opened", "closed"],+ label: "State",+ },+ mode: {+ type: "select",+ default: "light",+ options: ["light", "dark"],+ label: "Mode",+ },+ },+ durationInFrames: 120,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ snippet: (values) => {+ const state = (values.state as DialogState) ?? "opened";+ const title = values.title as string | undefined;+ const description = values.description as string | undefined;+ const actionLabel = values.actionLabel as string | undefined;+ const cancelLabel = values.cancelLabel as string | undefined;+ const mode = values.mode as string | undefined;++ const props: string[] = [` state="${state}"`];+ if (title !== undefined && title !== "Edit profile")+ props.push(` title="${title}"`);+ if (description !== undefined && description !== DEFAULT_DESCRIPTION)+ props.push(` description="${description}"`);+ if (actionLabel !== undefined && actionLabel !== "Save changes")+ props.push(` actionLabel="${actionLabel}"`);+ if (cancelLabel !== undefined && cancelLabel !== "Cancel")+ props.push(` cancelLabel="${cancelLabel}"`);+ if (mode !== undefined && mode !== "light")+ props.push(` mode="${mode}"`);++ return `import { Dialog } from "@/components/remocn/dialog";++<Dialog+${props.join("\n")}+/>`;+ },+};diff --git a/registry/remocn-ui/dialog/index.tsx b/registry/remocn-ui/dialog/index.tsxnew file mode 100644index 00000000..f255ca81--- /dev/null+++ b/registry/remocn-ui/dialog/index.tsx@@ -0,0 +1,259 @@+"use client";++import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";++export type DialogState = "opened" | "closed";++export interface DialogProps {+ /** Current visual state (snap path). State changes snap (no enter-tweens). */+ state?: DialogState;+ /**+ * Resolved animated visual (smooth path). When provided, takes precedence over+ * `state` — feed it an interpolated `DialogStyle` from `useDialogTransition`.+ */+ style?: DialogStyle;+ /** Headline of the dialog. */+ title?: string;+ /** Body copy under the title. */+ description?: string;+ /** Label of the confirming (primary) action. */+ actionLabel?: string;+ /** Label of the dismissing action. */+ cancelLabel?: string;+ theme?: Partial<RemocnTheme>;+ mode?: "light" | "dark";+ className?: string;+}++/** Popup card width (px). */+const POPUP_WIDTH = 440;+/** Backdrop dim at full reveal — the overlay opacity scales up to this alpha. */+const MAX_OVERLAY_ALPHA = 0.5;++// ===========================================================================+// Dialog visual — the COMPLETE animated look for a moment in time. A `state` is+// a named preset of this visual (`dialogStyle`); the smooth path feeds an+// interpolated `DialogStyle` straight through. The component is a pure renderer+// of whichever `DialogStyle` it receives.+// ===========================================================================++export interface DialogStyle {+ /** Backdrop dim reveal 0→1 (scales `MAX_OVERLAY_ALPHA`). */+ overlayOpacity: number;+ /** Popup fade 0→1. */+ popupOpacity: number;+ /** Popup zoom 0.95→1. */+ popupScale: number;+ /** Popup lift 8→0 (px). */+ popupTranslateY: number;+}++/** Concrete colors for the active theme, resolved once per render. */+export interface DialogStyleContext {+ popoverBg: string;+ popoverFg: string;+ mutedFg: string;+ border: string;+ radius: number;+ actionBg: string;+ actionFg: string;+ cancelFg: string;+}++/**+ * Derive the concrete colors for a theme. Pure — call it once and reuse the+ * result for every `dialogStyle(state, ctx)` preset.+ */+export function dialogStyleContext(theme: RemocnTheme): DialogStyleContext {+ return {+ popoverBg: theme.popover,+ popoverFg: theme.popoverForeground,+ mutedFg: theme.mutedForeground,+ border: theme.border,+ radius: theme.radius,+ // The action is the PRIMARY (affirmative) action — not destructive.+ actionBg: theme.primary,+ actionFg: theme.primaryForeground,+ cancelFg: theme.foreground,+ };+}++/**+ * The COMPLETE resting visual for a state — a pure `(state, ctx) => DialogStyle`+ * map. To change how a state looks, edit one entry.+ */+export function dialogStyle(+ state: DialogState,+ _ctx: DialogStyleContext,+): DialogStyle {+ switch (state) {+ case "opened":+ return {+ overlayOpacity: 1,+ popupOpacity: 1,+ popupScale: 1,+ popupTranslateY: 0,+ };+ default:+ return {+ overlayOpacity: 0,+ popupOpacity: 0,+ popupScale: 0.95,+ popupTranslateY: 8,+ };+ }+}++export function Dialog({+ state = "closed",+ style,+ title = "Edit profile",+ description = "Make changes to your profile here. Click save when you're done.",+ actionLabel = "Save changes",+ cancelLabel = "Cancel",+ theme: themeOverride,+ mode,+ className,+}: DialogProps) {+ const theme = useRemocnTheme(themeOverride, mode);++ const ctx = dialogStyleContext(theme);+ const v = style ?? dialogStyle(state, ctx);++ // Shared base for the two footer buttons. These are plain inline `<button>`s,+ // not the remocn `Button` component — that renders a full-frame scene wrapper+ // (absolute inset) and so can't nest inline here; the sizing mirrors its+ // `default` size.+ const buttonBase: React.CSSProperties = {+ height: 40,+ padding: "0 20px",+ fontSize: 15,+ fontWeight: 500,+ letterSpacing: "-0.01em",+ borderRadius: ctx.radius,+ display: "inline-flex",+ alignItems: "center",+ justifyContent: "center",+ cursor: "pointer",+ };++ return (+ // The wrapper is TRANSPARENT — unlike button/accordion (which paint an+ // opaque `theme.background`), this atom is a modal layer meant to compose+ // OVER another scene, so it must not blanket the frame with a background.+ <div+ style={{+ position: "absolute",+ inset: 0,+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ fontFamily:+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",+ }}+ >+ {/* Backdrop dim — fades in as the dialog opens. */}+ <div+ style={{+ position: "absolute",+ inset: 0,+ background: `rgba(0, 0, 0, ${MAX_OVERLAY_ALPHA * v.overlayOpacity})`,+ }}+ />+ <div+ className={className}+ style={{+ position: "relative",+ width: POPUP_WIDTH,+ transform: `translateY(${v.popupTranslateY}px) scale(${v.popupScale})`,+ opacity: v.popupOpacity,+ background: ctx.popoverBg,+ color: ctx.popoverFg,+ border: `1px solid ${ctx.border}`,+ borderRadius: ctx.radius + 6,+ padding: 24,+ display: "flex",+ flexDirection: "column",+ gap: 8,+ boxShadow: "0 24px 48px -12px rgba(0,0,0,0.25)",+ }}+ >+ {/* Close (X) — static chrome in the top-right corner, not animated. */}+ <button+ type="button"+ style={{+ position: "absolute",+ top: 16,+ right: 16,+ width: 28,+ height: 28,+ display: "inline-flex",+ alignItems: "center",+ justifyContent: "center",+ background: "transparent",+ border: "none",+ borderRadius: ctx.radius,+ color: ctx.mutedFg,+ cursor: "pointer",+ }}+ >+ <svg width={16} height={16} viewBox="0 0 24 24" fill="none">+ <path+ d="M18 6 6 18 M6 6 18 18"+ stroke={ctx.mutedFg}+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ </svg>+ </button>+ <div+ style={{+ fontSize: 18,+ fontWeight: 500,+ letterSpacing: "-0.01em",+ paddingRight: 28,+ }}+ >+ {title}+ </div>+ <div style={{ fontSize: 14, lineHeight: 1.5, color: ctx.mutedFg }}>+ {description}+ </div>+ <div+ style={{+ display: "flex",+ justifyContent: "flex-end",+ gap: 8,+ marginTop: 16,+ }}+ >+ {/* Cancel — outline variant. */}+ <button+ type="button"+ style={{+ ...buttonBase,+ background: "transparent",+ color: ctx.cancelFg,+ border: `1px solid ${ctx.border}`,+ }}+ >+ {cancelLabel}+ </button>+ {/* Action — primary variant. */}+ <button+ type="button"+ style={{+ ...buttonBase,+ background: ctx.actionBg,+ color: ctx.actionFg,+ border: "1px solid transparent",+ }}+ >+ {actionLabel}+ </button>+ </div>+ </div>+ </div>+ );+}diff --git a/registry/remocn-ui/dialog/use-dialog-transition.ts b/registry/remocn-ui/dialog/use-dialog-transition.tsnew file mode 100644index 00000000..0605a0fe--- /dev/null+++ b/registry/remocn-ui/dialog/use-dialog-transition.ts@@ -0,0 +1,68 @@+"use client";++import {+ easings,+ type RemocnTheme,+ type Step,+ useRemocnTheme,+ useStateTransition,+} from "@/lib/remocn-ui";+import {+ dialogStyle,+ dialogStyleContext,+ type DialogState,+ type DialogStyle,+} from "@/components/remocn/dialog";+// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.++/** Default transition length (frames) when a step omits `duration`. Tune to taste. */+export const DEFAULT_DURATION = 12;++/** Blend two dialog visuals: all four fields are pure numeric lerps. */+export function tweenDialogStyle(+ a: DialogStyle,+ b: DialogStyle,+ t: number,+): DialogStyle {+ return {+ overlayOpacity: a.overlayOpacity + (b.overlayOpacity - a.overlayOpacity) * t,+ popupOpacity: a.popupOpacity + (b.popupOpacity - a.popupOpacity) * t,+ popupScale: a.popupScale + (b.popupScale - a.popupScale) * t,+ popupTranslateY:+ a.popupTranslateY + (b.popupTranslateY - a.popupTranslateY) * t,+ };+}++export interface DialogTransitionOptions {+ theme?: Partial<RemocnTheme>;+ mode?: "light" | "dark";+ speed?: number;+ defaultDuration?: number;+}++/**+ * Timeline → resolved (eased, tweened) DialogStyle. The CALLER invokes this;+ * it reads the frame, the `<Dialog>` component does not. Feed the result to+ * `<Dialog style={...} />` for smooth open/close transitions.+ */+export function useDialogTransition(+ steps: Step<DialogState>[],+ opts: DialogTransitionOptions = {},+): DialogStyle {+ const {+ theme: themeOverride,+ mode,+ speed = 1,+ defaultDuration = DEFAULT_DURATION,+ } = opts;+ const theme = useRemocnTheme(themeOverride, mode);+ const ctx = dialogStyleContext(theme);+ const { from, to, progress } = useStateTransition(+ steps,+ "closed",+ speed,+ defaultDuration,+ );+ const t = easings.out(progress);+ return tweenDialogStyle(dialogStyle(from, ctx), dialogStyle(to, ctx), t);+}diff --git a/registry/remocn-ui/registry.json b/registry/remocn-ui/registry.jsonindex 05237b68..ed539828 100644--- a/registry/remocn-ui/registry.json+++ b/registry/remocn-ui/registry.json@@ -117,6 +117,26 @@}]},+ {+ "name": "dialog",+ "type": "registry:component",+ "title": "UI Dialog",+ "description": "A modal dialog whose opened/closed state is a pure function of the timeline; the backdrop dim and popup zoom are keyframed presets, with a close button and a primary action. Self-contained — pair it with the Button as a trigger (see the example).",+ "dependencies": ["remotion"],+ "registryDependencies": ["remocn-ui"],+ "files": [+ {+ "path": "dialog/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/dialog.tsx"+ },+ {+ "path": "dialog/use-dialog-transition.ts",+ "type": "registry:component",+ "target": "components/remocn/use-dialog-transition.ts"+ }+ ]+ },{"name": "checkbox","type": "registry:component",