Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: added alert dialog
dev_wandry9c2070937b27
diff --git a/components/docs/examples/alert-dialog-example.tsx b/components/docs/examples/alert-dialog-example.tsxnew file mode 100644index 00000000..c133ecd7--- /dev/null+++ b/components/docs/examples/alert-dialog-example.tsx@@ -0,0 +1,55 @@+"use client";++import { AlertDialog } from "@/registry/remocn-ui/alert-dialog";+import { useAlertDialogTransition } from "@/registry/remocn-ui/alert-dialog/use-alert-dialog-transition";+import { Button } from "@/registry/remocn-ui/button";+import { useButtonTransition } from "@/registry/remocn-ui/button/use-button-transition";++export const AlertDialogExampleScene = () => {+ // 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" },+ ],+ { variant: "destructive" },+ );+ // The dialog opens right after the press, then closes near the end.+ const dialog = useAlertDialogTransition([+ { at: 32, state: "opened", duration: 16 },+ { at: 92, state: "closed", duration: 12 },+ ]);+ return (+ <>+ <Button label="Delete account" variant="destructive" style={trigger} />+ <AlertDialog style={dialog} />+ </>+ );+};++export const alertDialogExampleCode = `import { AlertDialog } from "@/components/remocn/alert-dialog";+import { useAlertDialogTransition } from "@/components/remocn/use-alert-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" },+ ],+ { variant: "destructive" },+ );+ const dialog = useAlertDialogTransition([+ { at: 32, state: "opened", duration: 16 },+ { at: 92, state: "closed", duration: 12 },+ ]);++ return (+ <>+ <Button label="Delete account" variant="destructive" style={trigger} />+ <AlertDialog style={dialog} />+ </>+ );+};`;diff --git a/components/docs/examples/index.tsx b/components/docs/examples/index.tsxindex b63106e4..2503ca77 100644--- a/components/docs/examples/index.tsx+++ b/components/docs/examples/index.tsx@@ -4,6 +4,10 @@ import {AccordionExampleScene,accordionExampleCode,} from "./accordion-example";+import {+ AlertDialogExampleScene,+ alertDialogExampleCode,+} from "./alert-dialog-example";import { ButtonExampleScene, buttonExampleCode } from "./button-example";export interface ExampleEntry {@@ -33,4 +37,13 @@ export const examples: Record<string, ExampleEntry> = {width: W,height: H,},+ "alert-dialog-example": {+ Component: AlertDialogExampleScene,+ code: alertDialogExampleCode,+ // Dialog closes at 92 + dur 12 = 104; a short settle then loop.+ durationInFrames: 120,+ fps: FPS,+ width: W,+ height: H,+ },};diff --git a/content/docs/ui/components/alert-dialog.mdx b/content/docs/ui/components/alert-dialog.mdxnew file mode 100644index 00000000..c1f420e8--- /dev/null+++ b/content/docs/ui/components/alert-dialog.mdx@@ -0,0 +1,144 @@+---+title: AlertDialog+description: A modal alert dialog whose opened/closed state is a pure function of the timeline+---++<ComponentPreview name="alert-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: AlertDialog is a modal layer meant to compose over another scene, so it does not paint an opaque background.++## Installation++<InstallBlock name="alert-dialog" />++<Note>+Installing `alert-dialog` automatically installs the shared `remocn-ui` core (`lib/remocn-ui/`) and the `button` primitive via `registryDependencies` (`["remocn-ui", "button"]`). You do not need to install them separately — the dialog pairs with the Button as its trigger in the canonical lifecycle example.+</Note>++## States++`AlertDialogState` is:++```ts+type AlertDialogState =+ | "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 { AlertDialog } from "@/components/remocn/alert-dialog";++export const Scene = () => <AlertDialog state="opened" />;+```++To drive state from the timeline, use `useCurrentState`:++```tsx+import { useCurrentState } from "@/lib/remocn-ui";+import { AlertDialog } from "@/components/remocn/alert-dialog";++export const Scene = () => {+ const state = useCurrentState(+ [+ { at: 32, state: "opened" },+ { at: 92, state: "closed" },+ ],+ "closed",+ );++ return <AlertDialog title="Delete account?" 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 `useAlertDialogTransition` from the copied `use-alert-dialog-transition.ts` file. It reads the frame, interpolates between state presets, and returns a resolved `AlertDialogStyle` — pass it to the `style` prop:++```tsx+import { AlertDialog } from "@/components/remocn/alert-dialog";+import { useAlertDialogTransition } from "@/components/remocn/use-alert-dialog-transition";++export const Scene = () => {+ const style = useAlertDialogTransition([+ { at: 32, state: "opened", duration: 16 },+ { at: 92, state: "closed", duration: 12 },+ ]);+ return <AlertDialog title="Delete account?" 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-alert-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 destructive 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="alert-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: "AlertDialogStyle",+ description: "Resolved animated visual (smooth path). Pass an interpolated AlertDialogStyle from useAlertDialogTransition. Takes precedence over state when provided.",+ },+ {+ name: "title",+ type: "string",+ default: "\"Delete account?\"",+ description: "Headline of the alert dialog popup.",+ },+ {+ name: "description",+ type: "string",+ default: "\"This action cannot be undone. This will permanently remove your data from our servers.\"",+ description: "Body copy displayed under the title.",+ },+ {+ name: "actionLabel",+ type: "string",+ default: "\"Delete\"",+ description: "Label of the confirming (destructive) 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 2d98d9a8..b438b18a 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", "button", "spinner"]+ "pages": ["accordion", "alert-dialog", "button", "spinner"]}diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex 620cf5fa..d73d1e18 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -107,6 +107,8 @@ import { Typewriter } from "@/registry/remocn/typewriter";import { typewriterConfig } from "@/registry/remocn/typewriter/config";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 { Button } from "@/registry/remocn-ui/button";import { buttonConfig } from "@/registry/remocn-ui/button/config";import { Spinner } from "@/registry/remocn-ui/spinner";@@ -286,6 +288,7 @@ const registry: Record<string, RegistryEntry> = {"github-stars": { Component: GitHubStars, config: githubStarsConfig },"button": { Component: Button, config: buttonConfig },"accordion": { Component: Accordion, config: accordionConfig },+ "alert-dialog": { Component: AlertDialog, config: alertDialogConfig },"spinner": { Component: Spinner, config: spinnerConfig },};diff --git a/registry/remocn-ui/alert-dialog/__tests__/README.md b/registry/remocn-ui/alert-dialog/__tests__/README.mdnew file mode 100644index 00000000..285c6684--- /dev/null+++ b/registry/remocn-ui/alert-dialog/__tests__/README.md@@ -0,0 +1,129 @@+# `alert-dialog` — verification tests++Pure / deterministic verification for the `alert-dialog` component+(`registry/remocn-ui/alert-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: `AlertDialogState`+union membership, `alertDialogConfig.controls` wiring, `alertDialogConfig.snippet`+codegen, `alertDialogStyle` presets, `tweenAlertDialogStyle` interpolation, and+`DEFAULT_DURATION`.++## Animation model — pure snap + opt-in smooth path++AlertDialog ships two complementary paths:++**Snap path** (`state?: AlertDialogState` prop):+`AlertDialog` 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+`alertDialogStyle(state, ctx) => AlertDialogStyle`. State changes snap instantly —+no tweening inside the component.++**Smooth path** (`style?: AlertDialogStyle` prop):+Callers opt in to smooth transitions by passing a pre-interpolated+`AlertDialogStyle` to the `style` prop. The caller — typically+`useAlertDialogTransition` — reads `useCurrentFrame()` and calls+`useStateTransition` from `core/timeline.ts` to compute+`{ from, to, progress }`, then blends the two presets via+`tweenAlertDialogStyle(from, to, t)`. The `AlertDialog` component itself remains+frame-free; it simply renders whatever `AlertDialogStyle` it receives.++This design keeps `AlertDialog` 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/alert-dialog/__tests__+```++`alert-dialog.test.ts` imports `bun:test` (not `vitest`/`jest`), so no test+script or framework dep is added to `package.json`.++## What is covered++- **`AlertDialogState` union** — asserts the two states `["opened", "closed"]`+ are the complete set (via the real `controls.state.options` list from+ `config.ts`).+- **`alertDialogConfig.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 `AlertDialogState` union.+- **`alertDialogConfig.snippet`** — REAL pure string builder (high value).+ Asserts: always emits `state="<state>"` for every option; NEVER emits `steps`;+ includes `import { AlertDialog }` from `@/components/remocn/alert-dialog`;+ omits default-equal props (`title="Delete account?"`, the default description,+ `actionLabel="Delete"`, `cancelLabel="Cancel"`, `mode="light"`); EMITS+ non-default `title`/`description`/`actionLabel`/`cancelLabel`/`mode`;+ structural round-trip (starts with import, contains `<AlertDialog`, ends `/>`).+ Note: `action=` is not checked for absence because `actionLabel=` is a+ legitimate emitted prop — only `steps` is asserted absent.+- **`alertDialogStyleContext`** — exported pure `(theme) => AlertDialogStyleContext`+ (takes only `theme`, no variant — unlike accordion). Built from+ `alertDialogStyleContext(defaultLightTheme)`. Asserts each field+ (`popoverBg`, `popoverFg`, `mutedFg`, `border`, `actionBg`, `actionFg`,+ `cancelFg`) is a non-empty string, and `radius` is a number.+- **`alertDialogStyle` presets** — exported pure `(state, ctx) => AlertDialogStyle`.+ All four fields (`overlayOpacity`, `popupOpacity`, `popupScale`,+ `popupTranslateY`) are numeric. Asserts per-state invariants: closed →+ `{ 0, 0, 0.95, 8 }`; opened → `{ 1, 1, 1, 0 }`.+- **`tweenAlertDialogStyle`** — exported pure `(a, b, t) => AlertDialogStyle`.+ 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.++**AlertDialog render** is a pure `(style | state) => visual` observable only via+Remotion render, not unit-tested here.++## Import strategy++`alert-dialog.test.ts` imports via a mix of **relative paths** and the+**`@/lib/remocn-ui` tsconfig alias**:++- `../index` — relative, for `AlertDialogState`, `alertDialogStyle`,+ `alertDialogStyleContext`+- `../use-alert-dialog-transition` — relative, for `tweenAlertDialogStyle`,+ `DEFAULT_DURATION`+- `../config` — relative, for `alertDialogConfig`+- `@/lib/remocn-ui` — alias (resolves to `registry/remocn-ui/core/index.ts`),+ for `defaultLightTheme`++Importing `index.tsx` and `use-alert-dialog-transition.ts` pulls the `remotion`+module (and React), but neither `alertDialogStyle`, `alertDialogStyleContext`,+nor `tweenAlertDialogStyle` 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)++AlertDialog 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/alert-dialog/index.tsx+```++Expected: no output. Any match is a determinism violation.++`use-alert-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+`AlertDialog` pure.++Tier-wide sweep:++```bash+grep -nE "useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \+ registry/remocn-ui/alert-dialog/index.tsx registry/remocn-ui/core/*.ts+```diff --git a/registry/remocn-ui/alert-dialog/__tests__/alert-dialog.test.ts b/registry/remocn-ui/alert-dialog/__tests__/alert-dialog.test.tsnew file mode 100644index 00000000..09c89d12--- /dev/null+++ b/registry/remocn-ui/alert-dialog/__tests__/alert-dialog.test.ts@@ -0,0 +1,474 @@+/**+ * Verification tests for the PURE / DETERMINISTIC parts of `alert-dialog`.+ *+ * Scope:+ * - registry/remocn-ui/alert-dialog/index.tsx — AlertDialogState union membership,+ * alertDialogStyle presets, alertDialogStyleContext+ * - registry/remocn-ui/alert-dialog/config.ts — alertDialogConfig.controls wiring+ * + alertDialogConfig.snippet output (the state → JSX codegen)+ * - registry/remocn-ui/alert-dialog/use-alert-dialog-transition.ts+ * — tweenAlertDialogStyle interpolation, DEFAULT_DURATION+ *+ * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.+ * `<AlertDialog>` 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/alert-dialog/__tests__+ *+ * --------------------------------------------------------------------------+ * IMPORT STRATEGY+ * --------------------------------------------------------------------------+ * `config.ts` imports `AlertDialogState` from `@/registry/remocn-ui/alert-dialog`+ * and the pieces under test never CALL a Remotion runtime API at import time —+ * `alertDialogConfig` is a plain object; `.snippet` is a pure string builder;+ * `alertDialogStyle` and `tweenAlertDialogStyle` 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 AlertDialogState,+ alertDialogStyle,+ alertDialogStyleContext,+} from "../index";+import { tweenAlertDialogStyle, DEFAULT_DURATION } from "../use-alert-dialog-transition";+import { alertDialogConfig } from "../config";+import { defaultLightTheme } from "@/lib/remocn-ui";++// ===========================================================================+// Shared fixtures+// ===========================================================================++/**+ * The AlertDialogState union, enumerated as a runtime list for membership checks.+ * Must stay in sync with `export type AlertDialogState` in index.tsx.+ */+const VALID_STATES: readonly AlertDialogState[] = ["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 =>+ alertDialogConfig.snippet(values as Record<string, unknown>);++/**+ * A shared AlertDialogStyleContext built from the default light theme.+ * `alertDialogStyleContext` takes only `(theme)` — no variant arg, unlike accordion.+ */+const ctx = alertDialogStyleContext(defaultLightTheme);++// ===========================================================================+// 1. AlertDialogState union membership+// ===========================================================================++describe("AlertDialogState 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 = alertDialogConfig.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 = alertDialogConfig.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. alertDialogConfig.controls.state — customizer control wiring+// ===========================================================================++describe("alertDialogConfig.controls.state", () => {+ it("is a select control", () => {+ expect(alertDialogConfig.controls.state.type).toBe("select");+ });++ it("has exactly the two AlertDialogState options in order", () => {+ const control = alertDialogConfig.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 = alertDialogConfig.controls.state;+ expect(control.default).toBe("opened");+ });++ it("every option is a member of the AlertDialogState union", () => {+ const control = alertDialogConfig.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 AlertDialogState);+ }+ });+});++// ===========================================================================+// 3. alertDialogConfig.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("alertDialogConfig.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 = alertDialogConfig.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("alertDialogConfig.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("alertDialogConfig.snippet: import line", () => {+ it("includes `import { AlertDialog }` from the correct path", () => {+ const out = snippet({ state: "opened" });+ expect(out).toContain('import { AlertDialog }');+ expect(out).toContain('from "@/components/remocn/alert-dialog"');+ });+});++describe("alertDialogConfig.snippet: default props are omitted", () => {+ // Defaults: title="Delete account?",+ // description="This action cannot be undone. This will permanently remove your data from our servers.",+ // actionLabel="Delete", cancelLabel="Cancel", mode="light"+ const allDefaults = snippet({+ state: "opened",+ title: "Delete account?",+ description: "This action cannot be undone. This will permanently remove your data from our servers.",+ actionLabel: "Delete",+ cancelLabel: "Cancel",+ mode: "light",+ });++ it("omits title when it equals the default 'Delete account?'", () => {+ 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 'Delete'", () => {+ 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("alertDialogConfig.snippet: non-default props are emitted", () => {+ it("emits a non-default title", () => {+ expect(snippet({ state: "opened", title: "Remove workspace?" }))+ .toContain('title="Remove workspace?"');+ });++ it("emits a non-default description", () => {+ expect(snippet({ state: "opened", description: "This cannot be undone." }))+ .toContain('description="This cannot be undone."');+ });++ 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("alertDialogConfig.snippet: structural round-trip", () => {+ const out = snippet({ state: "opened" });++ it("starts with the import line", () => {+ expect(out.startsWith('import { AlertDialog }')).toBe(true);+ });++ it("contains a <AlertDialog JSX opening", () => {+ expect(out).toContain("<AlertDialog");+ });++ it("ends with a self-closing />", () => {+ expect(out.trimEnd().endsWith("/>")).toBe(true);+ });+});++// ===========================================================================+// 4. alertDialogStyleContext — 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("alertDialogStyleContext: 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. alertDialogStyle presets — pure (state, ctx) => AlertDialogStyle+// alertDialogStyleContext and alertDialogStyle are exported and frame-free.+// Build one ctx from the default light theme, then assert the numeric+// invariants for every state.+// ===========================================================================++describe("alertDialogStyle: closed state", () => {+ const s = alertDialogStyle("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("alertDialogStyle: opened state", () => {+ const s = alertDialogStyle("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("alertDialogStyle: closed/opened invariant", () => {+ it("closed: overlayOpacity 0, popupOpacity 0, popupScale 0.95, popupTranslateY 8", () => {+ const s = alertDialogStyle("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 = alertDialogStyle("opened", ctx);+ expect(s.overlayOpacity).toBe(1);+ expect(s.popupOpacity).toBe(1);+ expect(s.popupScale).toBe(1);+ expect(s.popupTranslateY).toBe(0);+ });+});++// ===========================================================================+// 6. tweenAlertDialogStyle — pure linear interpolation between two AlertDialogStyles.+// All four fields are pure numeric lerps (no color fields, unlike accordion).+// Concrete expectations: closed → opened for midpoint math.+// ===========================================================================++describe("tweenAlertDialogStyle: t=0 returns values equal to `a`", () => {+ const a = alertDialogStyle("closed", ctx);+ const b = alertDialogStyle("opened", ctx);+ const r = tweenAlertDialogStyle(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("tweenAlertDialogStyle: t=1 returns values equal to `b`", () => {+ const a = alertDialogStyle("closed", ctx);+ const b = alertDialogStyle("opened", ctx);+ const r = tweenAlertDialogStyle(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("tweenAlertDialogStyle: 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 = alertDialogStyle("closed", ctx);+ const b = alertDialogStyle("opened", ctx);+ const r = tweenAlertDialogStyle(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("tweenAlertDialogStyle: 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 = alertDialogStyle("opened", ctx);+ const b = alertDialogStyle("closed", ctx);+ const r = tweenAlertDialogStyle(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/alert-dialog/config.ts b/registry/remocn-ui/alert-dialog/config.tsnew file mode 100644index 00000000..faa0b1da--- /dev/null+++ b/registry/remocn-ui/alert-dialog/config.ts@@ -0,0 +1,63 @@+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";+import type { AlertDialogState } from "@/registry/remocn-ui/alert-dialog";++const DEFAULT_DESCRIPTION =+ "This action cannot be undone. This will permanently remove your data from our servers.";++export const alertDialogConfig: ComponentConfig = {+ componentName: "AlertDialog",+ importPath: "@/components/remocn/alert-dialog",+ controls: {+ title: { type: "text", default: "Delete account?", label: "Title" },+ description: {+ type: "text",+ default: DEFAULT_DESCRIPTION,+ label: "Description",+ },+ actionLabel: { type: "text", default: "Delete", 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 AlertDialogState) ?? "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 !== "Delete account?")+ props.push(` title="${title}"`);+ if (description !== undefined && description !== DEFAULT_DESCRIPTION)+ props.push(` description="${description}"`);+ if (actionLabel !== undefined && actionLabel !== "Delete")+ props.push(` actionLabel="${actionLabel}"`);+ if (cancelLabel !== undefined && cancelLabel !== "Cancel")+ props.push(` cancelLabel="${cancelLabel}"`);+ if (mode !== undefined && mode !== "light")+ props.push(` mode="${mode}"`);++ return `import { AlertDialog } from "@/components/remocn/alert-dialog";++<AlertDialog+${props.join("\n")}+/>`;+ },+};diff --git a/registry/remocn-ui/alert-dialog/index.tsx b/registry/remocn-ui/alert-dialog/index.tsxnew file mode 100644index 00000000..be6584de--- /dev/null+++ b/registry/remocn-ui/alert-dialog/index.tsx@@ -0,0 +1,226 @@+"use client";++import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";++export type AlertDialogState = "closed" | "opened";++export interface AlertDialogProps {+ /** Current visual state (snap path). State changes snap (no enter-tweens). */+ state?: AlertDialogState;+ /**+ * Resolved animated visual (smooth path). When provided, takes precedence over+ * `state` — feed it an interpolated `AlertDialogStyle` from `useAlertDialogTransition`.+ */+ style?: AlertDialogStyle;+ /** Headline of the alert. */+ title?: string;+ /** Body copy under the title. */+ description?: string;+ /** Label of the confirming (destructive) 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 = 400;+/** Backdrop dim at full reveal — the overlay opacity scales up to this alpha. */+const MAX_OVERLAY_ALPHA = 0.5;++// ===========================================================================+// Alert-dialog visual — the COMPLETE animated look for a moment in time. A+// `state` is a named preset of this visual (`alertDialogStyle`); the smooth+// path feeds an interpolated `AlertDialogStyle` straight through. The component+// is a pure renderer of whichever `AlertDialogStyle` it receives.+// ===========================================================================++export interface AlertDialogStyle {+ /** 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 AlertDialogStyleContext {+ 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 `alertDialogStyle(state, ctx)` preset.+ */+export function alertDialogStyleContext(+ theme: RemocnTheme,+): AlertDialogStyleContext {+ return {+ popoverBg: theme.popover,+ popoverFg: theme.popoverForeground,+ mutedFg: theme.mutedForeground,+ border: theme.border,+ radius: theme.radius,+ actionBg: theme.destructive,+ actionFg: theme.destructiveForeground,+ cancelFg: theme.foreground,+ };+}++/**+ * The COMPLETE resting visual for a state — a pure `(state, ctx) => AlertDialogStyle`+ * map. To change how a state looks, edit one entry.+ */+export function alertDialogStyle(+ state: AlertDialogState,+ _ctx: AlertDialogStyleContext,+): AlertDialogStyle {+ 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 AlertDialog({+ state = "closed",+ style,+ title = "Delete account?",+ description = "This action cannot be undone. This will permanently remove your data from our servers.",+ actionLabel = "Delete",+ cancelLabel = "Cancel",+ theme: themeOverride,+ mode,+ className,+}: AlertDialogProps) {+ const theme = useRemocnTheme(themeOverride, mode);++ const ctx = alertDialogStyleContext(theme);+ const v = style ?? alertDialogStyle(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)",+ }}+ >+ <div+ style={{ fontSize: 18, fontWeight: 500, letterSpacing: "-0.01em" }}+ >+ {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 — destructive 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/alert-dialog/use-alert-dialog-transition.ts b/registry/remocn-ui/alert-dialog/use-alert-dialog-transition.tsnew file mode 100644index 00000000..86c70c36--- /dev/null+++ b/registry/remocn-ui/alert-dialog/use-alert-dialog-transition.ts@@ -0,0 +1,72 @@+"use client";++import {+ easings,+ type RemocnTheme,+ type Step,+ useRemocnTheme,+ useStateTransition,+} from "@/lib/remocn-ui";+import {+ alertDialogStyle,+ alertDialogStyleContext,+ type AlertDialogState,+ type AlertDialogStyle,+} from "@/components/remocn/alert-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 alert-dialog visuals: all four fields are pure numeric lerps. */+export function tweenAlertDialogStyle(+ a: AlertDialogStyle,+ b: AlertDialogStyle,+ t: number,+): AlertDialogStyle {+ 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 AlertDialogTransitionOptions {+ theme?: Partial<RemocnTheme>;+ mode?: "light" | "dark";+ speed?: number;+ defaultDuration?: number;+}++/**+ * Timeline → resolved (eased, tweened) AlertDialogStyle. The CALLER invokes this;+ * it reads the frame, the `<AlertDialog>` component does not. Feed the result to+ * `<AlertDialog style={...} />` for smooth open/close transitions.+ */+export function useAlertDialogTransition(+ steps: Step<AlertDialogState>[],+ opts: AlertDialogTransitionOptions = {},+): AlertDialogStyle {+ const {+ theme: themeOverride,+ mode,+ speed = 1,+ defaultDuration = DEFAULT_DURATION,+ } = opts;+ const theme = useRemocnTheme(themeOverride, mode);+ const ctx = alertDialogStyleContext(theme);+ const { from, to, progress } = useStateTransition(+ steps,+ "closed",+ speed,+ defaultDuration,+ );+ const t = easings.out(progress);+ return tweenAlertDialogStyle(+ alertDialogStyle(from, ctx),+ alertDialogStyle(to, ctx),+ t,+ );+}diff --git a/registry/remocn-ui/registry.json b/registry/remocn-ui/registry.jsonindex 591d6db9..a963dd8f 100644--- a/registry/remocn-ui/registry.json+++ b/registry/remocn-ui/registry.json@@ -96,6 +96,26 @@"target": "components/remocn/use-accordion-transition.ts"}]+ },+ {+ "name": "alert-dialog",+ "type": "registry:component",+ "title": "UI Alert Dialog",+ "description": "A modal alert dialog whose opened/closed state is a pure function of the timeline; the backdrop dim and popup zoom are keyframed presets. Self-contained — pair it with the Button as a trigger (see the example).",+ "dependencies": ["remotion"],+ "registryDependencies": ["remocn-ui"],+ "files": [+ {+ "path": "alert-dialog/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/alert-dialog.tsx"+ },+ {+ "path": "alert-dialog/use-alert-dialog-transition.ts",+ "type": "registry:component",+ "target": "components/remocn/use-alert-dialog-transition.ts"+ }+ ]}]}