Skip to content

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

feat: added popover component

dev_wandry0a0f3f8f5686
diff --git a/components/docs/examples/index.tsx b/components/docs/examples/index.tsx
index 23257e5e..5e753395 100644
--- a/components/docs/examples/index.tsx
+++ b/components/docs/examples/index.tsx
@@ -48,6 +48,10 @@ import {
ComboboxExampleScene,
comboboxExampleCode,
} from "./combobox-example";
+import {
+ PopoverExampleScene,
+ popoverExampleCode,
+} from "./popover-example";
export interface ExampleEntry {
Component: ComponentType;
@@ -244,4 +248,13 @@ export const examples: Record<string, ExampleEntry> = {
width: W,
height: H,
},
+ "popover-example": {
+ Component: PopoverExampleScene,
+ code: popoverExampleCode,
+ // Popover closes at 100 + dur 10 = 110; cursor parks at 110; short settle then loop.
+ durationInFrames: 130,
+ fps: FPS,
+ width: W,
+ height: H,
+ },
};
diff --git a/components/docs/examples/popover-example.tsx b/components/docs/examples/popover-example.tsx
new file mode 100644
index 00000000..b21e6463
--- /dev/null
+++ b/components/docs/examples/popover-example.tsx
@@ -0,0 +1,210 @@
+"use client";
+
+import { Cursor } from "@/registry/remocn-ui/cursor";
+import { useCursorPath } from "@/registry/remocn-ui/cursor/use-cursor-path";
+import { Popover } from "@/registry/remocn-ui/popover";
+import { usePopoverTransition } from "@/registry/remocn-ui/popover/use-popover-transition";
+
+// The "@username" chip is centered on the 1280×720 canvas.
+const CHIP_X = 640;
+const CHIP_Y = 360;
+
+export const PopoverExampleScene = () => {
+ // Cursor: park top-left → ease onto the chip → hover → leave.
+ const cursorStyle = useCursorPath([
+ { at: 0, x: 80, y: 60 },
+ { at: 28, x: CHIP_X, y: CHIP_Y, duration: 24 },
+ { at: 110, x: 200, y: 200, duration: 20 },
+ ]);
+
+ // Hover-card popover: opens shortly after the cursor arrives, closes as it leaves.
+ const popoverStyle = usePopoverTransition([
+ { at: 36, state: "opened", duration: 10 },
+ { at: 100, state: "closed", duration: 10 },
+ ]);
+
+ return (
+ <div style={{ position: "relative", width: "100%", height: "100%" }}>
+ {/* Anchor — the @username chip centered in the canvas. */}
+ <div
+ style={{
+ position: "absolute",
+ left: "50%",
+ top: "50%",
+ transform: "translate(-50%, -50%)",
+ display: "inline-block",
+ }}
+ >
+ {/* Chip */}
+ <div
+ style={{
+ display: "inline-flex",
+ alignItems: "center",
+ gap: 6,
+ padding: "4px 10px",
+ borderRadius: 999,
+ background: "oklch(0.94 0 0)",
+ border: "1px solid oklch(0.87 0 0)",
+ fontSize: 14,
+ fontWeight: 500,
+ fontFamily: "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
+ color: "oklch(0.3 0 0)",
+ cursor: "default",
+ }}
+ >
+ @alexsmith
+ </div>
+
+ {/* Popover anchored above the chip, centered horizontally. */}
+ <div
+ style={{
+ position: "absolute",
+ bottom: "calc(100% + 12px)",
+ left: "50%",
+ transform: "translateX(-50%)",
+ }}
+ >
+ <Popover
+ style={popoverStyle}
+ side="top"
+ width={240}
+ >
+ {/* Hover-card content: avatar + name + bio */}
+ <div style={{ display: "flex", gap: 12, alignItems: "flex-start" }}>
+ {/* Avatar placeholder */}
+ <div
+ style={{
+ width: 40,
+ height: 40,
+ borderRadius: 20,
+ background: "oklch(0.75 0.08 260)",
+ flexShrink: 0,
+ }}
+ />
+ <div style={{ display: "flex", flexDirection: "column", gap: 2 }}>
+ <span
+ style={{
+ fontSize: 14,
+ fontWeight: 600,
+ letterSpacing: "-0.01em",
+ fontFamily: "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
+ }}
+ >
+ Alex Smith
+ </span>
+ <span
+ style={{
+ fontSize: 12,
+ color: "oklch(0.55 0 0)",
+ fontFamily: "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
+ }}
+ >
+ @alexsmith
+ </span>
+ <span
+ style={{
+ fontSize: 13,
+ lineHeight: 1.4,
+ color: "oklch(0.4 0 0)",
+ marginTop: 4,
+ fontFamily: "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
+ }}
+ >
+ Product designer. Building in public.
+ </span>
+ </div>
+ </div>
+ </Popover>
+ </div>
+ </div>
+
+ <Cursor style={cursorStyle} variant="pointer" />
+ </div>
+ );
+};
+
+export const popoverExampleCode = `import { Cursor } from "@/components/remocn/cursor";
+import { useCursorPath } from "@/components/remocn/use-cursor-path";
+import { Popover } from "@/components/remocn/popover";
+import { usePopoverTransition } from "@/components/remocn/use-popover-transition";
+
+const CHIP_X = 320;
+const CHIP_Y = 180;
+
+export const Scene = () => {
+ // Cursor eases onto the chip, triggers the hover-card, then leaves.
+ const cursorStyle = useCursorPath([
+ { at: 0, x: 80, y: 60 },
+ { at: 28, x: CHIP_X, y: CHIP_Y, duration: 24 },
+ { at: 110, x: 100, y: 100, duration: 20 },
+ ]);
+
+ // Hover-card opens shortly after the cursor arrives, closes as it leaves.
+ const popoverStyle = usePopoverTransition([
+ { at: 36, state: "opened", duration: 10 },
+ { at: 100, state: "closed", duration: 10 },
+ ]);
+
+ return (
+ <div style={{ position: "relative", width: "100%", height: "100%" }}>
+ {/* Anchor — the @username chip. */}
+ <div
+ style={{
+ position: "absolute",
+ left: "50%",
+ top: "50%",
+ transform: "translate(-50%, -50%)",
+ display: "inline-block",
+ }}
+ >
+ <div
+ style={{
+ display: "inline-flex",
+ alignItems: "center",
+ padding: "4px 10px",
+ borderRadius: 999,
+ background: "oklch(0.94 0 0)",
+ border: "1px solid oklch(0.87 0 0)",
+ fontSize: 14,
+ fontWeight: 500,
+ }}
+ >
+ @alexsmith
+ </div>
+
+ {/* Popover anchored above the chip, centered horizontally. */}
+ <div
+ style={{
+ position: "absolute",
+ bottom: "calc(100% + 12px)",
+ left: "50%",
+ transform: "translateX(-50%)",
+ }}
+ >
+ <Popover style={popoverStyle} side="top" width={240}>
+ <div style={{ display: "flex", gap: 12, alignItems: "flex-start" }}>
+ <div
+ style={{
+ width: 40,
+ height: 40,
+ borderRadius: 20,
+ background: "oklch(0.75 0.08 260)",
+ flexShrink: 0,
+ }}
+ />
+ <div style={{ display: "flex", flexDirection: "column", gap: 2 }}>
+ <span style={{ fontSize: 14, fontWeight: 600 }}>Alex Smith</span>
+ <span style={{ fontSize: 12, color: "oklch(0.55 0 0)" }}>@alexsmith</span>
+ <span style={{ fontSize: 13, lineHeight: 1.4, color: "oklch(0.4 0 0)", marginTop: 4 }}>
+ Product designer. Building in public.
+ </span>
+ </div>
+ </div>
+ </Popover>
+ </div>
+ </div>
+
+ <Cursor style={cursorStyle} variant="pointer" />
+ </div>
+ );
+};`;
diff --git a/content/docs/ui/components/meta.json b/content/docs/ui/components/meta.json
index 29903b0b..faa72e01 100644
--- a/content/docs/ui/components/meta.json
+++ b/content/docs/ui/components/meta.json
@@ -1,5 +1,5 @@
{
"title": "Components",
"collapsible": false,
- "pages": ["accordion", "alert-dialog", "button", "checkbox", "combobox", "command-menu", "cursor", "dialog", "drawer", "sheet", "dropdown-menu", "input", "progress", "radio", "select", "skeleton", "slider", "spinner", "switch", "tabs", "toast", "tooltip"]
+ "pages": ["accordion", "alert-dialog", "button", "checkbox", "combobox", "command-menu", "cursor", "dialog", "drawer", "sheet", "dropdown-menu", "input", "popover", "progress", "radio", "select", "skeleton", "slider", "spinner", "switch", "tabs", "toast", "tooltip"]
}
diff --git a/content/docs/ui/components/popover.mdx b/content/docs/ui/components/popover.mdx
new file mode 100644
index 00000000..d5a8451c
--- /dev/null
+++ b/content/docs/ui/components/popover.mdx
@@ -0,0 +1,203 @@
+---
+title: Popover
+description: A floating card that appears beside an anchor with arbitrary content
+---
+
+<ComponentPreview name="popover" />
+
+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 card fades in at 0.97 scale, slides 6 px toward the anchor, and rests fully visible; `closed` reverses the motion. Placement is the caller's responsibility — the popover renders inline and the caller wraps it in an absolutely-positioned anchor div.
+
+The hover-card pattern (a rich profile card that appears on hover) is this component driven by hover timing: use `usePopoverTransition` with steps that match when a `Cursor` arrives at and leaves the anchor.
+
+## Installation
+
+<InstallBlock name="popover" />
+
+<Note>
+Installing `popover` automatically installs the shared `remocn-ui` core (`lib/remocn-ui/`) via `registryDependencies` (`["remocn-ui"]`). You do not need to install it separately. Both `popover` (the renderer) and `use-popover-transition` (the hook) are copied into your project.
+</Note>
+
+## Example
+
+<LiveExample name="popover-example" />
+
+## States
+
+`PopoverState` is:
+
+```ts
+type PopoverState =
+ | "closed" // opacity 0, scale 0.97, translate 6px away from anchor
+ | "opened" // opacity 1, scale 1, translate 0
+```
+
+`closed` is the default. The `translate` magnitude (6 px when closed, 0 when opened) is resolved by the component into an axis offset based on `side` — a `"top"` popover slides upward when closed, a `"bottom"` popover slides downward, and so on. (Same `offsetFor` convention as the Tooltip primitive.)
+
+## 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 { Popover } from "@/components/remocn/popover";
+
+export const Scene = () => (
+ <div style={{ position: "relative", width: "100%", height: "100%" }}>
+ <div style={{ position: "absolute", left: "50%", top: "40%", transform: "translate(-50%, -100%)" }}>
+ <Popover state="opened" title="Alex Smith" description="Product designer. Building in public." />
+ </div>
+ </div>
+);
+```
+
+To drive state from the timeline, use `useCurrentState`:
+
+```tsx
+import { useCurrentState } from "@/lib/remocn-ui";
+import { Popover } from "@/components/remocn/popover";
+
+export const Scene = () => {
+ const state = useCurrentState(
+ [
+ { at: 36, state: "opened" },
+ { at: 100, state: "closed" },
+ ],
+ "closed",
+ );
+
+ return (
+ <div style={{ position: "relative", width: "100%", height: "100%" }}>
+ <div style={{ position: "absolute", left: "50%", top: "40%", transform: "translate(-50%, -100%)" }}>
+ <Popover state={state} title="Alex Smith" description="Product designer. Building in public." />
+ </div>
+ </div>
+ );
+};
+```
+
+Each `at` is a **Sequence-local authored frame**. State persists between steps: `opened` at frame 36 keeps the card on-screen until `closed` fires at frame 100. See [Concepts](/docs/ui/concepts) for the full `useCurrentState` API.
+
+## Smooth transitions
+
+State changes via `state` snap with no cross-fade. For an animated show/hide, use `usePopoverTransition` from the copied `use-popover-transition.ts` file. It reads the frame, interpolates between state presets, and returns a resolved `PopoverStyle` — pass it to the `style` prop:
+
+```tsx
+import { Popover } from "@/components/remocn/popover";
+import { usePopoverTransition } from "@/components/remocn/use-popover-transition";
+
+export const Scene = () => {
+ const style = usePopoverTransition([
+ { at: 36, state: "opened", duration: 10 },
+ { at: 100, state: "closed", duration: 10 },
+ ]);
+
+ return (
+ <div style={{ position: "relative", width: "100%", height: "100%" }}>
+ <div style={{ position: "absolute", left: "50%", top: "40%", transform: "translate(-50%, -100%)" }}>
+ <Popover style={style} title="Alex Smith" description="Product designer. Building in public." />
+ </div>
+ </div>
+ );
+};
+```
+
+The `duration` field on each step overrides the file's `DEFAULT_DURATION` (= `10`) for that specific transition. To globally tune timing and easing, edit `use-popover-transition.ts` directly in your project — that file is yours (shadcn "own your code" philosophy).
+
+`style` takes precedence over `state` when both are provided.
+
+## Sides
+
+The `side` prop controls which direction the card slides in from when it appears. It is a static prop — it does not animate.
+
+```ts
+type PopoverSide =
+ | "top" // card above anchor, enters sliding up 6px
+ | "bottom" // card below anchor, enters sliding down 6px (default)
+ | "left" // card left of anchor, enters sliding left 6px
+ | "right" // card right of anchor, enters sliding right 6px
+```
+
+Placement is the caller's responsibility. The popover renders inline — wrap it in an absolutely-positioned div that positions the card relative to its anchor. For a `"top"` popover:
+
+```tsx
+<div style={{ position: "relative", display: "inline-block" }}>
+ {/* Anchor element */}
+ <div>@alexsmith</div>
+
+ {/* Popover positioned above the anchor, centered horizontally */}
+ <div
+ style={{
+ position: "absolute",
+ bottom: "calc(100% + 12px)",
+ left: "50%",
+ transform: "translateX(-50%)",
+ }}
+ >
+ <Popover style={popoverStyle} side="top" width={240}>
+ {/* hover-card content */}
+ </Popover>
+ </div>
+</div>
+```
+
+For `"bottom"`, use `top: "calc(100% + 12px)"` instead. For `"left"` / `"right"`, use `right: "calc(100% + 12px)"` / `left: "calc(100% + 12px)"` and adjust vertical alignment to `top: "50%"` with `translateY(-50%)`.
+
+## Props
+
+<PropsTable
+ rows={[
+ {
+ name: "state",
+ type: "\"closed\" | \"opened\"",
+ default: "\"closed\"",
+ description: "Current visual state (snap path). State changes snap — no automatic cross-fade.",
+ },
+ {
+ name: "style",
+ type: "PopoverStyle",
+ description: "Resolved animated visual (smooth path). Pass an interpolated PopoverStyle from usePopoverTransition. Takes precedence over state when provided.",
+ },
+ {
+ name: "children",
+ type: "ReactNode",
+ description: "Arbitrary content rendered inside the card. Covers the hover-card scenario — pass an avatar, name, bio, or any layout. Rendered after title/description when both are given.",
+ },
+ {
+ name: "title",
+ type: "string",
+ description: "Card heading rendered at 15px/500 weight. Optional — omit for content-only cards.",
+ },
+ {
+ name: "description",
+ type: "string",
+ description: "Body copy rendered at 13px in muted-foreground color below the title. Optional.",
+ },
+ {
+ name: "side",
+ type: "\"top\" | \"bottom\" | \"left\" | \"right\"",
+ default: "\"bottom\"",
+ description: "Which side of the anchor the card sits on. Sets the enter-slide direction. Static — not animated.",
+ },
+ {
+ name: "width",
+ type: "number",
+ default: "288",
+ description: "Card width in px.",
+ },
+ {
+ name: "theme",
+ type: "Partial<RemocnTheme>",
+ description: "Per-component theme override. Merges with the active RemocnUIProvider theme and the mode defaults. Must be concrete oklch/hex/rgb values — not CSS custom properties.",
+ },
+ {
+ name: "mode",
+ type: "\"light\" | \"dark\"",
+ default: "\"light\"",
+ description: "Sets the base palette. Overrides the mode on RemocnUIProvider when both are present.",
+ },
+ {
+ name: "className",
+ type: "string",
+ description: "Optional className applied to the outer wrapper element.",
+ },
+ ]}
+/>
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index 1e152806..15a0ad30 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -157,6 +157,8 @@ import { SliderPreview } from "@/registry/remocn-ui/slider/preview";
import { sliderConfig } from "@/registry/remocn-ui/slider/config";
import { Combobox } from "@/registry/remocn-ui/combobox";
import { comboboxConfig } from "@/registry/remocn-ui/combobox/config";
+import { PopoverPreview } from "@/registry/remocn-ui/popover/preview";
+import { popoverConfig } from "@/registry/remocn-ui/popover/config";
import { ZoomThroughTransition } from "@/registry/remocn/zoom-through-transition";
import { zoomThroughTransitionConfig } from "@/registry/remocn/zoom-through-transition/config";
@@ -382,6 +384,9 @@ const registry: Record<string, RegistryEntry> = {
// combobox registers RAW (no preview wrapper): like select it paints its own
// opaque inset:0 wrapper, so the customizer mounts it directly and it centers.
"combobox": { Component: Combobox, config: comboboxConfig },
+ // popover's customizer Component is the preview-only PopoverPreview wrapper: a
+ // bare card has no backdrop and would not center as the composition root.
+ "popover": { Component: PopoverPreview, config: popoverConfig },
"spinner": { Component: Spinner, config: spinnerConfig },
};
diff --git a/registry/remocn-ui/popover/__tests__/README.md b/registry/remocn-ui/popover/__tests__/README.md
new file mode 100644
index 00000000..dd195d88
--- /dev/null
+++ b/registry/remocn-ui/popover/__tests__/README.md
@@ -0,0 +1,53 @@
+# popover/__tests__
+
+Verification tests for the pure, deterministic surface of the `popover` primitive.
+
+## What is tested
+
+| Section | Source | Coverage |
+|---------|--------|----------|
+| `DEFAULT_DURATION` | `use-popover-transition.ts` | Constant equals 10 |
+| `popoverStyle` | `index.tsx` lines 65–72 | closed keyframe full fields; opened keyframe full fields; distinct per state; all fields numeric; default arm |
+| `tweenPopoverStyle` | `use-popover-transition.ts` lines 20–30 | t=0 → a; t=1 → b; t=0.5 midpoint; t=0.25 quarter; identity; reverse direction |
+| `resolvePopoverTransition` | replica of `use-popover-transition.ts` lines 44–57 | before first step; at boundary (progress=0); mid-window eased (non-linear); past window; speed contract |
+| `popoverConfig.controls` | `config.ts` | state/side/title/description/width/mode types, defaults, options |
+| `popoverConfig.snippet` | `config.ts` | import line; structural invariants; default omission; non-default emission; state/side round-trip |
+
+## What is NOT tested
+
+**Render path** — `Popover` calls `useRemocnTheme` (React context) and renders JSX. The component function is not exercised here.
+
+**`offsetFor`** — This module-private helper (not exported) translates the `translate` magnitude into a CSS `x`/`y` offset for the active `side`. Its contract is:
+
+| `side` | `x` | `y` |
+|--------|-----|-----|
+| `top` | `0` | `+translate` (card above anchor, lifts up toward it) |
+| `bottom` | `0` | `-translate` (card below, lifts up) |
+| `left` | `+translate` | `0` |
+| `right` | `-translate` | `0` |
+
+Because `offsetFor` is not exported it cannot be unit-tested directly. The `translate` field it consumes is fully covered through `popoverStyle`, `tweenPopoverStyle`, and the resolver replica.
+
+## Animation model
+
+`popoverStyle` returns three numeric fields encoding the card reveal:
+
+| State | `opacity` | `scale` | `translate` |
+|-------|-----------|---------|-------------|
+| `closed` | 0 | 0.97 | 6 |
+| `opened` | 1 | 1.00 | 0 |
+
+`usePopoverTransition` folds a step list, applies `easings.out` to the linear `progress`, then lerps between the two endpoint presets with `tweenPopoverStyle`. Because `out(t) = 1-(1-t)³`, the midpoint `t=0.5` eases to `0.875` — confirmed in the mid-window tests: at frame 5 of a 10-frame window, `opacity=0.875`, `scale≈0.99625`, `translate=0.75`.
+
+The `side` prop is **static** — it only sets the enter-translate axis/sign in `offsetFor` and is not animated.
+
+## Determinism grep checklist
+
+Run this on `popover/index.tsx` — it must print nothing:
+
+```bash
+grep -nE "useState|useEffect|useCurrentFrame|onClick|onChange|addEventListener|Date\.now|Math\.random|requestAnimationFrame" \
+ registry/remocn-ui/popover/index.tsx
+```
+
+The `Popover` component is a pure renderer: no frame reading, no local state, no side effects. Frame reading lives exclusively in `usePopoverTransition` (`use-popover-transition.ts`), which is not imported here.
diff --git a/registry/remocn-ui/popover/__tests__/popover.test.ts b/registry/remocn-ui/popover/__tests__/popover.test.ts
new file mode 100644
index 00000000..d9c218d4
--- /dev/null
+++ b/registry/remocn-ui/popover/__tests__/popover.test.ts
@@ -0,0 +1,653 @@
+/**
+ * Verification tests for the PURE / DETERMINISTIC parts of `popover`.
+ *
+ * Scope:
+ * - registry/remocn-ui/popover/index.tsx
+ * popoverStyle(state) — complete state→visual preset map
+ * (no popoverStyleContext — Popover uses theme tokens directly; no pure
+ * style-context export on this component; `offsetFor` is module-private)
+ * - registry/remocn-ui/popover/use-popover-transition.ts
+ * tweenPopoverStyle(a, b, t) — pure lerp across all three fields
+ * DEFAULT_DURATION constant
+ * usePopoverTransition resolver — mirrored as resolvePopoverTransition
+ * with frame injected as `raw` (annotated source lines)
+ * - registry/remocn-ui/popover/config.ts
+ * popoverConfig.controls wiring + popoverConfig.snippet codegen
+ *
+ * The render path (index.tsx) imports `useRemocnTheme` which requires React
+ * context and cannot run headlessly — it is NOT exercised here. `offsetFor` is
+ * a module-private helper that turns the `translate` magnitude into a CSS
+ * transform offset for a side; it is not exported, so its contract is documented
+ * in the README and covered indirectly through the render path.
+ *
+ * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
+ * bun test registry/remocn-ui/popover/__tests__
+ *
+ * --------------------------------------------------------------------------
+ * IMPORT STRATEGY
+ * --------------------------------------------------------------------------
+ * Relative imports for component source; `@/lib/remocn-ui` alias for core.
+ * `usePopoverTransition` is NOT imported — it reads `useCurrentFrame()`.
+ * Its pure body is mirrored as `resolvePopoverTransition` with frame injected.
+ * --------------------------------------------------------------------------
+ */
+
+import { describe, expect, it } from "bun:test";
+import {
+ popoverStyle,
+ type PopoverState,
+ type PopoverSide,
+} from "../index";
+import {
+ tweenPopoverStyle,
+ DEFAULT_DURATION,
+} from "../use-popover-transition";
+import { popoverConfig } from "../config";
+import { easings } from "@/lib/remocn-ui";
+import type { Step } from "@/lib/remocn-ui";
+
+// ===========================================================================
+// Shared fixtures
+// ===========================================================================
+
+const VALID_STATES: readonly PopoverState[] = ["opened", "closed"];
+const VALID_SIDES: readonly PopoverSide[] = ["top", "bottom", "left", "right"];
+
+/** Convenience wrapper for snippet(). */
+type SnippetValues = {
+ state?: string;
+ title?: string;
+ description?: string;
+ side?: string;
+ width?: number;
+ mode?: string;
+};
+const snippet = (values: SnippetValues): string =>
+ popoverConfig.snippet(values as Record<string, unknown>);
+
+// ===========================================================================
+// 1. DEFAULT_DURATION constant
+// ===========================================================================
+
+describe("DEFAULT_DURATION", () => {
+ it("is 10 frames", () => {
+ expect(DEFAULT_DURATION).toBe(10);
+ });
+});
+
+// ===========================================================================
+// 2. popoverStyle — pure (state) => PopoverStyle map
+// MIRROR of index.tsx lines 65-72
+// Every field asserted for both states.
+// ===========================================================================
+
+describe("popoverStyle: closed state — off-screen keyframe", () => {
+ const s = popoverStyle("closed");
+
+ it("opacity is 0 (card invisible)", () => {
+ expect(s.opacity).toBe(0);
+ });
+
+ it("scale is 0.97 (slightly shrunken at closed)", () => {
+ expect(s.scale).toBeCloseTo(0.97, 10);
+ });
+
+ it("translate is 6 (enters from 6px offset)", () => {
+ expect(s.translate).toBe(6);
+ });
+});
+
+describe("popoverStyle: opened state — resting keyframe", () => {
+ const s = popoverStyle("opened");
+
+ it("opacity is 1 (card fully visible)", () => {
+ expect(s.opacity).toBe(1);
+ });
+
+ it("scale is 1 (full size)", () => {
+ expect(s.scale).toBe(1);
+ });
+
+ it("translate is 0 (at rest position, no offset)", () => {
+ expect(s.translate).toBe(0);
+ });
+});
+
+describe("popoverStyle: both states are complete keyframes", () => {
+ it("all three PopoverStyle fields are numeric for every state", () => {
+ for (const state of VALID_STATES) {
+ const s = popoverStyle(state);
+ expect(typeof s.opacity).toBe("number");
+ expect(typeof s.scale).toBe("number");
+ expect(typeof s.translate).toBe("number");
+ }
+ });
+
+ it("closed and opened have distinct opacity (0 vs 1)", () => {
+ expect(popoverStyle("closed").opacity).toBe(0);
+ expect(popoverStyle("opened").opacity).toBe(1);
+ });
+
+ it("closed and opened have distinct scale (0.97 vs 1)", () => {
+ expect(popoverStyle("closed").scale).toBeCloseTo(0.97, 10);
+ expect(popoverStyle("opened").scale).toBe(1);
+ });
+
+ it("closed and opened have distinct translate (6 vs 0)", () => {
+ expect(popoverStyle("closed").translate).toBe(6);
+ expect(popoverStyle("opened").translate).toBe(0);
+ });
+});
+
+describe("popoverStyle: unknown state falls through to closed preset", () => {
+ // The switch has only an explicit 'opened' arm; default → closed
+ it("'closed' returns opacity=0 (via default arm)", () => {
+ expect(popoverStyle("closed").opacity).toBe(0);
+ });
+});
+
+// ===========================================================================
+// 3. tweenPopoverStyle — pure lerp across all three numeric fields
+// MIRROR of use-popover-transition.ts lines 20-30
+// All fields are numeric (no animated colors); no mixOklch call.
+// ===========================================================================
+
+describe("tweenPopoverStyle: t=0 returns values equal to `a`", () => {
+ const a = popoverStyle("closed");
+ const b = popoverStyle("opened");
+ const r = tweenPopoverStyle(a, b, 0);
+
+ it("opacity equals a.opacity at t=0", () => {
+ expect(r.opacity).toBeCloseTo(a.opacity, 10);
+ });
+
+ it("scale equals a.scale at t=0", () => {
+ expect(r.scale).toBeCloseTo(a.scale, 10);
+ });
+
+ it("translate equals a.translate at t=0", () => {
+ expect(r.translate).toBeCloseTo(a.translate, 10);
+ });
+});
+
+describe("tweenPopoverStyle: t=1 returns values equal to `b`", () => {
+ const a = popoverStyle("closed");
+ const b = popoverStyle("opened");
+ const r = tweenPopoverStyle(a, b, 1);
+
+ it("opacity equals b.opacity at t=1", () => {
+ expect(r.opacity).toBeCloseTo(b.opacity, 10);
+ });
+
+ it("scale equals b.scale at t=1", () => {
+ expect(r.scale).toBeCloseTo(b.scale, 10);
+ });
+
+ it("translate equals b.translate at t=1", () => {
+ expect(r.translate).toBeCloseTo(b.translate, 10);
+ });
+});
+
+describe("tweenPopoverStyle: t=0.5 midpoint (closed → opened)", () => {
+ // closed: opacity=0, scale=0.97, translate=6
+ // opened: opacity=1, scale=1, translate=0
+ // midpoint: opacity=0.5, scale=0.985, translate=3
+ const a = popoverStyle("closed");
+ const b = popoverStyle("opened");
+ const r = tweenPopoverStyle(a, b, 0.5);
+
+ it("opacity midpoint: 0 → 1 gives 0.5", () => {
+ expect(r.opacity).toBeCloseTo(0.5, 10);
+ });
+
+ it("scale midpoint: 0.97 → 1 gives 0.985", () => {
+ expect(r.scale).toBeCloseTo(0.985, 10);
+ });
+
+ it("translate midpoint: 6 → 0 gives 3", () => {
+ expect(r.translate).toBeCloseTo(3, 10);
+ });
+});
+
+describe("tweenPopoverStyle: t=0.25 quarter-point (closed → opened)", () => {
+ // opacity: 0.25, scale: 0.97+0.03*0.25=0.9775, translate: 6-6*0.25=4.5
+ const a = popoverStyle("closed");
+ const b = popoverStyle("opened");
+ const r = tweenPopoverStyle(a, b, 0.25);
+
+ it("opacity at t=0.25 is 0.25", () => {
+ expect(r.opacity).toBeCloseTo(0.25, 10);
+ });
+
+ it("scale at t=0.25 is 0.9775", () => {
+ expect(r.scale).toBeCloseTo(0.9775, 10);
+ });
+
+ it("translate at t=0.25 is 4.5", () => {
+ expect(r.translate).toBeCloseTo(4.5, 10);
+ });
+});
+
+describe("tweenPopoverStyle: identity (a === b)", () => {
+ const s = popoverStyle("opened");
+
+ it("all fields unchanged when both endpoints are the same", () => {
+ const r = tweenPopoverStyle(s, s, 0.5);
+ expect(r.opacity).toBeCloseTo(s.opacity, 10);
+ expect(r.scale).toBeCloseTo(s.scale, 10);
+ expect(r.translate).toBeCloseTo(s.translate, 10);
+ });
+});
+
+describe("tweenPopoverStyle: reverse direction (opened → closed)", () => {
+ // By symmetry midpoints are the same magnitude
+ const a = popoverStyle("opened");
+ const b = popoverStyle("closed");
+ const r = tweenPopoverStyle(a, b, 0.5);
+
+ it("opacity midpoint: 1 → 0 gives 0.5", () => {
+ expect(r.opacity).toBeCloseTo(0.5, 10);
+ });
+
+ it("scale midpoint: 1 → 0.97 gives 0.985", () => {
+ expect(r.scale).toBeCloseTo(0.985, 10);
+ });
+
+ it("translate midpoint: 0 → 6 gives 3", () => {
+ expect(r.translate).toBeCloseTo(3, 10);
+ });
+});
+
+// ===========================================================================
+// 4. usePopoverTransition resolver replica
+// MIRRORS use-popover-transition.ts lines 44-57.
+// `usePopoverTransition` calls `useStateTransition` (reads useCurrentFrame())
+// then applies `easings.out(progress)` and `tweenPopoverStyle`.
+// We inject `raw` in place of useCurrentFrame().
+//
+// Key additional contract: progress is eased with `easings.out` before the
+// tween, making the result non-linear. out(0.5) = 0.875.
+//
+// MAINTENANCE CONTRACT: if use-popover-transition.ts lines 44-57 change,
+// update this replica in lockstep. Annotated source lines below.
+// ===========================================================================
+
+/** MIRROR of core/timeline.ts:clamp01. */
+function clamp01(t: number): number {
+ return Math.max(0, Math.min(1, t));
+}
+
+/**
+ * MIRROR of timeline.ts:useStateTransition pure resolver body.
+ * `raw` is injected in place of useCurrentFrame().
+ */
+function resolveStateTransition<S extends string>(
+ raw: number,
+ steps: Step<S>[],
+ defaultState: S,
+ speed = 1,
+ defaultDuration = 8,
+): { from: S; to: S; progress: number } {
+ const effectiveFrame = raw * speed;
+ const started = steps
+ .map((step, index) => ({ step, index }))
+ .sort((a, b) => a.step.at - b.step.at || a.index - b.index)
+ .filter((e) => e.step.at <= effectiveFrame);
+ if (started.length === 0)
+ return { from: defaultState, to: defaultState, progress: 1 };
+ const to = started[started.length - 1].step;
+ const from = started.length >= 2 ? started[started.length - 2].step : null;
+ const dur = to.duration ?? defaultDuration;
+ const progress = dur > 0 ? clamp01((effectiveFrame - to.at) / dur) : 1;
+ return { from: from ? from.state : defaultState, to: to.state, progress };
+}
+
+/**
+ * MIRROR of use-popover-transition.ts:usePopoverTransition (lines 44-57).
+ * `raw` is injected in place of useCurrentFrame().
+ * Annotated source lines:
+ * line 48: destructure speed + defaultDuration from opts
+ * lines 49-54: useStateTransition (mirrored as resolveStateTransition)
+ * line 55: t = easings.out(progress) ← MIRROR line 55
+ * line 56: tweenPopoverStyle(from, to, t) ← MIRROR line 56
+ */
+function resolvePopoverTransition(
+ raw: number, // injected useCurrentFrame() — MIRROR line 49
+ steps: Step<PopoverState>[],
+ speed = 1,
+ defaultDuration = DEFAULT_DURATION,
+): { opacity: number; scale: number; translate: number; from: PopoverState; to: PopoverState; progress: number } {
+ const { from, to, progress } = resolveStateTransition( // MIRROR lines 49-54
+ raw,
+ steps,
+ "closed",
+ speed,
+ defaultDuration,
+ );
+ const t = easings.out(progress); // MIRROR line 55
+ const style = tweenPopoverStyle( // MIRROR line 56
+ popoverStyle(from as PopoverState),
+ popoverStyle(to as PopoverState),
+ t,
+ );
+ return { ...style, from: from as PopoverState, to: to as PopoverState, progress };
+}
+
+// ---------------------------------------------------------------------------
+// Before any step: holds at closed (progress=1, tween(closed,closed,out(1)))
+// ---------------------------------------------------------------------------
+
+describe("resolvePopoverTransition: before any step — holds at closed", () => {
+ it("returns the closed style when no steps have started", () => {
+ const r = resolvePopoverTransition(0, []);
+ const closed = popoverStyle("closed");
+ expect(r.opacity).toBeCloseTo(closed.opacity, 10);
+ expect(r.scale).toBeCloseTo(closed.scale, 10);
+ expect(r.translate).toBeCloseTo(closed.translate, 10);
+ });
+
+ it("from and to are both 'closed' before any step", () => {
+ const r = resolvePopoverTransition(0, []);
+ expect(r.from).toBe("closed");
+ expect(r.to).toBe("closed");
+ });
+});
+
+// ---------------------------------------------------------------------------
+// Exactly at a step boundary: progress=0, t=out(0)=0 → closed style
+// ---------------------------------------------------------------------------
+
+describe("resolvePopoverTransition: exactly at closed→opened step boundary", () => {
+ const steps: Step<PopoverState>[] = [{ at: 10, state: "opened" }];
+
+ it("at raw=10, progress=0, t=out(0)=0 → style equals closed (from)", () => {
+ const r = resolvePopoverTransition(10, steps);
+ const closed = popoverStyle("closed");
+ expect(r.progress).toBe(0);
+ expect(r.opacity).toBeCloseTo(closed.opacity, 10);
+ expect(r.scale).toBeCloseTo(closed.scale, 10);
+ expect(r.translate).toBeCloseTo(closed.translate, 10);
+ });
+
+ it("from='closed', to='opened' at the step boundary", () => {
+ const r = resolvePopoverTransition(10, steps);
+ expect(r.from).toBe("closed");
+ expect(r.to).toBe("opened");
+ });
+});
+
+// ---------------------------------------------------------------------------
+// Mid-window: easings.out applied — non-linear (not raw 0.5)
+// step at=0, duration=10, raw=5: linear=0.5, out(0.5)=0.875
+// opacity: tween(0,1,0.875) = 0.875
+// scale: tween(0.97,1,0.875) = 0.97 + 0.03*0.875 = 0.99625
+// translate: tween(6,0,0.875) = 6*(1-0.875) = 0.75
+// ---------------------------------------------------------------------------
+
+describe("resolvePopoverTransition: mid-window uses easings.out (not linear)", () => {
+ const steps: Step<PopoverState>[] = [{ at: 0, state: "opened" }];
+
+ it("opacity at raw=5 is out(0.5)=0.875 (not linear 0.5)", () => {
+ const r = resolvePopoverTransition(5, steps, 1, 10);
+ const t = easings.out(0.5); // 0.875
+ expect(r.opacity).toBeCloseTo(t, 8);
+ });
+
+ it("scale at raw=5 is 0.97 + 0.03*out(0.5) = 0.99625", () => {
+ const r = resolvePopoverTransition(5, steps, 1, 10);
+ const t = easings.out(0.5);
+ const expected = 0.97 + (1 - 0.97) * t; // 0.99625
+ expect(r.scale).toBeCloseTo(expected, 8);
+ });
+
+ it("translate at raw=5 is 6*(1-out(0.5)) = 0.75", () => {
+ const r = resolvePopoverTransition(5, steps, 1, 10);
+ const t = easings.out(0.5);
+ const expected = 6 * (1 - t); // lerp(6,0,t) = 0.75
+ expect(r.translate).toBeCloseTo(expected, 8);
+ });
+
+ it("easing confirmed non-linear: opacity at raw=5 is not 0.5", () => {
+ const r = resolvePopoverTransition(5, steps, 1, 10);
+ expect(r.opacity).not.toBeCloseTo(0.5, 2);
+ });
+});
+
+// ---------------------------------------------------------------------------
+// Past the window: fully opened
+// ---------------------------------------------------------------------------
+
+describe("resolvePopoverTransition: past the window → fully opened", () => {
+ const steps: Step<PopoverState>[] = [{ at: 0, state: "opened" }];
+
+ it("opacity is 1 after DEFAULT_DURATION frames", () => {
+ expect(resolvePopoverTransition(DEFAULT_DURATION, steps).opacity).toBeCloseTo(1, 10);
+ });
+
+ it("scale is 1 after DEFAULT_DURATION frames", () => {
+ expect(resolvePopoverTransition(DEFAULT_DURATION, steps).scale).toBeCloseTo(1, 10);
+ });
+
+ it("translate is 0 after DEFAULT_DURATION frames", () => {
+ expect(resolvePopoverTransition(DEFAULT_DURATION, steps).translate).toBeCloseTo(0, 10);
+ });
+});
+
+// ---------------------------------------------------------------------------
+// Speed contract
+// ---------------------------------------------------------------------------
+
+describe("resolvePopoverTransition: speed contract", () => {
+ const steps: Step<PopoverState>[] = [{ at: 10, state: "opened" }];
+
+ it("speed=2: step at=10 fires at raw=5 (effectiveFrame=10)", () => {
+ expect(resolvePopoverTransition(5, steps, 2).to).toBe("opened");
+ });
+
+ it("speed=2: step at=10 has NOT fired at raw=4 (effectiveFrame=8 < 10)", () => {
+ expect(resolvePopoverTransition(4, steps, 2).to).toBe("closed");
+ });
+});
+
+// ===========================================================================
+// 5. popoverConfig.controls — customizer control wiring
+// ===========================================================================
+
+describe("popoverConfig.controls: state", () => {
+ it("state is a select control", () => {
+ expect(popoverConfig.controls.state.type).toBe("select");
+ });
+
+ it("state options are ['opened','closed']", () => {
+ const ctrl = popoverConfig.controls.state;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ expect(ctrl.options).toEqual(["opened", "closed"]);
+ });
+
+ it("state default is 'opened' (shows the resting card in preview)", () => {
+ expect(popoverConfig.controls.state.default).toBe("opened");
+ });
+
+ it("every state option is a valid PopoverState", () => {
+ const ctrl = popoverConfig.controls.state;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ for (const opt of ctrl.options) {
+ expect(VALID_STATES).toContain(opt as PopoverState);
+ }
+ });
+});
+
+describe("popoverConfig.controls: side", () => {
+ it("side is a select control", () => {
+ expect(popoverConfig.controls.side.type).toBe("select");
+ });
+
+ it("side options are ['top','bottom','left','right']", () => {
+ const ctrl = popoverConfig.controls.side;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ expect(ctrl.options).toEqual(["top", "bottom", "left", "right"]);
+ });
+
+ it("side default is 'bottom'", () => {
+ expect(popoverConfig.controls.side.default).toBe("bottom");
+ });
+
+ it("every side option is a valid PopoverSide", () => {
+ const ctrl = popoverConfig.controls.side;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ for (const opt of ctrl.options) {
+ expect(VALID_SIDES).toContain(opt as PopoverSide);
+ }
+ });
+});
+
+describe("popoverConfig.controls: title", () => {
+ it("title is a text control", () => {
+ expect(popoverConfig.controls.title.type).toBe("text");
+ });
+
+ it("title default is 'Dimensions'", () => {
+ expect(popoverConfig.controls.title.default).toBe("Dimensions");
+ });
+});
+
+describe("popoverConfig.controls: description", () => {
+ it("description is a text control", () => {
+ expect(popoverConfig.controls.description.type).toBe("text");
+ });
+
+ it("description default is 'Set the dimensions for the layer.'", () => {
+ expect(popoverConfig.controls.description.default).toBe(
+ "Set the dimensions for the layer.",
+ );
+ });
+});
+
+describe("popoverConfig.controls: width", () => {
+ it("width is a number control", () => {
+ expect(popoverConfig.controls.width.type).toBe("number");
+ });
+
+ it("width default is 288", () => {
+ expect(popoverConfig.controls.width.default).toBe(288);
+ });
+
+ it("width min is 160", () => {
+ const ctrl = popoverConfig.controls.width;
+ if (ctrl.type !== "number") throw new Error("expected number");
+ expect(ctrl.min).toBe(160);
+ });
+});
+
+describe("popoverConfig.controls: mode", () => {
+ it("mode is a select control", () => {
+ expect(popoverConfig.controls.mode.type).toBe("select");
+ });
+
+ it("mode default is 'light'", () => {
+ expect(popoverConfig.controls.mode.default).toBe("light");
+ });
+});
+
+// ===========================================================================
+// 6. popoverConfig.snippet — pure JSX string builder
+// ===========================================================================
+
+describe("popoverConfig.snippet: import line", () => {
+ it("includes 'import { Popover }' from the correct path", () => {
+ const out = snippet({ state: "opened" });
+ expect(out).toContain("import { Popover }");
+ expect(out).toContain('from "@/components/remocn/popover"');
+ });
+});
+
+describe("popoverConfig.snippet: structural invariants", () => {
+ it("contains a <Popover JSX element", () => {
+ expect(snippet({ state: "opened" })).toContain("<Popover");
+ });
+
+ it("ends with a self-closing />", () => {
+ expect(snippet({ state: "opened" }).trimEnd().endsWith("/>")).toBe(true);
+ });
+
+ it("state is always emitted", () => {
+ for (const state of VALID_STATES) {
+ expect(snippet({ state })).toContain(`state="${state}"`);
+ }
+ });
+});
+
+describe("popoverConfig.snippet: default props are omitted", () => {
+ it("omits title when it is empty string", () => {
+ expect(snippet({ state: "opened", title: "" })).not.toContain("title=");
+ });
+
+ it("omits description when it is empty string", () => {
+ expect(snippet({ state: "opened", description: "" })).not.toContain("description=");
+ });
+
+ it("omits side when it equals the default 'bottom'", () => {
+ expect(snippet({ state: "opened", side: "bottom" })).not.toContain("side=");
+ });
+
+ it("omits width when it equals the default 288", () => {
+ expect(snippet({ state: "opened", width: 288 })).not.toContain("width=");
+ });
+
+ it("omits mode when it equals the default 'light'", () => {
+ expect(snippet({ state: "opened", mode: "light" })).not.toContain("mode=");
+ });
+});
+
+describe("popoverConfig.snippet: non-default props are emitted", () => {
+ it("emits title when non-empty", () => {
+ expect(snippet({ state: "opened", title: "Dimensions" })).toContain('title="Dimensions"');
+ });
+
+ it("emits description when non-empty", () => {
+ expect(
+ snippet({ state: "opened", description: "Set the dimensions for the layer." })
+ ).toContain('description="Set the dimensions for the layer."');
+ });
+
+ it("emits side='top' when non-default", () => {
+ expect(snippet({ state: "opened", side: "top" })).toContain('side="top"');
+ });
+
+ it("emits side='left' when non-default", () => {
+ expect(snippet({ state: "opened", side: "left" })).toContain('side="left"');
+ });
+
+ it("emits side='right' when non-default", () => {
+ expect(snippet({ state: "opened", side: "right" })).toContain('side="right"');
+ });
+
+ it("emits width when non-default", () => {
+ expect(snippet({ state: "opened", width: 320 })).toContain("width={320}");
+ });
+
+ it("emits mode='dark' when non-default", () => {
+ expect(snippet({ state: "opened", mode: "dark" })).toContain('mode="dark"');
+ });
+});
+
+describe("popoverConfig.snippet: state options round-trip", () => {
+ it("emits the correct state for every control option", () => {
+ const ctrl = popoverConfig.controls.state;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ for (const state of ctrl.options) {
+ expect(snippet({ state })).toContain(`state="${state}"`);
+ }
+ });
+});
+
+describe("popoverConfig.snippet: side options round-trip", () => {
+ it("emits the correct side for every non-default side option", () => {
+ const ctrl = popoverConfig.controls.side;
+ if (ctrl.type !== "select") throw new Error("expected select");
+ const nonDefault = ctrl.options.filter((o) => o !== "bottom");
+ for (const side of nonDefault) {
+ expect(snippet({ state: "opened", side })).toContain(`side="${side}"`);
+ }
+ });
+});
diff --git a/registry/remocn-ui/popover/config.ts b/registry/remocn-ui/popover/config.ts
new file mode 100644
index 00000000..5607f834
--- /dev/null
+++ b/registry/remocn-ui/popover/config.ts
@@ -0,0 +1,75 @@
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+import type { PopoverState } from "@/registry/remocn-ui/popover";
+
+const DEFAULT_TITLE = "Dimensions";
+const DEFAULT_DESCRIPTION = "Set the dimensions for the layer.";
+
+export const popoverConfig: ComponentConfig = {
+ componentName: "Popover",
+ importPath: "@/components/remocn/popover",
+ controls: {
+ title: { type: "text", default: DEFAULT_TITLE, label: "Title" },
+ description: {
+ type: "text",
+ default: DEFAULT_DESCRIPTION,
+ label: "Description",
+ },
+ side: {
+ type: "select",
+ default: "bottom",
+ options: ["top", "bottom", "left", "right"],
+ label: "Side",
+ },
+ width: {
+ type: "number",
+ default: 288,
+ min: 160,
+ max: 480,
+ step: 8,
+ label: "Width",
+ },
+ state: {
+ type: "select",
+ // Default to `opened` so the preview shows the resting card.
+ 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 PopoverState) ?? "opened";
+ const title = values.title as string | undefined;
+ const description = values.description as string | undefined;
+ const side = values.side as string | undefined;
+ const width = values.width as number | undefined;
+ const mode = values.mode as string | undefined;
+
+ const props: string[] = [` state="${state}"`];
+ if (title !== undefined && title !== "")
+ props.push(` title="${title}"`);
+ if (description !== undefined && description !== "")
+ props.push(` description="${description}"`);
+ if (side !== undefined && side !== "bottom")
+ props.push(` side="${side}"`);
+ if (width !== undefined && width !== 288)
+ props.push(` width={${width}}`);
+ if (mode !== undefined && mode !== "light")
+ props.push(` mode="${mode}"`);
+
+ return `import { Popover } from "@/components/remocn/popover";
+
+<Popover
+${props.join("\n")}
+/>`;
+ },
+};
diff --git a/registry/remocn-ui/popover/index.tsx b/registry/remocn-ui/popover/index.tsx
new file mode 100644
index 00000000..f837686b
--- /dev/null
+++ b/registry/remocn-ui/popover/index.tsx
@@ -0,0 +1,169 @@
+"use client";
+
+import type { ReactNode } from "react";
+import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
+
+export type PopoverState = "opened" | "closed";
+
+export type PopoverSide = "top" | "bottom" | "left" | "right";
+
+export interface PopoverProps {
+ /** Current visual state (snap path). State changes snap (no enter-tweens). */
+ state?: PopoverState;
+ /**
+ * Resolved animated visual (smooth path). When provided, takes precedence over
+ * `state` — feed it an interpolated `PopoverStyle` from `usePopoverTransition`.
+ */
+ style?: PopoverStyle;
+ /** Card heading. */
+ title?: string;
+ /** Body copy under the title. */
+ description?: string;
+ /**
+ * Arbitrary content. Rendered after the title/description (or on its own when
+ * neither is given) — covers the hover-card scenario.
+ */
+ children?: ReactNode;
+ /**
+ * Which side of the anchor the card sits on. STATIC — it sets the enter
+ * translate axis/sign (the card lifts in toward the anchor). Not animated.
+ */
+ side?: PopoverSide;
+ /** Card width in px. */
+ width?: number;
+ theme?: Partial<RemocnTheme>;
+ mode?: "light" | "dark";
+ className?: string;
+}
+
+// ===========================================================================
+// Popover visual — the COMPLETE animated look for a moment in time. A `state` is
+// a named preset of this visual (`popoverStyle`); the smooth path feeds an
+// interpolated `PopoverStyle` straight through. The component is a pure renderer
+// of whichever `PopoverStyle` it receives. `translate` is a single magnitude in
+// px; the component applies it on the axis/sign chosen by `side`.
+// ===========================================================================
+
+export interface PopoverStyle {
+ /** Whole-card opacity 0→1. */
+ opacity: number;
+ /** Enter zoom 0.97→1. */
+ scale: number;
+ /**
+ * Enter offset MAGNITUDE in px (6 closed → 0 opened). The component turns this
+ * into a translateX/Y with the sign that lifts the card in toward the anchor
+ * for the active `side`.
+ */
+ translate: number;
+}
+
+/**
+ * The COMPLETE resting visual for a state — a pure `(state) => PopoverStyle` map.
+ * Both presets are full keyframes; the card enters from 6px offset at 0.97 scale
+ * and rests at 0/1. To change how a state looks, edit one entry.
+ */
+export function popoverStyle(state: PopoverState): PopoverStyle {
+ switch (state) {
+ case "opened":
+ return { opacity: 1, scale: 1, translate: 0 };
+ default:
+ return { opacity: 0, scale: 0.97, translate: 6 };
+ }
+}
+
+/**
+ * Resolve the `translate` magnitude into a CSS transform offset for a side. The
+ * card starts `translate` px on its OWN side away from the anchor and lifts back
+ * toward it: side "top" (card above) enters moving up (+Y → 0), etc.
+ */
+function offsetFor(side: PopoverSide, translate: number): { x: number; y: number } {
+ switch (side) {
+ case "bottom":
+ return { x: 0, y: -translate };
+ case "left":
+ return { x: translate, y: 0 };
+ case "right":
+ return { x: -translate, y: 0 };
+ default: // top
+ return { x: 0, y: translate };
+ }
+}
+
+export function Popover({
+ state = "closed",
+ style,
+ title,
+ description,
+ children,
+ side = "bottom",
+ width = 288,
+ theme: themeOverride,
+ mode,
+ className,
+}: PopoverProps) {
+ const theme = useRemocnTheme(themeOverride, mode);
+ const v = style ?? popoverStyle(state);
+ const { x, y } = offsetFor(side, v.translate);
+
+ const hasHeader = title !== undefined || description !== undefined;
+
+ return (
+ <div
+ className={className}
+ style={{
+ display: "inline-flex",
+ opacity: v.opacity,
+ transform: `translate(${x}px, ${y}px) scale(${v.scale})`,
+ transformOrigin: "center",
+ fontFamily:
+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
+ }}
+ >
+ <div
+ style={{
+ width,
+ boxSizing: "border-box",
+ display: "flex",
+ flexDirection: "column",
+ gap: 8,
+ padding: 16,
+ background: theme.popover,
+ color: theme.popoverForeground,
+ border: `1px solid ${theme.border}`,
+ borderRadius: theme.radius,
+ boxShadow: "0 8px 24px -8px rgba(0,0,0,0.2)",
+ textAlign: "left",
+ }}
+ >
+ {title !== undefined && (
+ <div
+ style={{
+ fontSize: 15,
+ fontWeight: 500,
+ letterSpacing: "-0.01em",
+ lineHeight: 1.3,
+ }}
+ >
+ {title}
+ </div>
+ )}
+ {description !== undefined && (
+ <div
+ style={{
+ fontSize: 13,
+ lineHeight: 1.5,
+ color: theme.mutedForeground,
+ }}
+ >
+ {description}
+ </div>
+ )}
+ {/* Arbitrary content sits after the header (or alone). The small top gap
+ is dropped when there's no header so custom content owns the box. */}
+ {children !== undefined && (
+ <div style={{ marginTop: hasHeader ? 4 : 0 }}>{children}</div>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/registry/remocn-ui/popover/preview.tsx b/registry/remocn-ui/popover/preview.tsx
new file mode 100644
index 00000000..2dfe25ee
--- /dev/null
+++ b/registry/remocn-ui/popover/preview.tsx
@@ -0,0 +1,58 @@
+"use client";
+
+import { useRemocnTheme } from "@/lib/remocn-ui";
+import {
+ Popover,
+ type PopoverSide,
+ type PopoverState,
+} from "@/registry/remocn-ui/popover";
+
+export interface PopoverPreviewProps {
+ title?: string;
+ description?: string;
+ side?: PopoverSide;
+ width?: number;
+ state?: PopoverState;
+ mode?: "light" | "dark";
+}
+
+/**
+ * Preview-only wrapper for the customizer. The shipped `Popover` is a
+ * placement-agnostic card in a transparent wrapper — the caller anchors it to a
+ * trigger (see the example). The customizer Player renders its `component` as the
+ * composition root, so a bare `Popover` would sit in normal flow and not center;
+ * this thin wrapper centers it on a theme-background stage just for the preview.
+ * NOT shipped: not listed in registry.json files.
+ */
+export function PopoverPreview({
+ title = "Dimensions",
+ description = "Set the dimensions for the layer.",
+ side = "bottom",
+ width = 288,
+ state = "opened",
+ mode,
+}: PopoverPreviewProps) {
+ const theme = useRemocnTheme(undefined, mode);
+
+ return (
+ <div
+ style={{
+ position: "absolute",
+ inset: 0,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ background: theme.background,
+ }}
+ >
+ <Popover
+ title={title}
+ description={description}
+ side={side}
+ width={width}
+ state={state}
+ mode={mode}
+ />
+ </div>
+ );
+}
diff --git a/registry/remocn-ui/popover/use-popover-transition.ts b/registry/remocn-ui/popover/use-popover-transition.ts
new file mode 100644
index 00000000..bc512cc5
--- /dev/null
+++ b/registry/remocn-ui/popover/use-popover-transition.ts
@@ -0,0 +1,57 @@
+"use client";
+
+import { easings, type Step, useStateTransition } from "@/lib/remocn-ui";
+import {
+ popoverStyle,
+ type PopoverState,
+ type PopoverStyle,
+} from "@/components/remocn/popover";
+// ^ 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 = 10;
+
+/**
+ * Blend two popover visuals: every field lerps. `PopoverStyle` carries no
+ * animated colors (the card bg/fg/border are static per theme), so there is no
+ * `mixOklch` here — but every field is covered so neither open nor close freezes
+ * a channel.
+ */
+export function tweenPopoverStyle(
+ a: PopoverStyle,
+ b: PopoverStyle,
+ t: number,
+): PopoverStyle {
+ return {
+ opacity: a.opacity + (b.opacity - a.opacity) * t,
+ scale: a.scale + (b.scale - a.scale) * t,
+ translate: a.translate + (b.translate - a.translate) * t,
+ };
+}
+
+export interface PopoverTransitionOptions {
+ mode?: "light" | "dark";
+ speed?: number;
+ defaultDuration?: number;
+}
+
+/**
+ * Timeline → resolved (eased, tweened) PopoverStyle. The CALLER invokes this; it
+ * reads the frame, the `<Popover>` component does not. Feed the result to
+ * `<Popover style={...} />`. Both the open (closed→opened) and the close
+ * (opened→closed) read from the same eased tween, so both look smooth.
+ */
+export function usePopoverTransition(
+ steps: Step<PopoverState>[],
+ opts: PopoverTransitionOptions = {},
+): PopoverStyle {
+ const { speed = 1, defaultDuration = DEFAULT_DURATION } = opts;
+ const { from, to, progress } = useStateTransition(
+ steps,
+ "closed",
+ speed,
+ defaultDuration,
+ );
+ const t = easings.out(progress);
+ return tweenPopoverStyle(popoverStyle(from), popoverStyle(to), t);
+}
diff --git a/registry/remocn-ui/registry.json b/registry/remocn-ui/registry.json
index e76fd30b..4af5eae7 100644
--- a/registry/remocn-ui/registry.json
+++ b/registry/remocn-ui/registry.json
@@ -551,6 +551,26 @@
"target": "components/remocn/use-combobox-transition.ts"
}
]
+ },
+ {
+ "name": "popover",
+ "type": "registry:component",
+ "title": "UI Popover",
+ "description": "A popover/hover-card whose opened/closed state is a pure function of the timeline. The Popover renderer is a pure function of a PopoverStyle (opacity, scale, translate); usePopoverTransition eases both the open and the close. The static `side` prop sets the enter translate axis; renders title + description and/or arbitrary children in a popover card.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["remocn-ui"],
+ "files": [
+ {
+ "path": "popover/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/popover.tsx"
+ },
+ {
+ "path": "popover/use-popover-transition.ts",
+ "type": "registry:component",
+ "target": "components/remocn/use-popover-transition.ts"
+ }
+ ]
}
]
}
diff --git a/registry/remocn-ui/tooltip/index.tsx b/registry/remocn-ui/tooltip/index.tsx
index 3cf8ca2d..22811393 100644
--- a/registry/remocn-ui/tooltip/index.tsx
+++ b/registry/remocn-ui/tooltip/index.tsx
@@ -61,7 +61,7 @@ export function tooltipStyle(state: TooltipState): TooltipStyle {
case "visible":
return { opacity: 1, scale: 1, translate: 0 };
default:
- return { opacity: 0, scale: 0.96, translate: 90 };
+ return { opacity: 0, scale: 0.96, translate: 4 };
}
}