Skip to content

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

feat: added accordion

dev_wandry51c711a7e2cd
diff --git a/components/docs/examples/accordion-example.tsx b/components/docs/examples/accordion-example.tsx
new file mode 100644
index 00000000..98520f7f
--- /dev/null
+++ b/components/docs/examples/accordion-example.tsx
@@ -0,0 +1,36 @@
+"use client";
+
+import { Accordion } from "@/registry/remocn-ui/accordion";
+import { useAccordionTransition } from "@/registry/remocn-ui/accordion/use-accordion-transition";
+
+export const AccordionExampleScene = () => {
+ const style = useAccordionTransition([
+ { at: 18, state: "opened", duration: 16 },
+ { at: 78, state: "closed", duration: 12 },
+ ]);
+ return (
+ <Accordion
+ title="Is it accessible?"
+ content="Yes. It adheres to the WAI-ARIA design pattern."
+ style={style}
+ />
+ );
+};
+
+export const accordionExampleCode = `import { Accordion } from "@/components/remocn/accordion";
+import { useAccordionTransition } from "@/components/remocn/use-accordion-transition";
+
+export const Scene = () => {
+ const style = useAccordionTransition([
+ { at: 18, state: "opened", duration: 16 },
+ { at: 78, state: "closed", duration: 12 },
+ ]);
+
+ return (
+ <Accordion
+ title="Is it accessible?"
+ content="Yes. It adheres to the WAI-ARIA design pattern."
+ style={style}
+ />
+ );
+};`;
diff --git a/components/docs/examples/index.tsx b/components/docs/examples/index.tsx
index d2fc94a9..b63106e4 100644
--- a/components/docs/examples/index.tsx
+++ b/components/docs/examples/index.tsx
@@ -1,5 +1,9 @@
import type { ComponentType } from "react";
import { FPS, H, W } from "@/lib/customizer-config";
+import {
+ AccordionExampleScene,
+ accordionExampleCode,
+} from "./accordion-example";
import { ButtonExampleScene, buttonExampleCode } from "./button-example";
export interface ExampleEntry {
@@ -20,4 +24,13 @@ export const examples: Record<string, ExampleEntry> = {
width: W,
height: H,
},
+ "accordion-example": {
+ Component: AccordionExampleScene,
+ code: accordionExampleCode,
+ // Last transition (close) completes at frame 90; a short settle then loop.
+ durationInFrames: 100,
+ fps: FPS,
+ width: W,
+ height: H,
+ },
};
diff --git a/content/docs/ui/components/accordion.mdx b/content/docs/ui/components/accordion.mdx
new file mode 100644
index 00000000..2eaaaa03
--- /dev/null
+++ b/content/docs/ui/components/accordion.mdx
@@ -0,0 +1,144 @@
+---
+title: Accordion
+description: An accordion panel whose open/closed state is a pure function of the timeline
+---
+
+<ComponentPreview name="accordion" />
+
+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.
+
+## Installation
+
+<InstallBlock name="accordion" />
+
+<Note>
+Installing `accordion` automatically installs the shared `remocn-ui` core (`lib/remocn-ui/`) via `registryDependencies`. You do not need to install it separately.
+</Note>
+
+## States
+
+`AccordionState` is:
+
+```ts
+type AccordionState =
+ | "closed" // panel collapsed, chevron points down
+ | "opened" // panel revealed, chevron rotated 180° (points up), item background fills
+```
+
+`opened` fills the item background with `bg-muted/50` (for the `default` variant) and rotates the chevron 180° to point upward. `closed` collapses the panel and resets the chevron.
+
+## 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 { Accordion } from "@/components/remocn/accordion";
+
+export const Scene = () => <Accordion state="opened" />;
+```
+
+To drive state from the timeline, use `useCurrentState`:
+
+```tsx
+import { useCurrentState } from "@/lib/remocn-ui";
+import { Accordion } from "@/components/remocn/accordion";
+
+export const Scene = () => {
+ const state = useCurrentState(
+ [
+ { at: 18, state: "opened" },
+ { at: 78, state: "closed" },
+ ],
+ "closed",
+ );
+
+ return <Accordion title="Is it accessible?" state={state} />;
+};
+```
+
+Each `at` is a **Sequence-local authored frame**. State persists between steps: `opened` at frame 18 keeps the panel revealed until `closed` fires at frame 78. 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 `useAccordionTransition` from the copied `use-accordion-transition.ts` file. It reads the frame, interpolates between state presets, and returns a resolved `AccordionStyle` — pass it to the `style` prop:
+
+```tsx
+import { Accordion } from "@/components/remocn/accordion";
+import { useAccordionTransition } from "@/components/remocn/use-accordion-transition";
+
+export const Scene = () => {
+ const style = useAccordionTransition([
+ { at: 18, state: "opened", duration: 16 },
+ { at: 78, state: "closed", duration: 12 },
+ ]);
+ return <Accordion title="Is it accessible?" style={style} />;
+};
+```
+
+The `duration` field on each step overrides the file's `DEFAULT_DURATION` for that specific transition. To globally tune timing and easing, edit `use-accordion-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
+
+A complete closed → opened → closed run using the smooth transition path. Copy the code to drop it into your own composition.
+
+<LiveExample name="accordion-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: "AccordionStyle",
+ description: "Resolved animated visual (smooth path). Pass an interpolated AccordionStyle from useAccordionTransition. Takes precedence over state when provided.",
+ },
+ {
+ name: "title",
+ type: "string",
+ default: "\"Is it accessible?\"",
+ description: "Accordion item trigger label.",
+ },
+ {
+ name: "content",
+ type: "string",
+ default: "\"Yes. It adheres to the WAI-ARIA design pattern.\"",
+ description: "Accordion panel body text, revealed when opened.",
+ },
+ {
+ name: "contentHeight",
+ type: "number",
+ default: "64",
+ description: "Authored panel height in px. Required because Remotion cannot measure auto height — set this to match the rendered height of your content.",
+ },
+ {
+ name: "variant",
+ type: "\"default\" | \"ghost\"",
+ default: "\"default\"",
+ description: "Visual variant. default fills the item background when opened; ghost has no fill.",
+ },
+ {
+ 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 passed to the accordion item element.",
+ },
+ ]}
+/>
diff --git a/content/docs/ui/components/meta.json b/content/docs/ui/components/meta.json
index e1a41f65..2d98d9a8 100644
--- a/content/docs/ui/components/meta.json
+++ b/content/docs/ui/components/meta.json
@@ -1,5 +1,5 @@
{
"title": "Components",
"collapsible": false,
- "pages": ["button", "spinner"]
+ "pages": ["accordion", "button", "spinner"]
}
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index 1dfc3749..620cf5fa 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -105,6 +105,8 @@ import { TrackingIn } from "@/registry/remocn/tracking-in";
import { trackingInConfig } from "@/registry/remocn/tracking-in/config";
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 { Button } from "@/registry/remocn-ui/button";
import { buttonConfig } from "@/registry/remocn-ui/button/config";
import { Spinner } from "@/registry/remocn-ui/spinner";
@@ -283,6 +285,7 @@ const registry: Record<string, RegistryEntry> = {
},
"github-stars": { Component: GitHubStars, config: githubStarsConfig },
"button": { Component: Button, config: buttonConfig },
+ "accordion": { Component: Accordion, config: accordionConfig },
"spinner": { Component: Spinner, config: spinnerConfig },
};
diff --git a/registry/remocn-ui/accordion/__tests__/README.md b/registry/remocn-ui/accordion/__tests__/README.md
new file mode 100644
index 00000000..47fee340
--- /dev/null
+++ b/registry/remocn-ui/accordion/__tests__/README.md
@@ -0,0 +1,126 @@
+# `accordion` — verification tests
+
+Pure / deterministic verification for the `accordion` component
+(`registry/remocn-ui/accordion/`). 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: `AccordionState`
+union membership, `accordionConfig.controls` wiring, `accordionConfig.snippet`
+codegen, `accordionStyle` presets, `tweenAccordionStyle` interpolation, and
+`DEFAULT_DURATION`.
+
+## Animation model — pure snap + opt-in smooth path
+
+Accordion ships two complementary paths:
+
+**Snap path** (`state?: AccordionState` prop):
+`Accordion` 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
+`accordionStyle(state, ctx) => AccordionStyle`. State changes snap instantly —
+no tweening inside the component.
+
+**Smooth path** (`style?: AccordionStyle` prop):
+Callers opt in to smooth transitions by passing a pre-interpolated
+`AccordionStyle` to the `style` prop. The caller — typically
+`useAccordionTransition` — reads `useCurrentFrame()` and calls
+`useStateTransition` from `core/timeline.ts` to compute
+`{ from, to, progress }`, then blends the two presets via
+`tweenAccordionStyle(from, to, t)`. The `Accordion` component itself remains
+frame-free; it simply renders whatever `AccordionStyle` it receives.
+
+This design keeps `Accordion` pure-testable (no Remotion render context needed)
+while still supporting smooth open/close transitions for production use.
+
+## How to run
+
+The repo uses **Bun**, which has a built-in test runner — runs TypeScript
+natively, no test-framework dep.
+
+```bash
+bun install
+bun test registry/remocn-ui/accordion/__tests__
+```
+
+`accordion.test.ts` imports `bun:test` (not `vitest`/`jest`), so no test script
+or framework dep is added to `package.json`.
+
+## What is covered
+
+- **`AccordionState` union** — asserts the two states `["opened", "closed"]`
+ are the complete set (via the real `controls.state.options` list from
+ `config.ts`).
+- **`accordionConfig.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 revealed panel), and that every
+ option is a member of the `AccordionState` union.
+- **`accordionConfig.controls.variant`** — asserts a `select` control with
+ options `["default", "ghost"]`, default `"default"`.
+- **`accordionConfig.snippet`** — REAL pure string builder (high value).
+ Asserts: always emits `state="<state>"` for every option; NEVER emits `steps`
+ or `action`; includes `import { Accordion }` from
+ `@/components/remocn/accordion`; omits default-equal props (`title="Is it
+ accessible?"`, `content="Yes. It adheres to the WAI-ARIA design pattern."`,
+ `variant="default"`, `mode="light"`); EMITS non-default
+ `title`/`content`/`variant`/`mode`; structural round-trip (starts with
+ import, contains `<Accordion`, ends `/>`).
+- **`accordionStyle` presets** — exported pure `(state, ctx) => AccordionStyle`
+ map. An `AccordionStyleContext` is built from
+ `accordionStyleContext("default", defaultLightTheme)` — the same call the
+ component makes internally. Asserts per-state numeric invariants
+ (`panelHeight`, `panelOpacity`, `chevronRotation`) and that `background` is
+ always a non-empty string. Also asserts the closed/opened invariant: closed
+ has all three numeric fields at 0; opened has `panelHeight` 1, `panelOpacity`
+ 1, `chevronRotation` 180.
+- **`tweenAccordionStyle`** — exported pure `(a, b, t) => AccordionStyle`.
+ Asserts: at t=0 all numeric fields equal `a`; at t=1 all equal `b`; at t=0.5
+ each numeric field is the exact midpoint (e.g. `panelHeight` 0→1 gives 0.5,
+ `chevronRotation` 0→180 gives 90, `panelOpacity` 0→1 gives 0.5).
+ `background` at all t is a non-empty string (the oklch mix value is not
+ hardcoded). Both directions (closed→opened and opened→closed) are verified.
+- **`DEFAULT_DURATION`** — sanity-checks the exported constant is a positive
+ number equal to 14.
+
+**Accordion render** is a pure `(style | state) => visual` observable only via
+Remotion render, not unit-tested here.
+
+## Import strategy
+
+`accordion.test.ts` imports via a mix of **relative paths** and the
+**`@/lib/remocn-ui` tsconfig alias**:
+
+- `../index` — relative, for `AccordionState`, `accordionStyle`,
+ `accordionStyleContext`
+- `../use-accordion-transition` — relative, for `tweenAccordionStyle`,
+ `DEFAULT_DURATION`
+- `../config` — relative, for `accordionConfig`
+- `@/lib/remocn-ui` — alias (resolves to `registry/remocn-ui/core/index.ts`),
+ for `defaultLightTheme`
+
+Importing `index.tsx` and `use-accordion-transition.ts` pulls the `remotion`
+module (and React), but neither `accordionStyle`, `accordionStyleContext`, nor
+`tweenAccordionStyle` 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)
+
+Accordion is a state atom and must be frame-free. The component's `index.tsx`
+must contain **none** of the following:
+
+```bash
+grep -nE "useCurrentFrame|useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \
+ registry/remocn-ui/accordion/index.tsx
+```
+
+Expected: no output. Any match is a determinism violation.
+
+`use-accordion-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
+`Accordion` pure.
+
+Tier-wide sweep:
+
+```bash
+grep -nE "useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \
+ registry/remocn-ui/accordion/index.tsx registry/remocn-ui/core/*.ts
+```
diff --git a/registry/remocn-ui/accordion/__tests__/accordion.test.ts b/registry/remocn-ui/accordion/__tests__/accordion.test.ts
new file mode 100644
index 00000000..38b23788
--- /dev/null
+++ b/registry/remocn-ui/accordion/__tests__/accordion.test.ts
@@ -0,0 +1,451 @@
+/**
+ * Verification tests for the PURE / DETERMINISTIC parts of `accordion`.
+ *
+ * Scope:
+ * - registry/remocn-ui/accordion/index.tsx — AccordionState union membership,
+ * accordionStyle presets, accordionStyleContext
+ * - registry/remocn-ui/accordion/config.ts — accordionConfig.controls wiring
+ * + accordionConfig.snippet output (the state → JSX codegen)
+ * - registry/remocn-ui/accordion/use-accordion-transition.ts
+ * — tweenAccordionStyle interpolation, DEFAULT_DURATION
+ *
+ * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
+ * `<Accordion>` 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/accordion/__tests__
+ *
+ * --------------------------------------------------------------------------
+ * IMPORT STRATEGY
+ * --------------------------------------------------------------------------
+ * `config.ts` imports `AccordionState` from `@/registry/remocn-ui/accordion`
+ * and the pieces under test never CALL a Remotion runtime API at import time —
+ * `accordionConfig` is a plain object; `.snippet` is a pure string builder;
+ * `accordionStyle` and `tweenAccordionStyle` 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 AccordionState,
+ accordionStyle,
+ accordionStyleContext,
+} from "../index";
+import { tweenAccordionStyle, DEFAULT_DURATION } from "../use-accordion-transition";
+import { accordionConfig } from "../config";
+import { defaultLightTheme } from "@/lib/remocn-ui";
+
+// ===========================================================================
+// Shared fixtures
+// ===========================================================================
+
+/**
+ * The AccordionState union, enumerated as a runtime list for membership checks.
+ * Must stay in sync with `export type AccordionState` in index.tsx.
+ */
+const VALID_STATES: readonly AccordionState[] = ["opened", "closed"];
+
+/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
+type SnippetValues = {
+ state?: string;
+ title?: string;
+ content?: string;
+ variant?: string;
+ mode?: string;
+};
+
+const snippet = (values: SnippetValues): string =>
+ accordionConfig.snippet(values as Record<string, unknown>);
+
+/**
+ * A shared AccordionStyleContext built from the default light theme + "default"
+ * variant. Mirrors how the component builds its own context internally.
+ */
+const ctx = accordionStyleContext("default", defaultLightTheme);
+
+// ===========================================================================
+// 1. AccordionState union membership
+// ===========================================================================
+
+describe("AccordionState 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 = accordionConfig.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 = accordionConfig.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. accordionConfig.controls.state — customizer control wiring
+// ===========================================================================
+
+describe("accordionConfig.controls.state", () => {
+ it("is a select control", () => {
+ expect(accordionConfig.controls.state.type).toBe("select");
+ });
+
+ it("has exactly the two AccordionState options in order", () => {
+ const control = accordionConfig.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 revealed panel", () => {
+ const control = accordionConfig.controls.state;
+ expect(control.default).toBe("opened");
+ });
+
+ it("every option is a member of the AccordionState union", () => {
+ const control = accordionConfig.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 AccordionState);
+ }
+ });
+});
+
+// ===========================================================================
+// 3. accordionConfig.controls.variant — customizer control wiring
+// ===========================================================================
+
+describe("accordionConfig.controls.variant", () => {
+ it("is a select control", () => {
+ expect(accordionConfig.controls.variant.type).toBe("select");
+ });
+
+ it("has exactly the two variant options in order", () => {
+ const control = accordionConfig.controls.variant;
+ if (control.type !== "select") throw new Error("variant control must be a select");
+ expect(control.options).toEqual(["default", "ghost"]);
+ });
+
+ it("defaults to 'default'", () => {
+ expect(accordionConfig.controls.variant.default).toBe("default");
+ });
+});
+
+// ===========================================================================
+// 4. accordionConfig.snippet — pure string builder
+// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.
+// It NEVER emits `steps` or `action`.
+// ===========================================================================
+
+describe("accordionConfig.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 = accordionConfig.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("accordionConfig.snippet: NEVER emits steps or action", () => {
+ it("never emits `steps` in any state", () => {
+ for (const state of VALID_STATES) {
+ expect(snippet({ state })).not.toContain("steps");
+ }
+ });
+
+ it("never emits `action` in any state", () => {
+ for (const state of VALID_STATES) {
+ expect(snippet({ state })).not.toContain("action");
+ }
+ });
+});
+
+describe("accordionConfig.snippet: import line", () => {
+ it("includes `import { Accordion }` from the correct path", () => {
+ const out = snippet({ state: "opened" });
+ expect(out).toContain('import { Accordion }');
+ expect(out).toContain('from "@/components/remocn/accordion"');
+ });
+});
+
+describe("accordionConfig.snippet: default props are omitted", () => {
+ // Defaults: title="Is it accessible?", content="Yes. It adheres to the WAI-ARIA design pattern.",
+ // variant="default", mode="light"
+ const allDefaults = snippet({
+ state: "opened",
+ title: "Is it accessible?",
+ content: "Yes. It adheres to the WAI-ARIA design pattern.",
+ variant: "default",
+ mode: "light",
+ });
+
+ it("omits title when it equals the default 'Is it accessible?'", () => {
+ expect(allDefaults).not.toContain("title=");
+ });
+
+ it("omits content when it equals the default WAI-ARIA text", () => {
+ expect(allDefaults).not.toContain("content=");
+ });
+
+ it("omits variant when it equals the default 'default'", () => {
+ expect(allDefaults).not.toContain("variant=");
+ });
+
+ it("omits mode when it equals the default 'light'", () => {
+ expect(allDefaults).not.toContain("mode=");
+ });
+});
+
+describe("accordionConfig.snippet: non-default props are emitted", () => {
+ it("emits a non-default title", () => {
+ expect(snippet({ state: "opened", title: "How do I reset my password?" }))
+ .toContain('title="How do I reset my password?"');
+ });
+
+ it("emits a non-default content", () => {
+ expect(snippet({ state: "opened", content: "Click the forgot password link." }))
+ .toContain('content="Click the forgot password link."');
+ });
+
+ it("emits a non-default variant", () => {
+ expect(snippet({ state: "opened", variant: "ghost" }))
+ .toContain('variant="ghost"');
+ });
+
+ it("emits a non-default mode", () => {
+ expect(snippet({ state: "opened", mode: "dark" }))
+ .toContain('mode="dark"');
+ });
+});
+
+describe("accordionConfig.snippet: structural round-trip", () => {
+ const out = snippet({ state: "opened" });
+
+ it("starts with the import line", () => {
+ expect(out.startsWith('import { Accordion }')).toBe(true);
+ });
+
+ it("contains a <Accordion JSX opening", () => {
+ expect(out).toContain("<Accordion");
+ });
+
+ it("ends with a self-closing />", () => {
+ expect(out.trimEnd().endsWith("/>")).toBe(true);
+ });
+});
+
+// ===========================================================================
+// 5. accordionStyle presets — pure (state, ctx) => AccordionStyle
+// accordionStyleContext and accordionStyle are exported and frame-free.
+// Build one ctx from the default light theme + "default" variant, then
+// assert the numeric invariants for every state.
+// background is a derived oklch/rgb string — asserted non-empty only
+// (its exact value is an implementation detail of mixOklch).
+// ===========================================================================
+
+describe("accordionStyle: closed state", () => {
+ const s = accordionStyle("closed", ctx);
+
+ it("panelHeight is 0 (panel fully collapsed)", () => {
+ expect(s.panelHeight).toBe(0);
+ });
+
+ it("panelOpacity is 0 (panel content invisible)", () => {
+ expect(s.panelOpacity).toBe(0);
+ });
+
+ it("chevronRotation is 0 (chevron points down, closed)", () => {
+ expect(s.chevronRotation).toBe(0);
+ });
+
+ it("background is a non-empty string", () => {
+ expect(typeof s.background).toBe("string");
+ expect(s.background.length).toBeGreaterThan(0);
+ });
+});
+
+describe("accordionStyle: opened state", () => {
+ const s = accordionStyle("opened", ctx);
+
+ it("panelHeight is 1 (panel fully revealed)", () => {
+ expect(s.panelHeight).toBe(1);
+ });
+
+ it("panelOpacity is 1 (panel content fully visible)", () => {
+ expect(s.panelOpacity).toBe(1);
+ });
+
+ it("chevronRotation is 180 (chevron flipped upward, opened)", () => {
+ expect(s.chevronRotation).toBe(180);
+ });
+
+ it("background is a non-empty string", () => {
+ expect(typeof s.background).toBe("string");
+ expect(s.background.length).toBeGreaterThan(0);
+ });
+});
+
+describe("accordionStyle: closed/opened invariant", () => {
+ it("closed has panelHeight 0, panelOpacity 0, chevronRotation 0", () => {
+ const s = accordionStyle("closed", ctx);
+ expect(s.panelHeight).toBe(0);
+ expect(s.panelOpacity).toBe(0);
+ expect(s.chevronRotation).toBe(0);
+ });
+
+ it("opened has panelHeight 1, panelOpacity 1, chevronRotation 180", () => {
+ const s = accordionStyle("opened", ctx);
+ expect(s.panelHeight).toBe(1);
+ expect(s.panelOpacity).toBe(1);
+ expect(s.chevronRotation).toBe(180);
+ });
+
+ it("closed background equals ctx.closedBg", () => {
+ const s = accordionStyle("closed", ctx);
+ expect(s.background).toBe(ctx.closedBg);
+ });
+
+ it("opened background equals ctx.openBg", () => {
+ const s = accordionStyle("opened", ctx);
+ expect(s.background).toBe(ctx.openBg);
+ });
+});
+
+// ===========================================================================
+// 6. tweenAccordionStyle — pure linear interpolation between two AccordionStyles.
+// Numbers lerp linearly; background is an oklch color string at all t.
+// Concrete expectations: closed(panelHeight=0) → opened(panelHeight=1)
+// for midpoint math.
+// ===========================================================================
+
+describe("tweenAccordionStyle: t=0 returns values equal to `a`", () => {
+ const a = accordionStyle("closed", ctx);
+ const b = accordionStyle("opened", ctx);
+ const r = tweenAccordionStyle(a, b, 0);
+
+ it("panelHeight equals a.panelHeight at t=0", () => {
+ expect(r.panelHeight).toBeCloseTo(a.panelHeight, 10);
+ });
+
+ it("panelOpacity equals a.panelOpacity at t=0", () => {
+ expect(r.panelOpacity).toBeCloseTo(a.panelOpacity, 10);
+ });
+
+ it("chevronRotation equals a.chevronRotation at t=0", () => {
+ expect(r.chevronRotation).toBeCloseTo(a.chevronRotation, 10);
+ });
+
+ it("background is a non-empty string at t=0", () => {
+ expect(typeof r.background).toBe("string");
+ expect(r.background.length).toBeGreaterThan(0);
+ });
+});
+
+describe("tweenAccordionStyle: t=1 returns values equal to `b`", () => {
+ const a = accordionStyle("closed", ctx);
+ const b = accordionStyle("opened", ctx);
+ const r = tweenAccordionStyle(a, b, 1);
+
+ it("panelHeight equals b.panelHeight at t=1", () => {
+ expect(r.panelHeight).toBeCloseTo(b.panelHeight, 10);
+ });
+
+ it("panelOpacity equals b.panelOpacity at t=1", () => {
+ expect(r.panelOpacity).toBeCloseTo(b.panelOpacity, 10);
+ });
+
+ it("chevronRotation equals b.chevronRotation at t=1", () => {
+ expect(r.chevronRotation).toBeCloseTo(b.chevronRotation, 10);
+ });
+
+ it("background is a non-empty string at t=1", () => {
+ expect(typeof r.background).toBe("string");
+ expect(r.background.length).toBeGreaterThan(0);
+ });
+});
+
+describe("tweenAccordionStyle: t=0.5 midpoint numeric lerp (closed → opened)", () => {
+ // closed: panelHeight=0, panelOpacity=0, chevronRotation=0
+ // opened: panelHeight=1, panelOpacity=1, chevronRotation=180
+ const a = accordionStyle("closed", ctx);
+ const b = accordionStyle("opened", ctx);
+ const r = tweenAccordionStyle(a, b, 0.5);
+
+ it("panelHeight midpoint: 0 → 1 gives 0.5", () => {
+ expect(r.panelHeight).toBeCloseTo(0.5, 10);
+ });
+
+ it("panelOpacity midpoint: 0 → 1 gives 0.5", () => {
+ expect(r.panelOpacity).toBeCloseTo(0.5, 10);
+ });
+
+ it("chevronRotation midpoint: 0 → 180 gives 90", () => {
+ expect(r.chevronRotation).toBeCloseTo(90, 10);
+ });
+
+ it("background is a non-empty string at t=0.5", () => {
+ expect(typeof r.background).toBe("string");
+ expect(r.background.length).toBeGreaterThan(0);
+ });
+});
+
+describe("tweenAccordionStyle: t=0.5 midpoint numeric lerp (opened → closed)", () => {
+ // opened: panelHeight=1, panelOpacity=1, chevronRotation=180
+ // closed: panelHeight=0, panelOpacity=0, chevronRotation=0
+ const a = accordionStyle("opened", ctx);
+ const b = accordionStyle("closed", ctx);
+ const r = tweenAccordionStyle(a, b, 0.5);
+
+ it("panelHeight midpoint: 1 → 0 gives 0.5", () => {
+ expect(r.panelHeight).toBeCloseTo(0.5, 10);
+ });
+
+ it("panelOpacity midpoint: 1 → 0 gives 0.5", () => {
+ expect(r.panelOpacity).toBeCloseTo(0.5, 10);
+ });
+
+ it("chevronRotation midpoint: 180 → 0 gives 90", () => {
+ expect(r.chevronRotation).toBeCloseTo(90, 10);
+ });
+
+ it("background is a non-empty string at t=0.5", () => {
+ expect(typeof r.background).toBe("string");
+ expect(r.background.length).toBeGreaterThan(0);
+ });
+});
+
+// ===========================================================================
+// 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 14 (the authored value)", () => {
+ expect(DEFAULT_DURATION).toBe(14);
+ });
+});
diff --git a/registry/remocn-ui/accordion/config.ts b/registry/remocn-ui/accordion/config.ts
new file mode 100644
index 00000000..b9cf3e68
--- /dev/null
+++ b/registry/remocn-ui/accordion/config.ts
@@ -0,0 +1,64 @@
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+import type { AccordionState } from "@/registry/remocn-ui/accordion";
+
+export const accordionConfig: ComponentConfig = {
+ componentName: "Accordion",
+ importPath: "@/components/remocn/accordion",
+ controls: {
+ title: { type: "text", default: "Is it accessible?", label: "Title" },
+ content: {
+ type: "text",
+ default: "Yes. It adheres to the WAI-ARIA design pattern.",
+ label: "Content",
+ },
+ variant: {
+ type: "select",
+ default: "default",
+ options: ["default", "ghost"],
+ label: "Variant",
+ },
+ state: {
+ type: "select",
+ // Default to `opened` so the preview shows the revealed panel.
+ 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 AccordionState) ?? "opened";
+ const title = values.title as string | undefined;
+ const content = values.content as string | undefined;
+ const variant = values.variant as string | undefined;
+ const mode = values.mode as string | undefined;
+
+ const props: string[] = [` state="${state}"`];
+ if (title !== undefined && title !== "Is it accessible?")
+ props.push(` title="${title}"`);
+ if (
+ content !== undefined &&
+ content !== "Yes. It adheres to the WAI-ARIA design pattern."
+ )
+ props.push(` content="${content}"`);
+ if (variant !== undefined && variant !== "default")
+ props.push(` variant="${variant}"`);
+ if (mode !== undefined && mode !== "light")
+ props.push(` mode="${mode}"`);
+
+ return `import { Accordion } from "@/components/remocn/accordion";
+
+<Accordion
+${props.join("\n")}
+/>`;
+ },
+};
diff --git a/registry/remocn-ui/accordion/index.tsx b/registry/remocn-ui/accordion/index.tsx
new file mode 100644
index 00000000..1d6c1570
--- /dev/null
+++ b/registry/remocn-ui/accordion/index.tsx
@@ -0,0 +1,237 @@
+"use client";
+
+import { mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
+
+export type AccordionState = "opened" | "closed";
+
+type AccordionVariant = "default" | "ghost";
+
+export interface AccordionProps {
+ /** Current visual state (snap path). State changes snap (no enter-tweens). */
+ state?: AccordionState;
+ /**
+ * Resolved animated visual (smooth path). When provided, takes precedence over
+ * `state` — feed it an interpolated `AccordionStyle` from `useAccordionTransition`.
+ */
+ style?: AccordionStyle;
+ /** Trigger label (the always-visible header row). */
+ title?: string;
+ /** Panel body text revealed when opened. */
+ content?: string;
+ /**
+ * Natural height (px) of the panel body at full reveal. The panel animates
+ * `panelHeight * contentHeight` — Remotion's headless render can't measure
+ * auto height, so the resting height is authored, not measured.
+ */
+ contentHeight?: number;
+ variant?: AccordionVariant;
+ theme?: Partial<RemocnTheme>;
+ mode?: "light" | "dark";
+ className?: string;
+}
+
+/** Card width (px) of the rendered disclosure. */
+const CARD_WIDTH = 440;
+
+interface VariantTokens {
+ /** Whether the card draws a 1px border. */
+ bordered: boolean;
+ /** Resting (closed) item background. */
+ closedBg: string;
+ /** Open item background. */
+ openBg: string;
+}
+
+function variantTokens(
+ variant: AccordionVariant,
+ theme: RemocnTheme,
+): VariantTokens {
+ const variants = {
+ ghost: {
+ bordered: false,
+ closedBg: theme.background,
+ // Subtle wash so the open state still reads without a border.
+ openBg: mixOklch(theme.background, theme.muted, 0.25),
+ },
+ default: {
+ bordered: true,
+ closedBg: theme.background,
+ // shadcn `data-open:bg-muted/50` — muted at half strength over the page.
+ openBg: mixOklch(theme.background, theme.muted, 0.5),
+ },
+ };
+
+ return variants[variant] ?? variants.default;
+}
+
+// ===========================================================================
+// Accordion visual — the COMPLETE animated look for a moment in time. A `state`
+// is a named preset of this visual (`accordionStyle`); the smooth path feeds an
+// interpolated `AccordionStyle` straight through. The component is a pure
+// renderer of whichever `AccordionStyle` it receives.
+// ===========================================================================
+
+export interface AccordionStyle {
+ /** Panel reveal fraction 0→1; multiplies `contentHeight` for the box height. */
+ panelHeight: number;
+ /** Panel body opacity 0→1. */
+ panelOpacity: number;
+ /** Chevron rotation in degrees: 0 (closed, points down) → 180 (opened, up). */
+ chevronRotation: number;
+ /** Animated item background (a concrete color, never "transparent"). */
+ background: string;
+}
+
+/** Concrete colors for the active variant/theme, resolved once per render. */
+export interface AccordionStyleContext {
+ bordered: boolean;
+ closedBg: string;
+ openBg: string;
+ border: string;
+ foreground: string;
+ mutedForeground: string;
+}
+
+/**
+ * Derive the concrete colors for a variant/theme. Pure — call it once and reuse
+ * the result for every `accordionStyle(state, ctx)` preset.
+ */
+export function accordionStyleContext(
+ variant: AccordionVariant,
+ theme: RemocnTheme,
+): AccordionStyleContext {
+ const tokens = variantTokens(variant, theme);
+ return {
+ bordered: tokens.bordered,
+ closedBg: tokens.closedBg,
+ openBg: tokens.openBg,
+ border: theme.border,
+ foreground: theme.foreground,
+ mutedForeground: theme.mutedForeground,
+ };
+}
+
+/**
+ * The COMPLETE resting visual for a state — a pure `(state, ctx) => AccordionStyle`
+ * map. To change how a state looks, edit one entry.
+ */
+export function accordionStyle(
+ state: AccordionState,
+ ctx: AccordionStyleContext,
+): AccordionStyle {
+ switch (state) {
+ case "opened":
+ return {
+ panelHeight: 1,
+ panelOpacity: 1,
+ chevronRotation: 180,
+ background: ctx.openBg,
+ };
+ default:
+ return {
+ panelHeight: 0,
+ panelOpacity: 0,
+ chevronRotation: 0,
+ background: ctx.closedBg,
+ };
+ }
+}
+
+export function Accordion({
+ state = "closed",
+ style,
+ title = "Is it accessible?",
+ content = "Yes. It adheres to the WAI-ARIA design pattern.",
+ contentHeight = 64,
+ variant = "default",
+ theme: themeOverride,
+ mode,
+ className,
+}: AccordionProps) {
+ const theme = useRemocnTheme(themeOverride, mode);
+
+ const ctx = accordionStyleContext(variant, theme);
+ const v = style ?? accordionStyle(state, ctx);
+
+ return (
+ <div
+ 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
+ className={className}
+ style={{
+ width: CARD_WIDTH,
+ background: v.background,
+ border: ctx.bordered
+ ? `1px solid ${ctx.border}`
+ : "1px solid transparent",
+ borderRadius: theme.radius + 6,
+ overflow: "hidden",
+ }}
+ >
+ {/* Trigger row — always visible; sets the card width. */}
+ <div
+ style={{
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "space-between",
+ gap: 24,
+ padding: 16,
+ fontSize: 15,
+ fontWeight: 500,
+ letterSpacing: "-0.01em",
+ color: ctx.foreground,
+ }}
+ >
+ <span>{title}</span>
+ <svg
+ width={16}
+ height={16}
+ viewBox="0 0 24 24"
+ fill="none"
+ style={{
+ flexShrink: 0,
+ transform: `rotate(${v.chevronRotation}deg)`,
+ }}
+ >
+ <path
+ d="M6 9l6 6 6-6"
+ stroke={ctx.mutedForeground}
+ strokeWidth="2.2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ </div>
+ {/* Panel — height + opacity animate the reveal; content stays mounted. */}
+ <div
+ style={{
+ height: contentHeight * v.panelHeight,
+ opacity: v.panelOpacity,
+ overflow: "hidden",
+ }}
+ >
+ <div
+ style={{
+ padding: "0 16px 16px",
+ fontSize: 14,
+ lineHeight: 1.5,
+ color: ctx.mutedForeground,
+ }}
+ >
+ {content}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/registry/remocn-ui/accordion/use-accordion-transition.ts b/registry/remocn-ui/accordion/use-accordion-transition.ts
new file mode 100644
index 00000000..22a806d3
--- /dev/null
+++ b/registry/remocn-ui/accordion/use-accordion-transition.ts
@@ -0,0 +1,75 @@
+"use client";
+
+import {
+ easings,
+ mixOklch,
+ type RemocnTheme,
+ type Step,
+ useRemocnTheme,
+ useStateTransition,
+} from "@/lib/remocn-ui";
+import {
+ accordionStyle,
+ accordionStyleContext,
+ type AccordionState,
+ type AccordionStyle,
+} from "@/components/remocn/accordion";
+// ^ 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 = 14;
+
+/** Blend two accordion visuals: numbers lerp, background via oklch mix. */
+export function tweenAccordionStyle(
+ a: AccordionStyle,
+ b: AccordionStyle,
+ t: number,
+): AccordionStyle {
+ return {
+ panelHeight: a.panelHeight + (b.panelHeight - a.panelHeight) * t,
+ panelOpacity: a.panelOpacity + (b.panelOpacity - a.panelOpacity) * t,
+ chevronRotation:
+ a.chevronRotation + (b.chevronRotation - a.chevronRotation) * t,
+ background: mixOklch(a.background, b.background, t),
+ };
+}
+
+export interface AccordionTransitionOptions {
+ variant?: "default" | "ghost";
+ theme?: Partial<RemocnTheme>;
+ mode?: "light" | "dark";
+ speed?: number;
+ defaultDuration?: number;
+}
+
+/**
+ * Timeline → resolved (eased, tweened) AccordionStyle. The CALLER invokes this;
+ * it reads the frame, the `<Accordion>` component does not. Feed the result to
+ * `<Accordion style={...} />` for smooth open/close transitions.
+ */
+export function useAccordionTransition(
+ steps: Step<AccordionState>[],
+ opts: AccordionTransitionOptions = {},
+): AccordionStyle {
+ const {
+ variant = "default",
+ theme: themeOverride,
+ mode,
+ speed = 1,
+ defaultDuration = DEFAULT_DURATION,
+ } = opts;
+ const theme = useRemocnTheme(themeOverride, mode);
+ const ctx = accordionStyleContext(variant, theme);
+ const { from, to, progress } = useStateTransition(
+ steps,
+ "closed",
+ speed,
+ defaultDuration,
+ );
+ const t = easings.out(progress);
+ return tweenAccordionStyle(
+ accordionStyle(from, ctx),
+ accordionStyle(to, ctx),
+ t,
+ );
+}
diff --git a/registry/remocn-ui/registry.json b/registry/remocn-ui/registry.json
index 6f444167..591d6db9 100644
--- a/registry/remocn-ui/registry.json
+++ b/registry/remocn-ui/registry.json
@@ -76,6 +76,26 @@
"target": "components/remocn/use-button-transition.ts"
}
]
+ },
+ {
+ "name": "accordion",
+ "type": "registry:component",
+ "title": "UI Accordion",
+ "description": "A disclosure whose opened/closed state is a pure function of the timeline; the panel reveal, chevron, and background are keyframed presets.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["remocn-ui"],
+ "files": [
+ {
+ "path": "accordion/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/accordion.tsx"
+ },
+ {
+ "path": "accordion/use-accordion-transition.ts",
+ "type": "registry:component",
+ "target": "components/remocn/use-accordion-transition.ts"
+ }
+ ]
}
]
}