Skip to content

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

feat: remove ugly comments

dev_wandryd0ee38a9bd98
diff --git a/registry/remocn-ui/accordion/__tests__/accordion.test.ts b/registry/remocn-ui/accordion/__tests__/accordion.test.ts
index 38b23788..b87c474f 100644
--- a/registry/remocn-ui/accordion/__tests__/accordion.test.ts
+++ b/registry/remocn-ui/accordion/__tests__/accordion.test.ts
@@ -1,34 +1,3 @@
-/**
- * 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 {
@@ -40,17 +9,8 @@ import { tweenAccordionStyle, DEFAULT_DURATION } from "../use-accordion-transiti
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;
@@ -62,28 +22,16 @@ type SnippetValues = {
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);
@@ -93,10 +41,6 @@ describe("AccordionState union", () => {
});
});
-// ===========================================================================
-// 2. accordionConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("accordionConfig.controls.state", () => {
it("is a select control", () => {
expect(accordionConfig.controls.state.type).toBe("select");
@@ -122,10 +66,6 @@ describe("accordionConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. accordionConfig.controls.variant — customizer control wiring
-// ===========================================================================
-
describe("accordionConfig.controls.variant", () => {
it("is a select control", () => {
expect(accordionConfig.controls.variant.type).toBe("select");
@@ -142,12 +82,6 @@ describe("accordionConfig.controls.variant", () => {
});
});
-// ===========================================================================
-// 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"');
@@ -190,8 +124,6 @@ describe("accordionConfig.snippet: import line", () => {
});
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?",
@@ -255,15 +187,6 @@ describe("accordionConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 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);
@@ -332,13 +255,6 @@ describe("accordionStyle: closed/opened invariant", () => {
});
});
-// ===========================================================================
-// 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);
@@ -386,8 +302,6 @@ describe("tweenAccordionStyle: t=1 returns values equal to `b`", () => {
});
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);
@@ -411,8 +325,6 @@ describe("tweenAccordionStyle: t=0.5 midpoint numeric lerp (closed → opened)",
});
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);
@@ -435,10 +347,6 @@ describe("tweenAccordionStyle: t=0.5 midpoint numeric lerp (opened → closed)",
});
});
-// ===========================================================================
-// 7. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
diff --git a/registry/remocn-ui/accordion/config.ts b/registry/remocn-ui/accordion/config.ts
index b9cf3e68..ae8a60a7 100644
--- a/registry/remocn-ui/accordion/config.ts
+++ b/registry/remocn-ui/accordion/config.ts
@@ -19,7 +19,6 @@ export const accordionConfig: ComponentConfig = {
},
state: {
type: "select",
- // Default to `opened` so the preview shows the revealed panel.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/accordion/index.tsx b/registry/remocn-ui/accordion/index.tsx
index 04157244..ca12531a 100644
--- a/registry/remocn-ui/accordion/index.tsx
+++ b/registry/remocn-ui/accordion/index.tsx
@@ -7,22 +7,10 @@ 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>;
@@ -30,15 +18,11 @@ export interface AccordionProps {
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;
}
@@ -50,13 +34,11 @@ function variantTokens(
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),
},
};
@@ -64,25 +46,13 @@ function variantTokens(
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;
@@ -92,10 +62,6 @@ export interface AccordionStyleContext {
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,
@@ -111,10 +77,6 @@ export function accordionStyleContext(
};
}
-/**
- * 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,
@@ -178,7 +140,7 @@ export function Accordion({
overflow: "hidden",
}}
>
- {/* Trigger row — always visible; sets the card width. */}
+ {}
<div
style={{
display: "flex",
@@ -212,7 +174,7 @@ export function Accordion({
/>
</svg>
</div>
- {/* Panel — height + opacity animate the reveal; content stays mounted. */}
+ {}
<div
style={{
height: contentHeight * v.panelHeight,
diff --git a/registry/remocn-ui/accordion/use-accordion-transition.ts b/registry/remocn-ui/accordion/use-accordion-transition.ts
index 22a806d3..34c974e6 100644
--- a/registry/remocn-ui/accordion/use-accordion-transition.ts
+++ b/registry/remocn-ui/accordion/use-accordion-transition.ts
@@ -14,12 +14,9 @@ import {
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,
@@ -42,11 +39,6 @@ export interface AccordionTransitionOptions {
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 = {},
diff --git a/registry/remocn-ui/ai-prompt-flow/index.tsx b/registry/remocn-ui/ai-prompt-flow/index.tsx
index ac69ee3f..4f5a48e8 100644
--- a/registry/remocn-ui/ai-prompt-flow/index.tsx
+++ b/registry/remocn-ui/ai-prompt-flow/index.tsx
@@ -12,35 +12,27 @@ import { Toast } from "@/components/remocn/toast";
import { useToastTransition } from "@/components/remocn/use-toast-transition";
export interface AiPromptFlowProps {
- /** Prompt typed into the field during the reveal. */
prompt?: string;
- /** Submit button label. */
buttonLabel?: string;
- /** Generated answer, as discrete lines (defines the response box). */
answerLines?: string[];
- /** Title shown in the ready toast. */
toastTitle?: string;
mode?: "light" | "dark";
theme?: Partial<RemocnTheme>;
}
-// Stage layout — the prompt field and answer box paint their own full-bleed
-// backgrounds, so each is pinned inside a non-overlapping slot it fills. The
-// answer column is fixed-width so the skeleton placeholder and the real answer
-// share one box (crossfade never resizes it).
const STAGE_W = 1280;
const PROMPT_W = 520;
-const PROMPT_LEFT = (STAGE_W - PROMPT_W) / 2; // 380
+const PROMPT_LEFT = (STAGE_W - PROMPT_W) / 2;
const PROMPT_TOP = 168;
const PROMPT_H = 92;
const BTN_W = 200;
-const BTN_LEFT = (STAGE_W - BTN_W) / 2; // 540
+const BTN_LEFT = (STAGE_W - BTN_W) / 2;
const BTN_TOP = 278;
const BTN_H = 64;
const ANSWER_W = 560;
-const ANSWER_LEFT = (STAGE_W - ANSWER_W) / 2; // 360
+const ANSWER_LEFT = (STAGE_W - ANSWER_W) / 2;
const ANSWER_TOP = 380;
const DEFAULT_ANSWER = [
@@ -49,13 +41,6 @@ const DEFAULT_ANSWER = [
"infra is unblocked before the team scales next quarter.",
];
-/**
- * Prompt → submit → skeleton shimmer → crossfade into the answer → ready toast.
- * A pure orchestrator: typing/button/skeleton/toast are each driven by their own
- * transition hook, and the shimmer is owned entirely by the `skeleton-block`
- * motion atom. The block holds no state, effects, or frame reads of its own.
- * Beat timings mirror US-B002's beat table.
- */
export function AiPromptFlow({
prompt = "Summarize this thread",
buttonLabel = "Generate",
@@ -67,7 +52,6 @@ export function AiPromptFlow({
const resolved = useRemocnTheme(theme, mode);
const opts = { mode, theme };
- // Input: focus, then reveal the typed prompt over 0→50.
const inputStyle = useInputTransition(
[
{ at: 0, state: "active", duration: 1 },
@@ -76,8 +60,6 @@ export function AiPromptFlow({
opts,
);
- // Button: hover after typing settles (52) → press → loading spinner. It stays
- // loading while the skeleton shimmers.
const buttonStyle = useButtonTransition(
[
{ at: 52, state: "hover", duration: 6 },
@@ -87,9 +69,6 @@ export function AiPromptFlow({
opts,
);
- // Skeleton: loads on submit (64), crossfades to the answer at 150. The two
- // opacities sum to 1, so the box never jumps. (No `theme` option — the
- // Skeleton component itself threads the theme into its blocks.)
const skeletonStyle = useSkeletonTransition(
[
{ at: 64, state: "loading", duration: 1 },
@@ -98,20 +77,8 @@ export function AiPromptFlow({
{ mode },
);
- // Output-panel reveal vs. answer-text reveal are TWO distinct moments, owned
- // by two different channels — do not conflate them:
- // • The output PANEL (the shimmer area) stays blank during prompt typing and
- // appears when generation STARTS. That onset is the button's already-
- // exposed `spinnerOpacity` channel — it ramps 0→1 as the button enters
- // `loading` (~62) — read linearly here (sanctioned §0B.3 read; semantics
- // correct: panel reveal == submit, never during typing).
- // • The answer TEXT is revealed later, at 150, ENTIRELY by the Skeleton
- // primitive's loaded crossfade (`contentOpacity`) — NOT by this gate. This
- // gate only hides the empty/shimmering area while the prompt is typed.
const panelOpacity = buttonStyle.spinnerOpacity;
- // Toast: enters once the crossfade settles (160), auto-dismisses at 220.
- // (No `theme` option — the Toast component resolves its own surface theme.)
const toastStyle = useToastTransition(
[
{ at: 160, state: "visible", duration: 14 },
@@ -129,7 +96,7 @@ export function AiPromptFlow({
background: resolved.background,
}}
>
- {/* Prompt field slot. */}
+ {}
<div
style={{
position: "absolute",
@@ -148,7 +115,7 @@ export function AiPromptFlow({
/>
</div>
- {/* Generate button slot. */}
+ {}
<div
style={{
position: "absolute",
@@ -166,10 +133,7 @@ export function AiPromptFlow({
/>
</div>
- {/* Output panel — appears on submit (panelOpacity), then the Skeleton
- shimmer crossfades into the real answer lines at 150 (contentOpacity,
- primitive-owned). The real content sits in normal flow and sets the box
- height; the shimmer placeholder mirrors it as SkeletonBlock rows. */}
+ {}
<div
style={{
position: "absolute",
@@ -226,7 +190,7 @@ export function AiPromptFlow({
</Skeleton>
</div>
- {/* Ready toast, anchored bottom-right. */}
+ {}
<div style={{ position: "absolute", right: 32, bottom: 32 }}>
<Toast
title={toastTitle}
diff --git a/registry/remocn-ui/alert-dialog/__tests__/alert-dialog.test.ts b/registry/remocn-ui/alert-dialog/__tests__/alert-dialog.test.ts
index 09c89d12..508b754d 100644
--- a/registry/remocn-ui/alert-dialog/__tests__/alert-dialog.test.ts
+++ b/registry/remocn-ui/alert-dialog/__tests__/alert-dialog.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `alert-dialog`.
- *
- * Scope:
- * - registry/remocn-ui/alert-dialog/index.tsx — AlertDialogState union membership,
- * alertDialogStyle presets, alertDialogStyleContext
- * - registry/remocn-ui/alert-dialog/config.ts — alertDialogConfig.controls wiring
- * + alertDialogConfig.snippet output (the state → JSX codegen)
- * - registry/remocn-ui/alert-dialog/use-alert-dialog-transition.ts
- * — tweenAlertDialogStyle interpolation, DEFAULT_DURATION
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * `<AlertDialog>` reads `useRemocnTheme()` internally — that hook is pure at
- * call-time in test context, but the JSX render tree is not exercised here.
- * The pure-testable surface is: the style presets + tween + customizer wiring
- * + snippet codegen.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/alert-dialog/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `AlertDialogState` from `@/registry/remocn-ui/alert-dialog`
- * and the pieces under test never CALL a Remotion runtime API at import time —
- * `alertDialogConfig` is a plain object; `.snippet` is a pure string builder;
- * `alertDialogStyle` and `tweenAlertDialogStyle` are pure value functions.
- * We import via RELATIVE paths (matching the existing test suite pattern),
- * annotating each import with the source it corresponds to.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -40,17 +9,8 @@ import { tweenAlertDialogStyle, DEFAULT_DURATION } from "../use-alert-dialog-tra
import { alertDialogConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The AlertDialogState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type AlertDialogState` in index.tsx.
- */
const VALID_STATES: readonly AlertDialogState[] = ["opened", "closed"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
title?: string;
@@ -63,28 +23,16 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
alertDialogConfig.snippet(values as Record<string, unknown>);
-/**
- * A shared AlertDialogStyleContext built from the default light theme.
- * `alertDialogStyleContext` takes only `(theme)` — no variant arg, unlike accordion.
- */
const ctx = alertDialogStyleContext(defaultLightTheme);
-// ===========================================================================
-// 1. AlertDialogState union membership
-// ===========================================================================
-
describe("AlertDialogState union", () => {
it("contains exactly the two documented states", () => {
- // We can't enumerate a TS type at runtime, but we can assert the REAL
- // controls.state options match and that all known states are members.
const control = alertDialogConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(control.options).toEqual(["opened", "closed"]);
});
it("every VALID_STATES entry is assignable (no typos in the fixture)", () => {
- // Belt-and-suspenders: the fixture array must have exactly 2 entries and
- // match the options list from the real config.
const control = alertDialogConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(VALID_STATES).toHaveLength(2);
@@ -94,10 +42,6 @@ describe("AlertDialogState union", () => {
});
});
-// ===========================================================================
-// 2. alertDialogConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("alertDialogConfig.controls.state", () => {
it("is a select control", () => {
expect(alertDialogConfig.controls.state.type).toBe("select");
@@ -123,15 +67,6 @@ describe("alertDialogConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. alertDialogConfig.snippet — pure string builder
-// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.
-// It NEVER emits `steps`.
-// Note on `action`: the snippet emits `actionLabel=` (a legitimate prop) but
-// must never emit a bare `action=` attribute. We assert `steps` is absent and
-// add a targeted check that `action=` only ever appears as `actionLabel=`.
-// ===========================================================================
-
describe("alertDialogConfig.snippet: state prop emission", () => {
it("emits state=\"opened\" for the opened option", () => {
expect(snippet({ state: "opened" })).toContain('state="opened"');
@@ -152,9 +87,6 @@ describe("alertDialogConfig.snippet: state prop emission", () => {
});
describe("alertDialogConfig.snippet: NEVER emits steps", () => {
- // `action=` is intentionally NOT checked here because `actionLabel=` is a
- // legitimate emitted prop and would cause a false positive on a naive
- // `.toContain("action")` check. Assert `steps` absence only.
it("never emits `steps` in any state", () => {
for (const state of VALID_STATES) {
expect(snippet({ state })).not.toContain("steps");
@@ -171,9 +103,6 @@ describe("alertDialogConfig.snippet: import line", () => {
});
describe("alertDialogConfig.snippet: default props are omitted", () => {
- // Defaults: title="Delete account?",
- // description="This action cannot be undone. This will permanently remove your data from our servers.",
- // actionLabel="Delete", cancelLabel="Cancel", mode="light"
const allDefaults = snippet({
state: "opened",
title: "Delete account?",
@@ -247,13 +176,6 @@ describe("alertDialogConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. alertDialogStyleContext — derives concrete colors from the theme.
-// Signature is `(theme)` — NO variant argument (unlike accordion).
-// Build ctx from the default light theme and assert each field is populated.
-// `radius` is a number (px); all other fields are non-empty strings.
-// ===========================================================================
-
describe("alertDialogStyleContext: field types from defaultLightTheme", () => {
it("popoverBg is a non-empty string", () => {
expect(typeof ctx.popoverBg).toBe("string");
@@ -295,13 +217,6 @@ describe("alertDialogStyleContext: field types from defaultLightTheme", () => {
});
});
-// ===========================================================================
-// 5. alertDialogStyle presets — pure (state, ctx) => AlertDialogStyle
-// alertDialogStyleContext and alertDialogStyle are exported and frame-free.
-// Build one ctx from the default light theme, then assert the numeric
-// invariants for every state.
-// ===========================================================================
-
describe("alertDialogStyle: closed state", () => {
const s = alertDialogStyle("closed", ctx);
@@ -360,12 +275,6 @@ describe("alertDialogStyle: closed/opened invariant", () => {
});
});
-// ===========================================================================
-// 6. tweenAlertDialogStyle — pure linear interpolation between two AlertDialogStyles.
-// All four fields are pure numeric lerps (no color fields, unlike accordion).
-// Concrete expectations: closed → opened for midpoint math.
-// ===========================================================================
-
describe("tweenAlertDialogStyle: t=0 returns values equal to `a`", () => {
const a = alertDialogStyle("closed", ctx);
const b = alertDialogStyle("opened", ctx);
@@ -411,8 +320,6 @@ describe("tweenAlertDialogStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenAlertDialogStyle: t=0.5 midpoint numeric lerp (closed → opened)", () => {
- // closed: overlayOpacity=0, popupOpacity=0, popupScale=0.95, popupTranslateY=8
- // opened: overlayOpacity=1, popupOpacity=1, popupScale=1, popupTranslateY=0
const a = alertDialogStyle("closed", ctx);
const b = alertDialogStyle("opened", ctx);
const r = tweenAlertDialogStyle(a, b, 0.5);
@@ -435,8 +342,6 @@ describe("tweenAlertDialogStyle: t=0.5 midpoint numeric lerp (closed → opened)
});
describe("tweenAlertDialogStyle: t=0.5 midpoint numeric lerp (opened → closed)", () => {
- // opened: overlayOpacity=1, popupOpacity=1, popupScale=1, popupTranslateY=0
- // closed: overlayOpacity=0, popupOpacity=0, popupScale=0.95, popupTranslateY=8
const a = alertDialogStyle("opened", ctx);
const b = alertDialogStyle("closed", ctx);
const r = tweenAlertDialogStyle(a, b, 0.5);
@@ -458,10 +363,6 @@ describe("tweenAlertDialogStyle: t=0.5 midpoint numeric lerp (opened → closed)
});
});
-// ===========================================================================
-// 7. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
diff --git a/registry/remocn-ui/alert-dialog/config.ts b/registry/remocn-ui/alert-dialog/config.ts
index faa0b1da..91c0b8ea 100644
--- a/registry/remocn-ui/alert-dialog/config.ts
+++ b/registry/remocn-ui/alert-dialog/config.ts
@@ -18,7 +18,6 @@ export const alertDialogConfig: ComponentConfig = {
cancelLabel: { type: "text", default: "Cancel", label: "Cancel Label" },
state: {
type: "select",
- // Default to `opened` so the preview shows the popup.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/alert-dialog/index.tsx b/registry/remocn-ui/alert-dialog/index.tsx
index be6584de..b060094f 100644
--- a/registry/remocn-ui/alert-dialog/index.tsx
+++ b/registry/remocn-ui/alert-dialog/index.tsx
@@ -5,50 +5,27 @@ import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
export type AlertDialogState = "closed" | "opened";
export interface AlertDialogProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: AlertDialogState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `AlertDialogStyle` from `useAlertDialogTransition`.
- */
style?: AlertDialogStyle;
- /** Headline of the alert. */
title?: string;
- /** Body copy under the title. */
description?: string;
- /** Label of the confirming (destructive) action. */
actionLabel?: string;
- /** Label of the dismissing action. */
cancelLabel?: string;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Popup card width (px). */
const POPUP_WIDTH = 400;
-/** Backdrop dim at full reveal — the overlay opacity scales up to this alpha. */
const MAX_OVERLAY_ALPHA = 0.5;
-// ===========================================================================
-// Alert-dialog visual — the COMPLETE animated look for a moment in time. A
-// `state` is a named preset of this visual (`alertDialogStyle`); the smooth
-// path feeds an interpolated `AlertDialogStyle` straight through. The component
-// is a pure renderer of whichever `AlertDialogStyle` it receives.
-// ===========================================================================
-
export interface AlertDialogStyle {
- /** Backdrop dim reveal 0→1 (scales `MAX_OVERLAY_ALPHA`). */
overlayOpacity: number;
- /** Popup fade 0→1. */
popupOpacity: number;
- /** Popup zoom 0.95→1. */
popupScale: number;
- /** Popup lift 8→0 (px). */
popupTranslateY: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface AlertDialogStyleContext {
popoverBg: string;
popoverFg: string;
@@ -60,10 +37,6 @@ export interface AlertDialogStyleContext {
cancelFg: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `alertDialogStyle(state, ctx)` preset.
- */
export function alertDialogStyleContext(
theme: RemocnTheme,
): AlertDialogStyleContext {
@@ -79,10 +52,6 @@ export function alertDialogStyleContext(
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => AlertDialogStyle`
- * map. To change how a state looks, edit one entry.
- */
export function alertDialogStyle(
state: AlertDialogState,
_ctx: AlertDialogStyleContext,
@@ -121,10 +90,6 @@ export function AlertDialog({
const ctx = alertDialogStyleContext(theme);
const v = style ?? alertDialogStyle(state, ctx);
- // Shared base for the two footer buttons. These are plain inline `<button>`s,
- // not the remocn `Button` component — that renders a full-frame scene wrapper
- // (absolute inset) and so can't nest inline here; the sizing mirrors its
- // `default` size.
const buttonBase: React.CSSProperties = {
height: 40,
padding: "0 20px",
@@ -139,9 +104,6 @@ export function AlertDialog({
};
return (
- // The wrapper is TRANSPARENT — unlike button/accordion (which paint an
- // opaque `theme.background`), this atom is a modal layer meant to compose
- // OVER another scene, so it must not blanket the frame with a background.
<div
style={{
position: "absolute",
@@ -153,7 +115,7 @@ export function AlertDialog({
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
- {/* Backdrop dim — fades in as the dialog opens. */}
+ {}
<div
style={{
position: "absolute",
@@ -195,7 +157,7 @@ export function AlertDialog({
marginTop: 16,
}}
>
- {/* Cancel — outline variant. */}
+ {}
<button
type="button"
style={{
@@ -207,7 +169,7 @@ export function AlertDialog({
>
{cancelLabel}
</button>
- {/* Action — destructive variant. */}
+ {}
<button
type="button"
style={{
diff --git a/registry/remocn-ui/alert-dialog/use-alert-dialog-transition.ts b/registry/remocn-ui/alert-dialog/use-alert-dialog-transition.ts
index 86c70c36..4adb3028 100644
--- a/registry/remocn-ui/alert-dialog/use-alert-dialog-transition.ts
+++ b/registry/remocn-ui/alert-dialog/use-alert-dialog-transition.ts
@@ -13,12 +13,9 @@ import {
type AlertDialogState,
type AlertDialogStyle,
} from "@/components/remocn/alert-dialog";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 12;
-/** Blend two alert-dialog visuals: all four fields are pure numeric lerps. */
export function tweenAlertDialogStyle(
a: AlertDialogStyle,
b: AlertDialogStyle,
@@ -40,11 +37,6 @@ export interface AlertDialogTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) AlertDialogStyle. The CALLER invokes this;
- * it reads the frame, the `<AlertDialog>` component does not. Feed the result to
- * `<AlertDialog style={...} />` for smooth open/close transitions.
- */
export function useAlertDialogTransition(
steps: Step<AlertDialogState>[],
opts: AlertDialogTransitionOptions = {},
diff --git a/registry/remocn-ui/blur-in/__tests__/blur-in.test.ts b/registry/remocn-ui/blur-in/__tests__/blur-in.test.ts
index 91867166..f31c33ec 100644
--- a/registry/remocn-ui/blur-in/__tests__/blur-in.test.ts
+++ b/registry/remocn-ui/blur-in/__tests__/blur-in.test.ts
@@ -1,38 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `blur-in`.
- *
- * Scope:
- * - registry/remocn-ui/blur-in/index.tsx — BlurInState union membership,
- * blurInStyleContext (direction → axis/sign), blurInStyle presets
- * - registry/remocn-ui/blur-in/config.ts — blurInConfig.controls.state
- * wiring + blurInConfig.snippet output (the state → JSX codegen)
- * - registry/remocn-ui/blur-in/use-blur-in-transition.ts — tweenBlurInStyle lerp
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * Every visual is the complete resting look for that state — state changes
- * snap (no tweening). `useBlurInTransition` reads `useCurrentFrame()` via
- * `useStateTransition`; it cannot run outside a Remotion render tree.
- * So BlurIn render is NOT exercised here. The pure-testable surface is the
- * customizer wiring + snippet codegen + style presets + tween (below).
- *
- * blur-in is THEME-INDEPENDENT: no theme/mode/primary anywhere, and the
- * "context" is a MOTION config (blur/distance/axis/sign), so no theme fixture
- * is imported here (unlike the other state atoms).
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/blur-in/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * The pieces under test never CALL a Remotion runtime API at import time —
- * `blurInConfig` is a plain object; `.snippet` is a pure string builder;
- * `blurInStyle`/`blurInStyleContext` are pure value functions;
- * `tweenBlurInStyle` is a pure lerp function.
- * 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 {
@@ -44,17 +9,8 @@ import {
import { tweenBlurInStyle } from "../use-blur-in-transition";
import { blurInConfig } from "../config";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The BlurInState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type BlurInState` in index.tsx.
- */
const VALID_STATES: readonly BlurInState[] = ["hidden", "revealed"];
-/** The BlurInDirection union, enumerated as a runtime list. */
const VALID_DIRECTIONS: readonly BlurInDirection[] = [
"up",
"down",
@@ -62,7 +18,6 @@ const VALID_DIRECTIONS: readonly BlurInDirection[] = [
"right",
];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
blur?: number;
@@ -73,10 +28,6 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
blurInConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. BlurInState union membership
-// ===========================================================================
-
describe("BlurInState union", () => {
it("contains exactly the two documented states", () => {
const control = blurInConfig.controls.state;
@@ -96,10 +47,6 @@ describe("BlurInState union", () => {
});
});
-// ===========================================================================
-// 2. blurInConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("blurInConfig.controls.state", () => {
it("is a select control", () => {
expect(blurInConfig.controls.state.type).toBe("select");
@@ -147,14 +94,6 @@ describe("blurInConfig.controls numeric knobs", () => {
});
});
-// ===========================================================================
-// 3. blurInStyleContext — direction → motion config (axis + sign)
-// up → y / +1 (starts BELOW, travels up into place)
-// down → y / −1 (starts above, travels down into place)
-// left → x / +1 (starts to the right, travels left into place)
-// right → x / −1 (starts to the left, travels right into place)
-// ===========================================================================
-
describe("blurInStyleContext: direction → axis + sign", () => {
it("up → axis y, sign +1", () => {
const ctx = blurInStyleContext(8, "up", 12);
@@ -195,14 +134,6 @@ describe("blurInStyleContext: direction → axis + sign", () => {
});
});
-// ===========================================================================
-// 4. blurInStyle presets — pure (state, ctx) => BlurInStyle
-// revealed is always { blur:0, opacity:1, translateX:0, translateY:0 }.
-// hidden carries ctx.blur, opacity 0, and the directional offset on the
-// ctx axis (ctx.sign * ctx.distance), the other axis 0.
-// Built with blur=8, distance=12 ctx (the control defaults).
-// ===========================================================================
-
describe("blurInStyle: revealed preset (direction-independent)", () => {
for (const direction of VALID_DIRECTIONS) {
const ctx = blurInStyleContext(8, direction, 12);
@@ -258,11 +189,6 @@ describe("blurInStyle: hidden preset per direction (blur=8, distance=12)", () =>
});
});
-// ===========================================================================
-// 5. tweenBlurInStyle — pure linear interpolation between two BlurInStyles.
-// All four fields are numbers and lerp linearly.
-// ===========================================================================
-
describe("tweenBlurInStyle: t=0 returns values equal to `a`", () => {
const a = blurInStyle("hidden", blurInStyleContext(8, "up", 12));
const b = blurInStyle("revealed", blurInStyleContext(8, "up", 12));
@@ -302,8 +228,6 @@ describe("tweenBlurInStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenBlurInStyle: t=0.5 midpoint numeric lerp (hidden up → revealed)", () => {
- // hidden(up): blur=8, opacity=0, translateX=0, translateY=12
- // revealed: blur=0, opacity=1, translateX=0, translateY=0
const a = blurInStyle("hidden", blurInStyleContext(8, "up", 12));
const b = blurInStyle("revealed", blurInStyleContext(8, "up", 12));
const r = tweenBlurInStyle(a, b, 0.5);
@@ -323,7 +247,6 @@ describe("tweenBlurInStyle: t=0.5 midpoint numeric lerp (hidden up → revealed)
});
describe("tweenBlurInStyle: t=0.5 midpoint on the x axis (hidden left → revealed)", () => {
- // hidden(left): blur=8, opacity=0, translateX=12, translateY=0
const a = blurInStyle("hidden", blurInStyleContext(8, "left", 12));
const b = blurInStyle("revealed", blurInStyleContext(8, "left", 12));
const r = tweenBlurInStyle(a, b, 0.5);
@@ -336,12 +259,6 @@ describe("tweenBlurInStyle: t=0.5 midpoint on the x axis (hidden left → reveal
});
});
-// ===========================================================================
-// 6. blurInConfig.snippet — pure string builder
-// Emits `state="<state>"` always; emits direction/blur/distance ONLY when
-// they differ from the control defaults (up / 8 / 12); never the speed knob.
-// ===========================================================================
-
describe("blurInConfig.snippet: state prop emission", () => {
it('emits state="hidden" for the hidden option', () => {
expect(snippet({ state: "hidden" })).toContain('state="hidden"');
diff --git a/registry/remocn-ui/blur-in/config.ts b/registry/remocn-ui/blur-in/config.ts
index 4655acc3..1e4cd44e 100644
--- a/registry/remocn-ui/blur-in/config.ts
+++ b/registry/remocn-ui/blur-in/config.ts
@@ -16,7 +16,6 @@ export const blurInConfig: ComponentConfig = {
controls: {
state: {
type: "select",
- // Default to `revealed` so the preview shows the settled, sharp child.
default: "revealed",
options: ["hidden", "revealed"],
label: "State",
diff --git a/registry/remocn-ui/blur-in/index.tsx b/registry/remocn-ui/blur-in/index.tsx
index 17ce0cd7..6f79f71f 100644
--- a/registry/remocn-ui/blur-in/index.tsx
+++ b/registry/remocn-ui/blur-in/index.tsx
@@ -5,32 +5,13 @@ import type { CSSProperties, ReactNode } from "react";
export type BlurInState = "hidden" | "revealed";
export type BlurInDirection = "up" | "down" | "left" | "right";
-// ===========================================================================
-// BlurIn visual — the COMPLETE animated look for a moment in time. A `state`
-// is a named preset of this visual (`blurInStyle`); the smooth path feeds an
-// interpolated `BlurInStyle` straight through. The component is a pure
-// renderer of whichever `BlurInStyle` it receives — it reads NO frame.
-//
-// THEME-INDEPENDENT (the one deviation from the other state atoms): BlurIn
-// carries no colors. It wraps a SINGLE child and reveals it with blur +
-// opacity + a directional offset, so its "context" is a MOTION config
-// (blur/distance/axis/sign), NOT a theme. There are no theme/mode/primary
-// props. The frame is read only by `useBlurInTransition` (caller-side), exactly
-// like `input`.
-// ===========================================================================
-
export interface BlurInStyle {
- /** Animated blur radius in px. 0 = sharp. */
blur: number;
- /** Child opacity 0→1. */
opacity: number;
- /** Horizontal offset in px (the directional slide-into-place). */
translateX: number;
- /** Vertical offset in px (the directional slide-into-place). */
translateY: number;
}
-/** The resolved MOTION config — the directional offset for the hidden preset. */
export interface BlurInStyleContext {
blur: number;
distance: number;
@@ -38,14 +19,6 @@ export interface BlurInStyleContext {
sign: 1 | -1;
}
-/**
- * Derive the motion config for a direction. Pure — call it once and reuse the
- * result for every `blurInStyle(state, ctx)` preset.
- *
- * `direction` is the way the child travels INTO place: `up` starts BELOW
- * (+Y), `down` starts above (−Y), `left` starts to the right (+X), `right`
- * starts to the left (−X).
- */
export function blurInStyleContext(
blur: number,
direction: BlurInDirection,
@@ -57,10 +30,6 @@ export function blurInStyleContext(
return { blur, distance, axis, sign };
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => BlurInStyle`
- * map. To change how a state looks, edit one entry.
- */
export function blurInStyle(
state: BlurInState,
ctx: BlurInStyleContext,
@@ -76,22 +45,12 @@ export function blurInStyle(
}
export interface BlurInProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: BlurInState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `BlurInStyle` from `useBlurInTransition`.
- */
style?: BlurInStyle;
- /** The single element revealed by the blur/opacity/offset. */
children: ReactNode;
- /** Hidden-state blur radius in px. */
blur?: number;
- /** Direction the child travels INTO place. */
direction?: BlurInDirection;
- /** Hidden-state offset distance in px (0 disables the slide). */
distance?: number;
- /** CSS `display` for the wrapper (inline-block by default so it sizes to the child). */
display?: CSSProperties["display"];
className?: string;
}
diff --git a/registry/remocn-ui/blur-in/preview.tsx b/registry/remocn-ui/blur-in/preview.tsx
index b350cf17..bad43c64 100644
--- a/registry/remocn-ui/blur-in/preview.tsx
+++ b/registry/remocn-ui/blur-in/preview.tsx
@@ -10,13 +10,6 @@ export interface BlurInPreviewProps {
speed?: number;
}
-/**
- * Preview-only wrapper for the customizer. `BlurIn` wraps a SINGLE child, so it
- * needs sample content — this thin wrapper supplies a fixed ~160×96 card and
- * centers it on a stage just for the preview. The customizer Player renders its
- * `component` as the composition root, so a bare wrapped child would sit
- * top-left. NOT shipped: not listed in registry.json files.
- */
export function BlurInPreview({
state = "revealed",
blur = 8,
diff --git a/registry/remocn-ui/blur-in/use-blur-in-transition.ts b/registry/remocn-ui/blur-in/use-blur-in-transition.ts
index e0346246..3fbb36db 100644
--- a/registry/remocn-ui/blur-in/use-blur-in-transition.ts
+++ b/registry/remocn-ui/blur-in/use-blur-in-transition.ts
@@ -12,12 +12,9 @@ import {
type BlurInState,
type BlurInStyle,
} from "@/components/remocn/blur-in";
-// ^ 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 = 18;
-/** Blend two blur-in visuals: every field is a number, so all four lerp linearly. */
export function tweenBlurInStyle(
a: BlurInStyle,
b: BlurInStyle,
@@ -39,11 +36,6 @@ export interface BlurInTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) BlurInStyle. The CALLER invokes this; it
- * reads the frame, the `<BlurIn>` component does not. Feed the result to
- * `<BlurIn style={...} />` for smooth transitions.
- */
export function useBlurInTransition(
steps: Step<BlurInState>[],
opts: BlurInTransitionOptions = {},
diff --git a/registry/remocn-ui/button/__tests__/button.test.ts b/registry/remocn-ui/button/__tests__/button.test.ts
index 44adb8b5..d9b270b5 100644
--- a/registry/remocn-ui/button/__tests__/button.test.ts
+++ b/registry/remocn-ui/button/__tests__/button.test.ts
@@ -1,31 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `button`.
- *
- * Scope:
- * - registry/remocn-ui/button/index.tsx — ButtonState union membership
- * - registry/remocn-ui/button/config.ts — buttonConfig.controls.state
- * wiring + buttonConfig.snippet output (the state → JSX codegen)
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * Every visual is the complete resting look for that state — state changes
- * snap (no tweening). The loading spinner lives in the separate `<Spinner/>`
- * motion atom which reads `useCurrentFrame()` internally; it cannot run
- * outside a Remotion render tree. So Button render is NOT exercised here.
- * The pure-testable surface is the customizer wiring + snippet codegen (below).
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/button/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `ButtonState` from `@/registry/remocn-ui/button` and
- * the pieces under test never CALL a Remotion runtime API at import time —
- * `buttonConfig` is a plain object; `.snippet` is a pure string builder.
- * 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 ButtonState, buttonStyle, buttonStyleContext } from "../index";
@@ -33,14 +5,6 @@ import { tweenButtonStyle } from "../use-button-transition";
import { buttonConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The ButtonState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type ButtonState` in index.tsx.
- */
const VALID_STATES: readonly ButtonState[] = [
"idle",
"hover",
@@ -49,7 +13,6 @@ const VALID_STATES: readonly ButtonState[] = [
"success",
];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
label?: string;
@@ -62,14 +25,8 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
buttonConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. ButtonState union membership
-// ===========================================================================
-
describe("ButtonState union", () => {
it("contains exactly the five 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 = buttonConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(control.options).toEqual([
@@ -82,8 +39,6 @@ describe("ButtonState union", () => {
});
it("every VALID_STATES entry is assignable (no typos in the fixture)", () => {
- // Belt-and-suspenders: the fixture array must have exactly 5 entries and
- // match the options list from the real config.
const control = buttonConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(VALID_STATES).toHaveLength(5);
@@ -93,10 +48,6 @@ describe("ButtonState union", () => {
});
});
-// ===========================================================================
-// 2. buttonConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("buttonConfig.controls.state", () => {
it("is a select control", () => {
expect(buttonConfig.controls.state.type).toBe("select");
@@ -128,12 +79,6 @@ describe("buttonConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. buttonConfig.snippet — pure string builder
-// State model: snippet emits `state="<state>"` as a bare JSX prop.
-// It NEVER emits `steps` or `action`.
-// ===========================================================================
-
describe("buttonConfig.snippet: state prop emission", () => {
it("emits state=\"idle\" for the idle option", () => {
expect(snippet({ state: "idle" })).toContain('state="idle"');
@@ -188,7 +133,6 @@ describe("buttonConfig.snippet: import line", () => {
});
describe("buttonConfig.snippet: default props are omitted", () => {
- // Defaults: label=Continue, variant=default, size=default, mode=light, primary=#171717
const allDefaults = snippet({
state: "loading",
label: "Continue",
@@ -257,15 +201,6 @@ describe("buttonConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. buttonStyle presets — pure (state, ctx) => ButtonStyle
-// buttonStyleContext and buttonStyle are now exported and frame-free.
-// Build one ctx from the default light theme + "default" variant, then
-// assert the numeric/opacity invariants for every state.
-// background is a derived oklch/rgb string — asserted non-empty only
-// (its exact value is an implementation detail of mixOklch).
-// ===========================================================================
-
const ctx = buttonStyleContext("default", defaultLightTheme);
describe("buttonStyle: idle state", () => {
@@ -398,7 +333,6 @@ describe("buttonStyle: success state", () => {
});
describe("buttonStyle: opacity invariant — exactly one of label/spinner/check is visible per non-idle state", () => {
- // For non-animated states the three opacities are always discrete 0 or 1.
const states: ButtonState[] = ["idle", "hover", "press", "loading", "success"];
it("sum of label+spinner+check opacities equals 1 for every state (exactly one is shown)", () => {
@@ -410,13 +344,6 @@ describe("buttonStyle: opacity invariant — exactly one of label/spinner/check
});
});
-// ===========================================================================
-// 5. tweenButtonStyle — pure linear interpolation between two ButtonStyles.
-// Numbers lerp linearly; background is an oklch color string at all t.
-// Concrete expectations: idle(translateY=0,scale=1) → hover(translateY=-1,scale=1)
-// and idle(spinnerOpacity=0) → loading(spinnerOpacity=1) for midpoint math.
-// ===========================================================================
-
describe("tweenButtonStyle: t=0 returns values equal to `a`", () => {
const a = buttonStyle("idle", ctx);
const b = buttonStyle("hover", ctx);
@@ -480,8 +407,6 @@ describe("tweenButtonStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenButtonStyle: t=0.5 midpoint numeric lerp (idle → hover)", () => {
- // idle: translateY=0, scale=1, labelOpacity=1, spinnerOpacity=0, checkOpacity=0
- // hover: translateY=-1, scale=1, labelOpacity=1, spinnerOpacity=0, checkOpacity=0
const a = buttonStyle("idle", ctx);
const b = buttonStyle("hover", ctx);
const r = tweenButtonStyle(a, b, 0.5);
@@ -505,8 +430,6 @@ describe("tweenButtonStyle: t=0.5 midpoint numeric lerp (idle → hover)", () =>
});
describe("tweenButtonStyle: t=0.5 midpoint numeric lerp (idle → loading)", () => {
- // idle: translateY=0, scale=1, labelOpacity=1, spinnerOpacity=0, checkOpacity=0
- // loading: translateY=-1, scale=1, labelOpacity=0, spinnerOpacity=1, checkOpacity=0
const a = buttonStyle("idle", ctx);
const b = buttonStyle("loading", ctx);
const r = tweenButtonStyle(a, b, 0.5);
@@ -538,8 +461,6 @@ describe("tweenButtonStyle: t=0.5 midpoint numeric lerp (idle → loading)", ()
});
describe("tweenButtonStyle: t=0.5 midpoint numeric lerp (hover → press)", () => {
- // hover: translateY=-1, scale=1
- // press: translateY=-1, scale=0.97
const a = buttonStyle("hover", ctx);
const b = buttonStyle("press", ctx);
const r = tweenButtonStyle(a, b, 0.5);
diff --git a/registry/remocn-ui/button/config.ts b/registry/remocn-ui/button/config.ts
index 22a4e006..0721e6ee 100644
--- a/registry/remocn-ui/button/config.ts
+++ b/registry/remocn-ui/button/config.ts
@@ -20,7 +20,6 @@ export const buttonConfig: ComponentConfig = {
},
state: {
type: "select",
- // Default to `loading` so the preview showcases the live spinner motion.
default: "loading",
options: ["idle", "hover", "press", "loading", "success"],
label: "State",
diff --git a/registry/remocn-ui/button/index.tsx b/registry/remocn-ui/button/index.tsx
index 6ea70d52..8d0e10b5 100644
--- a/registry/remocn-ui/button/index.tsx
+++ b/registry/remocn-ui/button/index.tsx
@@ -15,28 +15,19 @@ type ButtonVariant =
type ButtonSize = "sm" | "default" | "lg";
export interface ButtonProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: ButtonState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `ButtonStyle` from `useButtonTransition`.
- */
style?: ButtonStyle;
label?: string;
variant?: ButtonVariant;
size?: ButtonSize;
theme?: Partial<RemocnTheme>;
- /** Convenience override for the `primary` theme token — merged into `theme`. */
primary?: string;
mode?: "light" | "dark";
- /** Playhead scale, forwarded to the loading Spinner. */
speed?: number;
- /** Horizontal placement of the button within its (full-width) slot. */
align?: "start" | "center" | "end";
className?: string;
}
-/** Map an `align` value to a flexbox `justifyContent`. */
function justify(align: "start" | "center" | "end"): string {
return align === "start"
? "flex-start"
@@ -45,7 +36,6 @@ function justify(align: "start" | "center" | "end"): string {
: "center";
}
-/** Checkmark stroke length (svg path units). */
const CHECK_PATH_LENGTH = 14;
const SIZE_STYLES: Record<
@@ -104,13 +94,6 @@ function variantTokens(
return variants[variant] ?? variants.default;
}
-// ===========================================================================
-// Button visual — the COMPLETE animated look for a moment in time. A `state` is
-// a named preset of this visual (`buttonStyle`); the smooth path feeds an
-// interpolated `ButtonStyle` straight through. The component is a pure renderer
-// of whichever `ButtonStyle` it receives.
-// ===========================================================================
-
export interface ButtonStyle {
translateY: number;
scale: number;
@@ -120,26 +103,18 @@ export interface ButtonStyle {
checkOpacity: number;
}
-/** Concrete colors for the active variant/theme, resolved once per render. */
export interface ButtonStyleContext {
- /** Resting background (a concrete color, never "transparent"). */
restBg: string;
hoverBg: string;
pressBg: string;
primary: string;
}
-/**
- * Derive the concrete colors for a variant/theme. Pure — call it once and reuse
- * the result for every `buttonStyle(state, ctx)` preset.
- */
export function buttonStyleContext(
variant: ButtonVariant,
theme: RemocnTheme,
): ButtonStyleContext {
const tokens = variantTokens(variant, theme);
- // Transparent variants (outline/ghost) rest on the page background so the
- // resting state has a concrete color.
const restBg = tokens.bg === "transparent" ? theme.background : tokens.bg;
return {
restBg,
@@ -152,10 +127,6 @@ export function buttonStyleContext(
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => ButtonStyle`
- * map. To change how a state looks, edit one entry.
- */
export function buttonStyle(
state: ButtonState,
ctx: ButtonStyleContext,
@@ -272,9 +243,7 @@ export function Button({
cursor: "pointer",
}}
>
- {/* The label stays in normal flow so it sets the button width; the
- spinner and checkmark are absolutely-positioned overlays that
- crossfade over it. */}
+ {}
<span style={{ position: "relative", display: "inline-flex" }}>
<span style={{ opacity: v.labelOpacity }}>{label}</span>
<span
diff --git a/registry/remocn-ui/button/use-button-transition.ts b/registry/remocn-ui/button/use-button-transition.ts
index b5357957..74365898 100644
--- a/registry/remocn-ui/button/use-button-transition.ts
+++ b/registry/remocn-ui/button/use-button-transition.ts
@@ -14,12 +14,9 @@ import {
type ButtonState,
type ButtonStyle,
} from "@/components/remocn/button";
-// ^ 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 = 8;
-/** Blend two button visuals: numbers lerp, background via oklch mix. */
export function tweenButtonStyle(
a: ButtonStyle,
b: ButtonStyle,
@@ -45,11 +42,6 @@ export interface ButtonTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) ButtonStyle. The CALLER invokes this; it
- * reads the frame, the `<Button>` component does not. Feed the result to
- * `<Button style={...} />` for smooth transitions.
- */
export function useButtonTransition(
steps: Step<ButtonState>[],
opts: ButtonTransitionOptions = {},
diff --git a/registry/remocn-ui/checkbox/__tests__/checkbox.test.ts b/registry/remocn-ui/checkbox/__tests__/checkbox.test.ts
index f87bb4be..d046b4a1 100644
--- a/registry/remocn-ui/checkbox/__tests__/checkbox.test.ts
+++ b/registry/remocn-ui/checkbox/__tests__/checkbox.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `checkbox`.
- *
- * Scope:
- * - registry/remocn-ui/checkbox/index.tsx — CheckboxState union membership,
- * checkboxStyleContext, checkboxStyle presets
- * - registry/remocn-ui/checkbox/use-checkbox-transition.ts — tweenCheckboxStyle
- * - registry/remocn-ui/checkbox/config.ts — checkboxConfig.controls.state
- * wiring + checkboxConfig.snippet output (the state → JSX codegen)
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * State changes snap (no tweening inside the component). The smooth-path hook
- * `useCheckboxTransition` reads `useCurrentFrame()` via `useStateTransition`
- * internally; it cannot run outside a Remotion render tree. So Checkbox render
- * is NOT exercised here. The pure-testable surface is the customizer wiring,
- * snippet codegen, style presets, and tween interpolation (below).
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/checkbox/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `CheckboxState` from `@/registry/remocn-ui/checkbox`
- * and the pieces under test never CALL a Remotion runtime API at import time —
- * `checkboxConfig` is a plain object; `.snippet` is a pure string builder;
- * `checkboxStyle` and `tweenCheckboxStyle` 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 {
@@ -40,17 +9,8 @@ import { tweenCheckboxStyle } from "../use-checkbox-transition";
import { checkboxConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The CheckboxState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type CheckboxState` in index.tsx.
- */
const VALID_STATES: readonly CheckboxState[] = ["unchecked", "checked"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
label?: string;
@@ -62,22 +22,14 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
checkboxConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. CheckboxState union membership
-// ===========================================================================
-
describe("CheckboxState 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 = checkboxConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(control.options).toEqual(["unchecked", "checked"]);
});
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 = checkboxConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(VALID_STATES).toHaveLength(2);
@@ -87,10 +39,6 @@ describe("CheckboxState union", () => {
});
});
-// ===========================================================================
-// 2. checkboxConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("checkboxConfig.controls.state", () => {
it("is a select control", () => {
expect(checkboxConfig.controls.state.type).toBe("select");
@@ -116,12 +64,6 @@ describe("checkboxConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. checkboxConfig.snippet — pure string builder
-// State model: snippet emits `state="<state>"` as a bare JSX prop.
-// It NEVER emits `steps` or `action`.
-// ===========================================================================
-
describe("checkboxConfig.snippet: state prop emission", () => {
it("emits state=\"unchecked\" for the unchecked option", () => {
expect(snippet({ state: "unchecked" })).toContain('state="unchecked"');
@@ -164,7 +106,6 @@ describe("checkboxConfig.snippet: import line", () => {
});
describe("checkboxConfig.snippet: default props are omitted", () => {
- // Defaults: label="", size=default, mode=light, primary=#171717
const allDefaults = snippet({
state: "checked",
label: "",
@@ -224,15 +165,6 @@ describe("checkboxConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. checkboxStyle presets — pure (state, ctx) => CheckboxStyle
-// checkboxStyleContext and checkboxStyle are now exported and frame-free.
-// Build one ctx from the default light theme, then assert the
-// numeric/opacity invariants for both states.
-// boxBackground and boxBorderColor are derived oklch strings — asserted
-// non-empty only (exact value is an implementation detail of the theme).
-// ===========================================================================
-
const ctx = checkboxStyleContext(defaultLightTheme);
describe("checkboxStyle: unchecked state", () => {
@@ -301,14 +233,6 @@ describe("checkboxStyle: invariants — unchecked hides mark, checked shows mark
});
});
-// ===========================================================================
-// 5. tweenCheckboxStyle — pure linear interpolation between two CheckboxStyles.
-// Numbers lerp linearly; colors via oklch mix → non-empty string at all t.
-// Concrete expectations: unchecked→checked for midpoint math.
-// unchecked: checkOpacity=0, checkScale=0.6, checkDraw=0
-// checked: checkOpacity=1, checkScale=1, checkDraw=1
-// ===========================================================================
-
describe("tweenCheckboxStyle: t=0 returns values equal to `a`", () => {
const a = checkboxStyle("unchecked", ctx);
const b = checkboxStyle("checked", ctx);
@@ -366,8 +290,6 @@ describe("tweenCheckboxStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenCheckboxStyle: t=0.5 midpoint numeric lerp (unchecked → checked)", () => {
- // unchecked: checkOpacity=0, checkScale=0.6, checkDraw=0
- // checked: checkOpacity=1, checkScale=1, checkDraw=1
const a = checkboxStyle("unchecked", ctx);
const b = checkboxStyle("checked", ctx);
const r = tweenCheckboxStyle(a, b, 0.5);
diff --git a/registry/remocn-ui/checkbox/config.ts b/registry/remocn-ui/checkbox/config.ts
index ca6b2c4a..4003a07e 100644
--- a/registry/remocn-ui/checkbox/config.ts
+++ b/registry/remocn-ui/checkbox/config.ts
@@ -14,7 +14,6 @@ export const checkboxConfig: ComponentConfig = {
},
state: {
type: "select",
- // Default to `checked` so the preview shows the filled box + checkmark.
default: "checked",
options: ["unchecked", "checked"],
label: "State",
diff --git a/registry/remocn-ui/checkbox/index.tsx b/registry/remocn-ui/checkbox/index.tsx
index 72e61848..f8244883 100644
--- a/registry/remocn-ui/checkbox/index.tsx
+++ b/registry/remocn-ui/checkbox/index.tsx
@@ -7,26 +7,17 @@ export type CheckboxState = "unchecked" | "checked";
type CheckboxSize = "sm" | "default" | "lg";
export interface CheckboxProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: CheckboxState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `CheckboxStyle` from `useCheckboxTransition`.
- */
style?: CheckboxStyle;
- /** Optional text label rendered next to the box. */
label?: string;
size?: CheckboxSize;
theme?: Partial<RemocnTheme>;
- /** Convenience override for the `primary` theme token — merged into `theme`. */
primary?: string;
mode?: "light" | "dark";
- /** Horizontal placement of the box+label within its slot. */
align?: "start" | "center" | "end";
className?: string;
}
-/** Map an `align` value to a flexbox `justifyContent`. */
function justify(align: "start" | "center" | "end"): string {
return align === "start"
? "flex-start"
@@ -35,7 +26,6 @@ function justify(align: "start" | "center" | "end"): string {
: "center";
}
-/** Checkmark stroke length (svg path units), drives the draw-on animation. */
const CHECK_PATH_LENGTH = 14;
const SIZE_STYLES: Record<
@@ -47,40 +37,22 @@ const SIZE_STYLES: Record<
lg: { box: 24, fontSize: 17, gap: 12 },
};
-// ===========================================================================
-// Checkbox visual — the COMPLETE animated look for a moment in time. A `state`
-// is a named preset of this visual (`checkboxStyle`); the smooth path feeds an
-// interpolated `CheckboxStyle` straight through. The component is a pure
-// renderer of whichever `CheckboxStyle` it receives.
-// ===========================================================================
-
export interface CheckboxStyle {
- /** Animated box fill color (a concrete color, never "transparent"). */
boxBackground: string;
- /** Animated box border color. */
boxBorderColor: string;
- /** Checkmark opacity 0→1. */
checkOpacity: number;
- /** Checkmark scale 0.6→1 (a slight pop on check). */
checkScale: number;
- /** Checkmark draw fraction 0→1; drives the strokeDashoffset of the path. */
checkDraw: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface CheckboxStyleContext {
uncheckedBg: string;
checkedBg: string;
uncheckedBorder: string;
checkedBorder: string;
- /** Static checkmark stroke color (never animated). */
checkColor: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `checkboxStyle(state, ctx)` preset.
- */
export function checkboxStyleContext(theme: RemocnTheme): CheckboxStyleContext {
return {
uncheckedBg: theme.background,
@@ -91,10 +63,6 @@ export function checkboxStyleContext(theme: RemocnTheme): CheckboxStyleContext {
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => CheckboxStyle`
- * map. To change how a state looks, edit one entry.
- */
export function checkboxStyle(
state: CheckboxState,
ctx: CheckboxStyleContext,
@@ -161,7 +129,7 @@ export function Checkbox({
gap: sizeStyle.gap,
}}
>
- {/* The box — animated fill + border; the checkmark draws on inside it. */}
+ {}
<span
style={{
display: "flex",
diff --git a/registry/remocn-ui/checkbox/use-checkbox-transition.ts b/registry/remocn-ui/checkbox/use-checkbox-transition.ts
index afec9996..7be7dda5 100644
--- a/registry/remocn-ui/checkbox/use-checkbox-transition.ts
+++ b/registry/remocn-ui/checkbox/use-checkbox-transition.ts
@@ -14,12 +14,9 @@ import {
type CheckboxState,
type CheckboxStyle,
} from "@/components/remocn/checkbox";
-// ^ 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 checkbox visuals: numbers lerp, colors via oklch mix. */
export function tweenCheckboxStyle(
a: CheckboxStyle,
b: CheckboxStyle,
@@ -42,11 +39,6 @@ export interface CheckboxTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) CheckboxStyle. The CALLER invokes this;
- * it reads the frame, the `<Checkbox>` component does not. Feed the result to
- * `<Checkbox style={...} />` for smooth check/uncheck transitions.
- */
export function useCheckboxTransition(
steps: Step<CheckboxState>[],
opts: CheckboxTransitionOptions = {},
diff --git a/registry/remocn-ui/checkout-flow/index.tsx b/registry/remocn-ui/checkout-flow/index.tsx
index 246cfebc..87eb2d9a 100644
--- a/registry/remocn-ui/checkout-flow/index.tsx
+++ b/registry/remocn-ui/checkout-flow/index.tsx
@@ -25,65 +25,37 @@ import {
FieldLabel,
} from "@/components/remocn/field";
-/**
- * Checkout flow — a shippable composition scene rendered as a real card (no
- * Dialog). Pure orchestrator: it scripts the lifecycle by calling each
- * primitive's transition hook (which legitimately read the frame) and lays the
- * primitives out on a position:relative stage. The block holds no
- * state/effect/frame of its own.
- *
- * The card itself, its header, and each field blur-in in sequence (card →
- * header → toggle → card number → terms → pay), then a cursor flips the billing
- * toggle monthly → yearly, types the card number, ticks the terms checkbox, and
- * presses Pay → loading → success → success Toast. Beat `at` values are the
- * single source of truth and are frame-synced so each cursor click lands on the
- * same frame as the state change it triggers.
- */
-
-// Default plan segments for the billing toggle (value === label by default).
const DEFAULT_PLANS: ToggleGroupItem[] = [
{ value: "monthly", label: "Monthly" },
{ value: "yearly", label: "Yearly" },
];
-// Stage geometry (1280×720). The card is centered; cursor Y targets are the
-// vertical centers of each clickable control as they stack in the card column.
-// Fields are left-aligned and the Pay button is right-aligned, so the X targets
-// are anchored to the card's content edges, not its center.
const STAGE_W = 1280;
const CARD_W = 420;
const CARD_PAD = 28;
const CARD_TOP = 96;
-const CARD_LEFT = (STAGE_W - CARD_W) / 2; // 430
-const CENTER_X = STAGE_W / 2; // 640
-const CONTENT_LEFT = CARD_LEFT + CARD_PAD; // 458
-const CONTENT_RIGHT = CARD_LEFT + CARD_W - CARD_PAD; // 822
+const CARD_LEFT = (STAGE_W - CARD_W) / 2;
+const CENTER_X = STAGE_W / 2;
+const CONTENT_LEFT = CARD_LEFT + CARD_PAD;
+const CONTENT_RIGHT = CARD_LEFT + CARD_W - CARD_PAD;
const TOGGLE_Y = 222;
-const YEARLY_X = CONTENT_LEFT + 4 + 88 + 44; // 594 — "Yearly" segment center
-const CARD_X = CENTER_X; // the input fills the row; click its middle
+const YEARLY_X = CONTENT_LEFT + 4 + 88 + 44;
+const CARD_X = CENTER_X;
const CARD_Y = 312;
-const TERMS_X = CONTENT_LEFT + 12; // 470 — over the left-aligned checkbox box
+const TERMS_X = CONTENT_LEFT + 12;
const TERMS_Y = 376;
-const PAY_X = CONTENT_RIGHT - 48; // 774 — over the right-aligned Pay button
+const PAY_X = CONTENT_RIGHT - 48;
const PAY_Y = 442;
export interface CheckoutFlowProps {
- /** Card title. */
title?: string;
- /** Card description under the title. */
description?: string;
- /** Billing toggle segments. The first is the resting selection. */
plans?: ToggleGroupItem[];
- /** Label above the card-number input. */
cardLabel?: string;
- /** Card-number value revealed by the typing input. */
cardPlaceholder?: string;
- /** Label shown beside the terms checkbox. */
termsLabel?: string;
- /** Primary (pay) button label. */
payLabel?: string;
- /** Headline of the success toast. */
toastTitle?: string;
mode?: "light" | "dark";
theme?: Partial<RemocnTheme>;
@@ -104,10 +76,6 @@ export function CheckoutFlow({
const resolved = useRemocnTheme(theme, mode);
const opts = { mode, theme };
- // Entrance — card surface fades in place (distance 0 → no slide, so it never
- // becomes a transform containing block for the inset:0 atoms it holds), then
- // the header and each field blur-in staggered. All complete by frame 58,
- // before the first cursor click at 64.
const cardEnter = useBlurInTransition(
[{ at: 0, state: "revealed", duration: 18 }],
{ distance: 0 },
@@ -128,9 +96,6 @@ export function CheckoutFlow({
{ at: 42, state: "revealed", duration: 16 },
]);
- // Cursor — clicks the Yearly segment (64), the card-number field (96), the
- // terms checkbox (150), then the Pay button (180). Each click `at` equals the
- // `at` of the state change it drives.
const cursorStyle = useCursorPath([
{ at: 0, x: 140, y: 90 },
{ at: 64, x: YEARLY_X, y: TOGGLE_Y, duration: 22, click: true },
@@ -139,14 +104,11 @@ export function CheckoutFlow({
{ at: 180, x: PAY_X, y: PAY_Y, duration: 26, click: true },
]);
- // Billing toggle slides monthly → yearly on the click at 64.
const toggleStyle = useToggleGroupTransition(
[{ at: 64, state: plans[1]?.value ?? "yearly", duration: 16 }],
{ items: plans, ...opts },
);
- // Card-number field — focus on the click at 96, type 100→140, then settle to
- // the static blur (filled/unfocused) state as the cursor leaves at 150.
const cardStyle = useInputTransition(
[
{ at: 96, state: "active", duration: 6 },
@@ -156,13 +118,11 @@ export function CheckoutFlow({
opts,
);
- // Terms checkbox ticks on the click at 150.
const checkboxStyle = useCheckboxTransition(
[{ at: 150, state: "checked", duration: 14 }],
opts,
);
- // Pay button — hovers, presses into the click at 180, loads, then succeeds.
const payStyle = useButtonTransition(
[
{ at: 172, state: "hover", duration: 8 },
@@ -173,8 +133,6 @@ export function CheckoutFlow({
opts,
);
- // Success toast enters at 224, auto-dismisses at 286. The toast hook tints by
- // `mode` only; `theme` rides the component prop below.
const toastStyle = useToastTransition(
[
{ at: 224, state: "visible", duration: 14 },
diff --git a/registry/remocn-ui/combobox/__tests__/combobox.test.ts b/registry/remocn-ui/combobox/__tests__/combobox.test.ts
index a7820f1c..99c985b1 100644
--- a/registry/remocn-ui/combobox/__tests__/combobox.test.ts
+++ b/registry/remocn-ui/combobox/__tests__/combobox.test.ts
@@ -1,36 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `combobox`.
- *
- * Scope:
- * - registry/remocn-ui/combobox/index.tsx
- * filterComboboxItems(items, query, revealCount) — exported pure filter
- * comboboxStyle(state, ctx) — complete state→visual map
- * - registry/remocn-ui/combobox/use-combobox-transition.ts
- * tweenComboboxStyle(a, b, t) — pure lerp across all three fields
- * DEFAULT_DURATION constant
- * useComboboxTransition resolver — mirrored as resolveComboboxTransition
- * with frame injected as `raw` (annotated source lines)
- * - registry/remocn-ui/combobox/config.ts
- * comboboxConfig.controls wiring + comboboxConfig.snippet codegen
- *
- * The render path (index.tsx) imports `useRemocnTheme` / `useRemocnTheme` which
- * requires React context and cannot run headlessly — it is NOT exercised here.
- * `comboboxStyleContext` re-delegates to `inputStyleContext` and
- * `selectItemStyleContext`, both of which also require no React; they ARE called
- * here for fixture construction, but their internal correctness is covered by
- * the select/__tests__ suite.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/combobox/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports for component source; `@/lib/remocn-ui` alias for core.
- * `useComboboxTransition` is NOT imported — it reads `useCurrentFrame()`.
- * Its pure body is mirrored as `resolveComboboxTransition` with frame injected.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -48,18 +15,12 @@ import { comboboxConfig } from "../config";
import { defaultLightTheme, defaultDarkTheme, easings } from "@/lib/remocn-ui";
import type { Step } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
const VALID_STATES: readonly ComboboxState[] = ["opened", "closed"];
const SAMPLE_ITEMS = ["Apple", "Banana", "Orange", "Grape"];
-/** Build a shared ctx for style assertions (no React needed — pure function). */
const ctx = comboboxStyleContext(defaultLightTheme);
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
state?: string;
query?: string;
@@ -72,23 +33,12 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
comboboxConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is 12 frames", () => {
expect(DEFAULT_DURATION).toBe(12);
});
});
-// ===========================================================================
-// 2. filterComboboxItems — exported pure filter
-// MIRROR of index.tsx lines 77-89
-// Case-insensitive substring on query.slice(0, revealCount).
-// Items are plain strings (unlike command-menu's .label entries).
-// ===========================================================================
-
describe("filterComboboxItems: empty visible prefix → all items returned", () => {
it("returns all items when query is empty string", () => {
expect(filterComboboxItems(SAMPLE_ITEMS, "", undefined)).toHaveLength(4);
@@ -133,7 +83,6 @@ describe("filterComboboxItems: prefix narrows results", () => {
});
it("'a' matches Apple, Banana, Orange, Grape (all contain 'a')", () => {
- // Apple(a), Banana(a), Orange(a), Grape(a)
const result = filterComboboxItems(SAMPLE_ITEMS, "a", undefined);
expect(result).toHaveLength(4);
});
@@ -186,7 +135,6 @@ describe("filterComboboxItems: revealCount slices the query", () => {
});
it("revealCount > query length uses full query (no index error)", () => {
- // query='ap' (2 chars), revealCount=100 → uses full 'ap'
const result = filterComboboxItems(SAMPLE_ITEMS, "ap", 100);
expect(result).toHaveLength(1);
expect(result[0]).toBe("Apple");
@@ -196,17 +144,10 @@ describe("filterComboboxItems: revealCount slices the query", () => {
describe("filterComboboxItems: result preserves original string references", () => {
it("filtered items are the same string references (no cloning)", () => {
const result = filterComboboxItems(SAMPLE_ITEMS, "apple", undefined);
- // strings are primitives — identity check via toBe confirms no mutation
expect(result[0]).toBe(SAMPLE_ITEMS[0]);
});
});
-// ===========================================================================
-// 3. comboboxStyle — pure (state, ctx) => ComboboxStyle presets
-// MIRROR of index.tsx lines 138-148
-// Every field is asserted for both states.
-// ===========================================================================
-
describe("comboboxStyle: closed state — off-screen keyframe", () => {
const s = comboboxStyle("closed", ctx);
@@ -267,12 +208,6 @@ describe("comboboxStyle: every state produces a complete ComboboxStyle", () => {
});
});
-// ===========================================================================
-// 4. tweenComboboxStyle — pure lerp across all three numeric fields
-// MIRROR of use-combobox-transition.ts lines 22-33
-// All fields are numbers — straight lerp on everything.
-// ===========================================================================
-
describe("tweenComboboxStyle: t=0 returns values equal to `a`", () => {
const a = comboboxStyle("closed", ctx);
const b = comboboxStyle("opened", ctx);
@@ -310,9 +245,6 @@ describe("tweenComboboxStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenComboboxStyle: t=0.5 midpoint (closed → opened)", () => {
- // closed: panelOpacity=0, panelScale=0.96, panelTranslateY=-4
- // opened: panelOpacity=1, panelScale=1, panelTranslateY=0
- // midpoint: 0.5, 0.98, -2
const a = comboboxStyle("closed", ctx);
const b = comboboxStyle("opened", ctx);
const r = tweenComboboxStyle(a, b, 0.5);
@@ -331,7 +263,6 @@ describe("tweenComboboxStyle: t=0.5 midpoint (closed → opened)", () => {
});
describe("tweenComboboxStyle: t=0.25 quarter-point (closed → opened)", () => {
- // panelOpacity: 0.25, panelScale: 0.97, panelTranslateY: -3
const a = comboboxStyle("closed", ctx);
const b = comboboxStyle("opened", ctx);
const r = tweenComboboxStyle(a, b, 0.25);
@@ -374,29 +305,10 @@ describe("tweenComboboxStyle: reverse direction (opened → closed)", () => {
});
});
-// ===========================================================================
-// 5. useComboboxTransition resolver replica
-// MIRRORS use-combobox-transition.ts lines 47-71.
-// `useComboboxTransition` calls `useStateTransition` (reads useCurrentFrame())
-// then applies `easings.out(progress)` and `tweenComboboxStyle`.
-// We inject `raw` in place of useCurrentFrame().
-//
-// The key additional contract: progress is eased with `easings.out` before
-// the tween, making the result non-linear (confirmed: out(0.5) = 0.875).
-//
-// MAINTENANCE CONTRACT: if use-combobox-transition.ts lines 47-71 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>[],
@@ -418,30 +330,21 @@ function resolveStateTransition<S extends string>(
return { from: from ? from.state : defaultState, to: to.state, progress };
}
-/**
- * MIRROR of use-combobox-transition.ts:useComboboxTransition (lines 47-71).
- * `raw` is injected in place of useCurrentFrame().
- * Annotated source lines:
- * line 54: destructure speed + defaultDuration from opts
- * lines 59-64: useStateTransition (mirrored as resolveStateTransition)
- * line 65: t = easings.out(progress) ← MIRROR line 65
- * lines 66-70: tweenComboboxStyle(from, to, t) ← MIRROR lines 66-70
- */
function resolveComboboxTransition(
raw: number, // injected useCurrentFrame() — MIRROR line 59
steps: Step<ComboboxState>[],
speed = 1,
defaultDuration = DEFAULT_DURATION,
): ComboboxStyle & { from: ComboboxState; to: ComboboxState; progress: number } {
- const { from, to, progress } = resolveStateTransition( // MIRROR lines 59-64
+ const { from, to, progress } = resolveStateTransition(
raw,
steps,
"closed",
speed,
defaultDuration,
);
- const t = easings.out(progress); // MIRROR line 65
- const style = tweenComboboxStyle( // MIRROR lines 66-70
+ const t = easings.out(progress);
+ const style = tweenComboboxStyle(
comboboxStyle(from as ComboboxState, ctx),
comboboxStyle(to as ComboboxState, ctx),
t,
@@ -449,10 +352,6 @@ function resolveComboboxTransition(
return { ...style, from: from as ComboboxState, to: to as ComboboxState, progress };
}
-// ---------------------------------------------------------------------------
-// Before any step: holds at closed (progress=1, tween(closed,closed,out(1)))
-// ---------------------------------------------------------------------------
-
describe("resolveComboboxTransition: before any step — holds at closed", () => {
it("returns the closed style when no steps have started", () => {
const r = resolveComboboxTransition(0, []);
@@ -469,10 +368,6 @@ describe("resolveComboboxTransition: before any step — holds at closed", () =>
});
});
-// ---------------------------------------------------------------------------
-// Exactly at a step boundary: progress=0, t=out(0)=0 → closed style
-// ---------------------------------------------------------------------------
-
describe("resolveComboboxTransition: exactly at closed→opened step boundary", () => {
const steps: Step<ComboboxState>[] = [{ at: 10, state: "opened" }];
@@ -491,33 +386,26 @@ describe("resolveComboboxTransition: exactly at closed→opened step boundary",
});
});
-// ---------------------------------------------------------------------------
-// Mid-window: easings.out applied — non-linear (not raw 0.5)
-// out(0.5) = 1-(1-0.5)^3 = 1-0.125 = 0.875
-// ---------------------------------------------------------------------------
-
describe("resolveComboboxTransition: mid-window uses easings.out (not linear)", () => {
- // step at=0, defaultDuration=12. At raw=6: linear progress=0.5, out(0.5)=0.875
const steps: Step<ComboboxState>[] = [{ at: 0, state: "opened" }];
it("panelOpacity at raw=6 is out(0.5)=0.875 (not linear 0.5)", () => {
const r = resolveComboboxTransition(6, steps, 1, 12);
- const t = easings.out(0.5); // 0.875
- // tween(0, 1, 0.875) = 0.875
+ const t = easings.out(0.5);
expect(r.panelOpacity).toBeCloseTo(t, 8);
});
it("panelScale at raw=6 is 0.96 + 0.04*out(0.5) = 0.995", () => {
const r = resolveComboboxTransition(6, steps, 1, 12);
- const t = easings.out(0.5); // 0.875
- const expected = 0.96 + (1 - 0.96) * t; // 0.995
+ const t = easings.out(0.5);
+ const expected = 0.96 + (1 - 0.96) * t;
expect(r.panelScale).toBeCloseTo(expected, 8);
});
it("panelTranslateY at raw=6 is -4*(1-out(0.5)) = -0.5", () => {
const r = resolveComboboxTransition(6, steps, 1, 12);
- const t = easings.out(0.5); // 0.875
- const expected = -4 + (0 - (-4)) * t; // -4 + 4*0.875 = -0.5
+ const t = easings.out(0.5);
+ const expected = -4 + (0 - (-4)) * t;
expect(r.panelTranslateY).toBeCloseTo(expected, 8);
});
@@ -527,10 +415,6 @@ describe("resolveComboboxTransition: mid-window uses easings.out (not linear)",
});
});
-// ---------------------------------------------------------------------------
-// Past the window: fully opened
-// ---------------------------------------------------------------------------
-
describe("resolveComboboxTransition: past the window → fully opened", () => {
const steps: Step<ComboboxState>[] = [{ at: 0, state: "opened" }];
@@ -547,10 +431,6 @@ describe("resolveComboboxTransition: past the window → fully opened", () => {
});
});
-// ---------------------------------------------------------------------------
-// Speed contract
-// ---------------------------------------------------------------------------
-
describe("resolveComboboxTransition: speed contract", () => {
const steps: Step<ComboboxState>[] = [{ at: 12, state: "opened" }];
@@ -563,10 +443,6 @@ describe("resolveComboboxTransition: speed contract", () => {
});
});
-// ===========================================================================
-// 6. comboboxConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("comboboxConfig.controls: state", () => {
it("state is a select control", () => {
expect(comboboxConfig.controls.state.type).toBe("select");
@@ -639,10 +515,6 @@ describe("comboboxConfig.controls: mode", () => {
});
});
-// ===========================================================================
-// 7. comboboxConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("comboboxConfig.snippet: import line", () => {
it("includes 'import { Combobox }' from the correct path", () => {
const out = snippet({ state: "opened" });
diff --git a/registry/remocn-ui/combobox/config.ts b/registry/remocn-ui/combobox/config.ts
index 43cc8a86..158454bc 100644
--- a/registry/remocn-ui/combobox/config.ts
+++ b/registry/remocn-ui/combobox/config.ts
@@ -10,7 +10,6 @@ export const comboboxConfig: ComponentConfig = {
controls: {
state: {
type: "select",
- // Default to `opened` so the preview shows the revealed panel.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/combobox/index.tsx b/registry/remocn-ui/combobox/index.tsx
index 7fb4e066..ac3afbeb 100644
--- a/registry/remocn-ui/combobox/index.tsx
+++ b/registry/remocn-ui/combobox/index.tsx
@@ -19,61 +19,24 @@ import {
export type ComboboxState = "opened" | "closed";
export interface ComboboxProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: ComboboxState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `ComboboxStyle` from `useComboboxTransition`.
- */
style?: ComboboxStyle;
- /** Full typed query (the visible prefix is `query.slice(0, revealCount)`). */
query?: string;
- /**
- * Number of query characters revealed so far (the caller computes this with
- * core `revealCount`). Omitted → the whole `query` is shown.
- */
revealCount?: number;
- /** Trigger placeholder shown before any query is typed. */
placeholder?: string;
- /** The full option list (before filtering). */
items?: string[];
- /** Index (into the FILTERED list) of the persisted selection. `-1` for none. */
selectedIndex?: number;
- /** Index (into the FILTERED list) of the row under the pointer. `-1` for none. */
highlightedIndex?: number;
- /** Index (into the FILTERED list) of the row being pressed. `-1` for none. */
pressedIndex?: number;
- /**
- * Per-item resolved visual override (smooth path), indexed into the FILTERED
- * list. When present it wins over the index→state derivation.
- */
itemStyles?: (SelectItemStyle | undefined)[];
- /**
- * Resolved Input visual for the trigger (smooth path). Drive it with
- * `useInputTransition` for focus-ring + typed-text reveal. Defaults to the
- * resting `idle` look (or `typing` once a query is revealed).
- */
inputStyle?: InputStyle;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Trigger width = panel width (px). */
const WIDTH = 280;
-/**
- * Filter option strings by the visible query prefix. PURE — a case-insensitive
- * substring match on `query.slice(0, revealCount)`. An empty visible prefix
- * matches everything. Exported so tests can mirror it and the example can keep
- * its filtered indices in sync.
- *
- * NOTE: this is intentionally the SAME logic as command-menu's
- * `filterCommandItems` (deliberate duplication — the core is frozen, so the two
- * filters are kept textually parallel rather than extracted). The only
- * difference is the item shape: here `items` are plain strings, so the match is
- * on the string itself rather than an entry `.label`.
- */
export function filterComboboxItems(
items: string[],
query: string,
@@ -88,26 +51,13 @@ export function filterComboboxItems(
return items.filter((item) => item.toLowerCase().includes(visible));
}
-// ===========================================================================
-// Combobox visual — the COMPLETE animated look for a moment in time. A `state`
-// is a named preset of this visual (`comboboxStyle`); the smooth path feeds an
-// interpolated `ComboboxStyle` straight through. The component is a pure renderer
-// of whichever `ComboboxStyle` it receives. The trigger reuses the Input
-// presets and the panel rows reuse SelectItemRow — neither markup is duplicated.
-// ===========================================================================
-
export interface ComboboxStyle {
- /** Panel fade 0 (closed) → 1 (opened). */
panelOpacity: number;
- /** Panel zoom 0.96 (closed) → 1 (opened). */
panelScale: number;
- /** Panel lift -4 (closed) → 0 (opened) px. */
panelTranslateY: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface ComboboxStyleContext {
- /** Input presets — reused so the trigger IS the Input look. */
triggerCtx: InputStyleContext;
panelBg: string;
panelBorder: string;
@@ -116,10 +66,6 @@ export interface ComboboxStyleContext {
itemCtx: SelectItemStyleContext;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `comboboxStyle(state, ctx)` preset.
- */
export function comboboxStyleContext(theme: RemocnTheme): ComboboxStyleContext {
return {
triggerCtx: inputStyleContext(theme),
@@ -131,10 +77,6 @@ export function comboboxStyleContext(theme: RemocnTheme): ComboboxStyleContext {
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) =>
- * ComboboxStyle` map. To change how a state looks, edit one entry.
- */
export function comboboxStyle(
state: ComboboxState,
_ctx: ComboboxStyleContext,
@@ -147,7 +89,6 @@ export function comboboxStyle(
}
}
-/** Resolve one row's state from the index props (used when no itemStyle override). */
function rowState(
i: number,
selectedIndex: number,
@@ -184,18 +125,10 @@ export function Combobox({
revealCount === undefined ? query : query.slice(0, revealCount);
const filtered = filterComboboxItems(items, query, revealCount);
- // The trigger reuses the Input visual. Input itself is a full-frame scene
- // (absolute inset:0) and can't nest inline, so — like Select reuses the Button
- // presets for its trigger — the trigger is rendered inline from the Input
- // presets. Defaults to `typing` once a query is revealed, else `idle`; the
- // caller can pass a tweened `inputStyle` (from useInputTransition) instead.
const trigger: InputStyle =
inputStyleOverride ??
inputStyle(visibleQuery ? "typing" : "idle", ctx.triggerCtx);
- // The reveal width tracks the visible query length so the caret sits at its
- // end (headless render can't measure text; ~8px per char is a good monospace-
- // ish estimate for the trigger value).
const valueWidth = visibleQuery.length * 8;
return (
@@ -207,15 +140,13 @@ export function Combobox({
display: "flex",
alignItems: "center",
justifyContent: "center",
- // OPAQUE wrapper — a combobox is a self-contained widget, not a modal
- // layer (mirrors Select).
background: theme.background,
fontFamily:
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
<div style={{ position: "relative", width: WIDTH }}>
- {/* Trigger — the Input look, rendered inline. */}
+ {}
<div
style={{
position: "relative",
@@ -233,7 +164,7 @@ export function Combobox({
boxShadow: `0 0 0 ${trigger.ringWidth}px ${trigger.ringColor}`,
}}
>
- {/* Placeholder — hidden the instant the value starts revealing. */}
+ {}
<span
style={{
position: "absolute",
@@ -246,7 +177,7 @@ export function Combobox({
>
{placeholder}
</span>
- {/* Value + caret — the typed query. */}
+ {}
<div style={{ display: "flex", alignItems: "center", minWidth: 0 }}>
<span
style={{
@@ -271,7 +202,7 @@ export function Combobox({
/>
</div>
</div>
- {/* Panel — opacity/scale/lift animate the reveal below the trigger. */}
+ {}
<div
style={{
position: "absolute",
diff --git a/registry/remocn-ui/combobox/use-combobox-transition.ts b/registry/remocn-ui/combobox/use-combobox-transition.ts
index 40193ad1..34f2b9f7 100644
--- a/registry/remocn-ui/combobox/use-combobox-transition.ts
+++ b/registry/remocn-ui/combobox/use-combobox-transition.ts
@@ -13,12 +13,9 @@ import {
type ComboboxState,
type ComboboxStyle,
} from "@/components/remocn/combobox";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 12;
-/** Blend two combobox visuals: all fields are numbers, so a straight lerp. */
export function tweenComboboxStyle(
a: ComboboxStyle,
b: ComboboxStyle,
@@ -39,11 +36,6 @@ export interface ComboboxTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) ComboboxStyle. The CALLER invokes this;
- * it reads the frame, the `<Combobox>` component does not. Feed the result to
- * `<Combobox style={...} />` for a smooth open/close.
- */
export function useComboboxTransition(
steps: Step<ComboboxState>[],
opts: ComboboxTransitionOptions = {},
diff --git a/registry/remocn-ui/command-menu-item/__tests__/command-menu-item.test.ts b/registry/remocn-ui/command-menu-item/__tests__/command-menu-item.test.ts
index 2b949d0a..263f1237 100644
--- a/registry/remocn-ui/command-menu-item/__tests__/command-menu-item.test.ts
+++ b/registry/remocn-ui/command-menu-item/__tests__/command-menu-item.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `command-menu-item`.
- *
- * Scope:
- * - registry/remocn-ui/command-menu-item/index.tsx
- * commandMenuItemStyleContext(theme) — pure color derivation
- * commandMenuItemStyle(state, ctx) — complete state→visual preset map
- * - registry/remocn-ui/command-menu-item/use-command-menu-item-transition.ts
- * tweenCommandMenuItemStyle(a, b, t) — pure lerp/mix across every field
- * DEFAULT_DURATION constant
- *
- * - registry/remocn-ui/command-menu-item/config.ts
- * commandMenuItemConfig.controls wiring + commandMenuItemConfig.snippet codegen
- *
- * The render path (index.tsx) imports `useRemocnTheme` which requires React
- * context and cannot run headlessly — it is NOT exercised here.
- * `useCommandMenuItemTransition` calls `useStateTransition` → `useCurrentFrame`
- * and is NOT imported; its pure resolver logic is already tested in
- * core/__tests__/timeline.test.ts, and the additional easing + tween contract is
- * covered by the tweenCommandMenuItemStyle tests below.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/command-menu-item/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports for component source; `@/lib/remocn-ui` alias for core.
- * None of the imported functions call `useCurrentFrame()` at import or call time.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -43,10 +12,6 @@ import {
import { commandMenuItemConfig } from "../config";
import { defaultLightTheme, defaultDarkTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
const VALID_STATES: readonly CommandMenuItemState[] = [
"idle",
"hover",
@@ -54,10 +19,8 @@ const VALID_STATES: readonly CommandMenuItemState[] = [
"selected",
];
-/** A context built from the default light theme — reused across all preset tests. */
const ctx = commandMenuItemStyleContext(defaultLightTheme);
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
state?: string;
label?: string;
@@ -68,21 +31,12 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
commandMenuItemConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is 8 frames (item default — shorter than container's 12)", () => {
expect(DEFAULT_DURATION).toBe(8);
});
});
-// ===========================================================================
-// 2. commandMenuItemStyleContext — pure theme → context derivation
-// MIRROR of index.tsx lines 75-91
-// ===========================================================================
-
describe("commandMenuItemStyleContext: maps theme tokens correctly", () => {
it("idleBg equals theme.popover", () => {
expect(ctx.idleBg).toBe(defaultLightTheme.popover);
@@ -157,12 +111,6 @@ describe("commandMenuItemStyleContext: theme independence — different themes p
});
});
-// ===========================================================================
-// 3. commandMenuItemStyle — pure (state, ctx) => CommandMenuItemStyle presets
-// MIRROR of index.tsx lines 97-131
-// Every field is asserted for every state.
-// ===========================================================================
-
describe("commandMenuItemStyle: idle state", () => {
const s = commandMenuItemStyle("idle", ctx);
@@ -287,12 +235,6 @@ describe("commandMenuItemStyle: every state produces complete CommandMenuItemSty
});
});
-// ===========================================================================
-// 4. tweenCommandMenuItemStyle — pure lerp/mix across every field
-// MIRROR of use-command-menu-item-transition.ts lines 23-34
-// Numbers lerp; colors go through mixOklch (tested as non-empty strings).
-// ===========================================================================
-
describe("tweenCommandMenuItemStyle: t=0 returns values equal to `a`", () => {
const a = commandMenuItemStyle("idle", ctx);
const b = commandMenuItemStyle("selected", ctx);
@@ -344,7 +286,6 @@ describe("tweenCommandMenuItemStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenCommandMenuItemStyle: t=0.5 midpoint — numeric field (idle → press)", () => {
- // idle: scale=1, press: scale=0.98 → midpoint: 0.99
const a = commandMenuItemStyle("idle", ctx);
const b = commandMenuItemStyle("press", ctx);
const r = tweenCommandMenuItemStyle(a, b, 0.5);
@@ -360,7 +301,6 @@ describe("tweenCommandMenuItemStyle: t=0.5 midpoint — numeric field (idle →
});
describe("tweenCommandMenuItemStyle: t=0.5 midpoint — numeric field (idle → hover)", () => {
- // idle: scale=1, hover: scale=1 → midpoint: 1 (same, test that it holds)
const a = commandMenuItemStyle("idle", ctx);
const b = commandMenuItemStyle("hover", ctx);
const r = tweenCommandMenuItemStyle(a, b, 0.5);
@@ -405,10 +345,6 @@ describe("tweenCommandMenuItemStyle: all four fields are present in the result",
});
});
-// ===========================================================================
-// 5. commandMenuItemConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("commandMenuItemConfig.controls: state", () => {
it("state is a select control", () => {
expect(commandMenuItemConfig.controls.state.type).toBe("select");
@@ -479,10 +415,6 @@ describe("commandMenuItemConfig.controls: mode", () => {
});
});
-// ===========================================================================
-// 6. commandMenuItemConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("commandMenuItemConfig.snippet: import line", () => {
it("includes 'import { CommandMenuItem }' from the correct path", () => {
const out = snippet({ state: "selected" });
diff --git a/registry/remocn-ui/command-menu-item/config.ts b/registry/remocn-ui/command-menu-item/config.ts
index 4dfcb1d0..00017de3 100644
--- a/registry/remocn-ui/command-menu-item/config.ts
+++ b/registry/remocn-ui/command-menu-item/config.ts
@@ -15,7 +15,6 @@ export const commandMenuItemConfig: ComponentConfig = {
shortcut: { type: "text", default: "⌘ S", label: "Shortcut" },
state: {
type: "select",
- // Default to `selected` so the preview shows the highlighted row.
default: "selected",
options: ["idle", "hover", "press", "selected"],
label: "State",
diff --git a/registry/remocn-ui/command-menu-item/index.tsx b/registry/remocn-ui/command-menu-item/index.tsx
index f8b516ab..d5785ea8 100644
--- a/registry/remocn-ui/command-menu-item/index.tsx
+++ b/registry/remocn-ui/command-menu-item/index.tsx
@@ -5,54 +5,28 @@ import { mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
export type CommandMenuItemState = "idle" | "hover" | "press" | "selected";
export interface CommandMenuItemProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: CommandMenuItemState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `CommandMenuItemStyle` from
- * `useCommandMenuItemTransition`.
- */
style?: CommandMenuItemStyle;
- /** Row label. */
label?: string;
- /** Optional leading icon name from the built-in set (search/settings/user/file). */
icon?: CommandMenuIcon;
- /** Optional trailing keyboard shortcut, e.g. "⌘K" or "⌘ S". */
shortcut?: string;
- /** Row width (px). Matches the panel content width when composed in CommandMenu. */
width?: number;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** The built-in leading icons. Hand-drawn so nothing is imported from a kit. */
export type CommandMenuIcon = "search" | "settings" | "user" | "file";
-/** Standalone row width (px) when the atom is mounted on its own. */
const ROW_WIDTH = 360;
-// ===========================================================================
-// Command-menu-item visual — the COMPLETE animated look for a moment in time. A
-// `state` is a named preset of this visual (`commandMenuItemStyle`); the smooth
-// path feeds an interpolated `CommandMenuItemStyle` straight through. The
-// component is a pure renderer of whichever style it receives. This atom is NOT
-// a copy of select-item: its row is icon + label + trailing shortcut kbd, not
-// label + check icon.
-// ===========================================================================
-
export interface CommandMenuItemStyle {
- /** Animated row background (a concrete color, never "transparent"). */
background: string;
- /** Animated label color. */
labelColor: string;
- /** Animated icon color. */
iconColor: string;
- /** Row zoom: 1 default, 0.98 on press. */
scale: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface CommandMenuItemStyleContext {
idleBg: string;
hoverBg: string;
@@ -62,16 +36,11 @@ export interface CommandMenuItemStyleContext {
selectedFg: string;
idleIcon: string;
selectedIcon: string;
- /** Static shortcut-kbd colors (never animated). */
kbdBg: string;
kbdFg: string;
kbdBorder: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `commandMenuItemStyle(state, ctx)` preset.
- */
export function commandMenuItemStyleContext(
theme: RemocnTheme,
): CommandMenuItemStyleContext {
@@ -90,10 +59,6 @@ export function commandMenuItemStyleContext(
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) =>
- * CommandMenuItemStyle` map. To change how a state looks, edit one entry.
- */
export function commandMenuItemStyle(
state: CommandMenuItemState,
ctx: CommandMenuItemStyleContext,
@@ -130,7 +95,6 @@ export function commandMenuItemStyle(
}
}
-/** Hand-drawn leading icon paths on a 24×24 grid (stroke-driven). */
const ICON_PATHS: Record<CommandMenuIcon, string> = {
search: "M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14ZM20 20l-3.5-3.5",
settings:
@@ -159,28 +123,17 @@ function CommandMenuItemIcon({
);
}
-/** Props for the inline row — the shared visual that `CommandMenu` reuses. */
export interface CommandMenuItemRowProps {
- /** Resolved animated visual (smooth path); wins over `state` when present. */
style?: CommandMenuItemStyle;
- /** Current visual state (snap path) when no `style` is supplied. */
state?: CommandMenuItemState;
- /** Pre-derived ctx (the container passes its shared one to avoid re-resolving). */
ctx: CommandMenuItemStyleContext;
label: string;
icon?: CommandMenuIcon;
shortcut?: string;
width: number;
- /** Row corner radius (px). */
radius: number;
}
-/**
- * INLINE command row — no full-frame wrapper. One row of a command palette:
- * leading icon (optional) + label on the left, trailing shortcut kbd on the
- * right. The `CommandMenu` container renders a column of these; the standalone
- * `CommandMenuItem` wraps one in a centering frame.
- */
export function CommandMenuItemRow({
style,
state = "idle",
@@ -258,12 +211,6 @@ export function CommandMenuItemRow({
);
}
-/**
- * Standalone command-row atom — resolves theme/ctx/style then wraps a single
- * `<CommandMenuItemRow>` in the standard full-frame centering wrapper. THIS is
- * what the registry registers and the customizer mounts. The `CommandMenu`
- * container does NOT use this — it reuses `CommandMenuItemRow` directly.
- */
export function CommandMenuItem({
state = "idle",
style,
diff --git a/registry/remocn-ui/command-menu-item/use-command-menu-item-transition.ts b/registry/remocn-ui/command-menu-item/use-command-menu-item-transition.ts
index c22cbfce..5fa8e35e 100644
--- a/registry/remocn-ui/command-menu-item/use-command-menu-item-transition.ts
+++ b/registry/remocn-ui/command-menu-item/use-command-menu-item-transition.ts
@@ -14,12 +14,9 @@ import {
type CommandMenuItemState,
type CommandMenuItemStyle,
} from "@/components/remocn/command-menu-item";
-// ^ 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 = 8;
-/** Blend two command-menu-item visuals: numbers lerp, colors via oklch mix. */
export function tweenCommandMenuItemStyle(
a: CommandMenuItemStyle,
b: CommandMenuItemStyle,
@@ -40,11 +37,6 @@ export interface CommandMenuItemTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) CommandMenuItemStyle. The CALLER invokes
- * this; it reads the frame, the `<CommandMenuItem>` component does not. Feed the
- * result to `<CommandMenuItem style={...} />` (or a `CommandMenuItemRow`).
- */
export function useCommandMenuItemTransition(
steps: Step<CommandMenuItemState>[],
opts: CommandMenuItemTransitionOptions = {},
diff --git a/registry/remocn-ui/command-menu/__tests__/command-menu.test.ts b/registry/remocn-ui/command-menu/__tests__/command-menu.test.ts
index a83e1935..79a74cb4 100644
--- a/registry/remocn-ui/command-menu/__tests__/command-menu.test.ts
+++ b/registry/remocn-ui/command-menu/__tests__/command-menu.test.ts
@@ -1,33 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `command-menu`.
- *
- * Scope:
- * - registry/remocn-ui/command-menu/index.tsx
- * filterCommandItems(items, query, revealCount) — exported pure filter
- * commandMenuStyleContext(theme) — pure color derivation
- * commandMenuStyle(state, ctx) — complete state→visual map
- * - registry/remocn-ui/command-menu/use-command-menu-transition.ts
- * tweenCommandMenuStyle(a, b, t) — pure lerp across every field
- * DEFAULT_DURATION constant
- * useCommandMenuTransition resolver — mirrored as resolveCommandMenuTransition
- * with frame injected as `raw` (annotated source lines)
- * - registry/remocn-ui/command-menu/config.ts
- * commandMenuConfig.controls wiring + commandMenuConfig.snippet codegen
- *
- * The render path (index.tsx) imports `useRemocnTheme` which requires React
- * context and cannot run headlessly — it is NOT exercised here.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/command-menu/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports for component source; `@/lib/remocn-ui` alias for core.
- * `useCommandMenuTransition` is NOT imported — it reads `useCurrentFrame()`.
- * Its pure body is mirrored as `resolveCommandMenuTransition` with frame injected.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -45,10 +15,6 @@ import { commandMenuConfig } from "../config";
import { defaultLightTheme, defaultDarkTheme, easings } from "@/lib/remocn-ui";
import type { Step } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
const VALID_STATES: readonly CommandMenuState[] = ["opened", "closed"];
const SAMPLE_ITEMS: CommandMenuEntry[] = [
@@ -58,10 +24,8 @@ const SAMPLE_ITEMS: CommandMenuEntry[] = [
{ icon: "search", label: "Search docs" },
];
-/** Build a shared ctx for style assertions. */
const ctx = commandMenuStyleContext(defaultLightTheme);
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
state?: string;
query?: string;
@@ -73,22 +37,12 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
commandMenuConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is 12 frames (container default — longer than item's 8)", () => {
expect(DEFAULT_DURATION).toBe(12);
});
});
-// ===========================================================================
-// 2. filterCommandItems — exported pure filter
-// MIRROR of index.tsx lines 69-81
-// Case-insensitive substring on query.slice(0, revealCount).
-// ===========================================================================
-
describe("filterCommandItems: empty visible prefix → all items returned", () => {
it("returns all items when query is empty string", () => {
expect(filterCommandItems(SAMPLE_ITEMS, "", undefined)).toHaveLength(4);
@@ -183,13 +137,11 @@ describe("filterCommandItems: revealCount slices the query", () => {
it("revealCount=1 on 'profile' uses only 'p' → Profile matches", () => {
const result = filterCommandItems(SAMPLE_ITEMS, "profile", 1);
- // 'p' should match Profile
const labels = result.map((i) => i.label);
expect(labels).toContain("Profile");
});
it("revealCount > query length uses full query (no index error)", () => {
- // query='se' (2 chars), revealCount=100 → uses full 'se'
const result = filterCommandItems(SAMPLE_ITEMS, "se", 100);
expect(result).toHaveLength(2);
});
@@ -202,11 +154,6 @@ describe("filterCommandItems: result preserves original item objects", () => {
});
});
-// ===========================================================================
-// 3. commandMenuStyleContext — pure theme → context derivation
-// MIRROR of index.tsx lines 119-133
-// ===========================================================================
-
describe("commandMenuStyleContext: maps theme tokens correctly", () => {
it("panelBg equals theme.popover", () => {
expect(ctx.panelBg).toBe(defaultLightTheme.popover);
@@ -260,12 +207,6 @@ describe("commandMenuStyleContext: theme independence", () => {
});
});
-// ===========================================================================
-// 4. commandMenuStyle — pure (state, ctx) => CommandMenuStyle presets
-// MIRROR of index.tsx lines 139-159
-// Every field is asserted for every state.
-// ===========================================================================
-
describe("commandMenuStyle: closed state — off-screen keyframe", () => {
const s = commandMenuStyle("closed", ctx);
@@ -339,12 +280,6 @@ describe("commandMenuStyle: every state produces complete CommandMenuStyle", ()
});
});
-// ===========================================================================
-// 5. tweenCommandMenuStyle — pure lerp across all four numeric fields
-// MIRROR of use-command-menu-transition.ts lines 22-35
-// All fields are numbers — no color mixing; straight lerp on everything.
-// ===========================================================================
-
describe("tweenCommandMenuStyle: t=0 returns values equal to `a`", () => {
const a = commandMenuStyle("closed", ctx);
const b = commandMenuStyle("opened", ctx);
@@ -390,9 +325,6 @@ describe("tweenCommandMenuStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenCommandMenuStyle: t=0.5 midpoint (closed → opened)", () => {
- // closed: backdropOpacity=0, panelOpacity=0, panelScale=0.96, panelTranslateY=8
- // opened: backdropOpacity=1, panelOpacity=1, panelScale=1, panelTranslateY=0
- // midpoint: 0.5, 0.5, 0.98, 4
const a = commandMenuStyle("closed", ctx);
const b = commandMenuStyle("opened", ctx);
const r = tweenCommandMenuStyle(a, b, 0.5);
@@ -415,7 +347,6 @@ describe("tweenCommandMenuStyle: t=0.5 midpoint (closed → opened)", () => {
});
describe("tweenCommandMenuStyle: t=0.25 quarter-point (closed → opened)", () => {
- // backdropOpacity: 0.25, panelOpacity: 0.25, panelScale: 0.97, panelTranslateY: 6
const a = commandMenuStyle("closed", ctx);
const b = commandMenuStyle("opened", ctx);
const r = tweenCommandMenuStyle(a, b, 0.25);
@@ -450,7 +381,6 @@ describe("tweenCommandMenuStyle: identity (a === b)", () => {
});
describe("tweenCommandMenuStyle: reverse direction (opened → closed)", () => {
- // Same midpoints by symmetry
const a = commandMenuStyle("opened", ctx);
const b = commandMenuStyle("closed", ctx);
const r = tweenCommandMenuStyle(a, b, 0.5);
@@ -464,29 +394,10 @@ describe("tweenCommandMenuStyle: reverse direction (opened → closed)", () => {
});
});
-// ===========================================================================
-// 6. useCommandMenuTransition resolver replica
-// MIRRORS use-command-menu-transition.ts lines 49-73.
-// `useCommandMenuTransition` calls `useStateTransition` (reads useCurrentFrame())
-// then applies `easings.out(progress)` and `tweenCommandMenuStyle`.
-// We inject `raw` in place of useCurrentFrame().
-//
-// The key additional contract beyond core timeline.test.ts: progress is
-// eased with `easings.out` before the tween, making the result non-linear.
-//
-// MAINTENANCE CONTRACT: if use-command-menu-transition.ts lines 49-73 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 (lines 55-73).
- * `raw` is injected in place of useCurrentFrame().
- */
function resolveStateTransition<S extends string>(
raw: number,
steps: Step<S>[],
@@ -508,30 +419,21 @@ function resolveStateTransition<S extends string>(
return { from: from ? from.state : defaultState, to: to.state, progress };
}
-/**
- * MIRROR of use-command-menu-transition.ts:useCommandMenuTransition (lines 49-73).
- * `raw` is injected in place of useCurrentFrame().
- * Annotated source lines:
- * line 57: destructure speed + defaultDuration from opts
- * lines 61-66: useStateTransition (mirrored as resolveStateTransition)
- * line 67: t = easings.out(progress) ← MIRROR line 67
- * lines 68-72: tweenCommandMenuStyle(from, to, t) ← MIRROR lines 68-72
- */
function resolveCommandMenuTransition(
raw: number, // injected useCurrentFrame() — MIRROR line 61
steps: Step<CommandMenuState>[],
speed = 1,
defaultDuration = DEFAULT_DURATION,
): ReturnType<typeof tweenCommandMenuStyle> & { from: CommandMenuState; to: CommandMenuState; progress: number } {
- const { from, to, progress } = resolveStateTransition( // MIRROR lines 61-66
+ const { from, to, progress } = resolveStateTransition(
raw,
steps,
"closed",
speed,
defaultDuration,
);
- const t = easings.out(progress); // MIRROR line 67
- const style = tweenCommandMenuStyle( // MIRROR lines 68-72
+ const t = easings.out(progress);
+ const style = tweenCommandMenuStyle(
commandMenuStyle(from as CommandMenuState, ctx),
commandMenuStyle(to as CommandMenuState, ctx),
t,
@@ -539,10 +441,6 @@ function resolveCommandMenuTransition(
return { ...style, from: from as CommandMenuState, to: to as CommandMenuState, progress };
}
-// ---------------------------------------------------------------------------
-// Before any step: holds at closed (progress=1, tween(closed,closed,out(1)))
-// ---------------------------------------------------------------------------
-
describe("resolveCommandMenuTransition: before any step — holds at closed", () => {
it("returns the closed style when no steps have started", () => {
const r = resolveCommandMenuTransition(0, []);
@@ -560,10 +458,6 @@ describe("resolveCommandMenuTransition: before any step — holds at closed", ()
});
});
-// ---------------------------------------------------------------------------
-// Exactly at a step boundary: progress=0, t=out(0)=0 → closed style
-// ---------------------------------------------------------------------------
-
describe("resolveCommandMenuTransition: exactly at closed→opened step boundary", () => {
const steps: Step<CommandMenuState>[] = [{ at: 10, state: "opened" }];
@@ -582,25 +476,19 @@ describe("resolveCommandMenuTransition: exactly at closed→opened step boundary
});
});
-// ---------------------------------------------------------------------------
-// Mid-window: easings.out applied — non-linear (not raw 0.5)
-// ---------------------------------------------------------------------------
-
describe("resolveCommandMenuTransition: mid-window uses easings.out (not linear)", () => {
- // step at=0, defaultDuration=12. At raw=6: linear progress=0.5, out(0.5)=0.875
- // backdropOpacity: tween(0, 1, 0.875) = 0.875 (not linear 0.5)
const steps: Step<CommandMenuState>[] = [{ at: 0, state: "opened" }];
it("backdropOpacity at raw=6 is out(0.5) ≈ 0.875 (not linear 0.5)", () => {
const r = resolveCommandMenuTransition(6, steps, 1, 12);
- const t = easings.out(0.5); // 0.875
+ const t = easings.out(0.5);
expect(r.backdropOpacity).toBeCloseTo(t, 8);
});
it("panelTranslateY at raw=6 is 8*(1-out(0.5)): 8*0.125=1", () => {
const r = resolveCommandMenuTransition(6, steps, 1, 12);
- const t = easings.out(0.5); // 0.875
- const expected = 8 * (1 - t); // lerp(8, 0, t)
+ const t = easings.out(0.5);
+ const expected = 8 * (1 - t);
expect(r.panelTranslateY).toBeCloseTo(expected, 8);
});
@@ -612,10 +500,6 @@ describe("resolveCommandMenuTransition: mid-window uses easings.out (not linear)
});
});
-// ---------------------------------------------------------------------------
-// Past the window: fully opened
-// ---------------------------------------------------------------------------
-
describe("resolveCommandMenuTransition: past the window → fully opened", () => {
const steps: Step<CommandMenuState>[] = [{ at: 0, state: "opened" }];
@@ -636,10 +520,6 @@ describe("resolveCommandMenuTransition: past the window → fully opened", () =>
});
});
-// ---------------------------------------------------------------------------
-// Speed contract
-// ---------------------------------------------------------------------------
-
describe("resolveCommandMenuTransition: speed contract", () => {
const steps: Step<CommandMenuState>[] = [{ at: 12, state: "opened" }];
@@ -652,10 +532,6 @@ describe("resolveCommandMenuTransition: speed contract", () => {
});
});
-// ===========================================================================
-// 7. commandMenuConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("commandMenuConfig.controls: state", () => {
it("state is a select control", () => {
expect(commandMenuConfig.controls.state.type).toBe("select");
@@ -728,10 +604,6 @@ describe("commandMenuConfig.controls: mode", () => {
});
});
-// ===========================================================================
-// 8. commandMenuConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("commandMenuConfig.snippet: import line", () => {
it("includes 'import { CommandMenu }' from the correct path", () => {
const out = snippet({ state: "opened" });
@@ -770,7 +642,6 @@ describe("commandMenuConfig.snippet: default props are omitted", () => {
});
it("omits highlightedIndex when it equals -1 (no highlight)", () => {
- // highlightedIndex default in snippet omission is -1 (not highlighted)
expect(snippet({ state: "opened", highlightedIndex: -1 })).not.toContain("highlightedIndex=");
});
diff --git a/registry/remocn-ui/command-menu/config.ts b/registry/remocn-ui/command-menu/config.ts
index 50b2501e..15f7dc89 100644
--- a/registry/remocn-ui/command-menu/config.ts
+++ b/registry/remocn-ui/command-menu/config.ts
@@ -9,7 +9,6 @@ export const commandMenuConfig: ComponentConfig = {
controls: {
state: {
type: "select",
- // Default to `opened` so the preview shows the revealed palette.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/command-menu/index.tsx b/registry/remocn-ui/command-menu/index.tsx
index 623b6695..f5b2031a 100644
--- a/registry/remocn-ui/command-menu/index.tsx
+++ b/registry/remocn-ui/command-menu/index.tsx
@@ -13,7 +13,6 @@ import {
export type CommandMenuState = "opened" | "closed";
-/** One command row's data. */
export interface CommandMenuEntry {
icon?: CommandMenuIcon;
label: string;
@@ -21,51 +20,24 @@ export interface CommandMenuEntry {
}
export interface CommandMenuProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: CommandMenuState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `CommandMenuStyle` from `useCommandMenuTransition`.
- */
style?: CommandMenuStyle;
- /** Full search query text (the visible prefix is `query.slice(0, revealCount)`). */
query?: string;
- /**
- * Number of query characters revealed so far (the caller computes this with
- * core `revealCount`). Omitted → the whole `query` is shown.
- */
revealCount?: number;
- /** The rows to show before filtering. */
items?: CommandMenuEntry[];
- /** Index (into the FILTERED list) of the persisted selection. `-1` for none. */
selectedIndex?: number;
- /** Index (into the FILTERED list) of the row under the pointer. `-1` for none. */
highlightedIndex?: number;
- /** Index (into the FILTERED list) of the row being pressed. `-1` for none. */
pressedIndex?: number;
- /**
- * Per-item resolved visual override (smooth path), indexed into the FILTERED
- * list. When an entry is present it wins over the index→state derivation.
- */
itemStyles?: (CommandMenuItemStyle | undefined)[];
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Panel width (px). */
const PANEL_WIDTH = 440;
-/** Inner content width (panel minus padding). */
const CONTENT_WIDTH = PANEL_WIDTH - 16;
-/** Backdrop dim at full reveal — the overlay opacity scales up to this alpha. */
const MAX_OVERLAY_ALPHA = 0.5;
-/**
- * Filter command entries by the visible query prefix. PURE — a case-insensitive
- * substring match on `query.slice(0, revealCount)`. An empty visible prefix
- * matches everything. Exported so tests can mirror it and the example can keep
- * its filtered indices in sync.
- */
export function filterCommandItems(
items: CommandMenuEntry[],
query: string,
@@ -80,26 +52,13 @@ export function filterCommandItems(
return items.filter((item) => item.label.toLowerCase().includes(visible));
}
-// ===========================================================================
-// Command-menu visual — the COMPLETE animated look for a moment in time. A
-// `state` is a named preset of this visual (`commandMenuStyle`); the smooth path
-// feeds an interpolated `CommandMenuStyle` straight through. The component is a
-// pure renderer of whichever style it receives. Per-row visuals are derived from
-// the index props (or `itemStyles`), independent of this container reveal.
-// ===========================================================================
-
export interface CommandMenuStyle {
- /** Backdrop dim reveal 0→1 (scales `MAX_OVERLAY_ALPHA`). */
backdropOpacity: number;
- /** Panel fade 0→1. */
panelOpacity: number;
- /** Panel zoom 0.96→1. */
panelScale: number;
- /** Panel lift 8→0 (px). */
panelTranslateY: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface CommandMenuStyleContext {
panelBg: string;
panelBorder: string;
@@ -112,10 +71,6 @@ export interface CommandMenuStyleContext {
itemCtx: CommandMenuItemStyleContext;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `commandMenuStyle(state, ctx)` preset.
- */
export function commandMenuStyleContext(
theme: RemocnTheme,
): CommandMenuStyleContext {
@@ -132,10 +87,6 @@ export function commandMenuStyleContext(
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) =>
- * CommandMenuStyle` map. To change how a state looks, edit one entry.
- */
export function commandMenuStyle(
state: CommandMenuState,
_ctx: CommandMenuStyleContext,
@@ -158,7 +109,6 @@ export function commandMenuStyle(
}
}
-/** Resolve one row's state from the index props (used when no itemStyle override). */
function rowState(
i: number,
selectedIndex: number,
@@ -199,15 +149,11 @@ export function CommandMenu({
const filtered = filterCommandItems(items, query, revealCount);
return (
- // TRANSPARENT modal wrapper — like dialog, this composes OVER another scene,
- // so it paints no opaque background. Its intrinsic inset:0 backdrop is why no
- // preview wrapper is needed (the customizer mounts this directly).
<div
style={{
position: "absolute",
inset: 0,
display: "flex",
- // Command palettes sit in the upper third, not dead-center.
alignItems: "flex-start",
justifyContent: "center",
paddingTop: "18%",
@@ -215,7 +161,7 @@ export function CommandMenu({
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
- {/* Backdrop dim — fades in as the palette opens. */}
+ {}
<div
style={{
position: "absolute",
@@ -241,7 +187,7 @@ export function CommandMenu({
boxShadow: "0 24px 48px -12px rgba(0,0,0,0.25)",
}}
>
- {/* Search row — magnifier + typed query + caret. */}
+ {}
<div
style={{
display: "flex",
@@ -269,7 +215,7 @@ export function CommandMenu({
}}
>
{visibleQuery || "Type a command or search…"}
- {/* Caret sits after the revealed text. */}
+ {}
<span
style={{
display: "inline-block",
@@ -281,7 +227,7 @@ export function CommandMenu({
/>
</span>
</div>
- {/* Divider. */}
+ {}
<div
style={{
height: 1,
@@ -289,7 +235,7 @@ export function CommandMenu({
margin: "4px 0",
}}
/>
- {/* List of rows, or the empty state. */}
+ {}
<div
style={{
display: "flex",
diff --git a/registry/remocn-ui/command-menu/use-command-menu-transition.ts b/registry/remocn-ui/command-menu/use-command-menu-transition.ts
index c5008410..fd4c331c 100644
--- a/registry/remocn-ui/command-menu/use-command-menu-transition.ts
+++ b/registry/remocn-ui/command-menu/use-command-menu-transition.ts
@@ -13,12 +13,9 @@ import {
type CommandMenuState,
type CommandMenuStyle,
} from "@/components/remocn/command-menu";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 12;
-/** Blend two command-menu visuals: all fields are numbers, so a straight lerp. */
export function tweenCommandMenuStyle(
a: CommandMenuStyle,
b: CommandMenuStyle,
@@ -41,11 +38,6 @@ export interface CommandMenuTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) CommandMenuStyle. The CALLER invokes
- * this; it reads the frame, the `<CommandMenu>` component does not. Feed the
- * result to `<CommandMenu style={...} />` for a smooth open/close.
- */
export function useCommandMenuTransition(
steps: Step<CommandMenuState>[],
opts: CommandMenuTransitionOptions = {},
diff --git a/registry/remocn-ui/context-menu/__tests__/context-menu.test.ts b/registry/remocn-ui/context-menu/__tests__/context-menu.test.ts
index 83bc1ee9..e7fa9064 100644
--- a/registry/remocn-ui/context-menu/__tests__/context-menu.test.ts
+++ b/registry/remocn-ui/context-menu/__tests__/context-menu.test.ts
@@ -1,37 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `context-menu`.
- *
- * Scope:
- * - registry/remocn-ui/context-menu/index.tsx
- * contextMenuStyleContext(theme) — pure theme → context derivation
- * contextMenuStyle(state, ctx) — complete state→visual map
- * (rowState is module-private — not exported; documented in README)
- * - registry/remocn-ui/context-menu/use-context-menu-transition.ts
- * tweenContextMenuStyle(a, b, t) — pure lerp across all three fields
- * DEFAULT_DURATION constant
- * useContextMenuTransition resolver — mirrored as resolveContextMenuTransition
- * with frame injected as `raw` (annotated source lines)
- * - registry/remocn-ui/context-menu/config.ts
- * contextMenuConfig.controls wiring + contextMenuConfig.snippet codegen
- *
- * The render path (index.tsx) imports `useRemocnTheme` which requires React
- * context and cannot run headlessly — it is NOT exercised here.
- * `contextMenuStyleContext` delegates to `dropdownMenuItemStyleContext` for
- * the item context; that sub-function's correctness is covered by
- * dropdown-menu/__tests__. Here it is called only to build the shared `ctx`
- * fixture for `contextMenuStyle`.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/context-menu/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports for component source; `@/lib/remocn-ui` alias for core.
- * `useContextMenuTransition` is NOT imported — it reads `useCurrentFrame()`.
- * Its pure body is mirrored as `resolveContextMenuTransition` with frame injected.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -48,16 +14,10 @@ import { contextMenuConfig } from "../config";
import { defaultLightTheme, defaultDarkTheme, easings } from "@/lib/remocn-ui";
import type { Step } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
const VALID_STATES: readonly ContextMenuState[] = ["opened", "closed"];
-/** Build a shared ctx for style assertions (no React needed — pure function). */
const ctx = contextMenuStyleContext(defaultLightTheme);
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
state?: string;
highlightedIndex?: number;
@@ -66,21 +26,12 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
contextMenuConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is 10 frames", () => {
expect(DEFAULT_DURATION).toBe(10);
});
});
-// ===========================================================================
-// 2. contextMenuStyleContext — pure theme → context derivation
-// MIRROR of index.tsx lines 73-82
-// ===========================================================================
-
describe("contextMenuStyleContext: maps theme tokens correctly", () => {
it("panelBg equals theme.popover", () => {
expect(ctx.panelBg).toBe(defaultLightTheme.popover);
@@ -112,12 +63,6 @@ describe("contextMenuStyleContext: theme independence", () => {
});
});
-// ===========================================================================
-// 3. contextMenuStyle — pure (state, ctx) => ContextMenuStyle map
-// MIRROR of index.tsx lines 89-99
-// Every field asserted for both states.
-// ===========================================================================
-
describe("contextMenuStyle: closed state — off-screen keyframe", () => {
const s = contextMenuStyle("closed", ctx);
@@ -179,18 +124,11 @@ describe("contextMenuStyle: every state produces a complete ContextMenuStyle", (
});
describe("contextMenuStyle: 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(contextMenuStyle("closed", ctx).opacity).toBe(0);
});
});
-// ===========================================================================
-// 4. tweenContextMenuStyle — pure lerp across all three numeric fields
-// MIRROR of use-context-menu-transition.ts lines 22-32
-// All fields are numbers — straight lerp on everything.
-// ===========================================================================
-
describe("tweenContextMenuStyle: t=0 returns values equal to `a`", () => {
const a = contextMenuStyle("closed", ctx);
const b = contextMenuStyle("opened", ctx);
@@ -228,9 +166,6 @@ describe("tweenContextMenuStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenContextMenuStyle: t=0.5 midpoint (closed → opened)", () => {
- // closed: opacity=0, scale=0.95, translateY=-4
- // opened: opacity=1, scale=1, translateY=0
- // midpoint: opacity=0.5, scale=0.975, translateY=-2
const a = contextMenuStyle("closed", ctx);
const b = contextMenuStyle("opened", ctx);
const r = tweenContextMenuStyle(a, b, 0.5);
@@ -249,7 +184,6 @@ describe("tweenContextMenuStyle: t=0.5 midpoint (closed → opened)", () => {
});
describe("tweenContextMenuStyle: t=0.25 quarter-point (closed → opened)", () => {
- // opacity: 0.25, scale: 0.95+0.05*0.25=0.9625, translateY: -4+4*0.25=-3
const a = contextMenuStyle("closed", ctx);
const b = contextMenuStyle("opened", ctx);
const r = tweenContextMenuStyle(a, b, 0.25);
@@ -292,29 +226,10 @@ describe("tweenContextMenuStyle: reverse direction (opened → closed)", () => {
});
});
-// ===========================================================================
-// 5. useContextMenuTransition resolver replica
-// MIRRORS use-context-menu-transition.ts lines 46-70.
-// `useContextMenuTransition` calls `useStateTransition` (reads useCurrentFrame())
-// then applies `easings.out(progress)` and `tweenContextMenuStyle`.
-// 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-context-menu-transition.ts lines 46-70 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>[],
@@ -336,30 +251,21 @@ function resolveStateTransition<S extends string>(
return { from: from ? from.state : defaultState, to: to.state, progress };
}
-/**
- * MIRROR of use-context-menu-transition.ts:useContextMenuTransition (lines 46-70).
- * `raw` is injected in place of useCurrentFrame().
- * Annotated source lines:
- * lines 51-55: destructure opts (speed, defaultDuration)
- * lines 58-63: useStateTransition (mirrored as resolveStateTransition)
- * line 64: t = easings.out(progress) ← MIRROR line 64
- * lines 65-69: tweenContextMenuStyle(from, to, t) ← MIRROR lines 65-69
- */
function resolveContextMenuTransition(
raw: number, // injected useCurrentFrame() — MIRROR line 58
steps: Step<ContextMenuState>[],
speed = 1,
defaultDuration = DEFAULT_DURATION,
): ContextMenuStyle & { from: ContextMenuState; to: ContextMenuState; progress: number } {
- const { from, to, progress } = resolveStateTransition( // MIRROR lines 58-63
+ const { from, to, progress } = resolveStateTransition(
raw,
steps,
"closed",
speed,
defaultDuration,
);
- const t = easings.out(progress); // MIRROR line 64
- const style = tweenContextMenuStyle( // MIRROR lines 65-69
+ const t = easings.out(progress);
+ const style = tweenContextMenuStyle(
contextMenuStyle(from as ContextMenuState, ctx),
contextMenuStyle(to as ContextMenuState, ctx),
t,
@@ -367,10 +273,6 @@ function resolveContextMenuTransition(
return { ...style, from: from as ContextMenuState, to: to as ContextMenuState, progress };
}
-// ---------------------------------------------------------------------------
-// Before any step: holds at closed (progress=1, tween(closed,closed,out(1)))
-// ---------------------------------------------------------------------------
-
describe("resolveContextMenuTransition: before any step — holds at closed", () => {
it("returns the closed style when no steps have started", () => {
const r = resolveContextMenuTransition(0, []);
@@ -387,10 +289,6 @@ describe("resolveContextMenuTransition: before any step — holds at closed", ()
});
});
-// ---------------------------------------------------------------------------
-// Exactly at a step boundary: progress=0, t=out(0)=0 → closed style
-// ---------------------------------------------------------------------------
-
describe("resolveContextMenuTransition: exactly at closed→opened step boundary", () => {
const steps: Step<ContextMenuState>[] = [{ at: 10, state: "opened" }];
@@ -410,32 +308,26 @@ describe("resolveContextMenuTransition: exactly at closed→opened step boundary
});
});
-// ---------------------------------------------------------------------------
-// Mid-window: easings.out applied — non-linear (not raw 0.5)
-// step at=0, duration=10, raw=5: progress=0.5, out(0.5)=0.875
-// opacity: 0.875, scale: 0.95+0.05*0.875=0.99375, translateY: -4+4*0.875=-0.5
-// ---------------------------------------------------------------------------
-
describe("resolveContextMenuTransition: mid-window uses easings.out (not linear)", () => {
const steps: Step<ContextMenuState>[] = [{ at: 0, state: "opened" }];
it("opacity at raw=5 is out(0.5)=0.875 (not linear 0.5)", () => {
const r = resolveContextMenuTransition(5, steps, 1, 10);
- const t = easings.out(0.5); // 0.875
+ const t = easings.out(0.5);
expect(r.opacity).toBeCloseTo(t, 8);
});
it("scale at raw=5 is 0.95 + 0.05*out(0.5) = 0.99375", () => {
const r = resolveContextMenuTransition(5, steps, 1, 10);
const t = easings.out(0.5);
- const expected = 0.95 + (1 - 0.95) * t; // 0.99375
+ const expected = 0.95 + (1 - 0.95) * t;
expect(r.scale).toBeCloseTo(expected, 8);
});
it("translateY at raw=5 is -4*(1-out(0.5)) = -0.5", () => {
const r = resolveContextMenuTransition(5, steps, 1, 10);
const t = easings.out(0.5);
- const expected = -4 + (0 - (-4)) * t; // -4 + 3.5 = -0.5
+ const expected = -4 + (0 - (-4)) * t;
expect(r.translateY).toBeCloseTo(expected, 8);
});
@@ -445,10 +337,6 @@ describe("resolveContextMenuTransition: mid-window uses easings.out (not linear)
});
});
-// ---------------------------------------------------------------------------
-// Past the window: fully opened
-// ---------------------------------------------------------------------------
-
describe("resolveContextMenuTransition: past the window → fully opened", () => {
const steps: Step<ContextMenuState>[] = [{ at: 0, state: "opened" }];
@@ -465,10 +353,6 @@ describe("resolveContextMenuTransition: past the window → fully opened", () =>
});
});
-// ---------------------------------------------------------------------------
-// Speed contract
-// ---------------------------------------------------------------------------
-
describe("resolveContextMenuTransition: speed contract", () => {
const steps: Step<ContextMenuState>[] = [{ at: 10, state: "opened" }];
@@ -481,10 +365,6 @@ describe("resolveContextMenuTransition: speed contract", () => {
});
});
-// ===========================================================================
-// 6. contextMenuConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("contextMenuConfig.controls: state", () => {
it("state is a select control", () => {
expect(contextMenuConfig.controls.state.type).toBe("select");
@@ -535,10 +415,6 @@ describe("contextMenuConfig.controls: mode", () => {
});
});
-// ===========================================================================
-// 7. contextMenuConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("contextMenuConfig.snippet: import line", () => {
it("includes 'import { ContextMenu }' from the correct path", () => {
const out = snippet({ state: "opened" });
diff --git a/registry/remocn-ui/context-menu/config.ts b/registry/remocn-ui/context-menu/config.ts
index 2730234d..29d09141 100644
--- a/registry/remocn-ui/context-menu/config.ts
+++ b/registry/remocn-ui/context-menu/config.ts
@@ -9,7 +9,6 @@ export const contextMenuConfig: ComponentConfig = {
controls: {
state: {
type: "select",
- // Default to `opened` so the preview shows the revealed menu.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/context-menu/index.tsx b/registry/remocn-ui/context-menu/index.tsx
index d53b88f0..991252d4 100644
--- a/registry/remocn-ui/context-menu/index.tsx
+++ b/registry/remocn-ui/context-menu/index.tsx
@@ -13,63 +13,32 @@ import {
export type ContextMenuState = "opened" | "closed";
export interface ContextMenuProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: ContextMenuState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `ContextMenuStyle` from `useContextMenuTransition`.
- */
style?: ContextMenuStyle;
- /** Menu rows — plain string labels (same format as DropdownMenu). */
items?: string[];
- /** Row currently highlighted (hover); `-1` for none. */
highlightedIndex?: number;
- /** Row currently pressed; `-1` for none. */
pressedIndex?: number;
- /**
- * Smooth per-row override. When an entry is present it wins over the
- * index→state derivation, letting the example tween a single row.
- */
itemStyles?: (DropdownMenuItemStyle | undefined)[];
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Panel width (px). */
const WIDTH = 200;
-// ===========================================================================
-// Context-menu visual — the COMPLETE animated look for a moment in time. A
-// `state` is a named preset of this visual (`contextMenuStyle`); the smooth path
-// feeds an interpolated `ContextMenuStyle` straight through. The component is a
-// pure renderer of whichever style it receives. Unlike DropdownMenu there is NO
-// trigger — a context menu opens AT the click point, so it scales from its
-// top-left corner and the CALLER positions it (transparent placement).
-// ===========================================================================
-
export interface ContextMenuStyle {
- /** Panel fade 0 (closed) → 1 (opened). */
opacity: number;
- /** Panel zoom 0.95 (closed) → 1 (opened), growing from the top-left corner. */
scale: number;
- /** Panel lift -4 (closed) → 0 (opened) px. */
translateY: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface ContextMenuStyleContext {
panelBg: string;
panelBorder: string;
radius: number;
- /** Row presets for the panel items. */
itemCtx: DropdownMenuItemStyleContext;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `contextMenuStyle(state, ctx)` preset.
- */
export function contextMenuStyleContext(
theme: RemocnTheme,
): ContextMenuStyleContext {
@@ -81,11 +50,6 @@ export function contextMenuStyleContext(
};
}
-/**
- * The COMPLETE resting visual for a state — a pure
- * `(state, ctx) => ContextMenuStyle` map. To change how a state looks, edit one
- * entry.
- */
export function contextMenuStyle(
state: ContextMenuState,
_ctx: ContextMenuStyleContext,
@@ -98,7 +62,6 @@ export function contextMenuStyle(
}
}
-/** Resolve one row's state from the index props. */
function rowState(
i: number,
highlightedIndex: number,
@@ -125,15 +88,11 @@ export function ContextMenu({
const v = style ?? contextMenuStyle(state, ctx);
return (
- // TRANSPARENT wrapper — a context menu opens AT the click point; the caller
- // positions this with an absolute wrapper (no x/y props here). It paints no
- // opaque background and does not center the panel itself.
<div
className={className}
style={{
width: WIDTH,
opacity: v.opacity,
- // Grows from the top-left corner — where the cursor "clicked".
transformOrigin: "top left",
transform: `translateY(${v.translateY}px) scale(${v.scale})`,
background: ctx.panelBg,
diff --git a/registry/remocn-ui/context-menu/preview.tsx b/registry/remocn-ui/context-menu/preview.tsx
index 2f52dadf..3ac2c120 100644
--- a/registry/remocn-ui/context-menu/preview.tsx
+++ b/registry/remocn-ui/context-menu/preview.tsx
@@ -9,14 +9,6 @@ export interface ContextMenuPreviewProps {
mode?: "light" | "dark";
}
-/**
- * Preview-only wrapper for the customizer. The shipped `ContextMenu` is a
- * placement-agnostic panel that opens at the click point — the caller positions
- * it with an absolute wrapper. The customizer Player renders its `component` as
- * the composition root, so a bare panel would sit top-left; this thin wrapper
- * centers it on a theme-background stage just for the preview. NOT shipped: not
- * listed in registry.json files.
- */
export function ContextMenuPreview({
state = "opened",
highlightedIndex = 1,
diff --git a/registry/remocn-ui/context-menu/use-context-menu-transition.ts b/registry/remocn-ui/context-menu/use-context-menu-transition.ts
index fc141d33..2bd40e28 100644
--- a/registry/remocn-ui/context-menu/use-context-menu-transition.ts
+++ b/registry/remocn-ui/context-menu/use-context-menu-transition.ts
@@ -13,12 +13,9 @@ import {
type ContextMenuState,
type ContextMenuStyle,
} from "@/components/remocn/context-menu";
-// ^ 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 context-menu visuals: all fields are numbers, so a straight lerp. */
export function tweenContextMenuStyle(
a: ContextMenuStyle,
b: ContextMenuStyle,
@@ -38,11 +35,6 @@ export interface ContextMenuTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) ContextMenuStyle. The CALLER invokes
- * this; it reads the frame, the `<ContextMenu>` component does not. Feed the
- * result to `<ContextMenu style={...} />` for a smooth open/close.
- */
export function useContextMenuTransition(
steps: Step<ContextMenuState>[],
opts: ContextMenuTransitionOptions = {},
diff --git a/registry/remocn-ui/core/__tests__/color.test.ts b/registry/remocn-ui/core/__tests__/color.test.ts
index 0134fdea..5d0a054f 100644
--- a/registry/remocn-ui/core/__tests__/color.test.ts
+++ b/registry/remocn-ui/core/__tests__/color.test.ts
@@ -1,36 +1,3 @@
-/**
- * Verification tests for the OKLCH <-> sRGB color helpers in
- * registry/remocn-ui/core/color.ts.
- *
- * color.ts is now a thin wrapper over the `culori` package, and it exposes
- * culori's NATIVE shapes and scales:
- * - `Rgb` objects are mode-tagged `{ mode: "rgb", r, g, b, alpha }` with
- * channels in 0..1 (NOT 0..255).
- * - `Oklch` objects are `{ mode: "oklch", l, c, h, alpha? }` with lowercase
- * l/c/h; achromatic hue is normalized to 0.
- * - `rgbToOklch` takes a culori `Rgb` OBJECT (not 3 scalars).
- * - `toCss` uses culori's `formatRgb`, which emits LEGACY comma syntax with
- * 0..255 integer channels: `"rgb(255, 128, 0)"` / `"rgba(255, 128, 0, 0.5)"`.
- *
- * culori must be installed before these run:
- *
- * bun install # pulls culori + @types/culori
- * bun test registry/remocn-ui/core/__tests__
- *
- * These tests are deliberately PROPERTY-BASED, not pinned to magic RGB numbers.
- * culori uses its own matrices and gamut-mapping (clampChroma), so exact
- * channels can shift by a hair between culori versions. Instead we assert the
- * INVARIANTS that must hold regardless of culori's rounding: endpoint identity,
- * perceptual (non-sRGB) midpoint, shortest-arc hue, neutral-hold, round-trip,
- * and alpha handling. All channel tolerances are expressed in the 0..1 scale
- * (~0.01 ~= 2/255), immune to culori's 8-bit quantization.
- *
- * Where an exact value is genuinely useful (theme-override AC), we compute the
- * expected from the module's OWN oklchToRgb/parseColor so the test is
- * self-consistent and immune to culori version drift.
- *
- * These are PURE (no React / no Remotion), so they import the real module.
- */
import { describe, expect, it } from "bun:test";
import {
@@ -41,16 +8,6 @@ import {
toCss,
} from "../color";
-// --- helpers ---------------------------------------------------------------
-
-/**
- * Parse culori `formatRgb` output -- legacy comma syntax with 0..255 integer
- * channels -- back into a 0..1 culori-shaped Rgb so it compares directly
- * against parseColor/oklchToRgb output (which are also 0..1).
- * "rgb(255, 128, 0)" -> { r: 1, g: 0.502, b: 0, alpha: 1 }
- * "rgba(10, 20, 30, 0.5)" -> { r: 0.039, g: 0.078, b: 0.118, alpha: 0.5 }
- * Robust to either comma- or space-separated forms just in case.
- */
function rgbOf(css: string): { r: number; g: number; b: number; alpha: number } {
const inner = css.slice(css.indexOf("(") + 1, css.lastIndexOf(")"));
const parts = inner
@@ -69,7 +26,6 @@ function rgbOf(css: string): { r: number; g: number; b: number; alpha: number }
};
}
-/** Assert each RGB channel (0..1) of two colors is within `tol`. */
function expectRgbClose(
got: { r: number; g: number; b: number },
want: { r: number; g: number; b: number },
@@ -80,16 +36,11 @@ function expectRgbClose(
expect(Math.abs(got.b - want.b)).toBeLessThanOrEqual(tol);
}
-// Channel tolerance in the 0..1 scale: ~2/255, covers clampChroma + 8-bit
-// rounding on both the interpolate and the direct-convert paths.
const TOL = 0.01;
const BLACK = "oklch(0 0 0)";
const WHITE = "oklch(1 0 0)";
-// --- mixOklch endpoints ----------------------------------------------------
-// Property: a mix at t=0 IS the first color, at t=1 IS the second color.
-
describe("mixOklch endpoints", () => {
const a = "oklch(0.5 0.12 250)";
const b = "oklch(0.7 0.15 140)";
@@ -110,55 +61,31 @@ describe("mixOklch endpoints", () => {
});
});
-// --- midpoint is the OKLCH midpoint, NOT the naive sRGB midpoint -----------
-// Property (not a pinned value): mixing black<->white in OKLCH at t=0.5 lands
-// on the PERCEPTUAL midpoint, which is meaningfully different from the naive
-// sRGB lerp (0.5 in the 0..1 scale). It must also stay neutral (r==g==b).
-
describe("mixOklch midpoint (perceptual, not naive sRGB lerp)", () => {
it("black<->white at t=0.5 is neutral and clearly off the sRGB midpoint 0.5", () => {
const mid = rgbOf(mixOklch(BLACK, WHITE, 0.5));
- // Neutral: no phantom hue swept through the achromatic axis. Compared in
- // 0..1 with TOL (formatRgb rounds to ints, so equal channels stay equal).
expect(Math.abs(mid.r - mid.g)).toBeLessThanOrEqual(TOL);
expect(Math.abs(mid.g - mid.b)).toBeLessThanOrEqual(TOL);
- // A naive sRGB lerp at t=0.5 would land at ~0.5 (0..1). The OKLCH
- // (perceptual) midpoint is well clear of that by a real margin -> proves we
- // are NOT lerping in sRGB. Assert the GAP magnitude, never the exact value.
- // 10/255 ~= 0.039 in the 0..1 scale.
expect(Math.abs(mid.g - 0.5)).toBeGreaterThan(0.039);
});
it("matches the module's own oklchToRgb(0.5,0,0) (self-consistent, no magic number)", () => {
- // Both routes (interpolate->clampChroma->rgb vs oklchToRgb) must agree on
- // the neutral L=0.5 point. Computed from the module, so it tracks culori.
expectRgbClose(rgbOf(mixOklch(BLACK, WHITE, 0.5)), oklchToRgb(0.5, 0, 0), TOL);
});
});
-// --- shortest-arc hue ------------------------------------------------------
-// Property: culori's fixupHueShorter takes the SHORT way around the hue circle.
-// Hues straddling the 0/360 seam (350 <-> 10) mix to ~0/360, never ~180.
-
describe("mixOklch shortest-arc hue", () => {
it("h=350 <-> h=10 midpoint lands near 0/360, not ~180 (short way)", () => {
const a = "oklch(0.6 0.12 350)";
const b = "oklch(0.6 0.12 10)";
const mid = rgbOf(mixOklch(a, b, 0.5));
const hue = rgbToOklch({ mode: "rgb", r: mid.r, g: mid.g, b: mid.b }).h;
- // Short arc -> ~0deg. Accept the wraparound band [345,360] U [0,15];
- // reject the long-way ~180.
const nearZero = hue <= 15 || hue >= 345;
expect(nearZero).toBe(true);
expect(Math.abs(hue - 180)).toBeGreaterThan(120);
});
});
-// --- neutral-hold ----------------------------------------------------------
-// Property: mixing two grays yields a gray (no phantom hue), and mixing a gray
-// with a chromatic color carries the chromatic hue rather than the gray's
-// meaningless hue.
-
describe("mixOklch holds hue for neutrals (no phantom hue)", () => {
it("midpoint of two grays stays neutral (r==g==b within tol)", () => {
const a = "oklch(0.3 0 0)";
@@ -173,18 +100,11 @@ describe("mixOklch holds hue for neutrals (no phantom hue)", () => {
const blue = "oklch(0.6 0.12 250)";
const near = rgbOf(mixOklch(gray, blue, 0.9));
const hue = rgbToOklch({ mode: "rgb", r: near.r, g: near.g, b: near.b }).h;
- // Hue distance on the circle.
const dh = Math.abs(((hue - 250 + 540) % 360) - 180);
expect(dh).toBeLessThan(20);
});
});
-// --- oklchToRgb anchors ----------------------------------------------------
-// Only the TRUE endpoints (pure black / pure white) are pinned, since those are
-// gamut corners every correct implementation must hit exactly. In the 0..1
-// scale white is r==g==b==1 and black is r==g==b==0. Mid-lightness neutrals are
-// asserted as PROPERTIES (neutral + ordered), not pinned values.
-
describe("oklchToRgb anchors and neutral properties", () => {
it("oklch(1 0 0) -> pure white (r==g==b==1)", () => {
const w = oklchToRgb(1, 0, 0);
@@ -212,21 +132,11 @@ describe("oklchToRgb anchors and neutral properties", () => {
const light = oklchToRgb(0.985, 0, 0).r;
expect(dark).toBeLessThan(mid);
expect(mid).toBeLessThan(light);
- // Near-corner sanity without pinning: dark neutral is genuinely dark,
- // light neutral is genuinely light (0..1 scale; 80/255 ~= 0.314,
- // 230/255 ~= 0.902).
expect(dark).toBeLessThan(0.314);
expect(light).toBeGreaterThan(0.902);
});
});
-// --- theme-override AC (plan §6) -------------------------------------------
-// AC: a theme override "primary" oklch value resolves to a concrete RGB used in
-// the inline style. We assert SELF-CONSISTENCY between the two ways the module
-// can produce that RGB (oklchToRgb vs parseColor of the oklch string) rather
-// than hard-coding a culori-version-specific value. This is the (a) path from
-// the brief; no TODO/magic number needed.
-
describe("theme-override primary resolves consistently", () => {
it("oklchToRgb(0.205,0,0) ~= parseColor('oklch(0.205 0 0)')", () => {
const viaArgs = oklchToRgb(0.205, 0, 0);
@@ -235,11 +145,6 @@ describe("theme-override primary resolves consistently", () => {
});
});
-// --- round trip rgbToOklch(oklchToRgb(...)) --------------------------------
-// Property: converting OKLCH -> sRGB -> OKLCH recovers the original within
-// 8-bit quantization. Catches a transposed matrix / atan2 sign error.
-// rgbToOklch now takes the Rgb OBJECT directly, and returns lowercase l/c/h.
-
describe("oklch <-> rgb round-trip (in-gamut values)", () => {
const cases: Array<[number, number, number]> = [
[0.6, 0.1, 30],
@@ -252,14 +157,12 @@ describe("oklch <-> rgb round-trip (in-gamut values)", () => {
const back = rgbToOklch(rgb);
expect(Math.abs(back.l - L)).toBeLessThan(0.02);
expect(Math.abs((back.c ?? 0) - C)).toBeLessThan(0.02);
- // Hue compared on the circle.
const dh = Math.abs((((back.h ?? 0) - h + 540) % 360) - 180);
expect(dh).toBeLessThan(2);
});
}
it("achromatic round-trip normalizes hue to 0 (not NaN/undefined)", () => {
- // culori leaves hue undefined for achromatic; the module normalizes to 0.
const back = rgbToOklch({ mode: "rgb", r: 0.5, g: 0.5, b: 0.5 });
expect(back.h).toBe(0);
expect(Number.isNaN(back.h)).toBe(false);
@@ -267,13 +170,9 @@ describe("oklch <-> rgb round-trip (in-gamut values)", () => {
});
});
-// --- parseColor format coverage --------------------------------------------
-// parseColor returns { mode: "rgb", r, g, b, alpha } with channels in 0..1.
-
describe("parseColor formats", () => {
it("parses #rrggbb hex", () => {
const c = parseColor("#ff8000");
- // 0xff/255=1, 0x80/255~=0.502, 0x00/255=0
expectRgbClose(c, { r: 1, g: 0x80 / 255, b: 0 }, TOL);
expect(c.mode).toBe("rgb");
expect(c.alpha).toBe(1);
@@ -281,7 +180,6 @@ describe("parseColor formats", () => {
it("parses #rgb shorthand hex", () => {
const c = parseColor("#f80");
- // #f80 -> #ff8800: 1, 0x88/255~=0.533, 0
expectRgbClose(c, { r: 1, g: 0x88 / 255, b: 0 }, TOL);
});
@@ -311,8 +209,6 @@ describe("parseColor formats", () => {
});
it("var(...) does not throw and returns the black sentinel", () => {
- // Documented contract: the animated path cannot resolve var() under
- // Remotion's per-frame render; falls back to black rather than throwing.
expect(() => parseColor("var(--primary)")).not.toThrow();
expect(parseColor("var(--primary)")).toEqual({
mode: "rgb",
@@ -334,20 +230,14 @@ describe("parseColor formats", () => {
});
});
-// --- toCss -----------------------------------------------------------------
-// toCss uses culori's formatRgb: LEGACY comma syntax, 0..255 integer channels,
-// alpha emitted as rgba(...) only when alpha < 1.
-
describe("toCss (culori formatRgb output)", () => {
it('emits legacy "rgb(r, g, b)" with 0..255 ints when opaque', () => {
- // 1 -> 255, 0.5 -> round(127.5)=128, 0 -> 0
expect(toCss({ mode: "rgb", r: 1, g: 0.5, b: 0, alpha: 1 })).toBe(
"rgb(255, 128, 0)",
);
});
it("emits opaque rgb(...) when alpha is omitted", () => {
- // formatRgb treats undefined alpha as opaque.
expect(toCss({ mode: "rgb", r: 0, g: 0, b: 0 } as never)).toBe("rgb(0, 0, 0)");
});
@@ -358,8 +248,6 @@ describe("toCss (culori formatRgb output)", () => {
});
it("round-trips through culori: toCss output re-parses to the same channels", () => {
- // Structural guard independent of the exact format string: whatever
- // formatRgb emits must parse back to the same 0..1 channels (within 8-bit).
const want = { r: 1, g: 0.5, b: 0 };
const reparsed = parseColor(toCss({ mode: "rgb", ...want, alpha: 1 }));
expectRgbClose(reparsed, want, TOL);
@@ -374,14 +262,11 @@ describe("toCss (culori formatRgb output)", () => {
});
});
-// --- alpha interpolation through mixOklch ----------------------------------
-
describe("mixOklch interpolates alpha", () => {
it("midpoint of two alpha-bearing colors averages their alpha", () => {
const a = "oklch(0.5 0.12 250 / 20%)";
const b = "oklch(0.5 0.12 250 / 80%)";
const mid = rgbOf(mixOklch(a, b, 0.5));
- // Equal L/C/h so only alpha moves; midpoint alpha ~= 0.5.
expect(Math.abs(mid.alpha - 0.5)).toBeLessThanOrEqual(0.02);
});
});
diff --git a/registry/remocn-ui/core/__tests__/timeline.test.ts b/registry/remocn-ui/core/__tests__/timeline.test.ts
index 593d4699..98480551 100644
--- a/registry/remocn-ui/core/__tests__/timeline.test.ts
+++ b/registry/remocn-ui/core/__tests__/timeline.test.ts
@@ -1,49 +1,10 @@
-/**
- * Verification tests for the timeline semantics.
- *
- * Scope: registry/remocn-ui/core/timeline.ts — framesFor, revealCount, and
- * the pure resolver logic inside useCurrentState (speed contract, state
- * resolution, ties).
- *
- * Runner: Bun's built-in test runner.
- * bun test registry/remocn-ui/core/__tests__
- *
- * --------------------------------------------------------------------------
- * WHY THE RESOLVER IS REPLICATED HERE INSTEAD OF IMPORTED
- * --------------------------------------------------------------------------
- * `useCurrentState` is a React hook whose FIRST line is `useCurrentFrame()`
- * from "remotion" — it cannot run outside a Remotion render tree, and even
- * importing the module pulls the remotion runtime. `framesFor` and
- * `revealCount` are pure but share that module.
- *
- * So we do BOTH:
- * 1. Re-derive framesFor / revealCount as exact spec mirrors and assert
- * their numeric contract (these formulas are trivially copyable and
- * stable).
- * 2. Replicate the documented pure resolver ("resolveCurrentState" below)
- * byte-for-byte from timeline.ts's algorithm, factoring out the single
- * impure line (useCurrentFrame) into an injected `raw` frame. This lets
- * us assert the speed contract and state-resolution rules headlessly.
- *
- * MAINTENANCE CONTRACT: if timeline.ts's resolver body changes, this replica
- * MUST be updated in lockstep. The replica is annotated with the source line
- * ranges it mirrors. The numeric expectations are the real verification value;
- * the replica is the harness that lets us reach them without a Remotion render.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
-// ===========================================================================
-// 1. framesFor / revealCount — exact spec mirrors of timeline.ts lines 5-19
-// ===========================================================================
-
-/** MIRROR of timeline.ts:framesFor (lines 5-7). */
function framesFor(d: number | { seconds: number }, fps: number): number {
return typeof d === "number" ? d : Math.round(d.seconds * fps);
}
-/** MIRROR of timeline.ts:revealCount (lines 10-19). */
function revealCount(
localFrame: number,
fps: number,
@@ -66,24 +27,18 @@ describe("framesFor", () => {
});
it("rounds fractional second->frame conversions", () => {
- // 0.11s * 30 = 3.3 -> 3
expect(framesFor({ seconds: 0.11 }, 30)).toBe(3);
- // 0.117 * 30 = 3.51 -> 4
expect(framesFor({ seconds: 0.117 }, 30)).toBe(4);
});
});
describe("revealCount (typewriter math)", () => {
- // over = (len/cps)*fps. For len=5, cps=10, fps=30 => over = 0.5*30 = 15 frames
- // to fully reveal 5 chars. count = floor((frame/15)*5).
it("reveals nothing at frame 0", () => {
expect(revealCount(0, 30, 5, 10)).toBe(0);
});
it("reveals proportionally mid-flight", () => {
- // frame 6 of 15 => floor((6/15)*5) = floor(2) = 2
expect(revealCount(6, 30, 5, 10)).toBe(2);
- // frame 9 => floor((9/15)*5)=floor(3)=3
expect(revealCount(9, 30, 5, 10)).toBe(3);
});
@@ -97,41 +52,26 @@ describe("revealCount (typewriter math)", () => {
});
it("returns full length immediately when the window is non-positive", () => {
- // len=0 => over=0 => guarded early-return of len (0).
expect(revealCount(0, 30, 0, 10)).toBe(0);
});
});
-// ===========================================================================
-// 2. useCurrentState resolver replica — MIRROR of timeline.ts useCurrentState
-// body (lines 31-46), with the one impure line (useCurrentFrame) injected
-// as `raw`. Keep in lockstep with source.
-//
-// The resolver contract: returns the `state` of the latest step with
-// `at <= effectiveFrame` (effectiveFrame = raw * speed), else `defaultState`.
-// Ties on `at` resolve by array order — later entry wins.
-// ===========================================================================
-
interface Step<S extends string = string> {
at: number;
state: S;
duration?: number;
}
-/**
- * MIRROR of timeline.ts:useCurrentState (lines 31-46).
- * `raw` is the injected useCurrentFrame() value — annotates mirror source.
- */
function resolveCurrentState<S extends string>(
raw: number, // injected useCurrentFrame() — MIRROR of timeline.ts line 36
steps: Step<S>[],
defaultState: S,
speed = 1,
): S {
- const effectiveFrame = raw * speed; // MIRROR of timeline.ts line 36
- let current = defaultState; // MIRROR of timeline.ts line 38
- let bestAt = -Infinity; // MIRROR of timeline.ts line 39
- steps.forEach((step) => { // MIRROR of timeline.ts lines 40-44
+ const effectiveFrame = raw * speed;
+ let current = defaultState;
+ let bestAt = -Infinity;
+ steps.forEach((step) => {
if (step.at <= effectiveFrame && step.at >= bestAt) {
bestAt = step.at;
current = step.state;
@@ -140,10 +80,6 @@ function resolveCurrentState<S extends string>(
return current;
}
-// ---------------------------------------------------------------------------
-// Empty steps / default state
-// ---------------------------------------------------------------------------
-
describe("resolveCurrentState: empty steps always returns defaultState", () => {
it("returns defaultState when steps is empty", () => {
expect(resolveCurrentState(0, [], "idle")).toBe("idle");
@@ -157,10 +93,6 @@ describe("resolveCurrentState: empty steps always returns defaultState", () => {
});
});
-// ---------------------------------------------------------------------------
-// Exact-frame activation
-// ---------------------------------------------------------------------------
-
describe("resolveCurrentState: activates exactly at `at`", () => {
type S = "idle" | "hover";
const steps: Step<S>[] = [{ at: 10, state: "hover" }];
@@ -178,10 +110,6 @@ describe("resolveCurrentState: activates exactly at `at`", () => {
});
});
-// ---------------------------------------------------------------------------
-// Latest of several started steps wins
-// ---------------------------------------------------------------------------
-
describe("resolveCurrentState: latest started step wins", () => {
type S = "idle" | "hover" | "press" | "loading";
const steps: Step<S>[] = [
@@ -206,17 +134,13 @@ describe("resolveCurrentState: latest started step wins", () => {
});
});
-// ---------------------------------------------------------------------------
-// Ties on `at` — later array entry wins
-// ---------------------------------------------------------------------------
-
describe("resolveCurrentState: same-`at` ties resolve to later array entry", () => {
type S = "idle" | "hover" | "press";
it("second entry at the same `at` wins over the first", () => {
const steps: Step<S>[] = [
{ at: 5, state: "hover" },
- { at: 5, state: "press" }, // same `at`, later in array — must win
+ { at: 5, state: "press" },
];
expect(resolveCurrentState(5, steps, "idle")).toBe("press");
});
@@ -225,16 +149,12 @@ describe("resolveCurrentState: same-`at` ties resolve to later array entry", ()
const steps: Step<"idle" | "a" | "b" | "c">[] = [
{ at: 5, state: "a" },
{ at: 5, state: "b" },
- { at: 5, state: "c" }, // latest in array
+ { at: 5, state: "c" },
];
expect(resolveCurrentState(5, steps, "idle")).toBe("c");
});
});
-// ---------------------------------------------------------------------------
-// Speed contract — speed scales the playhead, not the authored `at`s
-// ---------------------------------------------------------------------------
-
describe("resolveCurrentState: speed contract", () => {
type S = "idle" | "go";
const steps: Step<S>[] = [{ at: 30, state: "go" }];
@@ -261,29 +181,10 @@ describe("resolveCurrentState: speed contract", () => {
});
});
-// ===========================================================================
-// 3. useStateTransition resolver replica
-// MIRRORS timeline.ts:useStateTransition (lines 55-73).
-// `raw` is injected in place of useCurrentFrame(). Keep in lockstep.
-//
-// Contract:
-// - `to` = latest step with at <= effectiveFrame; else defaultState.
-// - `from` = the step just before `to` in time-sorted order; else defaultState.
-// - `progress` = clamp01((eff - to.at) / (to.duration ?? defaultDuration));
-// before any step started → progress=1 (holds).
-// - Ties on `at`: later array index wins (sort is stable, later-index last).
-// - `speed` scales the playhead: effectiveFrame = raw * speed.
-// ===========================================================================
-
-/** MIRROR of timeline.ts:clamp01 (line 21-23). */
function clamp01(t: number): number {
return Math.max(0, Math.min(1, t));
}
-/**
- * MIRROR of timeline.ts:useStateTransition (lines 55-73).
- * `raw` = injected useCurrentFrame() value.
- */
function resolveStateTransition<S extends string>(
raw: number, // injected useCurrentFrame() — MIRROR of timeline.ts line 61
steps: Step<S>[],
@@ -291,24 +192,20 @@ function resolveStateTransition<S extends string>(
speed = 1,
defaultDuration = 8,
): { from: S; to: S; progress: number } {
- const effectiveFrame = raw * speed; // MIRROR line 61
- const started = steps // MIRROR lines 62-65
+ 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) // MIRROR line 66-67
+ if (started.length === 0)
return { from: defaultState, to: defaultState, progress: 1 };
- const to = started[started.length - 1].step; // MIRROR line 68
- const from = started.length >= 2 ? started[started.length - 2].step : null; // MIRROR line 69
- const dur = to.duration ?? defaultDuration; // MIRROR line 70
- const progress = dur > 0 ? clamp01((effectiveFrame - to.at) / dur) : 1; // MIRROR line 71
- return { from: from ? from.state : defaultState, to: to.state, progress }; // MIRROR line 72
+ 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 };
}
-// ---------------------------------------------------------------------------
-// Before any step: {from:default, to:default, progress:1}
-// ---------------------------------------------------------------------------
-
describe("resolveStateTransition: before any step starts", () => {
type S = "idle" | "hover";
@@ -339,15 +236,10 @@ describe("resolveStateTransition: before any step starts", () => {
});
});
-// ---------------------------------------------------------------------------
-// At a step boundary: from=prev (or default if first), to=that state, progress=0
-// ---------------------------------------------------------------------------
-
describe("resolveStateTransition: exactly at a step's `at` frame", () => {
type S = "idle" | "hover" | "press";
it("first step: from=default, to=step state, progress=0 (at transition start)", () => {
- // at frame=10 exactly: effectiveFrame=10, to.at=10, progress=(10-10)/8=0
const steps: Step<S>[] = [{ at: 10, state: "hover" }];
const result = resolveStateTransition(10, steps, "idle");
expect(result.from).toBe("idle");
@@ -356,8 +248,6 @@ describe("resolveStateTransition: exactly at a step's `at` frame", () => {
});
it("second step: from=first step state, to=second step state, progress=0", () => {
- // frame=20: to={at:20, state:press}, from={at:10, state:hover}
- // progress = (20-20)/8 = 0
const steps: Step<S>[] = [
{ at: 10, state: "hover" },
{ at: 20, state: "press" },
@@ -369,15 +259,10 @@ describe("resolveStateTransition: exactly at a step's `at` frame", () => {
});
});
-// ---------------------------------------------------------------------------
-// Mid-window: fractional progress
-// ---------------------------------------------------------------------------
-
describe("resolveStateTransition: fractional progress mid-window", () => {
type S = "idle" | "hover";
it("progress is 0.5 at the midpoint of defaultDuration=8 (frame=to.at+4)", () => {
- // step at=10, defaultDuration=8; at frame=14: progress=(14-10)/8=0.5
const steps: Step<S>[] = [{ at: 10, state: "hover" }];
const result = resolveStateTransition(14, steps, "idle", 1, 8);
expect(result.to).toBe("hover");
@@ -386,29 +271,22 @@ describe("resolveStateTransition: fractional progress mid-window", () => {
});
it("progress is 0.25 at one quarter through defaultDuration=8 (frame=to.at+2)", () => {
- // step at=10, frame=12: progress=(12-10)/8=0.25
const steps: Step<S>[] = [{ at: 10, state: "hover" }];
const result = resolveStateTransition(12, steps, "idle", 1, 8);
expect(result.progress).toBeCloseTo(0.25, 10);
});
it("progress is 0.75 three-quarters through defaultDuration=8 (frame=to.at+6)", () => {
- // step at=10, frame=16: progress=(16-10)/8=0.75
const steps: Step<S>[] = [{ at: 10, state: "hover" }];
const result = resolveStateTransition(16, steps, "idle", 1, 8);
expect(result.progress).toBeCloseTo(0.75, 10);
});
});
-// ---------------------------------------------------------------------------
-// Past the window: progress holds at 1, to = that state
-// ---------------------------------------------------------------------------
-
describe("resolveStateTransition: progress holds at 1 past the transition window", () => {
type S = "idle" | "hover";
it("progress=1 exactly at to.at+defaultDuration (frame=to.at+8)", () => {
- // step at=10, defaultDuration=8, frame=18: progress=(18-10)/8=1
const steps: Step<S>[] = [{ at: 10, state: "hover" }];
const result = resolveStateTransition(18, steps, "idle", 1, 8);
expect(result.to).toBe("hover");
@@ -423,23 +301,16 @@ describe("resolveStateTransition: progress holds at 1 past the transition window
});
});
-// ---------------------------------------------------------------------------
-// Per-step `duration` overrides `defaultDuration`
-// ---------------------------------------------------------------------------
-
describe("resolveStateTransition: per-step duration overrides defaultDuration", () => {
type S = "idle" | "hover";
it("step with duration:6 yields different progress at frame=to.at+4 than defaultDuration:8", () => {
- // With duration:6: progress=(14-10)/6 ≈ 0.667
- // With defaultDuration:8: progress=(14-10)/8 = 0.5
const stepsWithDur: Step<S>[] = [{ at: 10, state: "hover", duration: 6 }];
const stepsNoDur: Step<S>[] = [{ at: 10, state: "hover" }];
const withDur = resolveStateTransition(14, stepsWithDur, "idle", 1, 8);
const withDefault = resolveStateTransition(14, stepsNoDur, "idle", 1, 8);
expect(withDur.progress).toBeCloseTo(4 / 6, 10);
expect(withDefault.progress).toBeCloseTo(4 / 8, 10);
- // They must differ
expect(Math.abs(withDur.progress - withDefault.progress)).toBeGreaterThan(0.1);
});
@@ -448,7 +319,7 @@ describe("resolveStateTransition: per-step duration overrides defaultDuration",
const atSix = resolveStateTransition(16, steps, "idle", 1, 8);
const atEight = resolveStateTransition(18, steps, "idle", 1, 8);
expect(atSix.progress).toBe(1);
- expect(atEight.progress).toBe(1); // also clamped at 1, not beyond
+ expect(atEight.progress).toBe(1);
});
it("step with duration:0 snaps immediately to progress=1", () => {
@@ -458,10 +329,6 @@ describe("resolveStateTransition: per-step duration overrides defaultDuration",
});
});
-// ---------------------------------------------------------------------------
-// Chained steps: from = previous step state
-// ---------------------------------------------------------------------------
-
describe("resolveStateTransition: chained steps carry from=previous state", () => {
type S = "idle" | "hover" | "press" | "loading";
@@ -496,10 +363,6 @@ describe("resolveStateTransition: chained steps carry from=previous state", () =
});
});
-// ---------------------------------------------------------------------------
-// Ties on `at`: later array entry wins (same contract as useCurrentState)
-// ---------------------------------------------------------------------------
-
describe("resolveStateTransition: same-`at` ties — later array entry wins", () => {
type S = "idle" | "a" | "b" | "c";
@@ -521,27 +384,21 @@ describe("resolveStateTransition: same-`at` ties — later array entry wins", ()
];
const r = resolveStateTransition(5, steps, "idle");
expect(r.to).toBe("c");
- // all three share the same at, so only one "time slot" — from=default
expect(r.from).toBe("idle");
});
it("tie at second step: from=first step (different at), to=later-array winner", () => {
- // step at=0 state=a, then two tied at=10 steps
const steps: Step<S>[] = [
{ at: 0, state: "a" },
{ at: 10, state: "b" },
{ at: 10, state: "c" },
];
const r = resolveStateTransition(10, steps, "idle");
- expect(r.to).toBe("c"); // later array entry wins
- expect(r.from).toBe("b"); // the other at=10 entry is second-to-last in sorted order
+ expect(r.to).toBe("c");
+ expect(r.from).toBe("b");
});
});
-// ---------------------------------------------------------------------------
-// speed=2 scales the playhead
-// ---------------------------------------------------------------------------
-
describe("resolveStateTransition: speed contract", () => {
type S = "idle" | "hover";
@@ -559,7 +416,6 @@ describe("resolveStateTransition: speed contract", () => {
});
it("speed=2: progress mid-window uses effectiveFrame (raw=12, eff=24, at=20, dur=8 → prog=0.5)", () => {
- // eff=24, to.at=20, dur=8 → (24-20)/8 = 0.5
const steps: Step<S>[] = [{ at: 20, state: "hover" }];
const r = resolveStateTransition(12, steps, "idle", 2, 8);
expect(r.to).toBe("hover");
diff --git a/registry/remocn-ui/core/color.ts b/registry/remocn-ui/core/color.ts
index 31f2285a..676595fe 100644
--- a/registry/remocn-ui/core/color.ts
+++ b/registry/remocn-ui/core/color.ts
@@ -1,7 +1,3 @@
-// Thin wrapper over culori. All color objects use culori's NATIVE shapes and
-// scales: `Rgb` channels are 0..1 (mode "rgb", optional `alpha`), `Oklch` uses
-// lowercase `l,c,h` (mode "oklch", optional `alpha`). The public channel scale
-// is culori-native 0..1 (NOT 0..255).
import {
clampChroma,
@@ -44,13 +40,10 @@ export function parseColor(c: string): Rgb {
}
export function oklchToRgb(l: number, c: number, h: number): Rgb {
- // Map into the sRGB gamut before converting so the result is displayable.
const mapped = clampChroma({ mode: "oklch", l, c, h }, "oklch", "rgb");
return toRgb(mapped);
}
-// Takes a culori `Rgb` object (0..1). Achromatic colors yield an undefined/NaN
-// hue from culori; we normalize it to `0` to keep a numeric hue.
export function rgbToOklch(rgb: Rgb): Oklch {
const { l, c, h } = toOklch(rgb);
return { mode: "oklch", l, c, h: Number.isFinite(h) ? h : 0 };
@@ -86,8 +79,6 @@ export function mixOklch(a: string, b: string, t: number): string {
return toCss(toRgb(mixed));
}
-// Emits an inline-style sRGB string using culori's own formatter. `formatRgb`
-// produces the legacy `rgb()/rgba()` form.
export function toCss(color: Rgb): string {
return formatRgb(color);
}
diff --git a/registry/remocn-ui/core/motion.ts b/registry/remocn-ui/core/motion.ts
index 4e9a8f67..04c628d7 100644
--- a/registry/remocn-ui/core/motion.ts
+++ b/registry/remocn-ui/core/motion.ts
@@ -1,31 +1,17 @@
-/**
- * Deterministic, frame-based motion presets for remocn UI primitives.
- *
- * `easings` are pure functions on normalized progress `t ∈ [0,1]`. `springs` are
- * parameter bags passed straight to Remotion's `spring({ config })`.
- */
export const easings = {
- /** Linear. */
linear: (t: number): number => t,
- /** Ease-out cubic — decelerates into rest. */
out: (t: number): number => 1 - (1 - t) ** 3,
- /** Ease-in cubic — accelerates from rest. */
in: (t: number): number => t * t * t,
- /** Ease-in-out cubic. */
inOut: (t: number): number =>
t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2,
} as const;
export type EasingName = keyof typeof easings;
-/** Remotion `spring()` config presets. */
export const springs = {
- /** Fast, tight settle — good for presses and toggles. */
snappy: { damping: 18, stiffness: 220, mass: 0.7 },
- /** Gentle, smooth settle — good for entrances. */
soft: { damping: 14, stiffness: 120, mass: 0.9 },
- /** Slight overshoot for playful pops. */
bouncy: { damping: 10, stiffness: 180, mass: 0.8 },
} as const;
diff --git a/registry/remocn-ui/core/theme.ts b/registry/remocn-ui/core/theme.ts
index 6de4bca2..91cedcea 100644
--- a/registry/remocn-ui/core/theme.ts
+++ b/registry/remocn-ui/core/theme.ts
@@ -3,11 +3,6 @@
import { createContext, createElement, useContext } from "react";
import type { ReactNode } from "react";
-/**
- * The remocn UI theme — stock shadcn token names. Values are concrete oklch
- * strings (NOT `var(...)`) so they can be interpolated under Remotion's headless
- * per-frame render. `radius` is a pixel number (not the CSS `rem`).
- */
export interface RemocnTheme {
background: string;
foreground: string;
@@ -28,12 +23,9 @@ export interface RemocnTheme {
border: string;
input: string;
ring: string;
- /** Border radius in px. */
radius: number;
}
-
-/** Stock shadcn "neutral" light theme (oklch tokens). */
export const defaultLightTheme: RemocnTheme = {
background: "oklch(1 0 0)",
foreground: "oklch(0.145 0 0)",
@@ -57,7 +49,6 @@ export const defaultLightTheme: RemocnTheme = {
radius: 10,
}
-/** Stock shadcn "neutral" dark theme (oklch tokens). */
export const defaultDarkTheme: RemocnTheme = {
background: "oklch(0.145 0 0)",
foreground: "oklch(0.985 0 0)",
@@ -106,13 +97,6 @@ export function RemocnUIProvider({
);
}
-/**
- * Resolve the active theme.
- *
- * Token resolution order: per-component `override` ▸ Provider `theme` ▸ default[mode].
- * `mode` precedence: per-component `modeOverride` (the component's own `mode` prop)
- * ▸ Provider `mode` ▸ "light".
- */
export function useRemocnTheme(
override?: Partial<RemocnTheme>,
modeOverride?: "light" | "dark",
diff --git a/registry/remocn-ui/core/timeline.ts b/registry/remocn-ui/core/timeline.ts
index 6f720508..c6fa9d03 100644
--- a/registry/remocn-ui/core/timeline.ts
+++ b/registry/remocn-ui/core/timeline.ts
@@ -1,12 +1,10 @@
import { useCurrentFrame } from "remotion";
import type { Step } from "./types";
-/** duration(seconds-or-frames) -> frames. Number = frames; {seconds} -> *fps. */
export function framesFor(d: number | { seconds: number }, fps: number): number {
return typeof d === "number" ? d : Math.round(d.seconds * fps);
}
-/** Deterministic char-reveal count (same math as the typewriter component). */
export function revealCount(
localFrame: number,
fps: number,
@@ -22,12 +20,6 @@ export function clamp01(t: number): number {
return Math.max(0, Math.min(1, t));
}
-/**
- * Resolve the current state from a `steps` timeline: the state of the latest
- * step whose `at <= effectiveFrame`, else `defaultState`. Pure deterministic
- * fold; `speed` scales the playhead (effectiveFrame = useCurrentFrame()*speed).
- * Ties on `at` resolve by array order (later wins).
- */
export function useCurrentState<S extends string>(
steps: Step<S>[],
defaultState: S,
@@ -45,13 +37,6 @@ export function useCurrentState<S extends string>(
return current;
}
-/**
- * Resolve the in-flight transition for keyframe-style atoms. `to` = latest step
- * with at<=effectiveFrame (else defaultState); `from` = the step just before it
- * (else defaultState); `progress` ramps 0→1 over [to.at, to.at + (to.duration ??
- * defaultDuration)), then holds at 1. effectiveFrame = useCurrentFrame()*speed.
- * Ties on `at` resolve later-array-wins.
- */
export function useStateTransition<S extends string>(
steps: Step<S>[],
defaultState: S,
diff --git a/registry/remocn-ui/core/types.ts b/registry/remocn-ui/core/types.ts
index 5f0ebd7c..dea316eb 100644
--- a/registry/remocn-ui/core/types.ts
+++ b/registry/remocn-ui/core/types.ts
@@ -1,14 +1,5 @@
-/**
- * A single scripted state on the Remotion timeline.
- *
- * Every remocn UI state atom consumes the same `steps: Step[]` envelope. The
- * current state is the latest step whose `at` is <= the current frame.
- */
export interface Step<S extends string = string> {
- /** LOCAL (Sequence-relative) authored frame at which the component enters this state. */
at: number;
- /** Per-component state union (e.g. "idle" | "hover" | "loading"). */
state: S;
- /** Frames to animate the transition INTO this state. Omitted → caller's default. */
duration?: number;
}
diff --git a/registry/remocn-ui/cursor/__tests__/cursor.test.ts b/registry/remocn-ui/cursor/__tests__/cursor.test.ts
index 4b7a1dbd..82d1da4b 100644
--- a/registry/remocn-ui/cursor/__tests__/cursor.test.ts
+++ b/registry/remocn-ui/cursor/__tests__/cursor.test.ts
@@ -1,35 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `cursor`.
- *
- * Scope:
- * - registry/remocn-ui/cursor/use-cursor-path.ts
- * cursorPathAt() — pure fold with injected frame (MIRROR of useCursorPath)
- * ripplePhase() — click ripple opacity + scale preset
- * clickPress() — momentary press-dip preset
- * Constants: DEFAULT_DURATION, CLICK_FRAMES, PRESS_FRAMES
- * - registry/remocn-ui/cursor/config.ts
- * cursorConfig.controls wiring + cursorConfig.snippet codegen
- *
- * The render path (index.tsx) is a PURE renderer of CursorStyle — it never
- * reads the frame and is NOT exercised here (it imports `useRemocnTheme` from
- * a Remotion context). The pure-testable surface is:
- * 1. cursorPathAt — the frame-injected pure core of useCursorPath
- * 2. ripplePhase / clickPress — exported pure phase presets
- * 3. cursorConfig.snippet — the customizer JSX codegen
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/cursor/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * We import via RELATIVE paths so tsconfig aliases aren't required for the
- * pure functions under test. cursorPathAt, ripplePhase, and clickPress are
- * all exported from use-cursor-path.ts and never call useCurrentFrame() at
- * call time (only useCursorPath does — cursorPathAt is the pure extracted
- * core). cursorConfig is a plain object; .snippet is a pure string builder.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -43,16 +11,10 @@ import {
} from "../use-cursor-path";
import { cursorConfig } from "../config";
-// ===========================================================================
-// Shared helpers
-// ===========================================================================
-
-/** Convenience wrapper — injects a raw frame into cursorPathAt. */
function pathAt(waypoints: CursorWaypoint[], raw: number, speed = 1) {
return cursorPathAt(waypoints, raw, { speed });
}
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
variant?: string;
size?: number;
@@ -63,10 +25,6 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
cursorConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. Exported constants
-// ===========================================================================
-
describe("cursor constants", () => {
it("DEFAULT_DURATION is 24 frames", () => {
expect(DEFAULT_DURATION).toBe(24);
@@ -81,11 +39,6 @@ describe("cursor constants", () => {
});
});
-// ===========================================================================
-// 2. ripplePhase — PURE exported preset (use-cursor-path.ts lines 59-71)
-// Opacity: 0.5*(1-p), Scale: 2.5*easings.out(p), where p = frame/CLICK_FRAMES
-// ===========================================================================
-
describe("ripplePhase: out of range → zero ripple", () => {
it("returns zero opacity and scale before a click (sinceClick < 0)", () => {
const r = ripplePhase(-1);
@@ -107,7 +60,6 @@ describe("ripplePhase: out of range → zero ripple", () => {
});
describe("ripplePhase: at frame 0 (click moment)", () => {
- // p = 0/16 = 0 → opacity = 0.5*(1-0) = 0.5, scale = 2.5*out(0) = 0
it("rippleOpacity is 0.5 at click moment", () => {
expect(ripplePhase(0).rippleOpacity).toBeCloseTo(0.5, 10);
});
@@ -118,9 +70,7 @@ describe("ripplePhase: at frame 0 (click moment)", () => {
});
describe("ripplePhase: mid-flight (frame = CLICK_FRAMES / 2)", () => {
- // p = 0.5 → opacity = 0.5*(1-0.5) = 0.25, scale = 2.5*out(0.5)
- // out(0.5) = 1-(1-0.5)^3 = 1-0.125 = 0.875 → scale = 2.5*0.875 = 2.1875
- const half = CLICK_FRAMES / 2; // 8
+ const half = CLICK_FRAMES / 2;
it("rippleOpacity is 0.25 at mid-flight", () => {
expect(ripplePhase(half).rippleOpacity).toBeCloseTo(0.25, 10);
@@ -134,7 +84,6 @@ describe("ripplePhase: mid-flight (frame = CLICK_FRAMES / 2)", () => {
});
describe("ripplePhase: just before expiry (frame = CLICK_FRAMES - 1)", () => {
- // p = 15/16 → opacity = 0.5*(1 - 15/16) = 0.5/16 ≈ 0.03125
const lastFrame = CLICK_FRAMES - 1;
it("rippleOpacity approaches 0 near expiry", () => {
@@ -164,12 +113,6 @@ describe("ripplePhase: monotonic invariants across the window", () => {
});
});
-// ===========================================================================
-// 3. clickPress — PURE exported preset (use-cursor-path.ts lines 78-86)
-// Triangle down-up over PRESS_FRAMES, then holds at 1.
-// half = 4; down: p = f/half; up: p = 1-(f-half)/half → pressScale = 1-p
-// ===========================================================================
-
describe("clickPress: out of range → 1 (up)", () => {
it("returns 1 before click (sinceClick < 0)", () => {
expect(clickPress(-1)).toBe(1);
@@ -185,16 +128,13 @@ describe("clickPress: out of range → 1 (up)", () => {
});
describe("clickPress: at click moment (frame 0)", () => {
- // down half: p = 0/4 = 0 → pressScale = 1-0 = 1
it("pressScale is 1 at frame 0 (not yet dipped)", () => {
expect(clickPress(0)).toBeCloseTo(1, 10);
});
});
describe("clickPress: fully pressed at half-way (frame = PRESS_FRAMES/2)", () => {
- // At the half-way boundary (frame = half = 4): entering the up phase
- // up: p = 1-(4-4)/4 = 1 → pressScale = 1-1 = 0
- const half = PRESS_FRAMES / 2; // 4
+ const half = PRESS_FRAMES / 2;
it("pressScale is 0 at the bottom of the press dip", () => {
expect(clickPress(half)).toBeCloseTo(0, 10);
@@ -202,7 +142,6 @@ describe("clickPress: fully pressed at half-way (frame = PRESS_FRAMES/2)", () =>
});
describe("clickPress: returning up at frame PRESS_FRAMES - 1", () => {
- // last frame (7): up phase, p = 1-(7-4)/4 = 1-0.75 = 0.25 → pressScale = 1-0.25 = 0.75
const lastFrame = PRESS_FRAMES - 1;
it("pressScale is back above 0 near the end of the press window", () => {
@@ -213,14 +152,12 @@ describe("clickPress: returning up at frame PRESS_FRAMES - 1", () => {
describe("clickPress: dip then rise (down-up triangle shape)", () => {
it("pressScale decreases from frame 0 to the midpoint", () => {
- // down phase: 0..3 (half=4, so frame 0,1,2,3 are in the down half)
for (let f = 0; f < PRESS_FRAMES / 2 - 1; f++) {
expect(clickPress(f)).toBeGreaterThan(clickPress(f + 1));
}
});
it("pressScale increases from the midpoint back toward 1", () => {
- // up phase: 4..7
const half = PRESS_FRAMES / 2;
for (let f = half; f < PRESS_FRAMES - 1; f++) {
expect(clickPress(f)).toBeLessThan(clickPress(f + 1));
@@ -228,13 +165,6 @@ describe("clickPress: dip then rise (down-up triangle shape)", () => {
});
});
-// ===========================================================================
-// 4. cursorPathAt — PURE core of useCursorPath
-// MIRROR of use-cursor-path.ts lines 111-188.
-// `raw` is the injected useCurrentFrame() * speed.
-// Keep in lockstep with source.
-// ===========================================================================
-
describe("cursorPathAt: empty waypoints", () => {
it("returns origin with scale=1, no ripple, at any frame", () => {
const result = cursorPathAt([], 0);
@@ -253,7 +183,6 @@ describe("cursorPathAt: empty waypoints", () => {
});
describe("cursorPathAt: before first arrival — cursor waits at first waypoint", () => {
- // MIRROR of use-cursor-path.ts lines 126-135 ("before the first arrival")
const wps: CursorWaypoint[] = [{ at: 30, x: 100, y: 200 }];
it("parks at first waypoint x/y at raw=0 (before at)", () => {
@@ -267,7 +196,6 @@ describe("cursorPathAt: before first arrival — cursor waits at first waypoint"
});
it("parks at first waypoint when raw equals first.at", () => {
- // raw <= first.at: at first.at exactly it should hold (≤ guard in source)
const r = pathAt(wps, 30);
expect(r.x).toBe(100);
expect(r.y).toBe(200);
@@ -285,11 +213,6 @@ describe("cursorPathAt: single waypoint — holds at arrival position past at",
});
describe("cursorPathAt: two waypoints — interpolation window", () => {
- // Move from (0,0) at=0 to (100,200) at=24 with DEFAULT_DURATION=24
- // Window: [0, 24), start = 24-24 = 0
- // At raw=12: t_raw = (12-0)/24 = 0.5, then eased by inOut
- // inOut(0.5) = 4*0.5^3 = 0.5 (symmetric midpoint)
- // x = lerp(0, 100, 0.5) = 50, y = lerp(0, 200, 0.5) = 100
const wps: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0 },
{ at: 24, x: 100, y: 200 },
@@ -297,7 +220,6 @@ describe("cursorPathAt: two waypoints — interpolation window", () => {
it("position at midpoint uses inOut easing (default)", () => {
const r = pathAt(wps, 12);
- // inOut(0.5) = 0.5 (cubic in-out midpoint is exact 0.5)
expect(r.x).toBeCloseTo(50, 10);
expect(r.y).toBeCloseTo(100, 10);
});
@@ -322,14 +244,10 @@ describe("cursorPathAt: two waypoints — interpolation window", () => {
});
describe("cursorPathAt: easing override", () => {
- // Move from (0,0) at=0 to (100,0) at=24, easing=linear
- // At raw=12: t = linear(0.5) = 0.5, x = 50
const wpsLinear: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0 },
{ at: 24, x: 100, y: 0, easing: "linear" },
];
- // Move same path with easing=out
- // out(0.5) = 1-(1-0.5)^3 = 1-0.125 = 0.875, x = 87.5
const wpsOut: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0 },
{ at: 24, x: 100, y: 0, easing: "out" },
@@ -349,34 +267,23 @@ describe("cursorPathAt: easing override", () => {
});
describe("cursorPathAt: custom duration override", () => {
- // Waypoint with duration=12 instead of DEFAULT_DURATION=24
- // Window: [at - dur, at) = [12, 24), start=12
- // At raw=18: t=(18-12)/12=0.5
const wps: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0 },
{ at: 24, x: 100, y: 0, duration: 12 },
];
it("duration=12 — cursor holds FROM position before the window start", () => {
- // Before window [12,24): raw=10 is before the move starts but after from.at=0
- // toIndex should be 1 (wps[1].at=24 > raw=10); from=wps[0], to=wps[1]
- // t=(10-12)/12 = negative → clamp01 = 0 → x = lerp(0,100,eased(0)) = 0
const r = pathAt(wps, 10);
expect(r.x).toBeCloseTo(0, 10);
});
it("duration=12 — x=50 at midpoint of the 12-frame window (raw=18)", () => {
- // inOut(0.5) = 0.5 → x = 50
const r = pathAt(wps, 18);
expect(r.x).toBeCloseTo(50, 10);
});
});
describe("cursorPathAt: defaultDuration option", () => {
- // Two waypoints, no duration on second — uses defaultDuration from opts
- // With defaultDuration=12: window = [24-12, 24) = [12, 24)
- // At raw=18: t=(18-12)/12=0.5 → inOut(0.5)=0.5 → x=50
- // With defaultDuration=24 (default): t=(18-0)/24=0.75 → inOut(0.75)
const wps: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0 },
{ at: 24, x: 100, y: 0 },
@@ -395,7 +302,6 @@ describe("cursorPathAt: defaultDuration option", () => {
});
describe("cursorPathAt: scale is always 1", () => {
- // scale=1 is an invariant in the source — the component applies pressedScale
const wps: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0 },
{ at: 24, x: 100, y: 200, click: true },
@@ -414,11 +320,6 @@ describe("cursorPathAt: scale is always 1", () => {
});
});
-// ===========================================================================
-// 5. Click visuals — ripple and press-dip fire at a `click: true` waypoint
-// MIRROR of use-cursor-path.ts lines 162-178
-// ===========================================================================
-
describe("cursorPathAt: no click — ripple stays zero", () => {
const wps: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0 },
@@ -433,7 +334,6 @@ describe("cursorPathAt: no click — ripple stays zero", () => {
});
describe("cursorPathAt: click:true — ripple and press-dip fire at arrival", () => {
- // Click fires at at=24. sinceClick at raw=24 is 0.
const wps: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0 },
{ at: 24, x: 100, y: 0, click: true },
@@ -445,34 +345,27 @@ describe("cursorPathAt: click:true — ripple and press-dip fire at arrival", ()
});
it("rippleOpacity is 0.5 exactly at click arrival (sinceClick=0)", () => {
- // ripplePhase(0).rippleOpacity = 0.5*(1-0) = 0.5
expect(pathAt(wps, 24).rippleOpacity).toBeCloseTo(0.5, 10);
});
it("rippleOpacity decays to 0 after CLICK_FRAMES since click", () => {
- // raw = 24 + CLICK_FRAMES → sinceClick = CLICK_FRAMES → out of range → 0
expect(pathAt(wps, 24 + CLICK_FRAMES).rippleOpacity).toBe(0);
});
it("pressScale is 1 at frame 0 of click dip (not yet dipped)", () => {
- // clickPress(0) = 1 (first frame hasn't dipped yet — down phase p=0)
expect(pathAt(wps, 24).pressScale).toBeCloseTo(1, 10);
});
it("pressScale is 0 at the midpoint of the press dip", () => {
- // sinceClick = PRESS_FRAMES/2 = 4 → clickPress(4) = 0
expect(pathAt(wps, 24 + PRESS_FRAMES / 2).pressScale).toBeCloseTo(0, 10);
});
it("pressScale returns to 1 after the press window completes", () => {
- // sinceClick = PRESS_FRAMES = 8 → clickPress(8) = 1
expect(pathAt(wps, 24 + PRESS_FRAMES).pressScale).toBeCloseTo(1, 10);
});
});
describe("cursorPathAt: multiple clicks — only the most recent active click fires", () => {
- // Two click waypoints; at raw = first.at + 5, only the first should be active.
- // At raw = second.at + 2, only the second should be active.
const wps: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0, click: true },
{ at: 48, x: 100, y: 100, click: true },
@@ -499,22 +392,13 @@ describe("cursorPathAt: multiple clicks — only the most recent active click fi
});
});
-// ===========================================================================
-// 6. Press (drag) — held press visual channel
-// MIRROR of use-cursor-path.ts lines 173-178
-// ===========================================================================
-
describe("cursorPathAt: press:true — held press look", () => {
- // press:true on a segment means the FROM waypoint has press=true while we are
- // resting at or moving away from it. heldPress = holdWp.press ? 0 : 1.
const wps: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0, press: true },
{ at: 48, x: 100, y: 100 },
];
it("pressScale is 0 (fully pressed) while the press segment is active", () => {
- // raw=10: toIndex=1 (wps[1].at=48>10), from=wps[0] (press:true), holdWp=from
- // heldPress=0, no click dip → pressScale = min(1, 0) = 0
expect(pathAt(wps, 10).pressScale).toBe(0);
});
@@ -523,8 +407,6 @@ describe("cursorPathAt: press:true — held press look", () => {
});
it("pressScale is 1 after the second (non-press) waypoint arrives", () => {
- // pastLast=true → holdWp = last waypoint (wps[1], press=undefined → falsy)
- // heldPress = 1, no click → pressScale = min(1,1) = 1
expect(pathAt(wps, 48).pressScale).toBe(1);
});
});
@@ -540,16 +422,7 @@ describe("cursorPathAt: no press flag — pressScale is always 1", () => {
});
});
-// ===========================================================================
-// 7. Speed contract — speed scales the playhead
-// MIRROR of use-cursor-path.ts lines 97-104 (useCursorPath)
-// effectiveFrame = raw * speed; cursorPathAt receives raw with speed in opts
-// ===========================================================================
-
describe("cursorPathAt: speed contract", () => {
- // Single move: at=0 → at=24, DEFAULT_DURATION=24, no easing override (inOut)
- // At raw=6, speed=2: effectiveFrame=12. inOut(0.5)=0.5 → x=50.
- // At raw=24, speed=2: effectiveFrame=48, pastLast → x=100.
const wps: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0 },
{ at: 24, x: 100, y: 0 },
@@ -566,7 +439,6 @@ describe("cursorPathAt: speed contract", () => {
});
it("speed=0.5: arrival not reached at raw=24 (effectiveFrame=12)", () => {
- // effectiveFrame=12, t=(12-0)/24=0.5, inOut(0.5)=0.5 → x=50
const r = pathAt(wps, 24, 0.5);
expect(r.x).toBeCloseTo(50, 10);
});
@@ -586,10 +458,6 @@ describe("cursorPathAt: speed contract", () => {
});
});
-// ===========================================================================
-// 8. Three-waypoint path — correct segment selection
-// ===========================================================================
-
describe("cursorPathAt: three waypoints — segment selection", () => {
const wps: CursorWaypoint[] = [
{ at: 0, x: 0, y: 0 },
@@ -622,10 +490,6 @@ describe("cursorPathAt: three waypoints — segment selection", () => {
});
});
-// ===========================================================================
-// 9. cursorConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("cursorConfig.controls: variant", () => {
it("variant is a select control", () => {
expect(cursorConfig.controls.variant.type).toBe("select");
@@ -690,10 +554,6 @@ describe("cursorConfig.controls: rippleColor", () => {
});
});
-// ===========================================================================
-// 10. cursorConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("cursorConfig.snippet: import lines", () => {
it("includes 'import { Cursor }' from the correct path", () => {
const out = snippet({});
@@ -724,7 +584,6 @@ describe("cursorConfig.snippet: structural invariants", () => {
});
describe("cursorConfig.snippet: default props are omitted", () => {
- // Defaults: variant=arrow, size=28, mode=light
const allDefaults = snippet({ variant: "arrow", size: 28, mode: "light" });
it("omits variant when it equals 'arrow'", () => {
diff --git a/registry/remocn-ui/cursor/index.tsx b/registry/remocn-ui/cursor/index.tsx
index bf2e6e82..e4b47c01 100644
--- a/registry/remocn-ui/cursor/index.tsx
+++ b/registry/remocn-ui/cursor/index.tsx
@@ -4,52 +4,25 @@ import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
export type CursorVariant = "arrow" | "pointer";
-// ===========================================================================
-// Cursor visual — the COMPLETE animated look for a moment in time. The animated
-// channel here is numeric (position + ripple phase), the accepted value-channel
-// deviation from the string-`state` atoms (see STYLE-GUIDE §"value channel"):
-// `useCursorPath` feeds an interpolated `CursorStyle` straight through, exactly
-// like `style` on a state atom. The component is a pure renderer — it never
-// reads the frame.
-// ===========================================================================
-
export interface CursorStyle {
- /** Tip X in px, relative to the absolute wrapper's parent. */
x: number;
- /** Tip Y in px, relative to the absolute wrapper's parent. */
y: number;
- /** Cursor scale (1 = rest). A click dips this toward `pressScale` briefly. */
scale: number;
- /** Ripple circle opacity (0 = gone). */
rippleOpacity: number;
- /** Ripple circle scale (0 → ~2.5 over a click). */
rippleScale: number;
- /**
- * Held press visual (1 = up, 0 = fully pressed). Drives the press dip while a
- * `press` segment (drag) is held; `useCursorPath` blends it with the click dip.
- */
pressScale?: number;
}
export interface CursorProps {
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * the resting `style` defaults — feed it an interpolated `CursorStyle` from
- * `useCursorPath`.
- */
style?: CursorStyle;
- /** macOS arrow or hand pointer. Static choice, not animated. */
variant?: CursorVariant;
- /** Rendered cursor height in px (the SVG scales to it). Default 28. */
size?: number;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
- /** Ripple ring color. Defaults to `theme.primary`. */
rippleColor?: string;
className?: string;
}
-/** The resting visual when no `style` is supplied (cursor parked at origin). */
const REST: CursorStyle = {
x: 0,
y: 0,
@@ -58,8 +31,6 @@ const REST: CursorStyle = {
rippleScale: 0,
};
-// Hand-drawn SVGs on a 24×24 grid; the tip (hotspot) sits at (0,0) so `x`/`y`
-// position the pointing tip exactly, like a real cursor hotspot.
const ARROW_PATH =
"M1 1 L1 18.5 L5.6 14.4 L8.7 21.6 L11.6 20.4 L8.5 13.2 L14.5 13.2 Z";
const POINTER_PATH =
@@ -71,12 +42,6 @@ const POINTER_PATH =
"C9 22.3 7.9 21.2 6.6 19.2 L4 15.2 C3.5 14.4 3.7 13.4 4.5 12.9 " +
"C5.1 12.5 5.9 12.6 6.4 13.2 L8 15 Z";
-/**
- * A deterministic animated cursor. Pure renderer of whatever `CursorStyle` it
- * receives — it reads no frame, holds no state, runs no effects. The single time
- * source is `useCursorPath`, on the caller's side; this component cannot tell
- * whether the `style` it got was a resting preset or an interpolated frame.
- */
export function Cursor({
style,
variant = "arrow",
@@ -89,14 +54,12 @@ export function Cursor({
const theme = useRemocnTheme(themeOverride, mode);
const v = style ?? REST;
- // Press dips the cursor; click and held-press dips combine to one factor.
const press = v.pressScale ?? 1;
const pressedScale = v.scale * (0.9 + 0.1 * press);
const ring = rippleColor ?? theme.primary;
const fill = theme.foreground;
const stroke = theme.background;
- // Ripple is centered on the cursor tip (the hotspot at the SVG origin).
const rippleSize = size * 1.8;
return (
@@ -110,7 +73,7 @@ export function Cursor({
pointerEvents: "none",
}}
>
- {/* Ripple sits UNDER the tip and is centered on the hotspot. */}
+ {}
<div
style={{
position: "absolute",
@@ -125,7 +88,7 @@ export function Cursor({
transformOrigin: "center",
}}
/>
- {/* Cursor SVG, scaled about its tip so the hotspot stays anchored. */}
+ {}
<svg
width={size}
height={size}
diff --git a/registry/remocn-ui/cursor/preview.tsx b/registry/remocn-ui/cursor/preview.tsx
index a172c17d..f55caa20 100644
--- a/registry/remocn-ui/cursor/preview.tsx
+++ b/registry/remocn-ui/cursor/preview.tsx
@@ -11,13 +11,6 @@ export interface CursorPreviewProps {
speed?: number;
}
-/**
- * Preview-only wrapper for the customizer. The shipped `Cursor` is a pure
- * renderer driven by `useCursorPath`; the customizer Player can only pass scalar
- * control values, so this thin wrapper runs a fixed demo path (move → click →
- * drag → move) and feeds the resulting `CursorStyle` to `<Cursor>`. NOT shipped:
- * not listed in registry.json files; users author their own path.
- */
export function CursorPreview({
variant = "arrow",
size = 28,
diff --git a/registry/remocn-ui/cursor/use-cursor-path.ts b/registry/remocn-ui/cursor/use-cursor-path.ts
index 3f9ba0fb..9a2a45a2 100644
--- a/registry/remocn-ui/cursor/use-cursor-path.ts
+++ b/registry/remocn-ui/cursor/use-cursor-path.ts
@@ -7,55 +7,32 @@ import {
easings,
} from "@/lib/remocn-ui";
import type { CursorStyle } from "@/components/remocn/cursor";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/**
- * A scripted point the cursor moves to. The cursor eases from the previous
- * waypoint's position to this one over `[at, at + (duration ?? DEFAULT_DURATION))`.
- */
export interface CursorWaypoint {
- /** LOCAL (Sequence-relative) authored frame the cursor finishes arriving here. */
at: number;
- /** Tip X in px (parent-relative). */
x: number;
- /** Tip Y in px (parent-relative). */
y: number;
- /** Frames the move INTO this waypoint takes. Omitted → DEFAULT_DURATION. */
duration?: number;
- /** Fire a click on arrival: a ripple (~CLICK_FRAMES) + a brief press dip. */
click?: boolean;
- /** Hold the pressed look from this waypoint until the next one (drag). */
press?: boolean;
- /** Override the easing for the move into this waypoint. Default `inOut`. */
easing?: EasingName;
}
-/** Default frames for a move into a waypoint when it omits `duration`. */
export const DEFAULT_DURATION = 24;
-/** Frames a click ripple takes to scale up and fully fade out. */
export const CLICK_FRAMES = 16;
-/** Frames the cursor's click press-dip lasts (a quick down-and-up). */
export const PRESS_FRAMES = 8;
export interface CursorPathOptions {
- /** Playhead scale (effectiveFrame = useCurrentFrame() * speed). */
speed?: number;
- /** Move duration (frames) when a waypoint omits `duration`. */
defaultDuration?: number;
}
-/** Linear blend; numeric channels only. */
function lerp(a: number, b: number, t: number): number {
return a + (b - a) * t;
}
-/**
- * The ripple's opacity + scale for `framesSinceClick` into a click. Pure preset
- * of the click phase: scale ramps 0 → ~2.5 (eased out), opacity 0.5 → 0. Past
- * CLICK_FRAMES the ripple is fully gone. Exported for the pure-surface tests.
- */
export function ripplePhase(framesSinceClick: number): {
rippleOpacity: number;
rippleScale: number;
@@ -70,30 +47,16 @@ export function ripplePhase(framesSinceClick: number): {
};
}
-/**
- * The momentary click press-dip for `framesSinceClick` into a click: dips
- * 1 → 0 → 1 over PRESS_FRAMES (a quick down-and-up), then holds at 1. Returned
- * as `pressScale` (1 = up, 0 = fully pressed). Pure; exported for tests.
- */
export function clickPress(framesSinceClick: number): number {
if (framesSinceClick < 0 || framesSinceClick >= PRESS_FRAMES) return 1;
const half = PRESS_FRAMES / 2;
const p =
framesSinceClick < half
- ? framesSinceClick / half // down
- : 1 - (framesSinceClick - half) / half; // up
+ ? framesSinceClick / half
+ : 1 - (framesSinceClick - half) / half;
return 1 - clamp01(p);
}
-/**
- * Resolve the cursor's `CursorStyle` for a path of waypoints. THIS is the only
- * frame-reading file in the component — `<Cursor>` itself stays pure. Mirrors
- * the value-channel deviation: instead of a string-state timeline it folds a
- * numeric position path plus click/press phases.
- *
- * The fold is a pure function of `raw = useCurrentFrame() * speed`; the tests
- * replicate `cursorPathAt(waypoints, raw, opts)` with the frame injected.
- */
export function useCursorPath(
waypoints: CursorWaypoint[],
opts: CursorPathOptions = {},
@@ -103,11 +66,6 @@ export function useCursorPath(
return cursorPathAt(waypoints, raw, opts);
}
-/**
- * Pure core of `useCursorPath` with the effective frame injected as `raw`. Kept
- * separate so it can be unit-tested without a Remotion render. `useCursorPath`
- * is exactly `cursorPathAt(waypoints, useCurrentFrame() * speed, opts)`.
- */
export function cursorPathAt(
waypoints: CursorWaypoint[],
raw: number,
@@ -119,10 +77,8 @@ export function cursorPathAt(
return { x: 0, y: 0, scale: 1, rippleOpacity: 0, rippleScale: 0 };
}
- // Authored order is the path order; `at` is the arrival frame of each point.
const first = waypoints[0];
- // Before the first arrival, the cursor waits parked at the first waypoint.
if (raw <= first.at) {
return {
x: first.x,
@@ -134,8 +90,6 @@ export function cursorPathAt(
};
}
- // Find the segment we're in: the move from waypoint i-1 into waypoint i, where
- // i is the first waypoint with at > raw. If none, we're resting at the last.
let toIndex = waypoints.length - 1;
for (let i = 1; i < waypoints.length; i++) {
if (waypoints[i].at > raw) {
@@ -143,7 +97,6 @@ export function cursorPathAt(
break;
}
}
- // If raw is past the last arrival, hold at the last waypoint.
const pastLast = raw >= waypoints[waypoints.length - 1].at;
const to = pastLast ? waypoints[waypoints.length - 1] : waypoints[toIndex];
const from = pastLast
@@ -152,14 +105,11 @@ export function cursorPathAt(
const dur = to.duration ?? defaultDuration;
const ease = easings[to.easing ?? "inOut"];
- // The move runs over [start, to.at); start = to.at - dur.
const start = to.at - dur;
const t = pastLast || dur <= 0 ? 1 : ease(clamp01((raw - start) / dur));
const x = lerp(from.x, to.x, t);
const y = lerp(from.y, to.y, t);
- // Click visuals: ripple + press-dip start at the arrival of any waypoint with
- // `click`. Find the most recent such arrival at or before `raw`.
let lastClickAt = -Infinity;
for (const wp of waypoints) {
if (wp.click && wp.at <= raw && wp.at > lastClickAt) lastClickAt = wp.at;
@@ -168,13 +118,9 @@ export function cursorPathAt(
const ripple = ripplePhase(sinceClick);
const clickDip = clickPress(sinceClick);
- // Held press (drag): the segment we're resting at / arrived from is `pressed`
- // when the waypoint that STARTED the current hold has `press: true`. We hold
- // the look from a `press` waypoint's arrival until the next waypoint arrives.
const holdWp = pastLast ? waypoints[waypoints.length - 1] : from;
const heldPress = holdWp.press ? 0 : 1;
- // Combine the momentary click dip with the held drag press (min = most down).
const pressScale = Math.min(clickDip, heldPress);
return {
diff --git a/registry/remocn-ui/dialog/__tests__/dialog.test.ts b/registry/remocn-ui/dialog/__tests__/dialog.test.ts
index 3638d491..04efc9d2 100644
--- a/registry/remocn-ui/dialog/__tests__/dialog.test.ts
+++ b/registry/remocn-ui/dialog/__tests__/dialog.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `dialog`.
- *
- * Scope:
- * - registry/remocn-ui/dialog/index.tsx — DialogState union membership,
- * dialogStyle presets, dialogStyleContext
- * - registry/remocn-ui/dialog/config.ts — dialogConfig.controls wiring
- * + dialogConfig.snippet output (the state → JSX codegen)
- * - registry/remocn-ui/dialog/use-dialog-transition.ts
- * — tweenDialogStyle interpolation, DEFAULT_DURATION
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * `<Dialog>` reads `useRemocnTheme()` internally — that hook is pure at
- * call-time in test context, but the JSX render tree is not exercised here.
- * The pure-testable surface is: the style presets + tween + customizer wiring
- * + snippet codegen.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/dialog/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `DialogState` from `@/registry/remocn-ui/dialog`
- * and the pieces under test never CALL a Remotion runtime API at import time —
- * `dialogConfig` is a plain object; `.snippet` is a pure string builder;
- * `dialogStyle` and `tweenDialogStyle` are pure value functions.
- * We import via RELATIVE paths (matching the existing test suite pattern),
- * annotating each import with the source it corresponds to.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -40,17 +9,8 @@ import { tweenDialogStyle, DEFAULT_DURATION } from "../use-dialog-transition";
import { dialogConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The DialogState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type DialogState` in index.tsx.
- */
const VALID_STATES: readonly DialogState[] = ["opened", "closed"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
title?: string;
@@ -63,28 +23,16 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
dialogConfig.snippet(values as Record<string, unknown>);
-/**
- * A shared DialogStyleContext built from the default light theme.
- * `dialogStyleContext` takes only `(theme)` — no variant arg, unlike accordion.
- */
const ctx = dialogStyleContext(defaultLightTheme);
-// ===========================================================================
-// 1. DialogState union membership
-// ===========================================================================
-
describe("DialogState union", () => {
it("contains exactly the two documented states", () => {
- // We can't enumerate a TS type at runtime, but we can assert the REAL
- // controls.state options match and that all known states are members.
const control = dialogConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(control.options).toEqual(["opened", "closed"]);
});
it("every VALID_STATES entry is assignable (no typos in the fixture)", () => {
- // Belt-and-suspenders: the fixture array must have exactly 2 entries and
- // match the options list from the real config.
const control = dialogConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(VALID_STATES).toHaveLength(2);
@@ -94,10 +42,6 @@ describe("DialogState union", () => {
});
});
-// ===========================================================================
-// 2. dialogConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("dialogConfig.controls.state", () => {
it("is a select control", () => {
expect(dialogConfig.controls.state.type).toBe("select");
@@ -123,15 +67,6 @@ describe("dialogConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. dialogConfig.snippet — pure string builder
-// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.
-// It NEVER emits `steps`.
-// Note on `action`: the snippet emits `actionLabel=` (a legitimate prop) but
-// must never emit a bare `action=` attribute. We assert `steps` is absent and
-// add a targeted check that `action=` only ever appears as `actionLabel=`.
-// ===========================================================================
-
describe("dialogConfig.snippet: state prop emission", () => {
it("emits state=\"opened\" for the opened option", () => {
expect(snippet({ state: "opened" })).toContain('state="opened"');
@@ -152,9 +87,6 @@ describe("dialogConfig.snippet: state prop emission", () => {
});
describe("dialogConfig.snippet: NEVER emits steps", () => {
- // `action=` is intentionally NOT checked here because `actionLabel=` is a
- // legitimate emitted prop and would cause a false positive on a naive
- // `.toContain("action")` check. Assert `steps` absence only.
it("never emits `steps` in any state", () => {
for (const state of VALID_STATES) {
expect(snippet({ state })).not.toContain("steps");
@@ -171,9 +103,6 @@ describe("dialogConfig.snippet: import line", () => {
});
describe("dialogConfig.snippet: default props are omitted", () => {
- // Defaults: title="Edit profile",
- // description="Make changes to your profile here. Click save when you're done.",
- // actionLabel="Save changes", cancelLabel="Cancel", mode="light"
const allDefaults = snippet({
state: "opened",
title: "Edit profile",
@@ -247,13 +176,6 @@ describe("dialogConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. dialogStyleContext — derives concrete colors from the theme.
-// Signature is `(theme)` — NO variant argument (unlike accordion).
-// Build ctx from the default light theme and assert each field is populated.
-// `radius` is a number (px); all other fields are non-empty strings.
-// ===========================================================================
-
describe("dialogStyleContext: field types from defaultLightTheme", () => {
it("popoverBg is a non-empty string", () => {
expect(typeof ctx.popoverBg).toBe("string");
@@ -295,13 +217,6 @@ describe("dialogStyleContext: field types from defaultLightTheme", () => {
});
});
-// ===========================================================================
-// 5. dialogStyle presets — pure (state, ctx) => DialogStyle
-// dialogStyleContext and dialogStyle are exported and frame-free.
-// Build one ctx from the default light theme, then assert the numeric
-// invariants for every state.
-// ===========================================================================
-
describe("dialogStyle: closed state", () => {
const s = dialogStyle("closed", ctx);
@@ -360,12 +275,6 @@ describe("dialogStyle: closed/opened invariant", () => {
});
});
-// ===========================================================================
-// 6. tweenDialogStyle — pure linear interpolation between two DialogStyles.
-// All four fields are pure numeric lerps (no color fields, unlike accordion).
-// Concrete expectations: closed → opened for midpoint math.
-// ===========================================================================
-
describe("tweenDialogStyle: t=0 returns values equal to `a`", () => {
const a = dialogStyle("closed", ctx);
const b = dialogStyle("opened", ctx);
@@ -411,8 +320,6 @@ describe("tweenDialogStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenDialogStyle: t=0.5 midpoint numeric lerp (closed → opened)", () => {
- // closed: overlayOpacity=0, popupOpacity=0, popupScale=0.95, popupTranslateY=8
- // opened: overlayOpacity=1, popupOpacity=1, popupScale=1, popupTranslateY=0
const a = dialogStyle("closed", ctx);
const b = dialogStyle("opened", ctx);
const r = tweenDialogStyle(a, b, 0.5);
@@ -435,8 +342,6 @@ describe("tweenDialogStyle: t=0.5 midpoint numeric lerp (closed → opened)", ()
});
describe("tweenDialogStyle: t=0.5 midpoint numeric lerp (opened → closed)", () => {
- // opened: overlayOpacity=1, popupOpacity=1, popupScale=1, popupTranslateY=0
- // closed: overlayOpacity=0, popupOpacity=0, popupScale=0.95, popupTranslateY=8
const a = dialogStyle("opened", ctx);
const b = dialogStyle("closed", ctx);
const r = tweenDialogStyle(a, b, 0.5);
@@ -458,10 +363,6 @@ describe("tweenDialogStyle: t=0.5 midpoint numeric lerp (opened → closed)", ()
});
});
-// ===========================================================================
-// 7. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
diff --git a/registry/remocn-ui/dialog/config.ts b/registry/remocn-ui/dialog/config.ts
index b61083d1..7b634110 100644
--- a/registry/remocn-ui/dialog/config.ts
+++ b/registry/remocn-ui/dialog/config.ts
@@ -22,7 +22,6 @@ export const dialogConfig: ComponentConfig = {
cancelLabel: { type: "text", default: "Cancel", label: "Cancel Label" },
state: {
type: "select",
- // Default to `opened` so the preview shows the popup.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/dialog/index.tsx b/registry/remocn-ui/dialog/index.tsx
index f255ca81..f24816c5 100644
--- a/registry/remocn-ui/dialog/index.tsx
+++ b/registry/remocn-ui/dialog/index.tsx
@@ -5,50 +5,27 @@ import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
export type DialogState = "opened" | "closed";
export interface DialogProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: DialogState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `DialogStyle` from `useDialogTransition`.
- */
style?: DialogStyle;
- /** Headline of the dialog. */
title?: string;
- /** Body copy under the title. */
description?: string;
- /** Label of the confirming (primary) action. */
actionLabel?: string;
- /** Label of the dismissing action. */
cancelLabel?: string;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Popup card width (px). */
const POPUP_WIDTH = 440;
-/** Backdrop dim at full reveal — the overlay opacity scales up to this alpha. */
const MAX_OVERLAY_ALPHA = 0.5;
-// ===========================================================================
-// Dialog visual — the COMPLETE animated look for a moment in time. A `state` is
-// a named preset of this visual (`dialogStyle`); the smooth path feeds an
-// interpolated `DialogStyle` straight through. The component is a pure renderer
-// of whichever `DialogStyle` it receives.
-// ===========================================================================
-
export interface DialogStyle {
- /** Backdrop dim reveal 0→1 (scales `MAX_OVERLAY_ALPHA`). */
overlayOpacity: number;
- /** Popup fade 0→1. */
popupOpacity: number;
- /** Popup zoom 0.95→1. */
popupScale: number;
- /** Popup lift 8→0 (px). */
popupTranslateY: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface DialogStyleContext {
popoverBg: string;
popoverFg: string;
@@ -60,10 +37,6 @@ export interface DialogStyleContext {
cancelFg: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `dialogStyle(state, ctx)` preset.
- */
export function dialogStyleContext(theme: RemocnTheme): DialogStyleContext {
return {
popoverBg: theme.popover,
@@ -71,17 +44,12 @@ export function dialogStyleContext(theme: RemocnTheme): DialogStyleContext {
mutedFg: theme.mutedForeground,
border: theme.border,
radius: theme.radius,
- // The action is the PRIMARY (affirmative) action — not destructive.
actionBg: theme.primary,
actionFg: theme.primaryForeground,
cancelFg: theme.foreground,
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => DialogStyle`
- * map. To change how a state looks, edit one entry.
- */
export function dialogStyle(
state: DialogState,
_ctx: DialogStyleContext,
@@ -120,10 +88,6 @@ export function Dialog({
const ctx = dialogStyleContext(theme);
const v = style ?? dialogStyle(state, ctx);
- // Shared base for the two footer buttons. These are plain inline `<button>`s,
- // not the remocn `Button` component — that renders a full-frame scene wrapper
- // (absolute inset) and so can't nest inline here; the sizing mirrors its
- // `default` size.
const buttonBase: React.CSSProperties = {
height: 40,
padding: "0 20px",
@@ -138,9 +102,6 @@ export function Dialog({
};
return (
- // The wrapper is TRANSPARENT — unlike button/accordion (which paint an
- // opaque `theme.background`), this atom is a modal layer meant to compose
- // OVER another scene, so it must not blanket the frame with a background.
<div
style={{
position: "absolute",
@@ -152,7 +113,7 @@ export function Dialog({
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
- {/* Backdrop dim — fades in as the dialog opens. */}
+ {}
<div
style={{
position: "absolute",
@@ -178,7 +139,7 @@ export function Dialog({
boxShadow: "0 24px 48px -12px rgba(0,0,0,0.25)",
}}
>
- {/* Close (X) — static chrome in the top-right corner, not animated. */}
+ {}
<button
type="button"
style={{
@@ -228,7 +189,7 @@ export function Dialog({
marginTop: 16,
}}
>
- {/* Cancel — outline variant. */}
+ {}
<button
type="button"
style={{
@@ -240,7 +201,7 @@ export function Dialog({
>
{cancelLabel}
</button>
- {/* Action — primary variant. */}
+ {}
<button
type="button"
style={{
diff --git a/registry/remocn-ui/dialog/use-dialog-transition.ts b/registry/remocn-ui/dialog/use-dialog-transition.ts
index 0605a0fe..688e7707 100644
--- a/registry/remocn-ui/dialog/use-dialog-transition.ts
+++ b/registry/remocn-ui/dialog/use-dialog-transition.ts
@@ -13,12 +13,9 @@ import {
type DialogState,
type DialogStyle,
} from "@/components/remocn/dialog";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 12;
-/** Blend two dialog visuals: all four fields are pure numeric lerps. */
export function tweenDialogStyle(
a: DialogStyle,
b: DialogStyle,
@@ -40,11 +37,6 @@ export interface DialogTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) DialogStyle. The CALLER invokes this;
- * it reads the frame, the `<Dialog>` component does not. Feed the result to
- * `<Dialog style={...} />` for smooth open/close transitions.
- */
export function useDialogTransition(
steps: Step<DialogState>[],
opts: DialogTransitionOptions = {},
diff --git a/registry/remocn-ui/drawer/__tests__/drawer.test.ts b/registry/remocn-ui/drawer/__tests__/drawer.test.ts
index 551a67ee..39d22414 100644
--- a/registry/remocn-ui/drawer/__tests__/drawer.test.ts
+++ b/registry/remocn-ui/drawer/__tests__/drawer.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `drawer`.
- *
- * Scope:
- * - registry/remocn-ui/drawer/index.tsx — DrawerState union membership,
- * drawerStyle presets, drawerStyleContext
- * - registry/remocn-ui/drawer/config.ts — drawerConfig.controls wiring
- * + drawerConfig.snippet output (the state → JSX codegen)
- * - registry/remocn-ui/drawer/use-drawer-transition.ts
- * — tweenDrawerStyle interpolation, DEFAULT_DURATION
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * `<Drawer>` 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/drawer/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `DrawerState` from `@/registry/remocn-ui/drawer`
- * and the pieces under test never CALL a Remotion runtime API at import time —
- * `drawerConfig` is a plain object; `.snippet` is a pure string builder;
- * `drawerStyle` and `tweenDrawerStyle` 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 {
@@ -40,17 +9,8 @@ import { tweenDrawerStyle, DEFAULT_DURATION } from "../use-drawer-transition";
import { drawerConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The DrawerState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type DrawerState` in index.tsx.
- */
const VALID_STATES: readonly DrawerState[] = ["opened", "closed"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
title?: string;
@@ -63,28 +23,16 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
drawerConfig.snippet(values as Record<string, unknown>);
-/**
- * A shared DrawerStyleContext built from the default light theme.
- * `drawerStyleContext` takes only `(theme)` — no variant arg, unlike accordion.
- */
const ctx = drawerStyleContext(defaultLightTheme);
-// ===========================================================================
-// 1. DrawerState union membership
-// ===========================================================================
-
describe("DrawerState 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 = drawerConfig.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 = drawerConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(VALID_STATES).toHaveLength(2);
@@ -94,10 +42,6 @@ describe("DrawerState union", () => {
});
});
-// ===========================================================================
-// 2. drawerConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("drawerConfig.controls.state", () => {
it("is a select control", () => {
expect(drawerConfig.controls.state.type).toBe("select");
@@ -123,15 +67,6 @@ describe("drawerConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. drawerConfig.snippet — pure string builder
-// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.
-// It NEVER emits `steps`.
-// Note on `action`: the snippet emits `actionLabel=` (a legitimate prop) but
-// must never emit a bare `action=` attribute. We assert `steps` is absent and
-// add a targeted check that `action=` only ever appears as `actionLabel=`.
-// ===========================================================================
-
describe("drawerConfig.snippet: state prop emission", () => {
it("emits state=\"opened\" for the opened option", () => {
expect(snippet({ state: "opened" })).toContain('state="opened"');
@@ -152,9 +87,6 @@ describe("drawerConfig.snippet: state prop emission", () => {
});
describe("drawerConfig.snippet: NEVER emits steps", () => {
- // `action=` is intentionally NOT checked here because `actionLabel=` is a
- // legitimate emitted prop and would cause a false positive on a naive
- // `.toContain("action")` check. Assert `steps` absence only.
it("never emits `steps` in any state", () => {
for (const state of VALID_STATES) {
expect(snippet({ state })).not.toContain("steps");
@@ -171,9 +103,6 @@ describe("drawerConfig.snippet: import line", () => {
});
describe("drawerConfig.snippet: default props are omitted", () => {
- // Defaults: title="Edit profile",
- // description="Make changes to your profile here. Click save when you're done.",
- // actionLabel="Save changes", cancelLabel="Cancel", mode="light"
const allDefaults = snippet({
state: "opened",
title: "Edit profile",
@@ -247,13 +176,6 @@ describe("drawerConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. drawerStyleContext — derives concrete colors from the theme.
-// Signature is `(theme)` — NO variant argument (unlike accordion).
-// Build ctx from the default light theme and assert each field is populated.
-// `radius` is a number (px); all other fields are non-empty strings.
-// ===========================================================================
-
describe("drawerStyleContext: field types from defaultLightTheme", () => {
it("popoverBg is a non-empty string", () => {
expect(typeof ctx.popoverBg).toBe("string");
@@ -295,13 +217,6 @@ describe("drawerStyleContext: field types from defaultLightTheme", () => {
});
});
-// ===========================================================================
-// 5. drawerStyle presets — pure (state, ctx) => DrawerStyle
-// drawerStyleContext and drawerStyle are exported and frame-free.
-// Build one ctx from the default light theme, then assert the numeric
-// invariants for every state.
-// ===========================================================================
-
describe("drawerStyle: closed state", () => {
const s = drawerStyle("closed", ctx);
@@ -350,12 +265,6 @@ describe("drawerStyle: closed/opened invariant", () => {
});
});
-// ===========================================================================
-// 6. tweenDrawerStyle — pure linear interpolation between two DrawerStyles.
-// All three fields are pure numeric lerps (no color fields, unlike accordion).
-// Concrete expectations: closed → opened for midpoint math.
-// ===========================================================================
-
describe("tweenDrawerStyle: t=0 returns values equal to `a`", () => {
const a = drawerStyle("closed", ctx);
const b = drawerStyle("opened", ctx);
@@ -393,8 +302,6 @@ describe("tweenDrawerStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenDrawerStyle: t=0.5 midpoint numeric lerp (closed → opened)", () => {
- // closed: overlayOpacity=0, panelOpacity=0, panelTranslateY=320
- // opened: overlayOpacity=1, panelOpacity=1, panelTranslateY=0
const a = drawerStyle("closed", ctx);
const b = drawerStyle("opened", ctx);
const r = tweenDrawerStyle(a, b, 0.5);
@@ -413,8 +320,6 @@ describe("tweenDrawerStyle: t=0.5 midpoint numeric lerp (closed → opened)", ()
});
describe("tweenDrawerStyle: t=0.5 midpoint numeric lerp (opened → closed)", () => {
- // opened: overlayOpacity=1, panelOpacity=1, panelTranslateY=0
- // closed: overlayOpacity=0, panelOpacity=0, panelTranslateY=320
const a = drawerStyle("opened", ctx);
const b = drawerStyle("closed", ctx);
const r = tweenDrawerStyle(a, b, 0.5);
@@ -432,10 +337,6 @@ describe("tweenDrawerStyle: t=0.5 midpoint numeric lerp (opened → closed)", ()
});
});
-// ===========================================================================
-// 7. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
diff --git a/registry/remocn-ui/drawer/config.ts b/registry/remocn-ui/drawer/config.ts
index 7d4dd55e..d9229e0c 100644
--- a/registry/remocn-ui/drawer/config.ts
+++ b/registry/remocn-ui/drawer/config.ts
@@ -22,7 +22,6 @@ export const drawerConfig: ComponentConfig = {
cancelLabel: { type: "text", default: "Cancel", label: "Cancel Label" },
state: {
type: "select",
- // Default to `opened` so the preview shows the panel.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/drawer/index.tsx b/registry/remocn-ui/drawer/index.tsx
index 7b1e57f1..7b0d71ac 100644
--- a/registry/remocn-ui/drawer/index.tsx
+++ b/registry/remocn-ui/drawer/index.tsx
@@ -5,48 +5,26 @@ import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
export type DrawerState = "opened" | "closed";
export interface DrawerProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: DrawerState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `DrawerStyle` from `useDrawerTransition`.
- */
style?: DrawerStyle;
- /** Headline of the drawer. */
title?: string;
- /** Body copy under the title. */
description?: string;
- /** Label of the confirming (primary) action. */
actionLabel?: string;
- /** Label of the dismissing action. */
cancelLabel?: string;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Drawer panel height (px) — also the off-screen-bottom translate distance. */
const DRAWER_HEIGHT = 320;
-/** Backdrop dim at full reveal — the overlay opacity scales up to this alpha. */
const MAX_OVERLAY_ALPHA = 0.5;
-// ===========================================================================
-// Drawer visual — the COMPLETE animated look for a moment in time. A `state` is
-// a named preset of this visual (`drawerStyle`); the smooth path feeds an
-// interpolated `DrawerStyle` straight through. The component is a pure renderer
-// of whichever `DrawerStyle` it receives.
-// ===========================================================================
-
export interface DrawerStyle {
- /** Backdrop dim reveal 0→1 (scales `MAX_OVERLAY_ALPHA`). */
overlayOpacity: number;
- /** Panel fade 0→1. */
panelOpacity: number;
- /** Panel slide (px): `DRAWER_HEIGHT` = off-screen bottom → 0 = resting. */
panelTranslateY: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface DrawerStyleContext {
popoverBg: string;
popoverFg: string;
@@ -58,10 +36,6 @@ export interface DrawerStyleContext {
cancelFg: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `drawerStyle(state, ctx)` preset.
- */
export function drawerStyleContext(theme: RemocnTheme): DrawerStyleContext {
return {
popoverBg: theme.popover,
@@ -69,17 +43,12 @@ export function drawerStyleContext(theme: RemocnTheme): DrawerStyleContext {
mutedFg: theme.mutedForeground,
border: theme.border,
radius: theme.radius,
- // The action is the PRIMARY (affirmative) action — not destructive.
actionBg: theme.primary,
actionFg: theme.primaryForeground,
cancelFg: theme.foreground,
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => DrawerStyle`
- * map. To change how a state looks, edit one entry.
- */
export function drawerStyle(
state: DrawerState,
_ctx: DrawerStyleContext,
@@ -116,10 +85,6 @@ export function Drawer({
const ctx = drawerStyleContext(theme);
const v = style ?? drawerStyle(state, ctx);
- // Shared base for the two footer buttons. These are plain inline `<button>`s,
- // not the remocn `Button` component — that renders a full-frame scene wrapper
- // (absolute inset) and so can't nest inline here; the sizing mirrors its
- // `default` size.
const buttonBase: React.CSSProperties = {
height: 40,
padding: "0 20px",
@@ -134,9 +99,6 @@ export function Drawer({
};
return (
- // The wrapper is TRANSPARENT — unlike button/accordion (which paint an
- // opaque `theme.background`), this atom is a modal layer meant to compose
- // OVER another scene, so it must not blanket the frame with a background.
<div
style={{
position: "absolute",
@@ -145,7 +107,7 @@ export function Drawer({
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
- {/* Backdrop dim — fades in as the drawer opens. */}
+ {}
<div
style={{
position: "absolute",
@@ -153,7 +115,7 @@ export function Drawer({
background: `rgba(0, 0, 0, ${MAX_OVERLAY_ALPHA * v.overlayOpacity})`,
}}
/>
- {/* The panel — anchored to the bottom edge, full width, slides up. */}
+ {}
<div
className={className}
style={{
@@ -177,7 +139,7 @@ export function Drawer({
boxShadow: "0 -24px 48px -12px rgba(0,0,0,0.25)",
}}
>
- {/* Drag-handle pill — static chrome at the top, not animated. */}
+ {}
<div
style={{
width: 40,
@@ -187,7 +149,7 @@ export function Drawer({
marginBottom: 8,
}}
/>
- {/* Centered content column with a max width. */}
+ {}
<div
style={{
width: "100%",
@@ -217,7 +179,7 @@ export function Drawer({
marginTop: 16,
}}
>
- {/* Cancel — outline variant. */}
+ {}
<button
type="button"
style={{
@@ -229,7 +191,7 @@ export function Drawer({
>
{cancelLabel}
</button>
- {/* Action — primary variant. */}
+ {}
<button
type="button"
style={{
diff --git a/registry/remocn-ui/drawer/use-drawer-transition.ts b/registry/remocn-ui/drawer/use-drawer-transition.ts
index f14f96c9..ab07343a 100644
--- a/registry/remocn-ui/drawer/use-drawer-transition.ts
+++ b/registry/remocn-ui/drawer/use-drawer-transition.ts
@@ -13,12 +13,9 @@ import {
type DrawerState,
type DrawerStyle,
} from "@/components/remocn/drawer";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 12;
-/** Blend two drawer visuals: all three fields are pure numeric lerps. */
export function tweenDrawerStyle(
a: DrawerStyle,
b: DrawerStyle,
@@ -39,11 +36,6 @@ export interface DrawerTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) DrawerStyle. The CALLER invokes this;
- * it reads the frame, the `<Drawer>` component does not. Feed the result to
- * `<Drawer style={...} />` for smooth open/close transitions.
- */
export function useDrawerTransition(
steps: Step<DrawerState>[],
opts: DrawerTransitionOptions = {},
diff --git a/registry/remocn-ui/dropdown-menu-item/__tests__/dropdown-menu-item.test.ts b/registry/remocn-ui/dropdown-menu-item/__tests__/dropdown-menu-item.test.ts
index 22247402..e2a14492 100644
--- a/registry/remocn-ui/dropdown-menu-item/__tests__/dropdown-menu-item.test.ts
+++ b/registry/remocn-ui/dropdown-menu-item/__tests__/dropdown-menu-item.test.ts
@@ -1,35 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `dropdown-menu-item`.
- *
- * Scope:
- * - registry/remocn-ui/dropdown-menu-item/index.tsx — DropdownMenuItemState
- * union membership, dropdownMenuItemStyle presets, dropdownMenuItemStyleContext
- * - registry/remocn-ui/dropdown-menu-item/config.ts — dropdownMenuItemConfig
- * .controls wiring + .snippet output (the state → JSX codegen)
- * - registry/remocn-ui/dropdown-menu-item/use-dropdown-menu-item-transition.ts
- * — tweenDropdownMenuItemStyle interpolation, DEFAULT_DURATION
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * `<DropdownMenuItem>` 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/dropdown-menu-item/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `DropdownMenuItemState` from
- * `@/registry/remocn-ui/dropdown-menu-item` and the pieces under test never
- * CALL a Remotion runtime API at import time — `dropdownMenuItemConfig` is a
- * plain object; `.snippet` is a pure string builder; `dropdownMenuItemStyle`
- * and `tweenDropdownMenuItemStyle` 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 {
@@ -41,17 +9,8 @@ import { tweenDropdownMenuItemStyle, DEFAULT_DURATION } from "../use-dropdown-me
import { dropdownMenuItemConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The DropdownMenuItemState union, enumerated as a runtime list for membership
- * checks. Must stay in sync with `export type DropdownMenuItemState` in index.tsx.
- */
const VALID_STATES: readonly DropdownMenuItemState[] = ["idle", "hover", "press"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
label?: string;
@@ -61,16 +20,8 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
dropdownMenuItemConfig.snippet(values as Record<string, unknown>);
-/**
- * A shared DropdownMenuItemStyleContext built from the default light theme.
- * `dropdownMenuItemStyleContext` takes only `(theme)` — no variant arg.
- */
const ctx = dropdownMenuItemStyleContext(defaultLightTheme);
-// ===========================================================================
-// 1. DropdownMenuItemState union membership
-// ===========================================================================
-
describe("DropdownMenuItemState union", () => {
it("contains exactly the three documented states", () => {
const control = dropdownMenuItemConfig.controls.state;
@@ -88,10 +39,6 @@ describe("DropdownMenuItemState union", () => {
});
});
-// ===========================================================================
-// 2. dropdownMenuItemConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("dropdownMenuItemConfig.controls.state", () => {
it("is a select control", () => {
expect(dropdownMenuItemConfig.controls.state.type).toBe("select");
@@ -117,11 +64,6 @@ describe("dropdownMenuItemConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. dropdownMenuItemConfig.snippet — pure string builder
-// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.
-// ===========================================================================
-
describe("dropdownMenuItemConfig.snippet: state prop emission", () => {
it("emits state=\"idle\" for the idle option", () => {
expect(snippet({ state: "idle" })).toContain('state="idle"');
@@ -154,7 +96,6 @@ describe("dropdownMenuItemConfig.snippet: import line", () => {
});
describe("dropdownMenuItemConfig.snippet: default props are omitted", () => {
- // Defaults: label="Profile", mode="light"
const allDefaults = snippet({
state: "hover",
label: "Profile",
@@ -198,12 +139,6 @@ describe("dropdownMenuItemConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. dropdownMenuItemStyleContext — derives concrete colors from the theme.
-// Signature is `(theme)` — NO variant argument.
-// Build ctx from the default light theme and assert each field is populated.
-// ===========================================================================
-
describe("dropdownMenuItemStyleContext: field types from defaultLightTheme", () => {
it("idleBg is a non-empty string", () => {
expect(typeof ctx.idleBg).toBe("string");
@@ -240,12 +175,6 @@ describe("dropdownMenuItemStyleContext: maps theme tokens correctly", () => {
});
});
-// ===========================================================================
-// 5. dropdownMenuItemStyle presets — pure (state, ctx) => DropdownMenuItemStyle
-// No check icon, no `selected` state (3 states only).
-// Build one ctx from the default light theme, then assert the numeric invariants.
-// ===========================================================================
-
describe("dropdownMenuItemStyle: idle state", () => {
const s = dropdownMenuItemStyle("idle", ctx);
@@ -308,12 +237,6 @@ describe("dropdownMenuItemStyle: scale invariant summary", () => {
});
});
-// ===========================================================================
-// 6. tweenDropdownMenuItemStyle — pure interpolation between two
-// DropdownMenuItemStyles. Numeric fields lerp; color fields via mixOklch.
-// Concrete expectations: idle → press for scale midpoint math.
-// ===========================================================================
-
describe("tweenDropdownMenuItemStyle: t=0 returns values equal to `a`", () => {
const a = dropdownMenuItemStyle("idle", ctx);
const b = dropdownMenuItemStyle("press", ctx);
@@ -355,8 +278,6 @@ describe("tweenDropdownMenuItemStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenDropdownMenuItemStyle: t=0.5 midpoint numeric lerp (idle → press)", () => {
- // idle: scale=1
- // press: scale=0.98
const a = dropdownMenuItemStyle("idle", ctx);
const b = dropdownMenuItemStyle("press", ctx);
const r = tweenDropdownMenuItemStyle(a, b, 0.5);
@@ -367,8 +288,6 @@ describe("tweenDropdownMenuItemStyle: t=0.5 midpoint numeric lerp (idle → pres
});
describe("tweenDropdownMenuItemStyle: t=0.5 midpoint numeric lerp (hover → idle)", () => {
- // hover: scale=1
- // idle: scale=1
const a = dropdownMenuItemStyle("hover", ctx);
const b = dropdownMenuItemStyle("idle", ctx);
const r = tweenDropdownMenuItemStyle(a, b, 0.5);
@@ -378,10 +297,6 @@ describe("tweenDropdownMenuItemStyle: t=0.5 midpoint numeric lerp (hover → idl
});
});
-// ===========================================================================
-// 7. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
diff --git a/registry/remocn-ui/dropdown-menu-item/config.ts b/registry/remocn-ui/dropdown-menu-item/config.ts
index 3f96caa4..ba550c9d 100644
--- a/registry/remocn-ui/dropdown-menu-item/config.ts
+++ b/registry/remocn-ui/dropdown-menu-item/config.ts
@@ -8,7 +8,6 @@ export const dropdownMenuItemConfig: ComponentConfig = {
label: { type: "text", default: "Profile", label: "Label" },
state: {
type: "select",
- // Default to `hover` so the preview shows the highlighted row.
default: "hover",
options: ["idle", "hover", "press"],
label: "State",
diff --git a/registry/remocn-ui/dropdown-menu-item/index.tsx b/registry/remocn-ui/dropdown-menu-item/index.tsx
index 9008e123..5fd553a5 100644
--- a/registry/remocn-ui/dropdown-menu-item/index.tsx
+++ b/registry/remocn-ui/dropdown-menu-item/index.tsx
@@ -4,23 +4,12 @@ import { mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
export type DropdownMenuItemState = "idle" | "hover" | "press";
-// ===========================================================================
-// Dropdown-menu-item visual — the COMPLETE animated look for a moment in time.
-// A `state` is a named preset of this visual (`dropdownMenuItemStyle`); the
-// smooth path feeds an interpolated `DropdownMenuItemStyle` straight through.
-// The component is a pure renderer of whichever style it receives.
-// ===========================================================================
-
export interface DropdownMenuItemStyle {
- /** Animated row background. */
background: string;
- /** Animated label color. */
labelColor: string;
- /** Row scale: 1 default, 0.98 on press. */
scale: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface DropdownMenuItemStyleContext {
idleBg: string;
hoverBg: string;
@@ -28,10 +17,6 @@ export interface DropdownMenuItemStyleContext {
idleFg: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `dropdownMenuItemStyle(state, ctx)` preset.
- */
export function dropdownMenuItemStyleContext(
theme: RemocnTheme,
): DropdownMenuItemStyleContext {
@@ -43,11 +28,6 @@ export function dropdownMenuItemStyleContext(
};
}
-/**
- * The COMPLETE resting visual for a state — a pure
- * `(state, ctx) => DropdownMenuItemStyle` map. To change how a state looks,
- * edit one entry.
- */
export function dropdownMenuItemStyle(
state: DropdownMenuItemState,
ctx: DropdownMenuItemStyleContext,
@@ -62,26 +42,17 @@ export function dropdownMenuItemStyle(
}
}
-/** Default row width (px) — matches the dropdown-menu panel. */
const ROW_WIDTH = 240;
export interface DropdownMenuItemRowProps {
- /** Resolved animated visual (smooth path); takes precedence over `state`. */
style?: DropdownMenuItemStyle;
- /** Current visual state (snap path). */
state?: DropdownMenuItemState;
label?: string;
- /** Row width in px. */
width?: number;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
}
-/**
- * INLINE option row — no full-frame wrapper. Renders one menu row: padding
- * `8px 12px`, `borderRadius: theme.radius - 2`, label left. This is the shared
- * visual that `DropdownMenu` reuses for its panel rows.
- */
export function DropdownMenuItemRow({
style,
state = "idle",
@@ -119,11 +90,6 @@ export interface DropdownMenuItemProps extends DropdownMenuItemRowProps {
className?: string;
}
-/**
- * The standalone registered atom — resolves theme/ctx/style then wraps
- * `<DropdownMenuItemRow>` in the standard full-frame centering wrapper. This is
- * what the registry registers and the customizer mounts.
- */
export function DropdownMenuItem({
style,
state = "idle",
diff --git a/registry/remocn-ui/dropdown-menu-item/use-dropdown-menu-item-transition.ts b/registry/remocn-ui/dropdown-menu-item/use-dropdown-menu-item-transition.ts
index 65706d3f..493bfb19 100644
--- a/registry/remocn-ui/dropdown-menu-item/use-dropdown-menu-item-transition.ts
+++ b/registry/remocn-ui/dropdown-menu-item/use-dropdown-menu-item-transition.ts
@@ -14,12 +14,9 @@ import {
type DropdownMenuItemState,
type DropdownMenuItemStyle,
} from "@/components/remocn/dropdown-menu-item";
-// ^ 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 = 8;
-/** Blend two row visuals: numbers lerp, colors via oklch mix. */
export function tweenDropdownMenuItemStyle(
a: DropdownMenuItemStyle,
b: DropdownMenuItemStyle,
@@ -40,11 +37,6 @@ export interface DropdownMenuItemTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) DropdownMenuItemStyle. The CALLER invokes
- * this; it reads the frame, the row component does not. Feed the result to
- * `<DropdownMenuItemRow style={...} />` (or the panel rows) for smooth transitions.
- */
export function useDropdownMenuItemTransition(
steps: Step<DropdownMenuItemState>[],
opts: DropdownMenuItemTransitionOptions = {},
diff --git a/registry/remocn-ui/dropdown-menu/__tests__/dropdown-menu.test.ts b/registry/remocn-ui/dropdown-menu/__tests__/dropdown-menu.test.ts
index 73a470bc..5028c6ba 100644
--- a/registry/remocn-ui/dropdown-menu/__tests__/dropdown-menu.test.ts
+++ b/registry/remocn-ui/dropdown-menu/__tests__/dropdown-menu.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `dropdown-menu`.
- *
- * Scope:
- * - registry/remocn-ui/dropdown-menu/index.tsx — DropdownMenuState union
- * membership, dropdownMenuStyle presets, dropdownMenuStyleContext
- * - registry/remocn-ui/dropdown-menu/config.ts — dropdownMenuConfig.controls
- * wiring + .snippet output (the state → JSX codegen)
- * - registry/remocn-ui/dropdown-menu/use-dropdown-menu-transition.ts
- * — tweenDropdownMenuStyle interpolation, DEFAULT_DURATION
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * `<DropdownMenu>` 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/dropdown-menu/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `DropdownMenuState` from `@/registry/remocn-ui/dropdown-menu`
- * and the pieces under test never CALL a Remotion runtime API at import time —
- * `dropdownMenuConfig` is a plain object; `.snippet` is a pure string builder;
- * `dropdownMenuStyle` and `tweenDropdownMenuStyle` 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 {
@@ -40,17 +9,8 @@ import { tweenDropdownMenuStyle, DEFAULT_DURATION } from "../use-dropdown-menu-t
import { dropdownMenuConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The DropdownMenuState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type DropdownMenuState` in index.tsx.
- */
const VALID_STATES: readonly DropdownMenuState[] = ["opened", "closed"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
label?: string;
@@ -61,16 +21,8 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
dropdownMenuConfig.snippet(values as Record<string, unknown>);
-/**
- * A shared DropdownMenuStyleContext built from the default light theme.
- * `dropdownMenuStyleContext` takes only `(theme)` — no variant arg.
- */
const ctx = dropdownMenuStyleContext(defaultLightTheme);
-// ===========================================================================
-// 1. DropdownMenuState union membership
-// ===========================================================================
-
describe("DropdownMenuState union", () => {
it("contains exactly the two documented states", () => {
const control = dropdownMenuConfig.controls.state;
@@ -88,10 +40,6 @@ describe("DropdownMenuState union", () => {
});
});
-// ===========================================================================
-// 2. dropdownMenuConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("dropdownMenuConfig.controls.state", () => {
it("is a select control", () => {
expect(dropdownMenuConfig.controls.state.type).toBe("select");
@@ -117,11 +65,6 @@ describe("dropdownMenuConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. dropdownMenuConfig.snippet — pure string builder
-// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.
-// ===========================================================================
-
describe("dropdownMenuConfig.snippet: state prop emission", () => {
it("emits state=\"opened\" for the opened option", () => {
expect(snippet({ state: "opened" })).toContain('state="opened"');
@@ -150,9 +93,6 @@ describe("dropdownMenuConfig.snippet: import line", () => {
});
describe("dropdownMenuConfig.snippet: default props are omitted", () => {
- // Defaults: label="Options", highlightedIndex=-1, mode="light"
- // Note: config default for highlightedIndex is 0, but the omit condition is !== -1,
- // so highlightedIndex=0 IS emitted. We test the -1 case here (the condition boundary).
const allDefaults = snippet({
state: "opened",
label: "Options",
@@ -206,13 +146,6 @@ describe("dropdownMenuConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. dropdownMenuStyleContext — derives concrete colors from the theme.
-// Signature is `(theme)` — NO variant argument.
-// Build ctx from the default light theme and assert each field is populated.
-// `radius` is a number; all other non-nested fields are non-empty strings.
-// ===========================================================================
-
describe("dropdownMenuStyleContext: field types from defaultLightTheme", () => {
it("panelBg is a non-empty string", () => {
expect(typeof ctx.panelBg).toBe("string");
@@ -271,13 +204,6 @@ describe("dropdownMenuStyleContext: maps theme tokens correctly", () => {
});
});
-// ===========================================================================
-// 5. dropdownMenuStyle presets — pure (state, ctx) => DropdownMenuStyle
-// All four fields are numeric. Assert per-state invariants:
-// opened → { panelOpacity:1, panelScale:1, panelTranslateY:0, chevronRotation:180 }
-// closed → { panelOpacity:0, panelScale:0.96, panelTranslateY:-4, chevronRotation:0 }
-// ===========================================================================
-
describe("dropdownMenuStyle: opened state", () => {
const s = dropdownMenuStyle("opened", ctx);
@@ -336,12 +262,6 @@ describe("dropdownMenuStyle: closed/opened invariant", () => {
});
});
-// ===========================================================================
-// 6. tweenDropdownMenuStyle — pure linear interpolation between two
-// DropdownMenuStyles. All four fields are pure numeric lerps.
-// Concrete expectations: closed → opened for midpoint math.
-// ===========================================================================
-
describe("tweenDropdownMenuStyle: t=0 returns values equal to `a`", () => {
const a = dropdownMenuStyle("closed", ctx);
const b = dropdownMenuStyle("opened", ctx);
@@ -387,8 +307,6 @@ describe("tweenDropdownMenuStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenDropdownMenuStyle: t=0.5 midpoint numeric lerp (closed → opened)", () => {
- // closed: panelOpacity=0, panelScale=0.96, panelTranslateY=-4, chevronRotation=0
- // opened: panelOpacity=1, panelScale=1, panelTranslateY=0, chevronRotation=180
const a = dropdownMenuStyle("closed", ctx);
const b = dropdownMenuStyle("opened", ctx);
const r = tweenDropdownMenuStyle(a, b, 0.5);
@@ -411,8 +329,6 @@ describe("tweenDropdownMenuStyle: t=0.5 midpoint numeric lerp (closed → opened
});
describe("tweenDropdownMenuStyle: t=0.5 midpoint numeric lerp (opened → closed)", () => {
- // opened: panelOpacity=1, panelScale=1, panelTranslateY=0, chevronRotation=180
- // closed: panelOpacity=0, panelScale=0.96, panelTranslateY=-4, chevronRotation=0
const a = dropdownMenuStyle("opened", ctx);
const b = dropdownMenuStyle("closed", ctx);
const r = tweenDropdownMenuStyle(a, b, 0.5);
@@ -434,10 +350,6 @@ describe("tweenDropdownMenuStyle: t=0.5 midpoint numeric lerp (opened → closed
});
});
-// ===========================================================================
-// 7. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
diff --git a/registry/remocn-ui/dropdown-menu/config.ts b/registry/remocn-ui/dropdown-menu/config.ts
index c085fdf8..55ff4e76 100644
--- a/registry/remocn-ui/dropdown-menu/config.ts
+++ b/registry/remocn-ui/dropdown-menu/config.ts
@@ -8,7 +8,6 @@ export const dropdownMenuConfig: ComponentConfig = {
label: { type: "text", default: "Options", label: "Label" },
state: {
type: "select",
- // Default to `opened` so the preview shows the panel.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/dropdown-menu/index.tsx b/registry/remocn-ui/dropdown-menu/index.tsx
index f5896f8f..44754381 100644
--- a/registry/remocn-ui/dropdown-menu/index.tsx
+++ b/registry/remocn-ui/dropdown-menu/index.tsx
@@ -17,41 +17,23 @@ import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
export type DropdownMenuState = "opened" | "closed";
-// ===========================================================================
-// Dropdown-menu visual — the COMPLETE animated look for a moment in time. A
-// `state` is a named preset of this visual (`dropdownMenuStyle`); the smooth
-// path feeds an interpolated `DropdownMenuStyle` straight through. The
-// component is a pure renderer of whichever style it receives.
-// ===========================================================================
-
export interface DropdownMenuStyle {
- /** Panel fade 0 (closed) → 1 (opened). */
panelOpacity: number;
- /** Panel zoom 0.96 (closed) → 1 (opened). */
panelScale: number;
- /** Panel lift -4 (closed) → 0 (opened) px. */
panelTranslateY: number;
- /** Trigger chevron rotation: 0 (closed) → 180 (opened) deg. */
chevronRotation: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface DropdownMenuStyleContext {
- /** Trigger reuses the Button `outline` variant look. */
triggerCtx: ButtonStyleContext;
panelBg: string;
panelBorder: string;
triggerFg: string;
mutedFg: string;
radius: number;
- /** Row presets for the panel items. */
itemCtx: DropdownMenuItemStyleContext;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `dropdownMenuStyle(state, ctx)` preset.
- */
export function dropdownMenuStyleContext(
theme: RemocnTheme,
): DropdownMenuStyleContext {
@@ -66,11 +48,6 @@ export function dropdownMenuStyleContext(
};
}
-/**
- * The COMPLETE resting visual for a state — a pure
- * `(state, ctx) => DropdownMenuStyle` map. To change how a state looks, edit
- * one entry.
- */
export function dropdownMenuStyle(
state: DropdownMenuState,
_ctx: DropdownMenuStyleContext,
@@ -93,36 +70,16 @@ export function dropdownMenuStyle(
}
}
-/** Trigger + panel width (px). */
const WIDTH = 240;
export interface DropdownMenuProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: DropdownMenuState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence
- * over `state` — feed it an interpolated `DropdownMenuStyle` from
- * `useDropdownMenuTransition`.
- */
style?: DropdownMenuStyle;
- /** Trigger label. */
label?: string;
- /** Menu rows. */
items?: string[];
- /** Row currently highlighted (hover); `-1` for none. */
highlightedIndex?: number;
- /** Row currently pressed; `-1` for none. */
pressedIndex?: number;
- /**
- * Smooth per-row override. When an entry is present it wins over the
- * index→state derivation, letting the example tween a single row.
- */
itemStyles?: (DropdownMenuItemStyle | undefined)[];
- /**
- * Resolved Button visual for the trigger (smooth path). Drive it with
- * `useButtonTransition` for a hover/press "click". Defaults to the resting
- * Button `outline` look.
- */
triggerStyle?: ButtonStyle;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
@@ -147,18 +104,12 @@ export function DropdownMenu({
const ctx = dropdownMenuStyleContext(theme);
const v = style ?? dropdownMenuStyle(state, ctx);
- // The trigger reuses the Button `outline` look: its resting visual provides
- // the background + transform; the foreground/border come from the theme.
- // A driven `triggerStyle` (from `useButtonTransition`) overrides the resting
- // look so the trigger can animate a hover/press "click".
const trigger = triggerStyle ?? buttonStyle("idle", ctx.triggerCtx);
return (
<div
className={className}
style={{
- // Opaque — a menu is a self-contained widget (like Button/Accordion),
- // not a modal overlay.
position: "absolute",
inset: 0,
display: "flex",
@@ -171,7 +122,7 @@ export function DropdownMenu({
}}
>
<div style={{ position: "relative", width: WIDTH }}>
- {/* Trigger — the Button `outline` visual, inline-nestable. */}
+ {}
<div
style={{
display: "flex",
@@ -212,8 +163,7 @@ export function DropdownMenu({
/>
</svg>
</div>
- {/* Panel — sits below the trigger; opacity/scale/translateY animate the
- reveal, transformOrigin top so it grows downward. */}
+ {}
<div
style={{
position: "absolute",
diff --git a/registry/remocn-ui/dropdown-menu/use-dropdown-menu-transition.ts b/registry/remocn-ui/dropdown-menu/use-dropdown-menu-transition.ts
index a8c7db5a..e2d9ffe5 100644
--- a/registry/remocn-ui/dropdown-menu/use-dropdown-menu-transition.ts
+++ b/registry/remocn-ui/dropdown-menu/use-dropdown-menu-transition.ts
@@ -13,12 +13,9 @@ import {
type DropdownMenuState,
type DropdownMenuStyle,
} from "@/components/remocn/dropdown-menu";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 12;
-/** Blend two menu visuals: all fields are numbers, so lerp each. */
export function tweenDropdownMenuStyle(
a: DropdownMenuStyle,
b: DropdownMenuStyle,
@@ -42,11 +39,6 @@ export interface DropdownMenuTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) DropdownMenuStyle. The CALLER invokes
- * this; it reads the frame, the `<DropdownMenu>` component does not. Feed the
- * result to `<DropdownMenu style={...} />` for smooth transitions.
- */
export function useDropdownMenuTransition(
steps: Step<DropdownMenuState>[],
opts: DropdownMenuTransitionOptions = {},
diff --git a/registry/remocn-ui/field/index.tsx b/registry/remocn-ui/field/index.tsx
index bec4d7fa..50e2b01f 100644
--- a/registry/remocn-ui/field/index.tsx
+++ b/registry/remocn-ui/field/index.tsx
@@ -3,23 +3,12 @@
import type { CSSProperties, ReactNode } from "react";
import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
-/**
- * Field — a small, static layout family for composing labeled form controls,
- * modeled on shadcn's Field (FieldGroup ▸ Field ▸ FieldLabel / control /
- * FieldDescription). It reads no frame and holds no state; colors come from the
- * resolved theme. Stack note: remocn-ui controls (Input, Button) render
- * `position:absolute; inset:0`, so a control goes inside `FieldControl` — a
- * relative, fixed-height slot the absolute atom fills.
- */
-
export interface FieldGroupProps {
children: ReactNode;
- /** Vertical space (px) between stacked fields. */
gap?: number;
style?: CSSProperties;
}
-/** Stacks multiple `Field`s in a column with uniform vertical rhythm. */
export function FieldGroup({ children, gap = 16, style }: FieldGroupProps) {
return (
<div style={{ display: "flex", flexDirection: "column", gap, ...style }}>
@@ -30,12 +19,10 @@ export function FieldGroup({ children, gap = 16, style }: FieldGroupProps) {
export interface FieldProps {
children: ReactNode;
- /** Vertical space (px) between the label, control, and description. */
gap?: number;
style?: CSSProperties;
}
-/** One field: label + control + optional description, stacked. */
export function Field({ children, gap = 6, style }: FieldProps) {
return (
<div style={{ display: "flex", flexDirection: "column", gap, ...style }}>
@@ -51,7 +38,6 @@ export interface FieldLabelProps {
style?: CSSProperties;
}
-/** Field label — foreground, medium weight. Single line (predictable height). */
export function FieldLabel({ children, mode, theme, style }: FieldLabelProps) {
const t = useRemocnTheme(theme, mode);
return (
@@ -72,14 +58,12 @@ export function FieldLabel({ children, mode, theme, style }: FieldLabelProps) {
export interface FieldDescriptionProps {
children: ReactNode;
- /** Text alignment within the field column. */
align?: "start" | "center";
mode?: "light" | "dark";
theme?: Partial<RemocnTheme>;
style?: CSSProperties;
}
-/** Muted helper text under a control (or a centered footer line). */
export function FieldDescription({
children,
align = "start",
@@ -105,15 +89,10 @@ export function FieldDescription({
export interface FieldControlProps {
children: ReactNode;
- /** Slot height (px) — the absolute control fills it. Matches the control's size. */
height?: number;
style?: CSSProperties;
}
-/**
- * Relative, fixed-height slot for an absolute remocn-ui control (Input/Button,
- * which render `position:absolute; inset:0`). The control fills the slot.
- */
export function FieldControl({ children, height = 40, style }: FieldControlProps) {
return (
<div style={{ position: "relative", height, ...style }}>{children}</div>
diff --git a/registry/remocn-ui/input/__tests__/input.test.ts b/registry/remocn-ui/input/__tests__/input.test.ts
index a87979bf..f77a5b4d 100644
--- a/registry/remocn-ui/input/__tests__/input.test.ts
+++ b/registry/remocn-ui/input/__tests__/input.test.ts
@@ -1,35 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `input`.
- *
- * Scope:
- * - registry/remocn-ui/input/index.tsx — InputState union membership,
- * inputStyleContext, inputStyle presets
- * - registry/remocn-ui/input/config.ts — inputConfig.controls.state
- * wiring + inputConfig.snippet output (the state → JSX codegen)
- * - registry/remocn-ui/input/use-input-transition.ts — tweenInputStyle lerp
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * Every visual is the complete resting look for that state — state changes
- * snap (no tweening). `useInputTransition` reads `useCurrentFrame()` via
- * `useStateTransition`; it cannot run outside a Remotion render tree.
- * So Input render is NOT exercised here. The pure-testable surface is the
- * customizer wiring + snippet codegen + style presets + tween (below).
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/input/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `InputState` from `@/registry/remocn-ui/input` and
- * the pieces under test never CALL a Remotion runtime API at import time —
- * `inputConfig` is a plain object; `.snippet` is a pure string builder;
- * `inputStyle`/`inputStyleContext` are pure value functions; `tweenInputStyle`
- * is a pure lerp function.
- * 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 InputState, inputStyle, inputStyleContext } from "../index";
@@ -37,14 +5,6 @@ import { tweenInputStyle } from "../use-input-transition";
import { inputConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The InputState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type InputState` in index.tsx.
- */
const VALID_STATES: readonly InputState[] = [
"idle",
"hover",
@@ -54,7 +14,6 @@ const VALID_STATES: readonly InputState[] = [
"invalid",
];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
placeholder?: string;
@@ -67,14 +26,8 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
inputConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. InputState union membership
-// ===========================================================================
-
describe("InputState union", () => {
it("contains exactly the six 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 = inputConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(control.options).toEqual([
@@ -88,8 +41,6 @@ describe("InputState union", () => {
});
it("every VALID_STATES entry is assignable (no typos in the fixture)", () => {
- // Belt-and-suspenders: the fixture array must have exactly 6 entries and
- // match the options list from the real config.
const control = inputConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(VALID_STATES).toHaveLength(6);
@@ -99,10 +50,6 @@ describe("InputState union", () => {
});
});
-// ===========================================================================
-// 2. inputConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("inputConfig.controls.state", () => {
it("is a select control", () => {
expect(inputConfig.controls.state.type).toBe("select");
@@ -135,12 +82,6 @@ describe("inputConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. inputConfig.snippet — pure string builder
-// State model: snippet emits `state="<state>"` as a bare JSX prop.
-// It NEVER emits `steps` or `action`.
-// ===========================================================================
-
describe("inputConfig.snippet: state prop emission", () => {
it("emits state=\"idle\" for the idle option", () => {
expect(snippet({ state: "idle" })).toContain('state="idle"');
@@ -199,8 +140,6 @@ describe("inputConfig.snippet: import line", () => {
});
describe("inputConfig.snippet: default props are omitted", () => {
- // size=default, mode=light, primary=#171717
const allDefaults = snippet({
state: "typing",
placeholder: "[email protected]",
@@ -269,15 +208,6 @@ describe("inputConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. inputStyle presets — pure (state, ctx) => InputStyle
-// inputStyleContext and inputStyle are exported and frame-free.
-// Build one ctx from the default light theme, then assert the
-// numeric/opacity invariants for every state.
-// borderColor/ringColor/background are derived strings — asserted non-empty
-// only (exact values are implementation details of mixOklch).
-// ===========================================================================
-
const ctx = inputStyleContext(defaultLightTheme);
describe("inputStyle: idle state", () => {
@@ -501,12 +431,6 @@ describe("inputStyle: string-field invariant — borderColor/ringColor/backgroun
});
});
-// ===========================================================================
-// 5. tweenInputStyle — pure linear interpolation between two InputStyles.
-// Numbers lerp linearly; colors are oklch strings at all t.
-// Concrete pair checks below cover the seven fields.
-// ===========================================================================
-
describe("tweenInputStyle: t=0 returns values equal to `a`", () => {
const a = inputStyle("idle", ctx);
const b = inputStyle("active", ctx);
@@ -582,8 +506,6 @@ describe("tweenInputStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenInputStyle: t=0.5 midpoint numeric lerp (idle → active)", () => {
- // idle: ringWidth=0, caretOpacity=0, valueReveal=0, placeholderOpacity=1
- // active: ringWidth=3, caretOpacity=1, valueReveal=0, placeholderOpacity=1
const a = inputStyle("idle", ctx);
const b = inputStyle("active", ctx);
const r = tweenInputStyle(a, b, 0.5);
@@ -621,8 +543,6 @@ describe("tweenInputStyle: t=0.5 midpoint numeric lerp (idle → active)", () =>
});
describe("tweenInputStyle: t=0.5 midpoint numeric lerp (active → typing)", () => {
- // active: ringWidth=3, caretOpacity=1, valueReveal=0, placeholderOpacity=1
- // typing: ringWidth=3, caretOpacity=1, valueReveal=1, placeholderOpacity=0
const a = inputStyle("active", ctx);
const b = inputStyle("typing", ctx);
const r = tweenInputStyle(a, b, 0.5);
@@ -650,8 +570,6 @@ describe("tweenInputStyle: t=0.5 midpoint numeric lerp (active → typing)", ()
});
describe("tweenInputStyle: t=0.5 midpoint numeric lerp (typing → invalid)", () => {
- // typing: ringWidth=3, caretOpacity=1, valueReveal=1, placeholderOpacity=0
- // invalid: ringWidth=3, caretOpacity=0, valueReveal=1, placeholderOpacity=0
const a = inputStyle("typing", ctx);
const b = inputStyle("invalid", ctx);
const r = tweenInputStyle(a, b, 0.5);
diff --git a/registry/remocn-ui/input/config.ts b/registry/remocn-ui/input/config.ts
index a759348f..76add96f 100644
--- a/registry/remocn-ui/input/config.ts
+++ b/registry/remocn-ui/input/config.ts
@@ -19,7 +19,6 @@ export const inputConfig: ComponentConfig = {
},
state: {
type: "select",
- // Default to `typing` so the preview shows the caret + revealed value.
default: "typing",
options: ["idle", "hover", "active", "typing", "blur", "invalid"],
label: "State",
diff --git a/registry/remocn-ui/input/index.tsx b/registry/remocn-ui/input/index.tsx
index b975a19d..a469fa1b 100644
--- a/registry/remocn-ui/input/index.tsx
+++ b/registry/remocn-ui/input/index.tsx
@@ -13,32 +13,18 @@ export type InputState =
type InputSize = "sm" | "default" | "lg";
export interface InputProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: InputState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `InputStyle` from `useInputTransition`.
- */
style?: InputStyle;
- /** Placeholder text shown while the field is empty (idle/hover/active). */
placeholder?: string;
- /** The "typed" value revealed in the typing/invalid states. */
value?: string;
size?: InputSize;
theme?: Partial<RemocnTheme>;
- /** Convenience override for the `primary` theme token — merged into `theme`. */
primary?: string;
mode?: "light" | "dark";
- /**
- * Stretch the field to fill its slot instead of the intrinsic `FIELD_WIDTH`.
- * Use inside a sized container (e.g. a card column) so the box is flush with
- * the surrounding labels and controls.
- */
fullWidth?: boolean;
className?: string;
}
-/** Intrinsic field width (px) when not stretched to fill its slot. */
const FIELD_WIDTH = 320;
const SIZE_STYLES: Record<
@@ -50,58 +36,35 @@ const SIZE_STYLES: Record<
lg: { height: 48, padding: 16, fontSize: 17 },
};
-// ===========================================================================
-// Input visual — the COMPLETE animated look for a moment in time. A `state` is
-// a named preset of this visual (`inputStyle`); the smooth path feeds an
-// interpolated `InputStyle` straight through. The component is a pure renderer
-// of whichever `InputStyle` it receives.
-// ===========================================================================
-
export interface InputStyle {
- /** Animated border color (a concrete color, never "transparent"). */
borderColor: string;
- /** Animated focus-ring color (concrete; softened toward the page bg). */
ringColor: string;
- /** Focus-ring spread in px (box-shadow). 0 = no ring. */
ringWidth: number;
- /** Animated field background (a concrete color, never "transparent"). */
background: string;
- /** Caret bar opacity 0→1. */
caretOpacity: number;
- /** Value reveal 0→1; the fraction of the value shown as a substring (typewriter). */
valueReveal: number;
- /** Placeholder opacity 0→1 (fades out as the value reveals). */
placeholderOpacity: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface InputStyleContext {
idleBorder: string;
hoverBorder: string;
activeBorder: string;
invalidBorder: string;
- /** Resting focus ring (shadcn `ring/50` — ring mixed halfway to the bg). */
ring: string;
invalidRing: string;
background: string;
- /** Subtle hover wash over the page background. */
hoverBackground: string;
foreground: string;
mutedForeground: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `inputStyle(state, ctx)` preset.
- */
export function inputStyleContext(theme: RemocnTheme): InputStyleContext {
return {
idleBorder: theme.input,
hoverBorder: mixOklch(theme.input, theme.foreground, 0.18),
activeBorder: theme.ring,
invalidBorder: theme.destructive,
- // shadcn focus ring is `ring/50` — soften toward the page background so the
- // mix has a concrete endpoint (never pass "transparent" to mixOklch).
ring: mixOklch(theme.background, theme.ring, 0.5),
invalidRing: mixOklch(theme.background, theme.destructive, 0.4),
background: theme.background,
@@ -111,10 +74,6 @@ export function inputStyleContext(theme: RemocnTheme): InputStyleContext {
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => InputStyle`
- * map. To change how a state looks, edit one entry.
- */
export function inputStyle(
state: InputState,
ctx: InputStyleContext,
@@ -151,9 +110,6 @@ export function inputStyle(
placeholderOpacity: 0,
};
case "blur":
- // Filled but unfocused: the value stays fully shown (valueReveal 1, so a
- // typing→blur transition never un-types), but the focus ring and caret are
- // gone and the border relaxes to its resting tone.
return {
borderColor: ctx.idleBorder,
ringColor: ctx.ring,
@@ -206,9 +162,6 @@ export function Input({
const sizeStyle = SIZE_STYLES[size];
const ctx = inputStyleContext(theme);
const v = style ?? inputStyle(state, ctx);
- // Typewriter substring — reveal `valueReveal` of the value character-by-
- // character. The value box is content-sized, so the caret sits a fixed 4px
- // after the last visible glyph (no authored width, no floating caret).
const revealed = value.slice(0, Math.round(value.length * v.valueReveal));
return (
@@ -238,14 +191,10 @@ export function Input({
background: v.background,
border: `1px solid ${v.borderColor}`,
borderRadius: theme.radius,
- // Focus ring — an outset box-shadow that grows from 0 (no ring) to a
- // 3px spread when focused/invalid. Not clipped by overflow.
boxShadow: `0 0 0 ${v.ringWidth}px ${v.ringColor}`,
}}
>
- {/* Placeholder — absolute layer. It vanishes the INSTANT the value
- starts revealing (typing begins), rather than cross-fading, so the
- field never shows placeholder + typed text at once. */}
+ {}
<span
style={{
position: "absolute",
@@ -258,11 +207,7 @@ export function Input({
>
{placeholder}
</span>
- {/* Value + caret. The value is a content-sized substring (typewriter),
- so the caret sits a fixed 4px after the last visible glyph — never
- floating in authored whitespace. With no value revealed (the `active`
- focus state) the caret rests at the field's start. The caret is shown
- only by `caretOpacity` (on in `active`/`typing`, off otherwise). */}
+ {}
<div style={{ display: "flex", alignItems: "center", minWidth: 0 }}>
<span style={{ whiteSpace: "nowrap", color: ctx.foreground }}>
{revealed}
diff --git a/registry/remocn-ui/input/use-input-transition.ts b/registry/remocn-ui/input/use-input-transition.ts
index fac9f8d0..403bfc71 100644
--- a/registry/remocn-ui/input/use-input-transition.ts
+++ b/registry/remocn-ui/input/use-input-transition.ts
@@ -14,12 +14,9 @@ import {
type InputState,
type InputStyle,
} from "@/components/remocn/input";
-// ^ 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 = 8;
-/** Blend two input visuals: numbers lerp, colors via oklch mix. Covers EVERY field. */
export function tweenInputStyle(
a: InputStyle,
b: InputStyle,
@@ -45,11 +42,6 @@ export interface InputTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) InputStyle. The CALLER invokes this; it
- * reads the frame, the `<Input>` component does not. Feed the result to
- * `<Input style={...} />` for smooth transitions.
- */
export function useInputTransition(
steps: Step<InputState>[],
opts: InputTransitionOptions = {},
diff --git a/registry/remocn-ui/onboarding-stepper-flow/index.tsx b/registry/remocn-ui/onboarding-stepper-flow/index.tsx
index b4cf0bf3..ce10b22f 100644
--- a/registry/remocn-ui/onboarding-stepper-flow/index.tsx
+++ b/registry/remocn-ui/onboarding-stepper-flow/index.tsx
@@ -12,38 +12,18 @@ import { Switch } from "@/components/remocn/switch";
import { useSwitchTransition } from "@/components/remocn/use-switch-transition";
import { clamp01, type RemocnTheme } from "@/lib/remocn-ui";
-/**
- * Onboarding stepper flow — a shippable composition scene. Pure orchestrator:
- * each step is driven by its own primitive hook, navigation is button-driven (no
- * cursor). The stepper advances via `useStepperTransition`, exposing a single
- * continuous `position` float.
- *
- * §0B.3 SANCTIONED EXCEPTION (the ONE motion this block derives itself): each
- * step panel's `opacity` is a PURE LINEAR read of the stepper's exposed
- * `position` channel — `clamp01(1 - |position - i|)`. No new easing/spring, no
- * frame read, no per-element timeline, no state. Everything else lives inside
- * the primitives. This crossfades panels in lockstep with the stepper's own
- * eased advance (the easing already lives in `useStepperTransition`).
- */
-
const DEFAULT_STEPS = ["Account", "Plan", "Settings"];
const DEFAULT_PLANS = ["Free", "Pro", "Team"];
-// Stage geometry (1280×720): stepper rail up top, step content centered below.
const CONTENT_TOP = 300;
const CONTENT_HEIGHT = 220;
const NAV_TOP = 540;
export interface OnboardingStepperFlowProps {
- /** Step labels — their count is the step count. */
steps?: string[];
- /** Email value typed into the account step's input. */
name?: string;
- /** Plan options shown as radios on the plan step. */
plans?: string[];
- /** Label of the advance button on the non-final steps. */
nextLabel?: string;
- /** Label of the advance button on the final step. */
finishLabel?: string;
mode?: "light" | "dark";
theme?: Partial<RemocnTheme>;
@@ -60,17 +40,12 @@ export function OnboardingStepperFlow({
}: OnboardingStepperFlowProps) {
const opts = { mode, theme };
- // Stepper advances 0 → 1 (at 64) → 2 (at 104); checks draw on completed steps.
const stepperStyle = useStepperTransition([
{ at: 0, index: 0 },
{ at: 64, index: 1, duration: 20 },
{ at: 104, index: 2, duration: 20 },
]);
- // Step 1 — email types in (10 → 55). `at` is the transition START and the reveal
- // ramps over [at, at+duration) (useStateTransition / STYLE-GUIDE §5), so the
- // typing window is [10, 55] — fully revealed by 55, before the stepper advance
- // at 64 (PRD US-B004 beat 2 + AC5). A brief `active` focus precedes it.
const nameStyle = useInputTransition(
[
{ at: 2, state: "active", duration: 8 },
@@ -79,20 +54,16 @@ export function OnboardingStepperFlow({
opts,
);
- // Step 2 — plan radio checks at 90.
const planStyle = useRadioTransition(
[{ at: 90, state: "checked", duration: 14 }],
opts,
);
- // Step 3 — settings switch turns on at 130.
const settingsStyle = useSwitchTransition(
[{ at: 130, state: "checked", duration: 14 }],
opts,
);
- // Nav button — each Next/Finish press immediately precedes the stepper advance
- // (60→64, 100→104), the final press resolves to success at 150.
const navStyle = useButtonTransition(
[
{ at: 60, state: "press", duration: 6 },
@@ -105,24 +76,21 @@ export function OnboardingStepperFlow({
opts,
);
- // §0B.3: panel visibility = pure linear read of the exposed `position` channel.
- // No easing/spring/frame here — `clamp01` + `|·|` over `position` only.
const position = stepperStyle.position;
const panelOpacity = (i: number) => clamp01(1 - Math.abs(position - i));
- // The advance button reads "Finish" once the flow has moved onto the last step.
const navLabel = position >= steps.length - 1 ? finishLabel : nextLabel;
return (
<div style={{ position: "relative", width: "100%", height: "100%" }}>
- {/* Stepper rail — its own relative box scopes the primitive's inset:0. */}
+ {}
<div
style={{ position: "absolute", left: 0, right: 0, top: 96, height: 100 }}
>
<Stepper style={stepperStyle} steps={steps} mode={mode} theme={theme} />
</div>
- {/* Step content region — panels crossfade via the linear position read. */}
+ {}
<div
style={{
position: "absolute",
@@ -132,7 +100,7 @@ export function OnboardingStepperFlow({
height: CONTENT_HEIGHT,
}}
>
- {/* Step 1 — account email input. */}
+ {}
<div style={{ position: "absolute", inset: 0, opacity: panelOpacity(0) }}>
<Input
style={nameStyle}
@@ -143,7 +111,7 @@ export function OnboardingStepperFlow({
/>
</div>
- {/* Step 2 — plan radio. */}
+ {}
<div style={{ position: "absolute", inset: 0, opacity: panelOpacity(1) }}>
<Radio
style={planStyle}
@@ -153,7 +121,7 @@ export function OnboardingStepperFlow({
/>
</div>
- {/* Step 3 — settings switch. */}
+ {}
<div style={{ position: "absolute", inset: 0, opacity: panelOpacity(2) }}>
<Switch
style={settingsStyle}
@@ -164,7 +132,7 @@ export function OnboardingStepperFlow({
</div>
</div>
- {/* Advance button (Next / Finish). */}
+ {}
<div
style={{ position: "absolute", left: 0, right: 0, top: NAV_TOP, height: 64 }}
>
diff --git a/registry/remocn-ui/popover/__tests__/popover.test.ts b/registry/remocn-ui/popover/__tests__/popover.test.ts
index d9c218d4..81fdae09 100644
--- a/registry/remocn-ui/popover/__tests__/popover.test.ts
+++ b/registry/remocn-ui/popover/__tests__/popover.test.ts
@@ -1,36 +1,3 @@
-/**
- * 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 {
@@ -46,14 +13,9 @@ 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;
@@ -65,22 +27,12 @@ type SnippetValues = {
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");
@@ -140,18 +92,11 @@ describe("popoverStyle: both states are complete keyframes", () => {
});
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");
@@ -189,9 +134,6 @@ describe("tweenPopoverStyle: t=1 returns values equal to `b`", () => {
});
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);
@@ -210,7 +152,6 @@ describe("tweenPopoverStyle: t=0.5 midpoint (closed → opened)", () => {
});
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);
@@ -240,7 +181,6 @@ describe("tweenPopoverStyle: identity (a === b)", () => {
});
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);
@@ -258,29 +198,10 @@ describe("tweenPopoverStyle: reverse direction (opened → closed)", () => {
});
});
-// ===========================================================================
-// 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>[],
@@ -302,30 +223,21 @@ function resolveStateTransition<S extends string>(
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
+ const { from, to, progress } = resolveStateTransition(
raw,
steps,
"closed",
speed,
defaultDuration,
);
- const t = easings.out(progress); // MIRROR line 55
- const style = tweenPopoverStyle( // MIRROR line 56
+ const t = easings.out(progress);
+ const style = tweenPopoverStyle(
popoverStyle(from as PopoverState),
popoverStyle(to as PopoverState),
t,
@@ -333,10 +245,6 @@ function resolvePopoverTransition(
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, []);
@@ -353,10 +261,6 @@ describe("resolvePopoverTransition: before any step — holds at 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" }];
@@ -376,34 +280,26 @@ describe("resolvePopoverTransition: exactly at closed→opened step boundary", (
});
});
-// ---------------------------------------------------------------------------
-// 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
+ const t = easings.out(0.5);
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
+ const expected = 0.97 + (1 - 0.97) * t;
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
+ const expected = 6 * (1 - t);
expect(r.translate).toBeCloseTo(expected, 8);
});
@@ -413,10 +309,6 @@ describe("resolvePopoverTransition: mid-window uses easings.out (not linear)", (
});
});
-// ---------------------------------------------------------------------------
-// Past the window: fully opened
-// ---------------------------------------------------------------------------
-
describe("resolvePopoverTransition: past the window → fully opened", () => {
const steps: Step<PopoverState>[] = [{ at: 0, state: "opened" }];
@@ -433,10 +325,6 @@ describe("resolvePopoverTransition: past the window → fully opened", () => {
});
});
-// ---------------------------------------------------------------------------
-// Speed contract
-// ---------------------------------------------------------------------------
-
describe("resolvePopoverTransition: speed contract", () => {
const steps: Step<PopoverState>[] = [{ at: 10, state: "opened" }];
@@ -449,10 +337,6 @@ describe("resolvePopoverTransition: speed contract", () => {
});
});
-// ===========================================================================
-// 5. popoverConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("popoverConfig.controls: state", () => {
it("state is a select control", () => {
expect(popoverConfig.controls.state.type).toBe("select");
@@ -549,10 +433,6 @@ describe("popoverConfig.controls: mode", () => {
});
});
-// ===========================================================================
-// 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" });
diff --git a/registry/remocn-ui/popover/config.ts b/registry/remocn-ui/popover/config.ts
index 5607f834..6d59e2b2 100644
--- a/registry/remocn-ui/popover/config.ts
+++ b/registry/remocn-ui/popover/config.ts
@@ -30,7 +30,6 @@ export const popoverConfig: ComponentConfig = {
},
state: {
type: "select",
- // Default to `opened` so the preview shows the resting card.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/popover/index.tsx b/registry/remocn-ui/popover/index.tsx
index f837686b..e3439e18 100644
--- a/registry/remocn-ui/popover/index.tsx
+++ b/registry/remocn-ui/popover/index.tsx
@@ -8,60 +8,24 @@ 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":
@@ -71,11 +35,6 @@ export function popoverStyle(state: PopoverState): PopoverStyle {
}
}
-/**
- * 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":
@@ -84,7 +43,7 @@ function offsetFor(side: PopoverSide, translate: number): { x: number; y: number
return { x: translate, y: 0 };
case "right":
return { x: -translate, y: 0 };
- default: // top
+ default:
return { x: 0, y: translate };
}
}
@@ -158,8 +117,7 @@ export function Popover({
{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>
)}
diff --git a/registry/remocn-ui/popover/preview.tsx b/registry/remocn-ui/popover/preview.tsx
index 2dfe25ee..38dc37d5 100644
--- a/registry/remocn-ui/popover/preview.tsx
+++ b/registry/remocn-ui/popover/preview.tsx
@@ -16,14 +16,6 @@ export interface PopoverPreviewProps {
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.",
diff --git a/registry/remocn-ui/popover/use-popover-transition.ts b/registry/remocn-ui/popover/use-popover-transition.ts
index bc512cc5..e55bfab8 100644
--- a/registry/remocn-ui/popover/use-popover-transition.ts
+++ b/registry/remocn-ui/popover/use-popover-transition.ts
@@ -6,17 +6,9 @@ import {
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,
@@ -35,12 +27,6 @@ export interface PopoverTransitionOptions {
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 = {},
diff --git a/registry/remocn-ui/progress/__tests__/progress.test.ts b/registry/remocn-ui/progress/__tests__/progress.test.ts
index b84e1095..9e33e7e4 100644
--- a/registry/remocn-ui/progress/__tests__/progress.test.ts
+++ b/registry/remocn-ui/progress/__tests__/progress.test.ts
@@ -1,36 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `progress`.
- *
- * Scope:
- * - registry/remocn-ui/progress/index.tsx
- * clampValue (internal) — exercised via exported ProgressStyle + render logic
- * ProgressStyle interface — value field semantics
- * - registry/remocn-ui/progress/use-progress-transition.ts
- * tweenProgressStyle(a, b, t) — pure single-field lerp
- * progressValueAt(steps, raw, opts) — pure exported core of useProgressTransition
- * DEFAULT_DURATION constant
- * ProgressStep interface semantics
- * - registry/remocn-ui/progress/config.ts
- * progressConfig.controls wiring + progressConfig.snippet codegen
- *
- * The render path (index.tsx) imports `useRemocnTheme` which requires React
- * context — it is NOT exercised here. `useProgressTransition` IS a hook (calls
- * `useCurrentFrame()`) and is NOT imported; its pure body is the exported
- * `progressValueAt` which we call directly.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/progress/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports from component source; `@/lib/remocn-ui` alias for core.
- * `tweenProgressStyle` and `progressValueAt` are pure value functions — they
- * call neither `useCurrentFrame()` nor `useRemocnTheme` at import or call time.
- * `useProgressTransition` IS a hook and is NOT imported; we call `progressValueAt`
- * directly (it is the exported pure core, annotated as such in the source).
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -42,11 +9,6 @@ import {
import { progressConfig } from "../config";
import { easings, clamp01 } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
value?: number;
width?: number;
@@ -56,26 +18,12 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
progressConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is 24 frames", () => {
expect(DEFAULT_DURATION).toBe(24);
});
});
-// ===========================================================================
-// 2. clampValue semantics — the component applies clamp01(value/100)*100
-// This is the value-channel equivalent of the state-atom clamp.
-// MIRROR of index.tsx lines 43-45 (clampValue function).
-// ===========================================================================
-
-/**
- * MIRROR of index.tsx:clampValue (lines 43-45).
- * clamp01 is `Math.max(0, Math.min(1, t))`.
- */
function clampValue(value: number): number {
return clamp01(value / 100) * 100;
}
@@ -122,11 +70,6 @@ describe("clampValue: in-range values pass through unchanged", () => {
});
});
-// ===========================================================================
-// 3. showLabel floor — the label renders Math.floor(v)%
-// MIRROR of index.tsx line 113: {Math.floor(v)}%
-// ===========================================================================
-
describe("showLabel floor: Math.floor applied to clamped value", () => {
it("Math.floor(62.7) = 62", () => {
expect(Math.floor(clampValue(62.7))).toBe(62);
@@ -149,11 +92,6 @@ describe("showLabel floor: Math.floor applied to clamped value", () => {
});
});
-// ===========================================================================
-// 4. tweenProgressStyle — pure single-field lerp
-// MIRROR of use-progress-transition.ts lines 34-40
-// ===========================================================================
-
describe("tweenProgressStyle: t=0 returns value equal to `a`", () => {
it("value equals a.value at t=0", () => {
const r = tweenProgressStyle({ value: 0 }, { value: 100 }, 0);
@@ -188,7 +126,6 @@ describe("tweenProgressStyle: identity (a === b, any t)", () => {
});
describe("tweenProgressStyle: t=0.25 quarter-point", () => {
- // 0→100 at t=0.25: 0 + 0.25*(100-0) = 25
it("0→100 at t=0.25 gives 25", () => {
const r = tweenProgressStyle({ value: 0 }, { value: 100 }, 0.25);
expect(r.value).toBeCloseTo(25, 10);
@@ -209,18 +146,7 @@ describe("tweenProgressStyle: result has only a `value` field", () => {
});
});
-// ===========================================================================
-// 5. progressValueAt — pure exported core of useProgressTransition
-// MIRROR of use-progress-transition.ts lines 66-102.
-// useProgressTransition is exactly progressValueAt(steps, useCurrentFrame()*speed, opts).
-// We call progressValueAt directly with the frame injected as `raw`.
-//
-// MAINTENANCE CONTRACT: if use-progress-transition.ts lines 66-102 change,
-// update these tests in lockstep. Annotated source lines below.
-// ===========================================================================
-
describe("progressValueAt: empty steps → value=0", () => {
- // source line 73: if (steps.length === 0) return { value: 0 }
it("returns {value:0} for any raw frame when steps is empty", () => {
expect(progressValueAt([], 0).value).toBe(0);
expect(progressValueAt([], 100).value).toBe(0);
@@ -228,7 +154,6 @@ describe("progressValueAt: empty steps → value=0", () => {
});
describe("progressValueAt: before first step — holds at first.value", () => {
- // source lines 78-79: if (raw <= first.at) return { value: first.value }
const steps: ProgressStep[] = [{ at: 10, value: 60 }];
it("raw=5 < first.at=10 → holds at first.value=60", () => {
@@ -245,7 +170,6 @@ describe("progressValueAt: before first step — holds at first.value", () => {
});
describe("progressValueAt: past last step — rests at last.value", () => {
- // source lines 90-92: pastLast → to=from=last step, t=1
const steps: ProgressStep[] = [{ at: 20, value: 75 }];
it("raw=50 > last.at=20 → value=75 (rests at last)", () => {
@@ -258,9 +182,6 @@ describe("progressValueAt: past last step — rests at last.value", () => {
});
describe("progressValueAt: mid-window uses easings.out (not linear)", () => {
- // Two steps: [{at:0,value:0},{at:24,value:100}], default dur=24.
- // At raw=12: start=24-24=0, linear=(12-0)/24=0.5, t=out(0.5)=0.875
- // value = 0 + 100*0.875 = 87.5
const steps: ProgressStep[] = [{ at: 0, value: 0 }, { at: 24, value: 100 }];
it("raw=12 gives value=87.5 (out-eased, not linear 50)", () => {
@@ -269,15 +190,11 @@ describe("progressValueAt: mid-window uses easings.out (not linear)", () => {
});
it("out(0.5)=0.875 — easing is non-linear at the midpoint", () => {
- // This confirms the test above is not accidentally passing with linear math
expect(easings.out(0.5)).toBeCloseTo(0.875, 8);
});
});
describe("progressValueAt: exactly at a step boundary — progress=0", () => {
- // At raw just past first.at, before dur expires:
- // steps=[{at:0,value:0},{at:24,value:100}], raw=0.0001 (just after step[1].at=24? no)
- // Actually raw=24: steps[1].at=24. pastLast = raw(24) >= steps[1].at(24) = true → t=1 → value=100
const steps: ProgressStep[] = [{ at: 0, value: 0 }, { at: 24, value: 100 }];
it("raw=24 exactly (at last step boundary) → pastLast=true → value=100", () => {
@@ -290,13 +207,6 @@ describe("progressValueAt: exactly at a step boundary — progress=0", () => {
});
describe("progressValueAt: two-step timeline mid-second segment", () => {
- // steps=[{at:0,value:0},{at:24,value:50},{at:48,value:100}]
- // At raw=36 (mid of second segment [24→48], dur=24):
- // toIndex search: steps[2].at=48 > 36 → toIndex=2
- // pastLast = 36 >= 48 → false
- // to=steps[2]={at:48,value:100}, from=steps[1]={at:24,value:50}
- // dur=24, start=48-24=24, t=out(clamp01((36-24)/24))=out(0.5)=0.875
- // value=50+(100-50)*0.875=50+43.75=93.75
const steps: ProgressStep[] = [
{ at: 0, value: 0 },
{ at: 24, value: 50 },
@@ -308,17 +218,11 @@ describe("progressValueAt: two-step timeline mid-second segment", () => {
});
it("raw=24 (start of second segment, pastLast=false) is still in first segment end", () => {
- // raw=24: steps[2].at=48 > 24 → toIndex=2 (not pastLast)
- // Wait — steps[1].at=24 is NOT > raw(24), so we keep searching. steps[2].at=48 > 24 → toIndex=2
- // to=steps[2], from=steps[1]. start=48-24=24, t=out((24-24)/24)=out(0)=0
- // value=50+(100-50)*0=50
expect(progressValueAt(steps, 24).value).toBeCloseTo(50, 10);
});
});
describe("progressValueAt: custom duration on a step", () => {
- // steps=[{at:0,value:0},{at:12,value:100,duration:12}]
- // At raw=6: start=12-12=0, t=out(6/12)=out(0.5)=0.875, value=87.5
const steps: ProgressStep[] = [{ at: 0, value: 0 }, { at: 12, value: 100, duration: 12 }];
it("custom duration=12: raw=6 gives value=87.5", () => {
@@ -327,9 +231,6 @@ describe("progressValueAt: custom duration on a step", () => {
});
describe("progressValueAt: easing applied before lerp (default 'out')", () => {
- // Confirms t=easings.out(linear_progress), not raw linear_progress.
- // steps=[{at:0,value:0},{at:24,value:100}], raw=12 → linear=0.5
- // If linear: value=50. With out-easing: value=87.5.
const steps: ProgressStep[] = [{ at: 0, value: 0 }, { at: 24, value: 100 }];
it("value at raw=12 (linear 0.5) is 87.5, not 50", () => {
@@ -340,7 +241,6 @@ describe("progressValueAt: easing applied before lerp (default 'out')", () => {
});
describe("progressValueAt: past last with multiple steps", () => {
- // When past last, to=from=last → t=1 → value=last.value (from.value + 0*t = last.value)
const steps: ProgressStep[] = [
{ at: 0, value: 0 },
{ at: 24, value: 50 },
@@ -352,10 +252,6 @@ describe("progressValueAt: past last with multiple steps", () => {
});
});
-// ===========================================================================
-// 6. progressConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("progressConfig.controls: value", () => {
it("value is a number control", () => {
expect(progressConfig.controls.value.type).toBe("number");
@@ -416,10 +312,6 @@ describe("progressConfig.controls: mode", () => {
});
});
-// ===========================================================================
-// 7. progressConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("progressConfig.snippet: import line", () => {
it("includes 'import { Progress }' from the correct path", () => {
const out = snippet({ value: 50 });
@@ -439,7 +331,6 @@ describe("progressConfig.snippet: structural invariants", () => {
});
describe("progressConfig.snippet: value is always emitted", () => {
- // value is always emitted (including 0)
it("emits value={62} for the default value", () => {
const out = snippet({ value: 62 });
expect(out).toContain("value={62}");
@@ -456,14 +347,12 @@ describe("progressConfig.snippet: value is always emitted", () => {
});
it("emits value={0} when value is omitted from values (falls back to 0)", () => {
- // snippet uses `value ?? 0`
const out = snippet({});
expect(out).toContain("value={0}");
});
});
describe("progressConfig.snippet: default props are omitted", () => {
- // Defaults: width=320, mode=light; showLabel is omitted when falsy
it("omits width when it equals the default 320", () => {
const out = snippet({ value: 50, width: 320 });
@@ -500,10 +389,8 @@ describe("progressConfig.snippet: non-default props are emitted", () => {
});
it("emits showLabel (boolean shorthand) when true", () => {
- // snippet: if (showLabel) props.push(' showLabel') — no value, just the attribute
const out = snippet({ value: 50, showLabel: true });
expect(out).toContain("showLabel");
- // Must NOT be showLabel={true} — it's a boolean shorthand prop
expect(out).not.toContain("showLabel={true}");
});
});
diff --git a/registry/remocn-ui/progress/index.tsx b/registry/remocn-ui/progress/index.tsx
index 59e8e6ff..e1867a81 100644
--- a/registry/remocn-ui/progress/index.tsx
+++ b/registry/remocn-ui/progress/index.tsx
@@ -2,54 +2,26 @@
import { clamp01, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Progress visual — the COMPLETE animated look for a moment in time. The animated
-// channel here is numeric (the fill value), the accepted value-channel deviation
-// from the string-`state` atoms (STYLE-GUIDE §0): `useProgressTransition` feeds an
-// interpolated `ProgressStyle` straight through, exactly like `style` on a state
-// atom, while the snap path is the `value` prop. The component never reads the
-// frame.
-// ===========================================================================
-
export interface ProgressStyle {
- /** Fill percentage 0–100 (clamped by the renderer). */
value: number;
}
export interface ProgressProps {
- /**
- * Fill percentage 0–100 (snap path). Clamped to [0,100]. Ignored when `style`
- * is supplied.
- */
value?: number;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `value` — feed it an interpolated `ProgressStyle` from `useProgressTransition`.
- */
style?: ProgressStyle;
- /** Track width in px. */
width?: number;
- /** Show the floored percentage to the right of the track. */
showLabel?: boolean;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Track height (px) — shadcn `h-3`. */
const TRACK_HEIGHT = 12;
-/** Clamp a 0–100 value to [0,100]. Reuses core clamp01 on the normalized value. */
function clampValue(value: number): number {
return clamp01(value / 100) * 100;
}
-/**
- * A deterministic progress bar. Pure renderer of whatever value it receives — it
- * reads no frame, holds no state, runs no effects. Snap (`value`) and smooth
- * (`style`) share one render path. Placement is the caller's job; the bar renders
- * inline.
- */
export function Progress({
value = 0,
style,
@@ -76,7 +48,7 @@ export function Progress({
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
- {/* Track — muted rail; the indicator fills it left-to-right by `value%`. */}
+ {}
<div
style={{
position: "relative",
diff --git a/registry/remocn-ui/progress/preview.tsx b/registry/remocn-ui/progress/preview.tsx
index 4c0c3511..8ba26eda 100644
--- a/registry/remocn-ui/progress/preview.tsx
+++ b/registry/remocn-ui/progress/preview.tsx
@@ -10,13 +10,6 @@ export interface ProgressPreviewProps {
mode?: "light" | "dark";
}
-/**
- * Preview-only wrapper for the customizer. The shipped `Progress` is a
- * placement-agnostic inline bar — the caller positions it. The customizer Player
- * renders its `component` as the composition root, so a bare `Progress` would sit
- * top-left in normal flow; this thin wrapper centers it on a theme-background
- * stage just for the preview. NOT shipped: not listed in registry.json files.
- */
export function ProgressPreview({
value = 62,
width = 320,
diff --git a/registry/remocn-ui/progress/use-progress-transition.ts b/registry/remocn-ui/progress/use-progress-transition.ts
index b54abf88..23bc9d66 100644
--- a/registry/remocn-ui/progress/use-progress-transition.ts
+++ b/registry/remocn-ui/progress/use-progress-transition.ts
@@ -3,34 +3,21 @@
import { useCurrentFrame } from "remotion";
import { clamp01, type EasingName, easings } from "@/lib/remocn-ui";
import type { ProgressStyle } from "@/components/remocn/progress";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/**
- * A scripted progress value the bar eases TO. The fill tweens from the previous
- * step's value to this one over `[at, at + (duration ?? DEFAULT_DURATION))`.
- */
export interface ProgressStep {
- /** LOCAL (Sequence-relative) authored frame the bar finishes reaching `value`. */
at: number;
- /** Target fill percentage 0–100. */
value: number;
- /** Frames the move INTO this value takes. Omitted → DEFAULT_DURATION. */
duration?: number;
- /** Override the easing for the move into this value. Default `out`. */
easing?: EasingName;
}
-/** Default frames for a move into a step when it omits `duration`. */
export const DEFAULT_DURATION = 24;
export interface ProgressTransitionOptions {
- /** Playhead scale (effectiveFrame = useCurrentFrame() * speed). */
speed?: number;
- /** Move duration (frames) when a step omits `duration`. */
defaultDuration?: number;
}
-/** Blend two progress visuals: the single numeric `value` field lerps. */
export function tweenProgressStyle(
a: ProgressStyle,
b: ProgressStyle,
@@ -39,15 +26,6 @@ export function tweenProgressStyle(
return { value: a.value + (b.value - a.value) * t };
}
-/**
- * Resolve the bar's `ProgressStyle` for a value timeline. THIS is the only
- * frame-reading file in the component — `<Progress>` itself stays pure. Mirrors
- * the value-channel deviation (like cursor's `useCursorPath`): instead of a
- * string-state timeline it folds a numeric value path.
- *
- * The fold is a pure function of `raw = useCurrentFrame() * speed`; the tests
- * replicate `progressValueAt(steps, raw, opts)` with the frame injected.
- */
export function useProgressTransition(
steps: ProgressStep[],
opts: ProgressTransitionOptions = {},
@@ -57,12 +35,6 @@ export function useProgressTransition(
return progressValueAt(steps, raw, opts);
}
-/**
- * Pure core of `useProgressTransition` with the effective frame injected as
- * `raw`. Kept separate so it can be unit-tested without a Remotion render.
- * `useProgressTransition` is exactly `progressValueAt(steps, useCurrentFrame() *
- * speed, opts)`.
- */
export function progressValueAt(
steps: ProgressStep[],
raw: number,
@@ -72,14 +44,10 @@ export function progressValueAt(
if (steps.length === 0) return { value: 0 };
- // Authored order is the timeline order; `at` is the arrival frame of each step.
const first = steps[0];
- // Before the first arrival, hold at the first step's value (no teleport).
if (raw <= first.at) return { value: first.value };
- // Find the segment we're in: the move from step i-1 into step i, where i is
- // the first step with at > raw. If none, we're resting at the last step.
let toIndex = steps.length - 1;
for (let i = 1; i < steps.length; i++) {
if (steps[i].at > raw) {
@@ -93,7 +61,6 @@ export function progressValueAt(
const dur = to.duration ?? defaultDuration;
const ease = easings[to.easing ?? "out"];
- // The move runs over [start, to.at); start = to.at - dur.
const start = to.at - dur;
const t = pastLast || dur <= 0 ? 1 : ease(clamp01((raw - start) / dur));
const value = from.value + (to.value - from.value) * t;
diff --git a/registry/remocn-ui/radio/__tests__/radio.test.ts b/registry/remocn-ui/radio/__tests__/radio.test.ts
index 3b763379..d0e47702 100644
--- a/registry/remocn-ui/radio/__tests__/radio.test.ts
+++ b/registry/remocn-ui/radio/__tests__/radio.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `radio`.
- *
- * Scope:
- * - registry/remocn-ui/radio/index.tsx — RadioState union membership,
- * radioStyleContext, radioStyle presets
- * - registry/remocn-ui/radio/use-radio-transition.ts — tweenRadioStyle
- * - registry/remocn-ui/radio/config.ts — radioConfig.controls.state
- * wiring + radioConfig.snippet output (the state → JSX codegen)
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * State changes snap (no tweening inside the component). The smooth-path hook
- * `useRadioTransition` reads `useCurrentFrame()` via `useStateTransition`
- * internally; it cannot run outside a Remotion render tree. So Radio render
- * is NOT exercised here. The pure-testable surface is the customizer wiring,
- * snippet codegen, style presets, and tween interpolation (below).
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/radio/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `RadioState` from `@/registry/remocn-ui/radio`
- * and the pieces under test never CALL a Remotion runtime API at import time —
- * `radioConfig` is a plain object; `.snippet` is a pure string builder;
- * `radioStyle` and `tweenRadioStyle` 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 {
@@ -40,17 +9,8 @@ import { tweenRadioStyle } from "../use-radio-transition";
import { radioConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The RadioState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type RadioState` in index.tsx.
- */
const VALID_STATES: readonly RadioState[] = ["unchecked", "checked"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
label?: string;
@@ -62,22 +22,14 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
radioConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. RadioState union membership
-// ===========================================================================
-
describe("RadioState 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 = radioConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(control.options).toEqual(["unchecked", "checked"]);
});
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 = radioConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(VALID_STATES).toHaveLength(2);
@@ -87,10 +39,6 @@ describe("RadioState union", () => {
});
});
-// ===========================================================================
-// 2. radioConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("radioConfig.controls.state", () => {
it("is a select control", () => {
expect(radioConfig.controls.state.type).toBe("select");
@@ -116,12 +64,6 @@ describe("radioConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. radioConfig.snippet — pure string builder
-// State model: snippet emits `state="<state>"` as a bare JSX prop.
-// It NEVER emits `steps` or `action`.
-// ===========================================================================
-
describe("radioConfig.snippet: state prop emission", () => {
it("emits state=\"unchecked\" for the unchecked option", () => {
expect(snippet({ state: "unchecked" })).toContain('state="unchecked"');
@@ -164,7 +106,6 @@ describe("radioConfig.snippet: import line", () => {
});
describe("radioConfig.snippet: default props are omitted", () => {
- // Defaults: label="", size=default, mode=light, primary=#171717
const allDefaults = snippet({
state: "checked",
label: "",
@@ -224,15 +165,6 @@ describe("radioConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. radioStyle presets — pure (state, ctx) => RadioStyle
-// radioStyleContext and radioStyle are now exported and frame-free.
-// Build one ctx from the default light theme, then assert the
-// numeric/opacity invariants for both states.
-// ringBorderColor is derived from the theme — asserted non-empty only
-// (exact value is an implementation detail of the theme).
-// ===========================================================================
-
const ctx = radioStyleContext(defaultLightTheme);
describe("radioStyle: unchecked state", () => {
@@ -281,14 +213,6 @@ describe("radioStyle: invariants — unchecked hides dot, checked shows dot", ()
});
});
-// ===========================================================================
-// 5. tweenRadioStyle — pure linear interpolation between two RadioStyles.
-// Numbers lerp linearly; colors via oklch mix → non-empty string at all t.
-// Concrete expectations: unchecked→checked for midpoint math.
-// unchecked: dotOpacity=0, dotScale=0.4
-// checked: dotOpacity=1, dotScale=1
-// ===========================================================================
-
describe("tweenRadioStyle: t=0 returns values equal to `a`", () => {
const a = radioStyle("unchecked", ctx);
const b = radioStyle("checked", ctx);
@@ -328,8 +252,6 @@ describe("tweenRadioStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenRadioStyle: t=0.5 midpoint numeric lerp (unchecked → checked)", () => {
- // unchecked: dotOpacity=0, dotScale=0.4
- // checked: dotOpacity=1, dotScale=1
const a = radioStyle("unchecked", ctx);
const b = radioStyle("checked", ctx);
const r = tweenRadioStyle(a, b, 0.5);
diff --git a/registry/remocn-ui/radio/config.ts b/registry/remocn-ui/radio/config.ts
index 342dd7ae..7f73d6bc 100644
--- a/registry/remocn-ui/radio/config.ts
+++ b/registry/remocn-ui/radio/config.ts
@@ -14,7 +14,6 @@ export const radioConfig: ComponentConfig = {
},
state: {
type: "select",
- // Default to `checked` so the preview shows the filled dot.
default: "checked",
options: ["unchecked", "checked"],
label: "State",
diff --git a/registry/remocn-ui/radio/index.tsx b/registry/remocn-ui/radio/index.tsx
index 10c7bd4e..27f8a7f0 100644
--- a/registry/remocn-ui/radio/index.tsx
+++ b/registry/remocn-ui/radio/index.tsx
@@ -7,18 +7,11 @@ export type RadioState = "unchecked" | "checked";
type RadioSize = "sm" | "default" | "lg";
export interface RadioProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: RadioState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `RadioStyle` from `useRadioTransition`.
- */
style?: RadioStyle;
- /** Optional text label rendered next to the circle. */
label?: string;
size?: RadioSize;
theme?: Partial<RemocnTheme>;
- /** Convenience override for the `primary` theme token — merged into `theme`. */
primary?: string;
mode?: "light" | "dark";
className?: string;
@@ -33,34 +26,18 @@ const SIZE_STYLES: Record<
lg: { box: 24, fontSize: 17, gap: 12 },
};
-// ===========================================================================
-// Radio visual — the COMPLETE animated look for a moment in time. A `state`
-// is a named preset of this visual (`radioStyle`); the smooth path feeds an
-// interpolated `RadioStyle` straight through. The component is a pure
-// renderer of whichever `RadioStyle` it receives.
-// ===========================================================================
-
export interface RadioStyle {
- /** Animated outer-ring border color. */
ringBorderColor: string;
- /** Inner dot opacity 0→1. */
dotOpacity: number;
- /** Inner dot scale 0.4→1 (a slight pop on check). */
dotScale: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface RadioStyleContext {
uncheckedBorder: string;
checkedBorder: string;
- /** Static dot fill color (never animated). */
dotColor: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `radioStyle(state, ctx)` preset.
- */
export function radioStyleContext(theme: RemocnTheme): RadioStyleContext {
return {
uncheckedBorder: theme.border,
@@ -69,10 +46,6 @@ export function radioStyleContext(theme: RemocnTheme): RadioStyleContext {
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => RadioStyle`
- * map. To change how a state looks, edit one entry.
- */
export function radioStyle(
state: RadioState,
ctx: RadioStyleContext,
@@ -134,7 +107,7 @@ export function Radio({
gap: sizeStyle.gap,
}}
>
- {/* The ring — animated border; the inner dot appears inside it. */}
+ {}
<span
style={{
display: "flex",
@@ -147,7 +120,7 @@ export function Radio({
background: theme.background,
}}
>
- {/* Inner dot — scales + fades in on check. */}
+ {}
<span
style={{
width: Math.round(boxSize * 0.45),
diff --git a/registry/remocn-ui/radio/use-radio-transition.ts b/registry/remocn-ui/radio/use-radio-transition.ts
index b3f6a429..5cbea448 100644
--- a/registry/remocn-ui/radio/use-radio-transition.ts
+++ b/registry/remocn-ui/radio/use-radio-transition.ts
@@ -14,12 +14,9 @@ import {
type RadioState,
type RadioStyle,
} from "@/components/remocn/radio";
-// ^ 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 radio visuals: numbers lerp, colors via oklch mix. */
export function tweenRadioStyle(
a: RadioStyle,
b: RadioStyle,
@@ -40,11 +37,6 @@ export interface RadioTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) RadioStyle. The CALLER invokes this;
- * it reads the frame, the `<Radio>` component does not. Feed the result to
- * `<Radio style={...} />` for smooth check/uncheck transitions.
- */
export function useRadioTransition(
steps: Step<RadioState>[],
opts: RadioTransitionOptions = {},
diff --git a/registry/remocn-ui/resizable/__tests__/resizable.test.ts b/registry/remocn-ui/resizable/__tests__/resizable.test.ts
index 2510dd40..35518ab3 100644
--- a/registry/remocn-ui/resizable/__tests__/resizable.test.ts
+++ b/registry/remocn-ui/resizable/__tests__/resizable.test.ts
@@ -1,35 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `resizable`.
- *
- * Scope:
- * - registry/remocn-ui/resizable/index.tsx
- * resizableHandleStyle(handleState) — pure handle-channel preset map
- * resizableStyleContext(theme) — pure theme → color derivation
- * resizableStyle(ratio, handleState) — pure snap-path composer
- * - registry/remocn-ui/resizable/use-resizable-transition.ts
- * tweenResizableStyle(a, b, t) — pure lerp across all three fields
- * resizableStyleAt(steps, raw, opts) — pure exported dual-channel core
- * DEFAULT_DURATION constant
- * - registry/remocn-ui/resizable/config.ts
- * resizableConfig.controls wiring + resizableConfig.snippet codegen
- *
- * The render path (index.tsx) imports `useRemocnTheme` which requires React
- * context — it is NOT exercised here. `useResizableTransition` IS a hook (calls
- * `useCurrentFrame()`) and is NOT imported; its pure body is the exported
- * `resizableStyleAt` which we call directly.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/resizable/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports from component source; `@/lib/remocn-ui` alias for core.
- * `resizableHandleStyle`, `resizableStyleContext`, `resizableStyle` are pure
- * value functions. `useResizableTransition` IS a hook and is NOT imported;
- * we call `resizableStyleAt` directly (the exported pure core).
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -47,17 +15,12 @@ import {
import { resizableConfig } from "../config";
import { defaultLightTheme, defaultDarkTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
const VALID_HANDLE_STATES: readonly ResizableHandleState[] = [
"idle",
"hover",
"press",
];
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
ratio?: number;
handleState?: string;
@@ -67,21 +30,12 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
resizableConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is 18 frames", () => {
expect(DEFAULT_DURATION).toBe(18);
});
});
-// ===========================================================================
-// 2. resizableHandleStyle — pure (handleState) => {handleScale, handleRingOpacity}
-// MIRROR of index.tsx lines 75-87
-// ===========================================================================
-
describe("resizableHandleStyle: idle state — resting handle", () => {
const s = resizableHandleStyle("idle");
@@ -146,15 +100,6 @@ describe("resizableHandleStyle: every state returns numeric fields", () => {
});
});
-// ===========================================================================
-// 3. clampRatio — the renderer clamps ratio to [minRatio, maxRatio]
-// MIRROR of index.tsx lines 66-68 (clampRatio function)
-//
-// Default minRatio=0.15, maxRatio=0.85 from ResizableProps.
-// The function is unexported but its semantics are contractual.
-// ===========================================================================
-
-/** MIRROR of index.tsx:clampRatio */
function clampRatio(
ratio: number,
minRatio: number,
@@ -215,11 +160,6 @@ describe("clampRatio: in-range values pass through unchanged", () => {
});
});
-// ===========================================================================
-// 4. resizableStyleContext — pure theme → ResizableStyleContext
-// MIRROR of index.tsx lines 106-116
-// ===========================================================================
-
describe("resizableStyleContext: light theme — token mapping", () => {
const ctx = resizableStyleContext(defaultLightTheme);
@@ -284,11 +224,6 @@ describe("resizableStyleContext: all fields are present and correctly typed", ()
});
});
-// ===========================================================================
-// 5. resizableStyle — pure (ratio, handleState) => ResizableStyle
-// MIRROR of index.tsx lines 123-133
-// ===========================================================================
-
describe("resizableStyle: idle handle preset", () => {
const s = resizableStyle(0.5, "idle");
const preset = resizableHandleStyle("idle");
@@ -359,15 +294,9 @@ describe("resizableStyle: all three ResizableStyle fields are present", () => {
});
});
-// ===========================================================================
-// 6. tweenResizableStyle — pure lerp across all three fields
-// MIRROR of use-resizable-transition.ts lines 42-53
-// Both channels (ratio + handle) are covered in one tween.
-// ===========================================================================
-
describe("tweenResizableStyle: t=0 returns values equal to `a`", () => {
- const a = resizableStyle(0.3, "idle"); // {ratio:0.3, handleScale:1, handleRingOpacity:0}
- const b = resizableStyle(0.7, "hover"); // {ratio:0.7, handleScale:1.15, handleRingOpacity:1}
+ const a = resizableStyle(0.3, "idle");
+ const b = resizableStyle(0.7, "hover");
const r = tweenResizableStyle(a, b, 0);
it("ratio equals a.ratio at t=0", () => {
@@ -398,9 +327,6 @@ describe("tweenResizableStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenResizableStyle: t=0.5 midpoint", () => {
- // a: ratio=0.3, handleScale=1(idle), handleRingOpacity=0
- // b: ratio=0.7, handleScale=1.15(hover), handleRingOpacity=1
- // midpoints: ratio=0.5, handleScale=1.075, handleRingOpacity=0.5
const a = resizableStyle(0.3, "idle");
const b = resizableStyle(0.7, "hover");
const r = tweenResizableStyle(a, b, 0.5);
@@ -428,9 +354,6 @@ describe("tweenResizableStyle: identity (a === b, any t)", () => {
});
describe("tweenResizableStyle: idle → press handle channel", () => {
- // idle: handleScale=1, handleRingOpacity=0
- // press: handleScale=1.25, handleRingOpacity=1
- // t=0.5: handleScale=1.125, handleRingOpacity=0.5
const a = resizableStyle(0.5, "idle");
const b = resizableStyle(0.5, "press");
const r = tweenResizableStyle(a, b, 0.5);
@@ -444,9 +367,6 @@ describe("tweenResizableStyle: idle → press handle channel", () => {
});
describe("tweenResizableStyle: hover → press handle channel", () => {
- // hover: handleScale=1.15, handleRingOpacity=1
- // press: handleScale=1.25, handleRingOpacity=1
- // t=0.5: handleScale=1.2, handleRingOpacity=1 (ring stays at 1)
const a = resizableStyle(0.5, "hover");
const b = resizableStyle(0.5, "press");
const r = tweenResizableStyle(a, b, 0.5);
@@ -459,21 +379,7 @@ describe("tweenResizableStyle: hover → press handle channel", () => {
});
});
-// ===========================================================================
-// 7. resizableStyleAt — pure exported dual-channel core
-// MIRROR of use-resizable-transition.ts lines 152-165.
-// useResizableTransition is exactly resizableStyleAt(steps, useCurrentFrame()*speed, opts).
-// We call resizableStyleAt directly with the frame injected as `raw`.
-//
-// The two channels (ratio + handle) are folded INDEPENDENTLY from the same
-// step list, filtering to ratio-bearing and handle-bearing steps respectively.
-//
-// MAINTENANCE CONTRACT: if use-resizable-transition.ts lines 70-165 change,
-// update these tests in lockstep. Annotated source lines below.
-// ===========================================================================
-
describe("resizableStyleAt: empty steps → ratio=0.5, handle=idle", () => {
- // source lines 78/113: empty ratio/handle steps → return 0.5 / resizableHandleStyle('idle')
it("empty steps returns {ratio:0.5, handleScale:1, handleRingOpacity:0}", () => {
const r = resizableStyleAt([], 0);
expect(r.ratio).toBe(0.5);
@@ -483,7 +389,6 @@ describe("resizableStyleAt: empty steps → ratio=0.5, handle=idle", () => {
});
describe("resizableStyleAt: before first ratio step — holds at first.ratio", () => {
- // source line 81: if (raw <= first.at) return first.ratio
const steps: ResizableStep[] = [{ at: 10, ratio: 0.6 }];
it("raw=5 < first.at=10 → holds at first.ratio=0.6", () => {
@@ -496,7 +401,6 @@ describe("resizableStyleAt: before first ratio step — holds at first.ratio", (
});
describe("resizableStyleAt: before first handle step — holds at first.handleState preset", () => {
- // source line 115: if (raw <= first.at) return resizableHandleStyle(first.handleState)
const steps: ResizableStep[] = [{ at: 10, handleState: "hover" }];
it("raw=5 holds at hover preset (handleScale=1.15)", () => {
@@ -509,7 +413,6 @@ describe("resizableStyleAt: before first handle step — holds at first.handleSt
});
describe("resizableStyleAt: past last ratio step — rests at last.ratio", () => {
- // source lines 90-93: pastLast → to=from=last, t=1
const steps: ResizableStep[] = [
{ at: 0, ratio: 0.3 },
{ at: 18, ratio: 0.7 },
@@ -539,8 +442,6 @@ describe("resizableStyleAt: past last handle step — rests at last.handleState
});
describe("resizableStyleAt: ratio channel mid-window uses easings.out", () => {
- // [{at:0,ratio:0.3},{at:18,ratio:0.7}], raw=9 → start=0, linear=0.5, t=out(0.5)=0.875
- // ratio = 0.3 + (0.7-0.3)*0.875 = 0.3 + 0.35 = 0.65
const steps: ResizableStep[] = [
{ at: 0, ratio: 0.3 },
{ at: 18, ratio: 0.7 },
@@ -557,9 +458,6 @@ describe("resizableStyleAt: ratio channel mid-window uses easings.out", () => {
});
describe("resizableStyleAt: handle channel mid-window uses easings.out", () => {
- // [{at:0,handleState:'idle'},{at:18,handleState:'hover'}], raw=9
- // t=out(0.5)=0.875; idle={hs:1,hro:0}, hover={hs:1.15,hro:1}
- // handleScale: 1 + 0.15*0.875 = 1.13125, handleRingOpacity: 0 + 1*0.875 = 0.875
const steps: ResizableStep[] = [
{ at: 0, handleState: "idle" },
{ at: 18, handleState: "hover" },
@@ -575,7 +473,6 @@ describe("resizableStyleAt: handle channel mid-window uses easings.out", () => {
});
describe("resizableStyleAt: dual-channel steps fold independently", () => {
- // Combined steps — both channels active simultaneously
const steps: ResizableStep[] = [
{ at: 0, ratio: 0.3, handleState: "idle" },
{ at: 18, ratio: 0.7, handleState: "hover" },
@@ -602,7 +499,6 @@ describe("resizableStyleAt: dual-channel steps fold independently", () => {
});
describe("resizableStyleAt: channels can have different step counts", () => {
- // Only ratio steps, no handle steps → handle stays idle
const ratioOnlySteps: ResizableStep[] = [
{ at: 0, ratio: 0.3 },
{ at: 18, ratio: 0.7 },
@@ -614,7 +510,6 @@ describe("resizableStyleAt: channels can have different step counts", () => {
expect(r.handleRingOpacity).toBe(resizableHandleStyle("idle").handleRingOpacity);
});
- // Only handle steps, no ratio steps → ratio stays 0.5
const handleOnlySteps: ResizableStep[] = [
{ at: 0, handleState: "idle" },
{ at: 18, handleState: "hover" },
@@ -650,9 +545,6 @@ describe("resizableStyleAt: before first with both channels — single-step time
});
describe("resizableStyleAt: custom defaultDuration override", () => {
- // With defaultDuration=9, a step at=9 with no explicit duration uses a 9-frame window
- // [0..9], raw=4.5 is mid → linear=0.5, out-eased → 0.875
- // ratio = 0.3 + (0.7-0.3)*0.875 = 0.65
const steps: ResizableStep[] = [
{ at: 0, ratio: 0.3 },
{ at: 9, ratio: 0.7 },
@@ -664,10 +556,6 @@ describe("resizableStyleAt: custom defaultDuration override", () => {
});
});
-// ===========================================================================
-// 8. resizableConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("resizableConfig.controls: ratio", () => {
it("ratio is a number control", () => {
expect(resizableConfig.controls.ratio.type).toBe("number");
@@ -728,10 +616,6 @@ describe("resizableConfig.controls: mode", () => {
});
});
-// ===========================================================================
-// 9. resizableConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("resizableConfig.snippet: import line", () => {
it("includes 'import { Resizable }' from the correct path", () => {
const out = snippet({ ratio: 0.5 });
diff --git a/registry/remocn-ui/resizable/index.tsx b/registry/remocn-ui/resizable/index.tsx
index bab646fe..adce30c4 100644
--- a/registry/remocn-ui/resizable/index.tsx
+++ b/registry/remocn-ui/resizable/index.tsx
@@ -7,46 +7,21 @@ export type ResizableHandleState = "idle" | "hover" | "press";
export type ResizableDirection = "horizontal" | "vertical";
-// ===========================================================================
-// Resizable visual — the COMPLETE animated look for a moment in time. This is a
-// DUAL-channel atom (value-channel deviation §0, like slider): the numeric
-// `ratio` animates as a lerp while the handle visuals (`handleScale`,
-// `handleRingOpacity`) come from a `handleState` preset. Both live in one
-// `ResizableStyle`; `useResizableTransition` feeds an interpolated one through
-// the `style` prop. The component never reads the frame.
-// ===========================================================================
-
export interface ResizableStyle {
- /** Fraction of the FIRST panel, 0–1 (clamped to [minRatio, maxRatio]). */
ratio: number;
- /** Handle grip zoom: 1 idle, grows on hover/press. */
handleScale: number;
- /** Handle grab-ring opacity 0 (idle) → 1 (hover/press). */
handleRingOpacity: number;
}
export interface ResizableProps {
- /** First panel content. Defaults to a muted placeholder card. */
first?: ReactNode;
- /** Second panel content. Defaults to a muted placeholder card. */
second?: ReactNode;
- /** Split direction — both implemented (horizontal splits width, vertical height). */
direction?: ResizableDirection;
- /** Fraction of the first panel, 0–1 (snap path). Ignored when `style` is set. */
ratio?: number;
- /** Handle visual state (snap path). Ignored when `style` is set. */
handleState?: ResizableHandleState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `ratio`/`handleState` — feed it an interpolated `ResizableStyle` from
- * `useResizableTransition`.
- */
style?: ResizableStyle;
- /** Minimum first-panel fraction. Default 0.15. */
minRatio?: number;
- /** Maximum first-panel fraction. Default 0.85. */
maxRatio?: number;
- /** Container size in px (width for horizontal, height for vertical primary axis). */
width?: number;
height?: number;
theme?: Partial<RemocnTheme>;
@@ -54,24 +29,15 @@ export interface ResizableProps {
className?: string;
}
-/** Divider thickness (px). */
const DIVIDER = 1;
-/** Grip pill dimensions (px) — shadcn `h-6 w-1`. */
const GRIP_LONG = 24;
const GRIP_SHORT = 4;
-/** Grab-ring spread (px) at full opacity. */
const RING_WIDTH = 4;
-/** Clamp a ratio into [minRatio, maxRatio]. */
function clampRatio(ratio: number, minRatio: number, maxRatio: number): number {
return Math.min(maxRatio, Math.max(minRatio, ratio));
}
-/**
- * The handle-channel preset for a state — pure `(handleState) => {handleScale,
- * handleRingOpacity}`. Hover and press both grow the grip and show the ring;
- * press grows it a touch more. The `ratio` channel is independent of this.
- */
export function resizableHandleStyle(handleState: ResizableHandleState): {
handleScale: number;
handleRingOpacity: number;
@@ -86,23 +52,16 @@ export function resizableHandleStyle(handleState: ResizableHandleState): {
}
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface ResizableStyleContext {
containerBg: string;
border: string;
panelBg: string;
grip: string;
- /** Grab ring — a visible halo derived from the ring token (US-006 contrast). */
ring: string;
placeholderFg: string;
radius: number;
}
-/**
- * Derive the concrete colors for a theme. Pure. The grab ring is a real mix of
- * the ring token toward the background (not a duplicate token), so it reads as a
- * distinct halo in both light and dark.
- */
export function resizableStyleContext(theme: RemocnTheme): ResizableStyleContext {
return {
containerBg: theme.background,
@@ -115,11 +74,6 @@ export function resizableStyleContext(theme: RemocnTheme): ResizableStyleContext
};
}
-/**
- * The COMPLETE resting visual for the snap path — a pure `(ratio, handleState)
- * => ResizableStyle` map. The ratio is NOT clamped here (the renderer clamps
- * with the active min/max); the handle visuals come from the preset.
- */
export function resizableStyle(
ratio: number,
handleState: ResizableHandleState,
@@ -132,7 +86,6 @@ export function resizableStyle(
};
}
-/** Default placeholder card for a panel slot. */
function Placeholder({ label, color }: { label: string; color: string }) {
return (
<div
@@ -175,8 +128,6 @@ export function Resizable({
const pct = clampRatio(v.ratio, minRatio, maxRatio) * 100;
const isHorizontal = direction === "horizontal";
- // The grip is a long pill along the divider; long axis is perpendicular to the
- // split direction (vertical pill for a horizontal split, and vice versa).
const gripW = isHorizontal ? GRIP_SHORT : GRIP_LONG;
const gripH = isHorizontal ? GRIP_LONG : GRIP_SHORT;
@@ -208,7 +159,7 @@ export function Resizable({
boxSizing: "border-box",
}}
>
- {/* First panel — sized by ratio along the split axis. */}
+ {}
<div
style={{
flex: "none",
@@ -219,7 +170,7 @@ export function Resizable({
>
{first ?? <Placeholder label="Panel one" color={ctx.placeholderFg} />}
</div>
- {/* Divider — a 1px border-color line; grip pill centered on it. */}
+ {}
<div
style={{
position: "relative",
@@ -228,7 +179,7 @@ export function Resizable({
background: ctx.border,
}}
>
- {/* Grab ring behind the grip, fading in on hover/press. */}
+ {}
<div
style={{
position: "absolute",
@@ -242,7 +193,7 @@ export function Resizable({
opacity: v.handleRingOpacity,
}}
/>
- {/* Grip pill — scales on grab. */}
+ {}
<div
style={{
position: "absolute",
@@ -256,7 +207,7 @@ export function Resizable({
}}
/>
</div>
- {/* Second panel — fills the remainder. */}
+ {}
<div
style={{
flex: "1 1 0",
diff --git a/registry/remocn-ui/resizable/use-resizable-transition.ts b/registry/remocn-ui/resizable/use-resizable-transition.ts
index fda4d557..2e9f3167 100644
--- a/registry/remocn-ui/resizable/use-resizable-transition.ts
+++ b/registry/remocn-ui/resizable/use-resizable-transition.ts
@@ -7,38 +7,22 @@ import {
type ResizableHandleState,
type ResizableStyle,
} from "@/components/remocn/resizable";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/**
- * One scripted resizable keyframe. A step may move the `ratio` channel, the
- * `handleState` channel, or both. The ratio eases from the previous ratio-bearing
- * step to this one; the handle visual tweens from the previous handle-bearing
- * step's preset to this one.
- */
export interface ResizableStep {
- /** LOCAL (Sequence-relative) authored frame this keyframe is reached. */
at: number;
- /** Target first-panel fraction 0–1 (this step moves the ratio channel). */
ratio?: number;
- /** Target handle state (this step moves the handle channel). */
handleState?: ResizableHandleState;
- /** Frames the move INTO this step takes. Omitted → DEFAULT_DURATION. */
duration?: number;
- /** Override the easing for the move into this step. Default `out`. */
easing?: EasingName;
}
-/** Default frames for a move into a step when it omits `duration`. */
export const DEFAULT_DURATION = 18;
export interface ResizableTransitionOptions {
- /** Playhead scale (effectiveFrame = useCurrentFrame() * speed). */
speed?: number;
- /** Move duration (frames) when a step omits `duration`. */
defaultDuration?: number;
}
-/** Blend two resizable visuals: all three fields lerp (ratio + handle channels). */
export function tweenResizableStyle(
a: ResizableStyle,
b: ResizableStyle,
@@ -52,12 +36,6 @@ export function tweenResizableStyle(
};
}
-/**
- * Resolve the resizable's `ResizableStyle` for a dual-channel timeline. THIS is
- * the only frame-reading file — `<Resizable>` itself stays pure. The fold is a
- * pure function of `raw = useCurrentFrame() * speed`; tests replicate
- * `resizableStyleAt(steps, raw, opts)` with the frame injected.
- */
export function useResizableTransition(
steps: ResizableStep[],
opts: ResizableTransitionOptions = {},
@@ -67,7 +45,6 @@ export function useResizableTransition(
return resizableStyleAt(steps, raw, opts);
}
-/** Eased ratio at `raw` over the ratio-bearing steps (numeric channel). */
function ratioAt(
steps: ResizableStep[],
raw: number,
@@ -100,7 +77,6 @@ function ratioAt(
return from.ratio + (to.ratio - from.ratio) * t;
}
-/** Eased handle visual at `raw` over the handle-bearing steps (state channel). */
function handleAt(
steps: ResizableStep[],
raw: number,
@@ -143,12 +119,6 @@ function handleAt(
};
}
-/**
- * Pure core of `useResizableTransition` with the effective frame injected as
- * `raw`. The two channels are folded independently and merged: `ratio` eases over
- * the ratio-bearing steps, the handle visual tweens over the handle-bearing
- * steps. Kept separate so it can be unit-tested without a Remotion render.
- */
export function resizableStyleAt(
steps: ResizableStep[],
raw: number,
diff --git a/registry/remocn-ui/select-item/__tests__/select-item.test.ts b/registry/remocn-ui/select-item/__tests__/select-item.test.ts
index 05e7edd6..2a4a0b52 100644
--- a/registry/remocn-ui/select-item/__tests__/select-item.test.ts
+++ b/registry/remocn-ui/select-item/__tests__/select-item.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `select-item`.
- *
- * Scope:
- * - registry/remocn-ui/select-item/index.tsx — SelectItemState union membership,
- * selectItemStyle presets, selectItemStyleContext
- * - registry/remocn-ui/select-item/config.ts — selectItemConfig.controls wiring
- * + selectItemConfig.snippet output (the state → JSX codegen)
- * - registry/remocn-ui/select-item/use-select-item-transition.ts
- * — tweenSelectItemStyle interpolation, DEFAULT_DURATION
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * `<SelectItem>` 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/select-item/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `SelectItemState` from `@/registry/remocn-ui/select-item`
- * and the pieces under test never CALL a Remotion runtime API at import time —
- * `selectItemConfig` is a plain object; `.snippet` is a pure string builder;
- * `selectItemStyle` and `tweenSelectItemStyle` 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 {
@@ -40,17 +9,8 @@ import { tweenSelectItemStyle, DEFAULT_DURATION } from "../use-select-item-trans
import { selectItemConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The SelectItemState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type SelectItemState` in index.tsx.
- */
const VALID_STATES: readonly SelectItemState[] = ["idle", "hover", "press", "selected"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
label?: string;
@@ -60,16 +20,8 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
selectItemConfig.snippet(values as Record<string, unknown>);
-/**
- * A shared SelectItemStyleContext built from the default light theme.
- * `selectItemStyleContext` takes only `(theme)` — no variant arg.
- */
const ctx = selectItemStyleContext(defaultLightTheme);
-// ===========================================================================
-// 1. SelectItemState union membership
-// ===========================================================================
-
describe("SelectItemState union", () => {
it("contains exactly the four documented states", () => {
const control = selectItemConfig.controls.state;
@@ -87,10 +39,6 @@ describe("SelectItemState union", () => {
});
});
-// ===========================================================================
-// 2. selectItemConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("selectItemConfig.controls.state", () => {
it("is a select control", () => {
expect(selectItemConfig.controls.state.type).toBe("select");
@@ -116,11 +64,6 @@ describe("selectItemConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. selectItemConfig.snippet — pure string builder
-// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.
-// ===========================================================================
-
describe("selectItemConfig.snippet: state prop emission", () => {
it("emits state=\"idle\" for the idle option", () => {
expect(snippet({ state: "idle" })).toContain('state="idle"');
@@ -157,7 +100,6 @@ describe("selectItemConfig.snippet: import line", () => {
});
describe("selectItemConfig.snippet: default props are omitted", () => {
- // Defaults: label="Banana", mode="light"
const allDefaults = snippet({
state: "selected",
label: "Banana",
@@ -201,12 +143,6 @@ describe("selectItemConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. selectItemStyleContext — derives concrete colors from the theme.
-// Signature is `(theme)` — NO variant argument.
-// Build ctx from the default light theme and assert each field is populated.
-// ===========================================================================
-
describe("selectItemStyleContext: field types from defaultLightTheme", () => {
it("idleBg is a non-empty string", () => {
expect(typeof ctx.idleBg).toBe("string");
@@ -270,12 +206,6 @@ describe("selectItemStyleContext: maps theme tokens correctly", () => {
});
});
-// ===========================================================================
-// 5. selectItemStyle presets — pure (state, ctx) => SelectItemStyle
-// Build one ctx from the default light theme, then assert the numeric
-// invariants for every state.
-// ===========================================================================
-
describe("selectItemStyle: idle state", () => {
const s = selectItemStyle("idle", ctx);
@@ -382,12 +312,6 @@ describe("selectItemStyle: state invariant summary", () => {
});
});
-// ===========================================================================
-// 6. tweenSelectItemStyle — pure linear interpolation between two SelectItemStyles.
-// Numeric fields lerp; color fields go through mixOklch (tested as non-empty strings).
-// Concrete expectations: idle → selected for numeric midpoint math.
-// ===========================================================================
-
describe("tweenSelectItemStyle: t=0 returns values equal to `a`", () => {
const a = selectItemStyle("idle", ctx);
const b = selectItemStyle("selected", ctx);
@@ -437,8 +361,6 @@ describe("tweenSelectItemStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenSelectItemStyle: t=0.5 midpoint numeric lerp (idle → selected)", () => {
- // idle: checkOpacity=0, scale=1
- // selected: checkOpacity=1, scale=1
const a = selectItemStyle("idle", ctx);
const b = selectItemStyle("selected", ctx);
const r = tweenSelectItemStyle(a, b, 0.5);
@@ -453,8 +375,6 @@ describe("tweenSelectItemStyle: t=0.5 midpoint numeric lerp (idle → selected)"
});
describe("tweenSelectItemStyle: t=0.5 midpoint numeric lerp (idle → press)", () => {
- // idle: scale=1
- // press: scale=0.98
const a = selectItemStyle("idle", ctx);
const b = selectItemStyle("press", ctx);
const r = tweenSelectItemStyle(a, b, 0.5);
@@ -468,10 +388,6 @@ describe("tweenSelectItemStyle: t=0.5 midpoint numeric lerp (idle → press)", (
});
});
-// ===========================================================================
-// 7. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
diff --git a/registry/remocn-ui/select-item/config.ts b/registry/remocn-ui/select-item/config.ts
index e05df26d..3418e6fa 100644
--- a/registry/remocn-ui/select-item/config.ts
+++ b/registry/remocn-ui/select-item/config.ts
@@ -8,7 +8,6 @@ export const selectItemConfig: ComponentConfig = {
label: { type: "text", default: "Banana", label: "Label" },
state: {
type: "select",
- // Default to `selected` so the preview shows the check icon + accent.
default: "selected",
options: ["idle", "hover", "press", "selected"],
label: "State",
diff --git a/registry/remocn-ui/select-item/index.tsx b/registry/remocn-ui/select-item/index.tsx
index 5d129f34..e880c901 100644
--- a/registry/remocn-ui/select-item/index.tsx
+++ b/registry/remocn-ui/select-item/index.tsx
@@ -5,44 +5,24 @@ import { mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
export type SelectItemState = "idle" | "hover" | "press" | "selected";
export interface SelectItemProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: SelectItemState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `SelectItemStyle` from `useSelectItemTransition`.
- */
style?: SelectItemStyle;
- /** Option text. */
label?: string;
- /** Row width (px). Matches the panel width when composed in `Select`. */
width?: number;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Standalone row width (px) when the atom is mounted on its own. */
const ROW_WIDTH = 260;
-// ===========================================================================
-// Select-item visual — the COMPLETE animated look for a moment in time. A
-// `state` is a named preset of this visual (`selectItemStyle`); the smooth path
-// feeds an interpolated `SelectItemStyle` straight through. The component is a
-// pure renderer of whichever `SelectItemStyle` it receives.
-// ===========================================================================
-
export interface SelectItemStyle {
- /** Animated row background (a concrete color, never "transparent"). */
background: string;
- /** Animated label color. */
labelColor: string;
- /** Check-icon opacity: 0 unless `selected` → 1. */
checkOpacity: number;
- /** Row zoom: 1 default, 0.98 on press. */
scale: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface SelectItemStyleContext {
idleBg: string;
hoverBg: string;
@@ -53,10 +33,6 @@ export interface SelectItemStyleContext {
check: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `selectItemStyle(state, ctx)` preset.
- */
export function selectItemStyleContext(
theme: RemocnTheme,
): SelectItemStyleContext {
@@ -71,10 +47,6 @@ export function selectItemStyleContext(
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => SelectItemStyle`
- * map. To change how a state looks, edit one entry.
- */
export function selectItemStyle(
state: SelectItemState,
ctx: SelectItemStyleContext,
@@ -111,27 +83,16 @@ export function selectItemStyle(
}
}
-/** Props for the inline row — the shared visual that `Select` reuses. */
export interface SelectItemRowProps {
- /** Resolved animated visual (smooth path); wins over `state` when present. */
style?: SelectItemStyle;
- /** Current visual state (snap path) when no `style` is supplied. */
state?: SelectItemState;
- /** Pre-derived ctx (the container passes its shared one to avoid re-resolving). */
ctx: SelectItemStyleContext;
label: string;
width: number;
- /** Row corner radius (px). */
radius: number;
- /** Check-icon color. */
check: string;
}
-/**
- * INLINE option row — no full-frame wrapper. One row of a select panel: label
- * left, check icon right (opacity from style). The `Select` container renders a
- * column of these; the standalone `SelectItem` wraps one in a centering frame.
- */
export function SelectItemRow({
style,
state = "idle",
@@ -181,12 +142,6 @@ export function SelectItemRow({
);
}
-/**
- * Standalone option-row atom — resolves theme/ctx/style then wraps a single
- * `<SelectItemRow>` in the standard full-frame centering wrapper. THIS is what
- * the registry registers and the customizer mounts. The `Select` container does
- * NOT use this — it reuses `SelectItemRow` directly inside its panel.
- */
export function SelectItem({
state = "idle",
style,
diff --git a/registry/remocn-ui/select-item/use-select-item-transition.ts b/registry/remocn-ui/select-item/use-select-item-transition.ts
index 3be365a9..3a2abd40 100644
--- a/registry/remocn-ui/select-item/use-select-item-transition.ts
+++ b/registry/remocn-ui/select-item/use-select-item-transition.ts
@@ -14,12 +14,9 @@ import {
type SelectItemState,
type SelectItemStyle,
} from "@/components/remocn/select-item";
-// ^ 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 = 8;
-/** Blend two select-item visuals: numbers lerp, colors via oklch mix. */
export function tweenSelectItemStyle(
a: SelectItemStyle,
b: SelectItemStyle,
@@ -40,11 +37,6 @@ export interface SelectItemTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) SelectItemStyle. The CALLER invokes this;
- * it reads the frame, the `<SelectItem>` component does not. Feed the result to
- * `<SelectItem style={...} />` (or a `SelectItemRow`) for smooth transitions.
- */
export function useSelectItemTransition(
steps: Step<SelectItemState>[],
opts: SelectItemTransitionOptions = {},
diff --git a/registry/remocn-ui/select/__tests__/select.test.ts b/registry/remocn-ui/select/__tests__/select.test.ts
index 013aa155..f25f0dbd 100644
--- a/registry/remocn-ui/select/__tests__/select.test.ts
+++ b/registry/remocn-ui/select/__tests__/select.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `select`.
- *
- * Scope:
- * - registry/remocn-ui/select/index.tsx — SelectState union membership,
- * selectStyle presets, selectStyleContext
- * - registry/remocn-ui/select/config.ts — selectConfig.controls wiring
- * + selectConfig.snippet output (the state → JSX codegen)
- * - registry/remocn-ui/select/use-select-transition.ts
- * — tweenSelectStyle interpolation, DEFAULT_DURATION
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * `<Select>` 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/select/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `SelectState` from `@/registry/remocn-ui/select` and the
- * pieces under test never CALL a Remotion runtime API at import time —
- * `selectConfig` is a plain object; `.snippet` is a pure string builder;
- * `selectStyle` and `tweenSelectStyle` 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 {
@@ -40,17 +9,8 @@ import { tweenSelectStyle, DEFAULT_DURATION } from "../use-select-transition";
import { selectConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The SelectState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type SelectState` in index.tsx.
- */
const VALID_STATES: readonly SelectState[] = ["opened", "closed"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
label?: string;
@@ -62,16 +22,8 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
selectConfig.snippet(values as Record<string, unknown>);
-/**
- * A shared SelectStyleContext built from the default light theme.
- * `selectStyleContext` takes only `(theme)` — no variant arg.
- */
const ctx = selectStyleContext(defaultLightTheme);
-// ===========================================================================
-// 1. SelectState union membership
-// ===========================================================================
-
describe("SelectState union", () => {
it("contains exactly the two documented states", () => {
const control = selectConfig.controls.state;
@@ -89,10 +41,6 @@ describe("SelectState union", () => {
});
});
-// ===========================================================================
-// 2. selectConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("selectConfig.controls.state", () => {
it("is a select control", () => {
expect(selectConfig.controls.state.type).toBe("select");
@@ -118,11 +66,6 @@ describe("selectConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. selectConfig.snippet — pure string builder
-// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.
-// ===========================================================================
-
describe("selectConfig.snippet: state prop emission", () => {
it("emits state=\"opened\" for the opened option", () => {
expect(snippet({ state: "opened" })).toContain('state="opened"');
@@ -151,7 +94,6 @@ describe("selectConfig.snippet: import line", () => {
});
describe("selectConfig.snippet: default props are omitted", () => {
- // Defaults: label="Select a fruit", selectedIndex=-1, highlightedIndex=-1, mode="light"
const allDefaults = snippet({
state: "opened",
label: "Select a fruit",
@@ -215,13 +157,6 @@ describe("selectConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. selectStyleContext — derives concrete colors from the theme.
-// Signature is `(theme)` — NO variant argument.
-// Build ctx from the default light theme and assert each field is populated.
-// `radius` is a number; all other non-nested fields are non-empty strings.
-// ===========================================================================
-
describe("selectStyleContext: field types from defaultLightTheme", () => {
it("panelBg is a non-empty string", () => {
expect(typeof ctx.panelBg).toBe("string");
@@ -280,13 +215,6 @@ describe("selectStyleContext: maps theme tokens correctly", () => {
});
});
-// ===========================================================================
-// 5. selectStyle presets — pure (state, ctx) => SelectStyle
-// All four fields are numeric. Assert per-state invariants:
-// opened → { panelOpacity:1, panelScale:1, panelTranslateY:0, chevronRotation:180 }
-// closed → { panelOpacity:0, panelScale:0.96, panelTranslateY:-4, chevronRotation:0 }
-// ===========================================================================
-
describe("selectStyle: opened state", () => {
const s = selectStyle("opened", ctx);
@@ -345,12 +273,6 @@ describe("selectStyle: closed/opened invariant", () => {
});
});
-// ===========================================================================
-// 6. tweenSelectStyle — pure linear interpolation between two SelectStyles.
-// All four fields are pure numeric lerps (no color fields).
-// Concrete expectations: closed → opened for midpoint math.
-// ===========================================================================
-
describe("tweenSelectStyle: t=0 returns values equal to `a`", () => {
const a = selectStyle("closed", ctx);
const b = selectStyle("opened", ctx);
@@ -396,8 +318,6 @@ describe("tweenSelectStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenSelectStyle: t=0.5 midpoint numeric lerp (closed → opened)", () => {
- // closed: panelOpacity=0, panelScale=0.96, panelTranslateY=-4, chevronRotation=0
- // opened: panelOpacity=1, panelScale=1, panelTranslateY=0, chevronRotation=180
const a = selectStyle("closed", ctx);
const b = selectStyle("opened", ctx);
const r = tweenSelectStyle(a, b, 0.5);
@@ -420,8 +340,6 @@ describe("tweenSelectStyle: t=0.5 midpoint numeric lerp (closed → opened)", ()
});
describe("tweenSelectStyle: t=0.5 midpoint numeric lerp (opened → closed)", () => {
- // opened: panelOpacity=1, panelScale=1, panelTranslateY=0, chevronRotation=180
- // closed: panelOpacity=0, panelScale=0.96, panelTranslateY=-4, chevronRotation=0
const a = selectStyle("opened", ctx);
const b = selectStyle("closed", ctx);
const r = tweenSelectStyle(a, b, 0.5);
@@ -443,10 +361,6 @@ describe("tweenSelectStyle: t=0.5 midpoint numeric lerp (opened → closed)", ()
});
});
-// ===========================================================================
-// 7. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
diff --git a/registry/remocn-ui/select/config.ts b/registry/remocn-ui/select/config.ts
index 1f6777d2..f6966a4a 100644
--- a/registry/remocn-ui/select/config.ts
+++ b/registry/remocn-ui/select/config.ts
@@ -8,7 +8,6 @@ export const selectConfig: ComponentConfig = {
label: { type: "text", default: "Select a fruit", label: "Label" },
state: {
type: "select",
- // Default to `opened` so the preview shows the revealed panel.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/select/index.tsx b/registry/remocn-ui/select/index.tsx
index 16c31951..d44773a0 100644
--- a/registry/remocn-ui/select/index.tsx
+++ b/registry/remocn-ui/select/index.tsx
@@ -19,65 +19,30 @@ import {
export type SelectState = "opened" | "closed";
export interface SelectProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: SelectState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `SelectStyle` from `useSelectTransition`.
- */
style?: SelectStyle;
- /** Trigger text (the always-visible row). */
label?: string;
- /**
- * Resolved Button visual for the trigger (smooth path). Drive it with
- * `useButtonTransition` for a hover/press "click". Defaults to the resting
- * Button `outline` look.
- */
triggerStyle?: ButtonStyle;
- /** Option labels rendered in the panel. */
items?: string[];
- /** Index of the persisted selection (check icon + accent). `-1` for none. */
selectedIndex?: number;
- /** Index of the row under the pointer (hover wash). `-1` for none. */
highlightedIndex?: number;
- /** Index of the row being pressed (press wash + shrink). `-1` for none. */
pressedIndex?: number;
- /**
- * Per-item resolved visual override (smooth path). When an entry is present it
- * wins over the index→state derivation — used by the live example to tween a
- * single row through hover → press → selected.
- */
itemStyles?: (SelectItemStyle | undefined)[];
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Trigger width = panel width (px). */
const WIDTH = 260;
-// ===========================================================================
-// Select visual — the COMPLETE animated look for a moment in time. A `state` is
-// a named preset of this visual (`selectStyle`); the smooth path feeds an
-// interpolated `SelectStyle` straight through. The component is a pure renderer
-// of whichever `SelectStyle` it receives. Per-row visuals are derived from the
-// index props (or `itemStyles`), independent of this container reveal.
-// ===========================================================================
-
export interface SelectStyle {
- /** Panel fade 0 (closed) → 1 (opened). */
panelOpacity: number;
- /** Panel zoom 0.96 (closed) → 1 (opened). */
panelScale: number;
- /** Panel lift -4 (closed) → 0 (opened) px. */
panelTranslateY: number;
- /** Trigger chevron rotation 0 (closed) → 180 (opened) degrees. */
chevronRotation: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface SelectStyleContext {
- /** Button `outline` presets — reused so the trigger IS the Button look. */
triggerCtx: ButtonStyleContext;
panelBg: string;
panelBorder: string;
@@ -87,10 +52,6 @@ export interface SelectStyleContext {
itemCtx: SelectItemStyleContext;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `selectStyle(state, ctx)` preset.
- */
export function selectStyleContext(theme: RemocnTheme): SelectStyleContext {
return {
triggerCtx: buttonStyleContext("outline", theme),
@@ -103,10 +64,6 @@ export function selectStyleContext(theme: RemocnTheme): SelectStyleContext {
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => SelectStyle`
- * map. To change how a state looks, edit one entry.
- */
export function selectStyle(
state: SelectState,
_ctx: SelectStyleContext,
@@ -129,7 +86,6 @@ export function selectStyle(
}
}
-/** Resolve one row's state from the index props (used when no itemStyle override). */
function rowState(
i: number,
selectedIndex: number,
@@ -160,9 +116,6 @@ export function Select({
const ctx = selectStyleContext(theme);
const v = style ?? selectStyle(state, ctx);
- // The trigger reuses the Button `outline` visual. Defaults to the resting
- // `idle` look; the caller can pass a tweened `triggerStyle` (from
- // `useButtonTransition`) so the trigger shows the hover/press "click".
const trigger: ButtonStyle =
triggerStyle ?? buttonStyle("idle", ctx.triggerCtx);
@@ -175,14 +128,13 @@ export function Select({
display: "flex",
alignItems: "center",
justifyContent: "center",
- // OPAQUE wrapper — a select is a self-contained widget, not a modal layer.
background: theme.background,
fontFamily:
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
<div style={{ position: "relative", width: WIDTH }}>
- {/* Trigger — the Button `outline` look, rendered inline. */}
+ {}
<div
style={{
width: WIDTH,
@@ -223,7 +175,7 @@ export function Select({
/>
</svg>
</div>
- {/* Panel — opacity/scale/translateY animate the reveal below the trigger. */}
+ {}
<div
style={{
position: "absolute",
diff --git a/registry/remocn-ui/select/use-select-transition.ts b/registry/remocn-ui/select/use-select-transition.ts
index 875c6514..87d97baa 100644
--- a/registry/remocn-ui/select/use-select-transition.ts
+++ b/registry/remocn-ui/select/use-select-transition.ts
@@ -13,12 +13,9 @@ import {
type SelectState,
type SelectStyle,
} from "@/components/remocn/select";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 12;
-/** Blend two select visuals: all fields are numbers, so a straight lerp. */
export function tweenSelectStyle(
a: SelectStyle,
b: SelectStyle,
@@ -41,11 +38,6 @@ export interface SelectTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) SelectStyle. The CALLER invokes this; it
- * reads the frame, the `<Select>` component does not. Feed the result to
- * `<Select style={...} />` for a smooth open/close.
- */
export function useSelectTransition(
steps: Step<SelectState>[],
opts: SelectTransitionOptions = {},
diff --git a/registry/remocn-ui/settings-toggle-flow/index.tsx b/registry/remocn-ui/settings-toggle-flow/index.tsx
index 2eb3377a..bdfcc02e 100644
--- a/registry/remocn-ui/settings-toggle-flow/index.tsx
+++ b/registry/remocn-ui/settings-toggle-flow/index.tsx
@@ -16,26 +16,6 @@ import { useToastTransition } from "@/components/remocn/use-toast-transition";
import { useBlurInTransition } from "@/components/remocn/use-blur-in-transition";
import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
-/**
- * Settings toggle flow — a shippable composition scene wrapped in a centered
- * card (muted stage behind it), laid out as a two-column settings section: a
- * descriptive text block on the LEFT, the controls stacked on the RIGHT (each
- * under its own label, including a "Volume" label for the slider) plus a
- * bottom-right Save button. Pure orchestrator: the card, its header, and each
- * control group blur-in in sequence, then a cursor flips a Switch, opens a
- * Select and picks an option, drags the Slider, and clicks Save — ending on a
- * "Settings saved" Toast. Each interaction is driven by its primitive's hook;
- * the block holds no state/effect/frame of its own. Beat `at` values are the
- * single source of truth and are frame-synced so each cursor click/press lands
- * on the same frame as the state change it triggers. The interaction timeline is
- * shifted by `DEMO` so it begins after the entrance completes.
- *
- * Each control's slot is sized to the control's intrinsic width and parked at
- * the column's left edge, so the primitive's centered `inset:0` content reads as
- * left-aligned under its label. The Select row is rendered LAST so its dropdown
- * panel paints over the Volume row below it while open.
- */
-
const DEFAULT_ROWS = [
{ label: "Notifications" },
{ label: "Theme" },
@@ -43,80 +23,59 @@ const DEFAULT_ROWS = [
];
const DEFAULT_SELECT_ITEMS = ["System", "Light", "Dark"];
-// Stage geometry (1280×720). Two columns centered on the stage: a text block on
-// the left, a controls stack on the right. Cursor X/Y targets are the centers of
-// each control as it sits at the right column's left edge.
const LEFT_X = 320;
const RIGHT_X = 700;
const COL_W = 300;
-// Notifications row → Switch (intrinsic track ~44px).
const NOTIF_LABEL_Y = 196;
const SWITCH_TOP = 222;
const SWITCH_W = 44;
const SWITCH_H = 28;
-const SWITCH_CX = RIGHT_X + SWITCH_W / 2; // 722
-const SWITCH_CY = SWITCH_TOP + SWITCH_H / 2; // 236
+const SWITCH_CX = RIGHT_X + SWITCH_W / 2;
+const SWITCH_CY = SWITCH_TOP + SWITCH_H / 2;
-// Theme row → Select (260px trigger; panel opens below).
const THEME_LABEL_Y = 280;
const SELECT_W = 260;
const TRIGGER_TOP = 320;
const TRIGGER_H = 40;
-const TRIGGER_CX = RIGHT_X + SELECT_W / 2; // 830
-const TRIGGER_CY = TRIGGER_TOP + TRIGGER_H / 2; // 340
-// Opened-panel geometry — the cursor must land on the CENTER of the selected
-// (last) row. The panel opens 6px below the trigger; rows are ~33px tall with a
-// 2px gap (matching the Select panel) inside a 4px pad. ITEM_CY is derived per
-// render from the item count.
+const TRIGGER_CX = RIGHT_X + SELECT_W / 2;
+const TRIGGER_CY = TRIGGER_TOP + TRIGGER_H / 2;
const ITEM_CX = TRIGGER_CX;
-const PANEL_TOP = TRIGGER_TOP + TRIGGER_H + 6; // 366
+const PANEL_TOP = TRIGGER_TOP + TRIGGER_H + 6;
const PANEL_PAD = 4;
const ITEM_H = 33;
const ITEM_GAP = 2;
-// Volume row → Slider (260px). Tucked just under the Select — the open dropdown
-// panel overlays this row only while open. The thumb travels value 20 → 80.
const VOL_LABEL_Y = 380;
const SLIDER_TOP = 400;
const SLIDER_W = 260;
const SLIDER_H = 16;
-const SLIDER_CY = SLIDER_TOP + SLIDER_H / 2; // 408
-const SLIDER_X0 = RIGHT_X; // 700
-const THUMB_X_AT_20 = SLIDER_X0 + 0.2 * SLIDER_W; // 752
-const THUMB_X_AT_80 = SLIDER_X0 + 0.8 * SLIDER_W; // 908
+const SLIDER_CY = SLIDER_TOP + SLIDER_H / 2;
+const SLIDER_X0 = RIGHT_X;
+const THUMB_X_AT_20 = SLIDER_X0 + 0.2 * SLIDER_W;
+const THUMB_X_AT_80 = SLIDER_X0 + 0.8 * SLIDER_W;
-// Save button — anchored bottom-right of the controls column (clear of the
-// dropdown panel's reach).
const SAVE_W = 160;
-const SAVE_LEFT = RIGHT_X + SELECT_W - SAVE_W; // 800 (right edge aligns to 960)
+const SAVE_LEFT = RIGHT_X + SELECT_W - SAVE_W;
const SAVE_TOP = 544;
const SAVE_H = 40;
-const SAVE_CX = SAVE_LEFT + SAVE_W / 2; // 880
-const SAVE_CY = SAVE_TOP + SAVE_H / 2; // 564
+const SAVE_CX = SAVE_LEFT + SAVE_W / 2;
+const SAVE_CY = SAVE_TOP + SAVE_H / 2;
-// Card — bounds the two columns with uniform padding, centered on the stage.
const CARD_PAD = 44;
-const CARD_LEFT = LEFT_X - CARD_PAD; // 276
-const CARD_TOP = NOTIF_LABEL_Y - CARD_PAD; // 152
-const CARD_W = RIGHT_X + SELECT_W + CARD_PAD - CARD_LEFT; // 728
-const CARD_H = SAVE_TOP + SAVE_H + CARD_PAD - CARD_TOP; // 476
+const CARD_LEFT = LEFT_X - CARD_PAD;
+const CARD_TOP = NOTIF_LABEL_Y - CARD_PAD;
+const CARD_W = RIGHT_X + SELECT_W + CARD_PAD - CARD_LEFT;
+const CARD_H = SAVE_TOP + SAVE_H + CARD_PAD - CARD_TOP;
-// Frames the entrance occupies; the interaction timeline starts after it.
const DEMO = 44;
export interface SettingsToggleFlowProps {
- /** Section title shown in the left text column. */
title?: string;
- /** Supporting paragraph under the title. */
description?: string;
- /** Setting rows (label only): [0] switch, [1] select, [2] slider. */
rows?: { label: string }[];
- /** Options shown in the Select panel. */
selectItems?: string[];
- /** Label of the bottom-right save button. */
saveLabel?: string;
- /** Headline of the success toast. */
toastTitle?: string;
mode?: "light" | "dark";
theme?: Partial<RemocnTheme>;
@@ -135,15 +94,10 @@ export function SettingsToggleFlow({
const resolved = useRemocnTheme(theme, mode);
const opts = { mode, theme };
- // Center Y of the selected (last) panel row — derived from the panel geometry
- // so the cursor lands dead-center regardless of how many items there are.
const lastItem = selectItems.length - 1;
const ITEM_CY =
PANEL_TOP + PANEL_PAD + lastItem * (ITEM_H + ITEM_GAP) + ITEM_H / 2;
- // Entrance — card surface fades in place (distance 0 → no slide, so it never
- // becomes a transform containing block), then the header and each control
- // group blur-in staggered, all complete by frame 58 (< first click at 68).
const cardEnter = useBlurInTransition(
[{ at: 0, state: "revealed", duration: 18 }],
{ distance: 0 },
@@ -164,18 +118,12 @@ export function SettingsToggleFlow({
{ at: 42, state: "revealed", duration: 16 },
]);
- // Resolve a blur-in style to the inline props applied to a positioned group.
- // Each group's slot is already a positioned containing block, so a transform
- // here never hijacks the inset:0 atoms inside it.
const reveal = (e: { opacity: number; blur: number; translateX: number; translateY: number }) => ({
opacity: e.opacity,
filter: e.blur > 0 ? `blur(${e.blur}px)` : "none",
transform: `translate(${e.translateX}px, ${e.translateY}px)`,
});
- // Cursor: click Switch (24) → click Select trigger (55) → click item (80) →
- // press Slider thumb (105) and drag to 150 → release → click Save (180). Each
- // click/press `at` equals the driven primitive's `at`; all shifted by DEMO.
const cursorStyle = useCursorPath([
{ at: 0, x: 220, y: 130 },
{ at: 24 + DEMO, x: SWITCH_CX, y: SWITCH_CY, duration: 20 },
@@ -192,13 +140,11 @@ export function SettingsToggleFlow({
{ at: 180 + DEMO, x: SAVE_CX, y: SAVE_CY, click: true, duration: 0 },
]);
- // Switch turns on at the click (24 + DEMO).
const switchStyle = useSwitchTransition(
[{ at: 24 + DEMO, state: "checked", duration: 12 }],
opts,
);
- // Select panel opens at 55 + DEMO, closes at 90 + DEMO.
const panelStyle = useSelectTransition(
[
{ at: 55 + DEMO, state: "opened", duration: 14 },
@@ -207,7 +153,6 @@ export function SettingsToggleFlow({
opts,
);
- // The select trigger "click" — hover into the open press at 55 + DEMO.
const triggerStyle = useButtonTransition(
[
{ at: 45 + DEMO, state: "hover", duration: 8 },
@@ -216,7 +161,6 @@ export function SettingsToggleFlow({
{ variant: "outline", ...opts },
);
- // The last item is highlighted, pressed, then selected at 80 + DEMO.
const itemStyle = useSelectItemTransition(
[
{ at: 68 + DEMO, state: "hover", duration: 8 },
@@ -226,8 +170,6 @@ export function SettingsToggleFlow({
opts,
);
- // Dual-channel slider: value eases 20 → 80 across the drag while the thumb
- // idles → press → idle, all from one hook. Holds 20 through the entrance.
const sliderStyle = useSliderTransition([
{ at: 0, value: 20, thumbState: "idle" },
{ at: 105 + DEMO, thumbState: "press", duration: 6 },
@@ -236,8 +178,6 @@ export function SettingsToggleFlow({
{ at: 158 + DEMO, thumbState: "idle", duration: 8 },
]);
- // Save button — hovers, presses into the click at 180 + DEMO, then shows a
- // success check. The toast follows it.
const saveStyle = useButtonTransition(
[
{ at: 172 + DEMO, state: "hover", duration: 8 },
@@ -247,8 +187,6 @@ export function SettingsToggleFlow({
opts,
);
- // Toast enters after the Save click, auto-dismisses 60 frames later. The toast
- // hook tints by `mode` only; `theme` rides the component prop below.
const toastStyle = useToastTransition(
[
{ at: 196 + DEMO, state: "visible", duration: 12 },
@@ -275,7 +213,7 @@ export function SettingsToggleFlow({
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
- {/* Card surface — fades in place (distance 0, no transform). */}
+ {}
<div
style={{
position: "absolute",
@@ -294,7 +232,7 @@ export function SettingsToggleFlow({
}}
/>
- {/* LEFT — descriptive text column. */}
+ {}
<div
style={{
position: "absolute",
@@ -329,7 +267,7 @@ export function SettingsToggleFlow({
</div>
</div>
- {/* RIGHT — Notifications (switch). */}
+ {}
<div
style={{
position: "absolute",
@@ -354,8 +292,7 @@ export function SettingsToggleFlow({
<Switch style={switchStyle} mode={mode} theme={theme} />
</div>
- {/* RIGHT — Volume (slider). Rendered before the Select so the dropdown
- panel paints over this row while open. */}
+ {}
<div
style={{
position: "absolute",
@@ -378,8 +315,7 @@ export function SettingsToggleFlow({
<Slider style={sliderStyle} width={SLIDER_W} mode={mode} theme={theme} />
</div>
- {/* RIGHT — Theme (select). Last in the DOM so the open panel overlays the
- Volume row below the trigger. */}
+ {}
<div
style={{
position: "absolute",
@@ -414,8 +350,7 @@ export function SettingsToggleFlow({
/>
</div>
- {/* Save button — bottom-right of the controls column; the cursor clicks it
- (180 + DEMO) just before the toast appears. */}
+ {}
<div
style={{
position: "absolute",
@@ -429,7 +364,7 @@ export function SettingsToggleFlow({
<Button label={saveLabel} style={saveStyle} mode={mode} theme={theme} />
</div>
- {/* Success toast, anchored bottom-right. */}
+ {}
<div style={{ position: "absolute", right: 24, bottom: 24 }}>
<Toast
style={toastStyle}
diff --git a/registry/remocn-ui/sheet/__tests__/sheet.test.ts b/registry/remocn-ui/sheet/__tests__/sheet.test.ts
index bbec6656..4b0b4c75 100644
--- a/registry/remocn-ui/sheet/__tests__/sheet.test.ts
+++ b/registry/remocn-ui/sheet/__tests__/sheet.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `sheet`.
- *
- * Scope:
- * - registry/remocn-ui/sheet/index.tsx — SheetState union membership,
- * sheetStyle presets, sheetStyleContext
- * - registry/remocn-ui/sheet/config.ts — sheetConfig.controls wiring
- * + sheetConfig.snippet output (the state → JSX codegen)
- * - registry/remocn-ui/sheet/use-sheet-transition.ts
- * — tweenSheetStyle interpolation, DEFAULT_DURATION
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * `<Sheet>` 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/sheet/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `SheetState` from `@/registry/remocn-ui/sheet`
- * and the pieces under test never CALL a Remotion runtime API at import time —
- * `sheetConfig` is a plain object; `.snippet` is a pure string builder;
- * `sheetStyle` and `tweenSheetStyle` 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 {
@@ -40,17 +9,8 @@ import { tweenSheetStyle, DEFAULT_DURATION } from "../use-sheet-transition";
import { sheetConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The SheetState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type SheetState` in index.tsx.
- */
const VALID_STATES: readonly SheetState[] = ["opened", "closed"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
title?: string;
@@ -63,28 +23,16 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
sheetConfig.snippet(values as Record<string, unknown>);
-/**
- * A shared SheetStyleContext built from the default light theme.
- * `sheetStyleContext` takes only `(theme)` — no variant arg, unlike accordion.
- */
const ctx = sheetStyleContext(defaultLightTheme);
-// ===========================================================================
-// 1. SheetState union membership
-// ===========================================================================
-
describe("SheetState 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 = sheetConfig.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 = sheetConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(VALID_STATES).toHaveLength(2);
@@ -94,10 +42,6 @@ describe("SheetState union", () => {
});
});
-// ===========================================================================
-// 2. sheetConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("sheetConfig.controls.state", () => {
it("is a select control", () => {
expect(sheetConfig.controls.state.type).toBe("select");
@@ -123,15 +67,6 @@ describe("sheetConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. sheetConfig.snippet — pure string builder
-// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.
-// It NEVER emits `steps`.
-// Note on `action`: the snippet emits `actionLabel=` (a legitimate prop) but
-// must never emit a bare `action=` attribute. We assert `steps` is absent and
-// add a targeted check that `action=` only ever appears as `actionLabel=`.
-// ===========================================================================
-
describe("sheetConfig.snippet: state prop emission", () => {
it("emits state=\"opened\" for the opened option", () => {
expect(snippet({ state: "opened" })).toContain('state="opened"');
@@ -152,9 +87,6 @@ describe("sheetConfig.snippet: state prop emission", () => {
});
describe("sheetConfig.snippet: NEVER emits steps", () => {
- // `action=` is intentionally NOT checked here because `actionLabel=` is a
- // legitimate emitted prop and would cause a false positive on a naive
- // `.toContain("action")` check. Assert `steps` absence only.
it("never emits `steps` in any state", () => {
for (const state of VALID_STATES) {
expect(snippet({ state })).not.toContain("steps");
@@ -171,9 +103,6 @@ describe("sheetConfig.snippet: import line", () => {
});
describe("sheetConfig.snippet: default props are omitted", () => {
- // Defaults: title="Edit profile",
- // description="Make changes to your profile here. Click save when you're done.",
- // actionLabel="Save changes", cancelLabel="Cancel", mode="light"
const allDefaults = snippet({
state: "opened",
title: "Edit profile",
@@ -247,13 +176,6 @@ describe("sheetConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. sheetStyleContext — derives concrete colors from the theme.
-// Signature is `(theme)` — NO variant argument (unlike accordion).
-// Build ctx from the default light theme and assert each field is populated.
-// `radius` is a number (px); all other fields are non-empty strings.
-// ===========================================================================
-
describe("sheetStyleContext: field types from defaultLightTheme", () => {
it("popoverBg is a non-empty string", () => {
expect(typeof ctx.popoverBg).toBe("string");
@@ -295,13 +217,6 @@ describe("sheetStyleContext: field types from defaultLightTheme", () => {
});
});
-// ===========================================================================
-// 5. sheetStyle presets — pure (state, ctx) => SheetStyle
-// sheetStyleContext and sheetStyle are exported and frame-free.
-// Build one ctx from the default light theme, then assert the numeric
-// invariants for every state.
-// ===========================================================================
-
describe("sheetStyle: closed state", () => {
const s = sheetStyle("closed", ctx);
@@ -350,12 +265,6 @@ describe("sheetStyle: closed/opened invariant", () => {
});
});
-// ===========================================================================
-// 6. tweenSheetStyle — pure linear interpolation between two SheetStyles.
-// All three fields are pure numeric lerps (no color fields, unlike accordion).
-// Concrete expectations: closed → opened for midpoint math.
-// ===========================================================================
-
describe("tweenSheetStyle: t=0 returns values equal to `a`", () => {
const a = sheetStyle("closed", ctx);
const b = sheetStyle("opened", ctx);
@@ -393,8 +302,6 @@ describe("tweenSheetStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenSheetStyle: t=0.5 midpoint numeric lerp (closed → opened)", () => {
- // closed: overlayOpacity=0, panelOpacity=0, panelTranslateX=400
- // opened: overlayOpacity=1, panelOpacity=1, panelTranslateX=0
const a = sheetStyle("closed", ctx);
const b = sheetStyle("opened", ctx);
const r = tweenSheetStyle(a, b, 0.5);
@@ -413,8 +320,6 @@ describe("tweenSheetStyle: t=0.5 midpoint numeric lerp (closed → opened)", ()
});
describe("tweenSheetStyle: t=0.5 midpoint numeric lerp (opened → closed)", () => {
- // opened: overlayOpacity=1, panelOpacity=1, panelTranslateX=0
- // closed: overlayOpacity=0, panelOpacity=0, panelTranslateX=400
const a = sheetStyle("opened", ctx);
const b = sheetStyle("closed", ctx);
const r = tweenSheetStyle(a, b, 0.5);
@@ -432,10 +337,6 @@ describe("tweenSheetStyle: t=0.5 midpoint numeric lerp (opened → closed)", ()
});
});
-// ===========================================================================
-// 7. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
diff --git a/registry/remocn-ui/sheet/config.ts b/registry/remocn-ui/sheet/config.ts
index 6514d4cc..5bc5a68e 100644
--- a/registry/remocn-ui/sheet/config.ts
+++ b/registry/remocn-ui/sheet/config.ts
@@ -22,7 +22,6 @@ export const sheetConfig: ComponentConfig = {
cancelLabel: { type: "text", default: "Cancel", label: "Cancel Label" },
state: {
type: "select",
- // Default to `opened` so the preview shows the panel.
default: "opened",
options: ["opened", "closed"],
label: "State",
diff --git a/registry/remocn-ui/sheet/index.tsx b/registry/remocn-ui/sheet/index.tsx
index d8fd9d05..c363c00d 100644
--- a/registry/remocn-ui/sheet/index.tsx
+++ b/registry/remocn-ui/sheet/index.tsx
@@ -5,48 +5,26 @@ import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
export type SheetState = "opened" | "closed";
export interface SheetProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: SheetState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `SheetStyle` from `useSheetTransition`.
- */
style?: SheetStyle;
- /** Headline of the sheet. */
title?: string;
- /** Body copy under the title. */
description?: string;
- /** Label of the confirming (primary) action. */
actionLabel?: string;
- /** Label of the dismissing action. */
cancelLabel?: string;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Side panel width (px). */
const SHEET_WIDTH = 400;
-/** Backdrop dim at full reveal — the overlay opacity scales up to this alpha. */
const MAX_OVERLAY_ALPHA = 0.5;
-// ===========================================================================
-// Sheet visual — the COMPLETE animated look for a moment in time. A `state` is
-// a named preset of this visual (`sheetStyle`); the smooth path feeds an
-// interpolated `SheetStyle` straight through. The component is a pure renderer
-// of whichever `SheetStyle` it receives.
-// ===========================================================================
-
export interface SheetStyle {
- /** Backdrop dim reveal 0→1 (scales `MAX_OVERLAY_ALPHA`). */
overlayOpacity: number;
- /** Panel fade 0→1. */
panelOpacity: number;
- /** Panel slide in px: SHEET_WIDTH = off-screen-right → 0 = resting. */
panelTranslateX: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface SheetStyleContext {
popoverBg: string;
popoverFg: string;
@@ -58,10 +36,6 @@ export interface SheetStyleContext {
cancelFg: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `sheetStyle(state, ctx)` preset.
- */
export function sheetStyleContext(theme: RemocnTheme): SheetStyleContext {
return {
popoverBg: theme.popover,
@@ -69,17 +43,12 @@ export function sheetStyleContext(theme: RemocnTheme): SheetStyleContext {
mutedFg: theme.mutedForeground,
border: theme.border,
radius: theme.radius,
- // The action is the PRIMARY (affirmative) action — not destructive.
actionBg: theme.primary,
actionFg: theme.primaryForeground,
cancelFg: theme.foreground,
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => SheetStyle`
- * map. To change how a state looks, edit one entry.
- */
export function sheetStyle(
state: SheetState,
_ctx: SheetStyleContext,
@@ -116,10 +85,6 @@ export function Sheet({
const ctx = sheetStyleContext(theme);
const v = style ?? sheetStyle(state, ctx);
- // Shared base for the two footer buttons. These are plain inline `<button>`s,
- // not the remocn `Button` component — that renders a full-frame scene wrapper
- // (absolute inset) and so can't nest inline here; the sizing mirrors its
- // `default` size.
const buttonBase: React.CSSProperties = {
height: 40,
padding: "0 20px",
@@ -134,9 +99,6 @@ export function Sheet({
};
return (
- // The wrapper is TRANSPARENT — unlike button/accordion (which paint an
- // opaque `theme.background`), this atom is a modal layer meant to compose
- // OVER another scene, so it must not blanket the frame with a background.
<div
style={{
position: "absolute",
@@ -145,7 +107,7 @@ export function Sheet({
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
- {/* Backdrop dim — fades in as the sheet opens. */}
+ {}
<div
style={{
position: "absolute",
@@ -173,7 +135,7 @@ export function Sheet({
boxShadow: "-24px 0 48px -12px rgba(0,0,0,0.25)",
}}
>
- {/* Close (X) — static chrome in the top-right corner, not animated. */}
+ {}
<button
type="button"
style={{
@@ -223,7 +185,7 @@ export function Sheet({
marginTop: "auto",
}}
>
- {/* Cancel — outline variant. */}
+ {}
<button
type="button"
style={{
@@ -235,7 +197,7 @@ export function Sheet({
>
{cancelLabel}
</button>
- {/* Action — primary variant. */}
+ {}
<button
type="button"
style={{
diff --git a/registry/remocn-ui/sheet/use-sheet-transition.ts b/registry/remocn-ui/sheet/use-sheet-transition.ts
index fe0f18d8..586678dc 100644
--- a/registry/remocn-ui/sheet/use-sheet-transition.ts
+++ b/registry/remocn-ui/sheet/use-sheet-transition.ts
@@ -13,12 +13,9 @@ import {
type SheetState,
type SheetStyle,
} from "@/components/remocn/sheet";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 12;
-/** Blend two sheet visuals: all three fields are pure numeric lerps. */
export function tweenSheetStyle(
a: SheetStyle,
b: SheetStyle,
@@ -39,11 +36,6 @@ export interface SheetTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) SheetStyle. The CALLER invokes this;
- * it reads the frame, the `<Sheet>` component does not. Feed the result to
- * `<Sheet style={...} />` for smooth open/close transitions.
- */
export function useSheetTransition(
steps: Step<SheetState>[],
opts: SheetTransitionOptions = {},
diff --git a/registry/remocn-ui/signup-flow/index.tsx b/registry/remocn-ui/signup-flow/index.tsx
index b2609eb2..c1f83340 100644
--- a/registry/remocn-ui/signup-flow/index.tsx
+++ b/registry/remocn-ui/signup-flow/index.tsx
@@ -20,23 +20,14 @@ import {
} from "@/components/remocn/field";
export interface SignupFlowProps {
- /** Card title. */
title?: string;
- /** Card description under the title. */
description?: string;
- /** Value typed into the Full Name field. */
fullName?: string;
- /** Value typed into the Email field. */
email?: string;
- /** Value typed into the password fields (rendered as the masked string). */
password?: string;
- /** Primary submit button label. */
createLabel?: string;
- /** Outline (social) button label. */
googleLabel?: string;
- /** Footer prompt shown before the "Sign in" link. */
signinText?: string;
- /** Title shown in the success toast. */
toastTitle?: string;
mode?: "light" | "dark";
theme?: Partial<RemocnTheme>;
@@ -45,8 +36,8 @@ export interface SignupFlowProps {
const STAGE_W = 1280;
const CARD_W = 376;
const CARD_TOP = 48;
-const CARD_LEFT = (STAGE_W - CARD_W) / 2; // 452
-const CENTER_X = STAGE_W / 2; // 640 — the centered content column
+const CARD_LEFT = (STAGE_W - CARD_W) / 2;
+const CENTER_X = STAGE_W / 2;
const NAME_Y = 216;
const EMAIL_Y = 296;
diff --git a/registry/remocn-ui/skeleton-block/__tests__/skeleton-block.test.ts b/registry/remocn-ui/skeleton-block/__tests__/skeleton-block.test.ts
index 068dce6b..da27b441 100644
--- a/registry/remocn-ui/skeleton-block/__tests__/skeleton-block.test.ts
+++ b/registry/remocn-ui/skeleton-block/__tests__/skeleton-block.test.ts
@@ -1,43 +1,7 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `skeleton-block`.
- *
- * Scope:
- * - registry/remocn-ui/skeleton-block/config.ts
- * skeletonBlockConfig.controls wiring + skeletonBlockConfig.snippet codegen
- *
- * WHY RENDER IS NOT UNIT-TESTED:
- * `SkeletonBlock` is a MOTION ATOM — it is the only file in the skeleton
- * primitive family explicitly allowed to read the frame. It calls
- * `useCurrentFrame()` directly (line 52 of index.tsx) and also calls
- * `useRemocnTheme()`. Neither can be called outside a Remotion render context.
- * The shimmer offset computation (`positionX = 100 - progress * 200`, where
- * `progress = (frame * speed % SWEEP_FRAMES) / SWEEP_FRAMES`) is module-private
- * and not exported. Per STYLE-GUIDE §10, frame-reading hooks are excluded from
- * unit tests; only the pure surface is in scope here.
- *
- * The shimmer seamless-loop property (frame 0 and frame SWEEP_FRAMES render
- * identically, positionX is monotonically decreasing within a cycle) is
- * documented in README.md and verified by reading the source; it cannot be
- * tested without a Remotion render context.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/skeleton-block/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative import for config only. SkeletonBlock itself is NOT imported here.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import { skeletonBlockConfig } from "../config";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
width?: number;
height?: number;
@@ -46,10 +10,6 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
skeletonBlockConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. skeletonBlockConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("skeletonBlockConfig.controls: width", () => {
it("width is a number control", () => {
expect(skeletonBlockConfig.controls.width.type).toBe("number");
@@ -101,10 +61,6 @@ describe("skeletonBlockConfig.controls: radius", () => {
});
});
-// ===========================================================================
-// 2. skeletonBlockConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("skeletonBlockConfig.snippet: import line", () => {
it("includes 'import { SkeletonBlock }' from the correct path", () => {
const out = snippet({});
@@ -124,7 +80,6 @@ describe("skeletonBlockConfig.snippet: structural invariants", () => {
});
describe("skeletonBlockConfig.snippet: default props are omitted", () => {
- // Defaults: width=240, height=20, radius=6
it("omits width when it equals the default 240", () => {
const out = snippet({ width: 240 });
@@ -142,7 +97,6 @@ describe("skeletonBlockConfig.snippet: default props are omitted", () => {
});
it("all defaults omitted → compact self-closing element on one line", () => {
- // When all props are default, propsBlock is "" and the element is compact
const out = snippet({ width: 240, height: 20, radius: 6 });
expect(out).toContain("<SkeletonBlock/>");
});
diff --git a/registry/remocn-ui/skeleton-block/index.tsx b/registry/remocn-ui/skeleton-block/index.tsx
index 6e8db6b0..79e84def 100644
--- a/registry/remocn-ui/skeleton-block/index.tsx
+++ b/registry/remocn-ui/skeleton-block/index.tsx
@@ -4,38 +4,18 @@ import { useCurrentFrame } from "remotion";
import { mixOklch, useRemocnTheme } from "@/lib/remocn-ui";
export interface SkeletonBlockProps {
- /** Block width in px (or any CSS length via string). */
width?: number | string;
- /** Block height in px. */
height?: number;
- /** Corner radius in px. */
radius?: number;
- /** Playhead scale: a full shimmer sweep takes (SWEEP_FRAMES / speed) frames. */
speed?: number;
- /** Base (resting) color of the block. Defaults to the theme muted token. */
baseColor?: string;
- /** Moving highlight color of the sweep. Defaults to a lighter wash. */
highlightColor?: string;
- /** CSS `flex-shrink`. Set 0 to stop a fixed-size block (e.g. an avatar) from
- * collapsing when it sits in a flex row narrower than its blocks. */
flexShrink?: number;
className?: string;
}
-/** Frames for one full shimmer sweep at speed 1. The loop is seamless. */
const SWEEP_FRAMES = 60;
-/**
- * A deterministic shimmer block — the motion atom behind `Skeleton`'s
- * placeholder. A diagonal highlight gradient sweeps left→right and wraps
- * seamlessly: background-position cycles over exactly one period of the
- * 200%-wide gradient, so frame 0 and frame SWEEP_FRAMES render identically.
- *
- * Pure function of `useCurrentFrame()` — it uses no wall-clock, no randomness,
- * and no animation-frame callbacks — so it renders frame-perfectly on the
- * Remotion timeline. This is a MOTION atom: the only file here allowed to read
- * the frame.
- */
export function SkeletonBlock({
width = 120,
height = 16,
@@ -48,17 +28,8 @@ export function SkeletonBlock({
}: SkeletonBlockProps) {
const theme = useRemocnTheme();
const base = baseColor ?? theme.muted;
- // Derive the moving highlight from the base toward the high-contrast
- // `foreground` token (dark in light theme, light in dark theme), so the sweep
- // band is visibly different from the base in BOTH themes. We deliberately do
- // NOT use the muted/accent tokens for the highlight — in the default theme
- // those equal the base, giving a zero-contrast (invisible) shimmer. 0.13 is
- // subtle but clearly visible.
const highlight = highlightColor ?? mixOklch(base, theme.foreground, 0.13);
- // progress 0→1 over one sweep, then wraps. The gradient is 200% wide and we
- // pan background-position from 100% → -100% across the period; because the
- // gradient tiles, position 100% and -100% are visually identical → seamless.
const frame = useCurrentFrame() * speed;
const progress = (frame % SWEEP_FRAMES) / SWEEP_FRAMES;
const positionX = 100 - progress * 200;
diff --git a/registry/remocn-ui/skeleton-block/preview.tsx b/registry/remocn-ui/skeleton-block/preview.tsx
index 461f043b..618d7f31 100644
--- a/registry/remocn-ui/skeleton-block/preview.tsx
+++ b/registry/remocn-ui/skeleton-block/preview.tsx
@@ -10,12 +10,6 @@ export interface SkeletonBlockPreviewProps {
speed?: number;
}
-/**
- * Preview-only wrapper for the customizer. The shipped `SkeletonBlock` is a bare
- * inline block; the customizer Player renders its `component` as the composition
- * root, so this thin wrapper centers it on a theme-background stage just for the
- * preview. NOT shipped: not listed in registry.json files.
- */
export function SkeletonBlockPreview({
width = 240,
height = 20,
diff --git a/registry/remocn-ui/skeleton/__tests__/skeleton.test.ts b/registry/remocn-ui/skeleton/__tests__/skeleton.test.ts
index b04d060f..3fa10be5 100644
--- a/registry/remocn-ui/skeleton/__tests__/skeleton.test.ts
+++ b/registry/remocn-ui/skeleton/__tests__/skeleton.test.ts
@@ -1,35 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `skeleton`.
- *
- * Scope:
- * - registry/remocn-ui/skeleton/index.tsx
- * skeletonStyle(state) — complete state→visual preset map
- * (crossfade invariant: opacities sum to 1)
- * - registry/remocn-ui/skeleton/use-skeleton-transition.ts
- * tweenSkeletonStyle(a, b, t) — pure lerp across both fields
- * DEFAULT_DURATION constant
- * useSkeletonTransition resolver — mirrored as resolveSkeletonTransition
- * with frame injected as `raw` (annotated source lines)
- * - registry/remocn-ui/skeleton/config.ts
- * skeletonConfig.controls wiring + skeletonConfig.snippet codegen
- *
- * The render path (index.tsx) imports `useRemocnTheme` which requires React
- * context — it is NOT exercised here. The pure-testable surface is everything
- * above.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/skeleton/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports from component source; `@/lib/remocn-ui` alias for core.
- * `skeletonStyle` and `tweenSkeletonStyle` are pure value functions — they call
- * neither `useCurrentFrame()` nor `useRemocnTheme` at import or call time.
- * `useSkeletonTransition` IS a hook (calls `useStateTransition` → `useCurrentFrame`)
- * and is NOT imported; we mirror its pure resolver body below.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -45,14 +13,9 @@ import { skeletonConfig } from "../config";
import { defaultLightTheme, defaultDarkTheme, easings } from "@/lib/remocn-ui";
import type { Step } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
const VALID_STATES: readonly SkeletonState[] = ["loading", "loaded"];
const VALID_LAYOUTS: readonly SkeletonLayout[] = ["lines", "card"];
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
state?: string;
layout?: string;
@@ -61,22 +24,12 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
skeletonConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is 12 frames", () => {
expect(DEFAULT_DURATION).toBe(12);
});
});
-// ===========================================================================
-// 2. skeletonStyle — pure (state) => SkeletonStyle map
-// MIRROR of index.tsx lines 56-63
-// KEY INVARIANT: skeletonOpacity + contentOpacity === 1 in every preset.
-// ===========================================================================
-
describe("skeletonStyle: loading state — placeholder visible", () => {
const s = skeletonStyle("loading");
@@ -136,18 +89,10 @@ describe("skeletonStyle: both states satisfy the crossfade invariant", () => {
});
it("unknown state falls through to loading preset (skeletonOpacity=1)", () => {
- // switch default arm → loading preset
expect(skeletonStyle("loading").skeletonOpacity).toBe(1);
});
});
-// ===========================================================================
-// 3. tweenSkeletonStyle — pure lerp across both fields
-// MIRROR of use-skeleton-transition.ts lines 23-34
-// KEY INVARIANT: the tween of two complementary pairs is complementary —
-// the crossfade invariant is preserved at every t.
-// ===========================================================================
-
describe("tweenSkeletonStyle: t=0 returns values equal to `a`", () => {
const a = skeletonStyle("loading");
const b = skeletonStyle("loaded");
@@ -185,9 +130,6 @@ describe("tweenSkeletonStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenSkeletonStyle: t=0.5 midpoint (loading → loaded)", () => {
- // loading: skeletonOpacity=1, contentOpacity=0
- // loaded: skeletonOpacity=0, contentOpacity=1
- // midpoint: skeletonOpacity=0.5, contentOpacity=0.5
const a = skeletonStyle("loading");
const b = skeletonStyle("loaded");
const r = tweenSkeletonStyle(a, b, 0.5);
@@ -241,8 +183,6 @@ describe("tweenSkeletonStyle: identity (a === b, any t)", () => {
});
describe("tweenSkeletonStyle: t=0.25 quarter-point (loading → loaded)", () => {
- // skeletonOpacity: 1 + 0.25*(0-1) = 0.75
- // contentOpacity: 0 + 0.25*(1-0) = 0.25
const a = skeletonStyle("loading");
const b = skeletonStyle("loaded");
const r = tweenSkeletonStyle(a, b, 0.25);
@@ -280,34 +220,14 @@ describe("tweenSkeletonStyle: crossfade invariant holds at any arbitrary t", ()
});
});
-// ===========================================================================
-// 4. useSkeletonTransition resolver replica
-// MIRRORS use-skeleton-transition.ts lines 47-60.
-// `useSkeletonTransition` calls `useStateTransition` (which reads
-// `useCurrentFrame()`) then applies `easings.out(progress)` and
-// `tweenSkeletonStyle`. We inject `raw` in place of `useCurrentFrame()`.
-//
-// Key additional contract: progress is eased with `easings.out` before the
-// tween. The crossfade invariant must hold on the eased result too.
-//
-// MAINTENANCE CONTRACT: if use-skeleton-transition.ts lines 47-60 change,
-// update this replica in lockstep. Annotated source lines below.
-// ===========================================================================
-
-/** MIRROR of core/timeline.ts:clamp01. */
function clamp01Mirror(t: number): number {
return Math.max(0, Math.min(1, t));
}
-/** MIRROR of core/motion.ts:easings.out (cubic ease-out). */
function easingOut(t: number): number {
return 1 - (1 - t) ** 3;
}
-/**
- * MIRROR of timeline.ts:useStateTransition pure resolver body,
- * with `raw` injected.
- */
function resolveStateTransition<S extends string>(
raw: number,
steps: Step<S>[],
@@ -329,41 +249,28 @@ function resolveStateTransition<S extends string>(
return { from: from ? from.state : defaultState, to: to.state, progress };
}
-/**
- * MIRROR of use-skeleton-transition.ts:useSkeletonTransition (lines 47-60).
- * `raw` is injected in place of useCurrentFrame().
- * Annotated source lines:
- * line 51: destructure speed + defaultDuration from opts
- * line 52-57: call useStateTransition (mirrored as resolveStateTransition)
- * line 58: t = easings.out(progress) ← MIRROR line 58
- * line 59: tweenSkeletonStyle(from, to, t) ← MIRROR line 59
- */
function resolveSkeletonTransition(
raw: number, // injected useCurrentFrame() — MIRROR line 52
steps: Step<SkeletonState>[],
speed = 1,
defaultDuration = DEFAULT_DURATION,
): { style: ReturnType<typeof tweenSkeletonStyle>; progress: number; from: SkeletonState; to: SkeletonState } {
- const { from, to, progress } = resolveStateTransition( // MIRROR lines 52-57
+ const { from, to, progress } = resolveStateTransition(
raw,
steps,
"loading",
speed,
defaultDuration,
);
- const t = easingOut(progress); // MIRROR line 58
+ const t = easingOut(progress);
const style = tweenSkeletonStyle(
skeletonStyle(from as SkeletonState),
skeletonStyle(to as SkeletonState),
t,
- ); // MIRROR line 59
+ );
return { style, progress, from: from as SkeletonState, to: to as SkeletonState };
}
-// ---------------------------------------------------------------------------
-// Before any step: holds at loading
-// ---------------------------------------------------------------------------
-
describe("resolveSkeletonTransition: before any step — holds at loading", () => {
it("returns the loading style when no steps have started", () => {
const { style } = resolveSkeletonTransition(0, []);
@@ -384,10 +291,6 @@ describe("resolveSkeletonTransition: before any step — holds at loading", () =
});
});
-// ---------------------------------------------------------------------------
-// Exactly at a step boundary: progress=0, t=out(0)=0
-// ---------------------------------------------------------------------------
-
describe("resolveSkeletonTransition: exactly at loading→loaded step boundary", () => {
const steps: Step<SkeletonState>[] = [{ at: 10, state: "loaded" }];
@@ -406,14 +309,7 @@ describe("resolveSkeletonTransition: exactly at loading→loaded step boundary",
});
});
-// ---------------------------------------------------------------------------
-// Mid-window: easings.out applied — non-linear + crossfade invariant
-// ---------------------------------------------------------------------------
-
describe("resolveSkeletonTransition: mid-window uses easings.out (not linear)", () => {
- // step at=0, dur=12. At raw=6: progress=0.5, t=out(0.5)=0.875
- // skeletonOpacity: tween(1, 0, 0.875) = 1 - 0.875 = 0.125
- // contentOpacity: tween(0, 1, 0.875) = 0.875
const steps: Step<SkeletonState>[] = [{ at: 0, state: "loaded" }];
it("skeletonOpacity at raw=6 is tween(1,0,out(0.5))=0.125 (not linear 0.5)", () => {
@@ -432,10 +328,6 @@ describe("resolveSkeletonTransition: mid-window uses easings.out (not linear)",
});
});
-// ---------------------------------------------------------------------------
-// Past the window: fully loaded
-// ---------------------------------------------------------------------------
-
describe("resolveSkeletonTransition: past the transition window → fully loaded", () => {
const steps: Step<SkeletonState>[] = [{ at: 0, state: "loaded" }];
@@ -455,12 +347,7 @@ describe("resolveSkeletonTransition: past the transition window → fully loaded
});
});
-// ---------------------------------------------------------------------------
-// Speed contract
-// ---------------------------------------------------------------------------
-
describe("resolveSkeletonTransition: speed contract", () => {
- // step at=12. speed=2: effectiveFrame = raw*2 → fires at raw=6.
const steps: Step<SkeletonState>[] = [{ at: 12, state: "loaded" }];
it("speed=2: step at=12 fires at raw=6 (eff=12)", () => {
@@ -474,10 +361,6 @@ describe("resolveSkeletonTransition: speed contract", () => {
});
});
-// ===========================================================================
-// 5. skeletonConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("skeletonConfig.controls: state", () => {
it("state is a select control", () => {
expect(skeletonConfig.controls.state.type).toBe("select");
@@ -542,10 +425,6 @@ describe("skeletonConfig.controls: mode", () => {
});
});
-// ===========================================================================
-// 6. skeletonConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("skeletonConfig.snippet: import line", () => {
it("includes 'import { Skeleton }' from the correct path", () => {
const out = snippet({ state: "loading" });
@@ -574,7 +453,6 @@ describe("skeletonConfig.snippet: structural invariants", () => {
});
describe("skeletonConfig.snippet: default props are omitted", () => {
- // Defaults: layout='lines' (snippet omits when 'lines'), mode='light'
it("omits layout when it equals the default 'lines'", () => {
const out = snippet({ state: "loading", layout: "lines" });
expect(out).not.toContain("layout=");
diff --git a/registry/remocn-ui/skeleton/config.ts b/registry/remocn-ui/skeleton/config.ts
index ccb2838b..0294a405 100644
--- a/registry/remocn-ui/skeleton/config.ts
+++ b/registry/remocn-ui/skeleton/config.ts
@@ -13,7 +13,6 @@ export const skeletonConfig: ComponentConfig = {
},
state: {
type: "select",
- // Default to `loading` so the preview showcases the live shimmer.
default: "loading",
options: ["loading", "loaded"],
label: "State",
diff --git a/registry/remocn-ui/skeleton/index.tsx b/registry/remocn-ui/skeleton/index.tsx
index 702f7097..e7728093 100644
--- a/registry/remocn-ui/skeleton/index.tsx
+++ b/registry/remocn-ui/skeleton/index.tsx
@@ -6,53 +6,25 @@ import { SkeletonBlock } from "@/components/remocn/skeleton-block";
export type SkeletonState = "loading" | "loaded";
-/** Built-in placeholder layouts assembled from SkeletonBlock. */
export type SkeletonLayout = "lines" | "card";
export interface SkeletonProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: SkeletonState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `SkeletonStyle` from `useSkeletonTransition`.
- */
style?: SkeletonStyle;
- /** The real content. It sits in normal flow and DEFINES the box size. */
children?: ReactNode;
- /**
- * Custom placeholder layer (arbitrary SkeletonBlock arrangement). Overrides
- * `layout` when present.
- */
placeholder?: ReactNode;
- /** Built-in placeholder when no `placeholder` is given. */
layout?: SkeletonLayout;
- /** Playhead scale forwarded to the placeholder SkeletonBlocks. */
speed?: number;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-// ===========================================================================
-// Skeleton visual — the COMPLETE animated look for a moment in time. A `state` is
-// a named preset of this visual (`skeletonStyle`); the smooth path feeds an
-// interpolated `SkeletonStyle` straight through. The component is a pure renderer
-// — it reads NO frame (only the composed SkeletonBlock motion atom does). The two
-// opacities CROSSFADE and sum to 1 per preset (child crossfade rule §3).
-// ===========================================================================
-
export interface SkeletonStyle {
- /** Placeholder layer opacity. */
skeletonOpacity: number;
- /** Real-content layer opacity. Always `1 - skeletonOpacity`. */
contentOpacity: number;
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state) => SkeletonStyle` map.
- * The two opacities sum to 1 so the crossfade never dims the box. To change how a
- * state looks, edit one entry.
- */
export function skeletonStyle(state: SkeletonState): SkeletonStyle {
switch (state) {
case "loaded":
@@ -62,7 +34,6 @@ export function skeletonStyle(state: SkeletonState): SkeletonStyle {
}
}
-/** A built-in placeholder layout, assembled from SkeletonBlock motion atoms. */
function LayoutPlaceholder({
layout,
speed,
@@ -70,20 +41,13 @@ function LayoutPlaceholder({
}: {
layout: SkeletonLayout;
speed?: number;
- /** Base shimmer color threaded from the resolved Skeleton theme. */
baseColor: string;
}) {
- // Pass the resolved base color explicitly so a per-instance Skeleton
- // `theme`/`mode` override reaches the built-in placeholder's blocks
- // (SkeletonBlock would otherwise resolve its own default theme). The highlight
- // is intentionally NOT passed — SkeletonBlock derives a visible contrast band
- // from this base, so a themed Skeleton gets a themed, visible shimmer.
const shimmer = { speed, baseColor };
if (layout === "card") {
return (
<div style={{ display: "flex", gap: 14, alignItems: "center" }}>
- {/* flexShrink:0 keeps the avatar a clean 48px circle even if the
- content box is narrower than this placeholder row. */}
+ {}
<SkeletonBlock
width={48}
height={48}
@@ -98,7 +62,6 @@ function LayoutPlaceholder({
</div>
);
}
- // lines — stacked rows of decreasing width.
return (
<div style={{ display: "flex", flexDirection: "column", gap: 10 }}>
<SkeletonBlock width={260} height={14} {...shimmer} />
@@ -108,13 +71,6 @@ function LayoutPlaceholder({
);
}
-/**
- * A deterministic skeleton→content crossfade. Pure renderer of whatever
- * `SkeletonStyle` it receives — it reads no frame, holds no state, runs no
- * effects (only the composed `SkeletonBlock` reads the frame). The real content
- * sits in normal flow and sets the box; the placeholder is an absolute overlay,
- * so the box does not jump as they crossfade.
- */
export function Skeleton({
state = "loading",
style,
@@ -126,14 +82,9 @@ export function Skeleton({
mode,
className,
}: SkeletonProps) {
- // Resolve the theme so the built-in placeholder's shimmer follows a
- // per-instance theme/mode override (its base = theme.muted; SkeletonBlock
- // derives the contrast highlight from that base).
const theme = useRemocnTheme(themeOverride, mode);
const v = style ?? skeletonStyle(state);
- // A custom `placeholder` is the caller's own markup — they theme its blocks.
- // Only the built-in layouts get the resolved base color threaded in.
const placeholderLayer = placeholder ?? (
<LayoutPlaceholder layout={layout} speed={speed} baseColor={theme.muted} />
);
@@ -148,9 +99,9 @@ export function Skeleton({
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
- {/* Real content — normal flow, defines the box. */}
+ {}
<div style={{ opacity: v.contentOpacity }}>{children}</div>
- {/* Placeholder — absolute overlay so the box does not jump on crossfade. */}
+ {}
<div
style={{
position: "absolute",
diff --git a/registry/remocn-ui/skeleton/preview.tsx b/registry/remocn-ui/skeleton/preview.tsx
index b834fbb0..df025ff7 100644
--- a/registry/remocn-ui/skeleton/preview.tsx
+++ b/registry/remocn-ui/skeleton/preview.tsx
@@ -14,7 +14,6 @@ export interface SkeletonPreviewProps {
speed?: number;
}
-/** Demo content matching each layout, so the loaded state has something real. */
function DemoContent({
layout,
theme,
@@ -34,9 +33,7 @@ function DemoContent({
background: theme.secondary,
}}
/>
- {/* width 180 matches the card placeholder's text column, so the loaded
- content box ≈ the placeholder box (avatar 48 + gap 14 + 180): the
- box width is stable between loading and loaded, no overflow/shift. */}
+ {}
<div
style={{
display: "flex",
@@ -73,13 +70,6 @@ function DemoContent({
);
}
-/**
- * Preview-only wrapper for the customizer. The shipped `Skeleton` needs real
- * `children` (they define the box) and renders inline; the customizer Player
- * renders its `component` as the composition root, so this wrapper supplies demo
- * content for the chosen layout and centers it on a theme-background stage. NOT
- * shipped: not listed in registry.json files.
- */
export function SkeletonPreview({
layout = "card",
state = "loading",
diff --git a/registry/remocn-ui/skeleton/use-skeleton-transition.ts b/registry/remocn-ui/skeleton/use-skeleton-transition.ts
index 5e2a0478..45217e0f 100644
--- a/registry/remocn-ui/skeleton/use-skeleton-transition.ts
+++ b/registry/remocn-ui/skeleton/use-skeleton-transition.ts
@@ -10,16 +10,9 @@ import {
type SkeletonState,
type SkeletonStyle,
} from "@/components/remocn/skeleton";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 12;
-/**
- * Blend two skeleton visuals: both opacities lerp. They stay summing to 1
- * because the endpoints do and a lerp of two complementary pairs is complementary
- * — so the crossfade never dims the box. No animated colors here.
- */
export function tweenSkeletonStyle(
a: SkeletonStyle,
b: SkeletonStyle,
@@ -39,11 +32,6 @@ export interface SkeletonTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) SkeletonStyle. The CALLER invokes this; it
- * reads the frame, the `<Skeleton>` component does not. Feed the result to
- * `<Skeleton style={...} />` for a smooth loading→loaded crossfade.
- */
export function useSkeletonTransition(
steps: Step<SkeletonState>[],
opts: SkeletonTransitionOptions = {},
diff --git a/registry/remocn-ui/slider/__tests__/slider.test.ts b/registry/remocn-ui/slider/__tests__/slider.test.ts
index 270e3fa3..a81ba370 100644
--- a/registry/remocn-ui/slider/__tests__/slider.test.ts
+++ b/registry/remocn-ui/slider/__tests__/slider.test.ts
@@ -1,35 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `slider`.
- *
- * Scope:
- * - registry/remocn-ui/slider/index.tsx
- * clampValue (internal) — exercised via SliderStyle semantics
- * sliderThumbStyle(thumbState) — pure thumb-channel preset map
- * sliderStyleContext(theme) — pure theme → color derivation
- * - registry/remocn-ui/slider/use-slider-transition.ts
- * tweenSliderStyle(a, b, t) — pure lerp across all three fields
- * sliderStyleAt(steps, raw, opts) — pure exported dual-channel core
- * DEFAULT_DURATION constant
- * - registry/remocn-ui/slider/config.ts
- * sliderConfig.controls wiring + sliderConfig.snippet codegen
- *
- * The render path (index.tsx) imports `useRemocnTheme` which requires React
- * context — it is NOT exercised here. `useSliderTransition` IS a hook (calls
- * `useCurrentFrame()`) and is NOT imported; its pure body is the exported
- * `sliderStyleAt` which we call directly.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/slider/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports from component source; `@/lib/remocn-ui` alias for core.
- * `sliderThumbStyle`, `sliderStyleContext`, and `tweenSliderStyle` / `sliderStyleAt`
- * are pure value functions. `useSliderTransition` IS a hook and is NOT imported;
- * we call `sliderStyleAt` directly (the exported pure core).
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -46,13 +14,8 @@ import {
import { sliderConfig } from "../config";
import { defaultLightTheme, defaultDarkTheme, easings, clamp01 } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
const VALID_THUMB_STATES: readonly SliderThumbState[] = ["idle", "hover", "press"];
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
value?: number;
thumbState?: string;
@@ -63,22 +26,12 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
sliderConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is 18 frames", () => {
expect(DEFAULT_DURATION).toBe(18);
});
});
-// ===========================================================================
-// 2. clampValue semantics — the component applies clamp01(value/100)*100
-// MIRROR of index.tsx lines 53-55 (clampValue function).
-// ===========================================================================
-
-/** MIRROR of index.tsx:clampValue */
function clampValue(value: number): number {
return clamp01(value / 100) * 100;
}
@@ -121,11 +74,6 @@ describe("clampValue: in-range values pass through unchanged", () => {
});
});
-// ===========================================================================
-// 3. showValue label — renders Math.round(pct)
-// MIRROR of index.tsx line 218: {Math.round(pct)}
-// ===========================================================================
-
describe("showValue label: Math.round applied to clamped value", () => {
it("Math.round(62.4) = 62", () => {
expect(Math.round(clampValue(62.4))).toBe(62);
@@ -144,11 +92,6 @@ describe("showValue label: Math.round applied to clamped value", () => {
});
});
-// ===========================================================================
-// 4. sliderThumbStyle — pure (thumbState) => {thumbScale, ringOpacity} map
-// MIRROR of index.tsx lines 62-74
-// ===========================================================================
-
describe("sliderThumbStyle: idle state — default thumb", () => {
const s = sliderThumbStyle("idle");
@@ -209,20 +152,6 @@ describe("sliderThumbStyle: every state returns numeric fields", () => {
});
});
-// ===========================================================================
-// 5. sliderStyleContext — pure theme → SliderStyleContext
-// MIRROR of index.tsx lines 100-113 (post-shadcn retheme)
-//
-// Field changes vs original:
-// track: was theme.muted, now mixOklch(theme.input, theme.background, 0.1)
-// range: unchanged — theme.primary
-// thumbBorder: REMOVED (no longer a field)
-// thumbBg: was theme.background, now literal "oklch(1 0 0)" (white, theme-independent)
-// thumbRing: NEW — literal "rgba(0, 0, 0, 0.1)" (resting hairline, theme-independent)
-// ring: was mixOklch(primary,bg,0.55), now mixOklch(theme.ring, theme.background, 0.7)
-// valueText: unchanged — theme.foreground
-// ===========================================================================
-
describe("sliderStyleContext: light theme", () => {
const ctx = sliderStyleContext(defaultLightTheme);
@@ -291,12 +220,6 @@ describe("sliderStyleContext: all fields are non-empty strings", () => {
});
});
-// ===========================================================================
-// 6. tweenSliderStyle — pure lerp across all three fields
-// MIRROR of use-slider-transition.ts lines 42-52
-// Both channels (value + thumb) are covered in one tween.
-// ===========================================================================
-
describe("tweenSliderStyle: t=0 returns values equal to `a`", () => {
const a = { value: 0, thumbScale: 1, ringOpacity: 0 };
const b = { value: 100, thumbScale: 1.1, ringOpacity: 1 };
@@ -330,9 +253,6 @@ describe("tweenSliderStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenSliderStyle: t=0.5 midpoint", () => {
- // a: value=0, thumbScale=1(idle), ringOpacity=0
- // b: value=100, thumbScale=1.1(hover), ringOpacity=1
- // midpoints: value=50, thumbScale=1.05, ringOpacity=0.5
const a = { value: 0, thumbScale: 1, ringOpacity: 0 };
const b = { value: 100, thumbScale: 1.1, ringOpacity: 1 };
const r = tweenSliderStyle(a, b, 0.5);
@@ -360,9 +280,6 @@ describe("tweenSliderStyle: identity (a === b, any t)", () => {
});
describe("tweenSliderStyle: idle → press thumb channel", () => {
- // idle: thumbScale=1, ringOpacity=0
- // press: thumbScale=1.15, ringOpacity=1
- // t=0.5: thumbScale=1.075, ringOpacity=0.5
const a = { value: 0, ...sliderThumbStyle("idle") };
const b = { value: 0, ...sliderThumbStyle("press") };
const r = tweenSliderStyle(a, b, 0.5);
@@ -375,21 +292,7 @@ describe("tweenSliderStyle: idle → press thumb channel", () => {
});
});
-// ===========================================================================
-// 7. sliderStyleAt — pure exported dual-channel core
-// MIRROR of use-slider-transition.ts lines 148-161.
-// useSliderTransition is exactly sliderStyleAt(steps, useCurrentFrame()*speed, opts).
-// We call sliderStyleAt directly with the frame injected as `raw`.
-//
-// The two channels (value + thumb) are folded INDEPENDENTLY from the same
-// step list, filtering to value-bearing and thumb-bearing steps respectively.
-//
-// MAINTENANCE CONTRACT: if use-slider-transition.ts lines 69-161 change,
-// update these tests in lockstep. Annotated source lines below.
-// ===========================================================================
-
describe("sliderStyleAt: empty steps → value=0, thumb=idle", () => {
- // source lines 78/112: empty value/thumb steps → return 0 / sliderThumbStyle('idle')
it("empty steps returns {value:0, thumbScale:1, ringOpacity:0}", () => {
const r = sliderStyleAt([], 0);
expect(r.value).toBe(0);
@@ -399,7 +302,6 @@ describe("sliderStyleAt: empty steps → value=0, thumb=idle", () => {
});
describe("sliderStyleAt: before first value step — holds at first.value", () => {
- // source line 80: if (raw <= first.at) return first.value
const steps: SliderStep[] = [{ at: 10, value: 60 }];
it("raw=5 < first.at=10 → holds at first.value=60", () => {
@@ -412,7 +314,6 @@ describe("sliderStyleAt: before first value step — holds at first.value", () =
});
describe("sliderStyleAt: before first thumb step — holds at first.thumbState preset", () => {
- // source line 114: if (raw <= first.at) return sliderThumbStyle(first.thumbState)
const steps: SliderStep[] = [{ at: 10, thumbState: "hover" }];
it("raw=5 holds at hover preset (thumbScale=1.1)", () => {
@@ -421,7 +322,6 @@ describe("sliderStyleAt: before first thumb step — holds at first.thumbState p
});
describe("sliderStyleAt: past last value step — rests at last.value", () => {
- // source lines 89-92: pastLast → to=from=last, t=1
const steps: SliderStep[] = [{ at: 0, value: 0 }, { at: 18, value: 75 }];
it("raw=50 → value=75 (rests at last)", () => {
@@ -430,8 +330,6 @@ describe("sliderStyleAt: past last value step — rests at last.value", () => {
});
describe("sliderStyleAt: value channel mid-window uses easings.out", () => {
- // [{at:0,value:0},{at:18,value:100}], raw=9 → start=0, linear=0.5, t=out(0.5)=0.875
- // value = 0 + 100*0.875 = 87.5
const steps: SliderStep[] = [{ at: 0, value: 0 }, { at: 18, value: 100 }];
it("value at raw=9 is 87.5 (out-eased, not linear 50)", () => {
@@ -445,9 +343,6 @@ describe("sliderStyleAt: value channel mid-window uses easings.out", () => {
});
describe("sliderStyleAt: thumb channel mid-window uses easings.out", () => {
- // [{at:0,thumbState:'idle'},{at:18,thumbState:'hover'}], raw=9
- // t=out(0.5)=0.875; idle={1,0}, hover={1.1,1}
- // thumbScale: 1 + 0.1*0.875 = 1.0875, ringOpacity: 0 + 1*0.875 = 0.875
const steps: SliderStep[] = [{ at: 0, thumbState: "idle" }, { at: 18, thumbState: "hover" }];
it("thumbScale at raw=9 is 1.0875 (out-eased)", () => {
@@ -460,9 +355,6 @@ describe("sliderStyleAt: thumb channel mid-window uses easings.out", () => {
});
describe("sliderStyleAt: dual-channel steps fold independently", () => {
- // value steps: [{at:0,value:0},{at:18,value:100}]
- // thumb steps: [{at:0,thumbState:'idle'},{at:18,thumbState:'hover'}]
- // Both in same step list via combined steps
const steps: SliderStep[] = [
{ at: 0, value: 0, thumbState: "idle" },
{ at: 18, value: 100, thumbState: "hover" },
@@ -480,7 +372,6 @@ describe("sliderStyleAt: dual-channel steps fold independently", () => {
});
describe("sliderStyleAt: channels can have different step counts", () => {
- // Only value steps, no thumb steps → thumb stays idle
const valueOnlySteps: SliderStep[] = [{ at: 0, value: 0 }, { at: 18, value: 100 }];
it("thumb is idle when no thumb steps are present", () => {
@@ -489,7 +380,6 @@ describe("sliderStyleAt: channels can have different step counts", () => {
expect(r.ringOpacity).toBe(sliderThumbStyle("idle").ringOpacity);
});
- // Only thumb steps, no value steps → value stays 0
const thumbOnlySteps: SliderStep[] = [{ at: 0, thumbState: "idle" }, { at: 18, thumbState: "hover" }];
it("value is 0 when no value steps are present", () => {
@@ -508,10 +398,6 @@ describe("sliderStyleAt: past last with both channels", () => {
});
});
-// ===========================================================================
-// 8. sliderConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("sliderConfig.controls: value", () => {
it("value is a number control", () => {
expect(sliderConfig.controls.value.type).toBe("number");
@@ -571,10 +457,6 @@ describe("sliderConfig.controls: mode", () => {
});
});
-// ===========================================================================
-// 9. sliderConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("sliderConfig.snippet: import line", () => {
it("includes 'import { Slider }' from the correct path", () => {
const out = snippet({ value: 40 });
diff --git a/registry/remocn-ui/slider/index.tsx b/registry/remocn-ui/slider/index.tsx
index d0a3cb4f..adab91d6 100644
--- a/registry/remocn-ui/slider/index.tsx
+++ b/registry/remocn-ui/slider/index.tsx
@@ -4,63 +4,33 @@ import { clamp01, mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remoc
export type SliderThumbState = "idle" | "hover" | "press";
-// ===========================================================================
-// Slider visual — the COMPLETE animated look for a moment in time. This is a
-// DUAL-channel atom (value-channel deviation §0): the numeric `value` animates
-// as a lerp while the thumb visuals (`thumbScale`, `ringOpacity`) come from a
-// `thumbState` preset. Both live in one `SliderStyle`; `useSliderTransition`
-// feeds an interpolated one through the `style` prop. The component never reads
-// the frame.
-// ===========================================================================
-
export interface SliderStyle {
- /** Fill percentage 0–100 (clamped by the renderer). */
value: number;
- /** Thumb zoom: 1 idle, grows on hover/press. */
thumbScale: number;
- /** Grab-ring opacity 0 (idle) → 1 (hover/press). */
ringOpacity: number;
}
export interface SliderProps {
- /** Fill percentage 0–100 (snap path). Clamped. Ignored when `style` is set. */
value?: number;
- /** Thumb visual state (snap path). Ignored when `style` is set. */
thumbState?: SliderThumbState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `value`/`thumbState` — feed it an interpolated `SliderStyle` from
- * `useSliderTransition`.
- */
style?: SliderStyle;
- /** Track width in px. */
width?: number;
- /** Show the current value above the thumb. */
showValue?: boolean;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Track height (px) — shadcn `h-2`. */
const TRACK_HEIGHT = 8;
-/** Thumb pill — shadcn `h-4 w-6` (16×24), `rounded-full` → radius = height/2. */
const THUMB_HEIGHT = 16;
const THUMB_WIDTH = 24;
const THUMB_RADIUS = THUMB_HEIGHT / 2;
-/** Grab-ring width (px) at full opacity — shadcn `ring-4`. */
const RING_WIDTH = 4;
-/** Clamp a 0–100 value to [0,100]. Reuses core clamp01 on the normalized value. */
function clampValue(value: number): number {
return clamp01(value / 100) * 100;
}
-/**
- * The thumb-channel preset for a state — pure `(thumbState) => {thumbScale,
- * ringOpacity}`. Hover and press both grow the thumb and show the grab ring;
- * press grows it a touch more. The `value` channel is independent of this.
- */
export function sliderThumbStyle(thumbState: SliderThumbState): {
thumbScale: number;
ringOpacity: number;
@@ -75,49 +45,26 @@ export function sliderThumbStyle(thumbState: SliderThumbState): {
}
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface SliderStyleContext {
- /** Track rail — shadcn `bg-input/90`. */
track: string;
- /** Range fill — shadcn `bg-primary`. */
range: string;
- /** Thumb fill — shadcn white in both themes. */
thumbBg: string;
- /** Resting 1px ring on the thumb — shadcn `ring-1 ring-black/10`. */
thumbRing: string;
- /** Grab ring — shadcn `ring-ring/30` (baked to ~30% via a mix toward bg). */
ring: string;
- /** showValue label color. */
valueText: string;
}
-/**
- * Derive the concrete colors for a theme. Pure. Matches the current shadcn
- * slider: an `input` track, a white thumb, and a `ring`-token grab ring baked to
- * ~30% (a mix toward the background) so it reads as a soft but visible halo in
- * both light and dark.
- */
export function sliderStyleContext(theme: RemocnTheme): SliderStyleContext {
return {
- // bg-input/90 — nudge the input token 10% toward background for the /90.
track: mixOklch(theme.input, theme.background, 0.1),
range: theme.primary,
- // shadcn thumb is white in both themes.
thumbBg: "oklch(1 0 0)",
- // ring-black/10 resting hairline.
thumbRing: "rgba(0, 0, 0, 0.1)",
- // ring-ring/30 → ~30% of the ring token: 70% toward background.
ring: mixOklch(theme.ring, theme.background, 0.7),
valueText: theme.foreground,
};
}
-/**
- * A deterministic slider. Pure renderer of whatever it receives — it reads no
- * frame, holds no state, runs no effects. Snap (`value` + `thumbState`) and
- * smooth (`style`) share one render path. Placement is the caller's job; the
- * slider renders inline.
- */
export function Slider({
value = 0,
thumbState = "idle",
@@ -152,7 +99,7 @@ export function Slider({
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
- {/* Track — muted rail. */}
+ {}
<div
style={{
position: "relative",
@@ -162,7 +109,7 @@ export function Slider({
background: ctx.track,
}}
>
- {/* Range — primary fill from the left to `value%`. */}
+ {}
<div
style={{
position: "absolute",
@@ -175,8 +122,7 @@ export function Slider({
}}
/>
</div>
- {/* Thumb — positioned at value%, centered via translateX(-50%). The grab
- ring sits behind it, fading in on hover/press. */}
+ {}
<div
style={{
position: "absolute",
@@ -185,8 +131,7 @@ export function Slider({
transform: `translate(-50%, -50%) scale(${v.thumbScale})`,
}}
>
- {/* Grab ring — a rounded-rect halo hugging the pill, fading in on
- hover/press (shadcn ring-4 ring-ring/30). */}
+ {}
<div
style={{
position: "absolute",
@@ -200,8 +145,7 @@ export function Slider({
opacity: v.ringOpacity,
}}
/>
- {/* Thumb — white 16×24 pill with shadow-md and a resting ring-1
- ring-black/10 hairline (inset box-shadow). */}
+ {}
<div
style={{
position: "relative",
diff --git a/registry/remocn-ui/slider/preview.tsx b/registry/remocn-ui/slider/preview.tsx
index e2171846..e5edc342 100644
--- a/registry/remocn-ui/slider/preview.tsx
+++ b/registry/remocn-ui/slider/preview.tsx
@@ -11,12 +11,6 @@ export interface SliderPreviewProps {
mode?: "light" | "dark";
}
-/**
- * Preview-only wrapper for the customizer. The shipped `Slider` is a
- * placement-agnostic inline bar; the customizer Player renders its `component`
- * as the composition root, so this thin wrapper centers it on a theme-background
- * stage just for the preview. NOT shipped: not listed in registry.json files.
- */
export function SliderPreview({
value = 40,
thumbState = "idle",
diff --git a/registry/remocn-ui/slider/use-slider-transition.ts b/registry/remocn-ui/slider/use-slider-transition.ts
index a546313b..9c3cfde0 100644
--- a/registry/remocn-ui/slider/use-slider-transition.ts
+++ b/registry/remocn-ui/slider/use-slider-transition.ts
@@ -7,38 +7,22 @@ import {
type SliderStyle,
type SliderThumbState,
} from "@/components/remocn/slider";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/**
- * One scripted slider keyframe. A step may move the `value` channel, the
- * `thumbState` channel, or both. The value eases from the previous value-bearing
- * step to this one; the thumb visual tweens from the previous thumb-bearing
- * step's preset to this one.
- */
export interface SliderStep {
- /** LOCAL (Sequence-relative) authored frame this keyframe is reached. */
at: number;
- /** Target fill percentage 0–100 (this step moves the value channel). */
value?: number;
- /** Target thumb state (this step moves the thumb channel). */
thumbState?: SliderThumbState;
- /** Frames the move INTO this step takes. Omitted → DEFAULT_DURATION. */
duration?: number;
- /** Override the easing for the move into this step. Default `out`. */
easing?: EasingName;
}
-/** Default frames for a move into a step when it omits `duration`. */
export const DEFAULT_DURATION = 18;
export interface SliderTransitionOptions {
- /** Playhead scale (effectiveFrame = useCurrentFrame() * speed). */
speed?: number;
- /** Move duration (frames) when a step omits `duration`. */
defaultDuration?: number;
}
-/** Blend two slider visuals: all three fields lerp (value + thumb channels). */
export function tweenSliderStyle(
a: SliderStyle,
b: SliderStyle,
@@ -51,12 +35,6 @@ export function tweenSliderStyle(
};
}
-/**
- * Resolve the slider's `SliderStyle` for a dual-channel timeline. THIS is the
- * only frame-reading file — `<Slider>` itself stays pure. The fold is a pure
- * function of `raw = useCurrentFrame() * speed`; tests replicate
- * `sliderStyleAt(steps, raw, opts)` with the frame injected.
- */
export function useSliderTransition(
steps: SliderStep[],
opts: SliderTransitionOptions = {},
@@ -66,7 +44,6 @@ export function useSliderTransition(
return sliderStyleAt(steps, raw, opts);
}
-/** Eased value at `raw` over the value-bearing steps (numeric channel). */
function valueAt(
steps: SliderStep[],
raw: number,
@@ -99,7 +76,6 @@ function valueAt(
return from.value + (to.value - from.value) * t;
}
-/** Eased thumb visual at `raw` over the thumb-bearing steps (state channel). */
function thumbAt(
steps: SliderStep[],
raw: number,
@@ -139,12 +115,6 @@ function thumbAt(
};
}
-/**
- * Pure core of `useSliderTransition` with the effective frame injected as `raw`.
- * The two channels are folded independently and merged: `value` eases over the
- * value-bearing steps, the thumb visual tweens over the thumb-bearing steps.
- * Kept separate so it can be unit-tested without a Remotion render.
- */
export function sliderStyleAt(
steps: SliderStep[],
raw: number,
diff --git a/registry/remocn-ui/spinner/index.tsx b/registry/remocn-ui/spinner/index.tsx
index 29570f74..5bee1848 100644
--- a/registry/remocn-ui/spinner/index.tsx
+++ b/registry/remocn-ui/spinner/index.tsx
@@ -3,23 +3,13 @@
import { useCurrentFrame } from "remotion";
export interface SpinnerProps {
- /** Rendered size in px (width === height). */
size?: number;
- /** Stroke color. Defaults to `currentColor` so it inherits text color. */
color?: string;
- /** Scales the playhead: rotation = frame * speed * 6 (deg). */
speed?: number;
- /** Arc stroke width in viewBox units. */
strokeWidth?: number;
className?: string;
}
-/**
- * A deterministic spinning arc. Pure function of `useCurrentFrame()` — no
- * Date, Math.random, or RAF — so it renders identically every render and
- * frame-perfectly on the Remotion timeline. The single time source is the
- * frame; there are no states.
- */
export function Spinner({
size = 20,
color = "currentColor",
diff --git a/registry/remocn-ui/stepper/__tests__/stepper.test.ts b/registry/remocn-ui/stepper/__tests__/stepper.test.ts
index ed02c9a7..90743d23 100644
--- a/registry/remocn-ui/stepper/__tests__/stepper.test.ts
+++ b/registry/remocn-ui/stepper/__tests__/stepper.test.ts
@@ -1,39 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `stepper`.
- *
- * Scope:
- * - registry/remocn-ui/stepper/index.tsx
- * StepperStyle interface — position field semantics
- * stepperStyle(activeIndex) — pure identity preset
- * stepperStyleContext(theme) — token mapping
- * stepCircleAt(i, position) — per-step fill/checkDraw/active thresholds
- * connectorFillAt(i, position) — connector fill fraction
- * - registry/remocn-ui/stepper/use-stepper-transition.ts
- * tweenStepperStyle(a, b, t) — pure single-field lerp
- * stepperStyleAt(steps, raw, opts) — pure exported core of useStepperTransition
- * DEFAULT_DURATION constant
- * StepperStep interface semantics
- * - registry/remocn-ui/stepper/config.ts
- * stepperConfig.controls wiring + stepperConfig.snippet codegen
- *
- * The render path (Stepper JSX) calls `useRemocnTheme` (React context) — NOT
- * exercised here. `useStepperTransition` is exactly
- * `stepperStyleAt(steps, useCurrentFrame() * speed, opts)` — we call
- * `stepperStyleAt` directly (the exported pure core).
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/stepper/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports for component source; `@/lib/remocn-ui` for core alias.
- * `stepperStyleAt` and `tweenStepperStyle` are pure value functions — they
- * call neither `useCurrentFrame()` nor `useRemocnTheme` at import or call time.
- * `useStepperTransition` IS a hook and is NOT imported; we call `stepperStyleAt`
- * directly (the exported pure core, documented as such in the source).
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -51,11 +15,6 @@ import {
import { stepperConfig } from "../config";
import { defaultLightTheme, easings } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
activeIndex?: number;
mode?: string;
@@ -63,10 +22,6 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
stepperConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
@@ -78,12 +33,6 @@ describe("DEFAULT_DURATION", () => {
});
});
-// ===========================================================================
-// 2. stepperStyleContext — token mapping
-// MIRROR of index.tsx lines 76-85.
-// Maps: primary, primaryFg, mutedBg, border, mutedFg, foreground.
-// ===========================================================================
-
describe("stepperStyleContext: token mapping (light theme)", () => {
const ctx = stepperStyleContext(defaultLightTheme);
@@ -112,12 +61,6 @@ describe("stepperStyleContext: token mapping (light theme)", () => {
});
});
-// ===========================================================================
-// 3. stepperStyle preset — pure (activeIndex) => StepperStyle
-// MIRROR of index.tsx lines 91-93.
-// stepperStyle(activeIndex) = { position: activeIndex }
-// ===========================================================================
-
describe("stepperStyle: identity map", () => {
it("stepperStyle(0) returns position=0", () => {
expect(stepperStyle(0).position).toBe(0);
@@ -136,21 +79,6 @@ describe("stepperStyle: identity map", () => {
});
});
-// ===========================================================================
-// 4. stepCircleAt — per-step fill / checkDraw / active thresholds
-// MIRROR of index.tsx lines 108-123.
-// fill = clamp01(position - i)
-// checkDraw = fill
-// active = Math.floor(position) === i && fill < 1
-//
-// Key positions tested (3-step stepper, i in {0,1,2}):
-// position=0: step 0 active, steps 1/2 future
-// position=0.5: step 0 mid-fill (active), step 1 future
-// position=1: step 0 completed, step 1 active
-// position=1.5: step 0 completed, step 1 mid-fill (active), step 2 future
-// position=2: steps 0/1 completed, step 2 active (fill=0)
-// ===========================================================================
-
describe("stepCircleAt: position=0 (first step active, rest future)", () => {
it("step 0: fill=0, checkDraw=0, active=true", () => {
const r = stepCircleAt(0, 0);
@@ -252,7 +180,6 @@ describe("stepCircleAt: position=2 (steps 0/1 completed, step 2 active)", () =>
});
it("step 2: fill=0, checkDraw=0, active=true (last step reached)", () => {
- // floor(2)=2, fill=clamp(2-2)=0 → active=true
const r = stepCircleAt(2, 2);
expect(r.fill).toBe(0);
expect(r.checkDraw).toBe(0);
@@ -286,13 +213,6 @@ describe("stepCircleAt: fill and checkDraw are always equal", () => {
}
});
-// ===========================================================================
-// 5. connectorFillAt — connector primary-fill fraction between steps
-// MIRROR of index.tsx lines 126-128.
-// connectorFillAt(i, position) = clamp01(position - i)
-// Same formula as stepCircleAt fill — tests confirm the identity.
-// ===========================================================================
-
describe("connectorFillAt: connector between step 0 and 1", () => {
it("position=0: fill=0 (connector empty)", () => {
expect(connectorFillAt(0, 0)).toBe(0);
@@ -331,12 +251,6 @@ describe("connectorFillAt: negative result is clamped to 0", () => {
});
});
-// ===========================================================================
-// 6. tweenStepperStyle — pure single-field lerp
-// MIRROR of use-stepper-transition.ts lines 34-40.
-// position lerps linearly: a.position + (b.position - a.position) * t
-// ===========================================================================
-
describe("tweenStepperStyle: t=0 returns value equal to a", () => {
it("position equals a.position at t=0", () => {
const r = tweenStepperStyle({ position: 0 }, { position: 2 }, 0);
@@ -352,7 +266,6 @@ describe("tweenStepperStyle: t=1 returns value equal to b", () => {
});
describe("tweenStepperStyle: t=0.5 midpoint (0 → 2)", () => {
- // 0 + (2-0)*0.5 = 1
it("0 → 2 at t=0.5 gives position=1", () => {
const r = tweenStepperStyle({ position: 0 }, { position: 2 }, 0.5);
expect(r.position).toBeCloseTo(1, 10);
@@ -360,7 +273,6 @@ describe("tweenStepperStyle: t=0.5 midpoint (0 → 2)", () => {
});
describe("tweenStepperStyle: t=0.5 midpoint (1 → 0, reverse)", () => {
- // 1 + (0-1)*0.5 = 0.5
it("1 → 0 at t=0.5 gives position=0.5", () => {
const r = tweenStepperStyle({ position: 1 }, { position: 0 }, 0.5);
expect(r.position).toBeCloseTo(0.5, 10);
@@ -375,25 +287,13 @@ describe("tweenStepperStyle: identity (a === b)", () => {
});
describe("tweenStepperStyle: t=0.25 quarter-point", () => {
- // 0 + (2-0)*0.25 = 0.5
it("0 → 2 at t=0.25 gives position=0.5", () => {
const r = tweenStepperStyle({ position: 0 }, { position: 2 }, 0.25);
expect(r.position).toBeCloseTo(0.5, 10);
});
});
-// ===========================================================================
-// 7. stepperStyleAt — pure exported core of useStepperTransition
-// MIRROR of use-stepper-transition.ts lines 66-102.
-// useStepperTransition = stepperStyleAt(steps, useCurrentFrame() * speed, opts).
-// Call stepperStyleAt directly with frame injected as `raw`.
-//
-// MAINTENANCE CONTRACT: if use-stepper-transition.ts lines 66-102 change,
-// update these tests in lockstep. Annotated source lines below.
-// ===========================================================================
-
describe("stepperStyleAt: empty steps → position=0", () => {
- // source line 73: if (steps.length === 0) return { position: 0 }
it("returns {position:0} for any raw frame when steps is empty", () => {
expect(stepperStyleAt([], 0).position).toBe(0);
expect(stepperStyleAt([], 100).position).toBe(0);
@@ -401,7 +301,6 @@ describe("stepperStyleAt: empty steps → position=0", () => {
});
describe("stepperStyleAt: before first step — holds at first.index", () => {
- // source line 79: if (raw <= first.at) return { position: first.index }
const steps: StepperStep[] = [{ at: 30, index: 1 }];
it("raw=0 < first.at=30 → holds at first.index=1", () => {
@@ -418,7 +317,6 @@ describe("stepperStyleAt: before first step — holds at first.index", () => {
});
describe("stepperStyleAt: past last step — rests at last.index", () => {
- // source lines 90-92: pastLast → to=from=last, t=1
const steps: StepperStep[] = [{ at: 0, index: 0 }, { at: 24, index: 1 }];
it("raw=50 past last.at=24 → position=1 (last index)", () => {
@@ -431,11 +329,6 @@ describe("stepperStyleAt: past last step — rests at last.index", () => {
});
describe("stepperStyleAt: mid-window uses easings.out (non-linear)", () => {
- // steps=[{at:0,index:0},{at:24,index:1}], raw=12
- // pastLast: 12>=24? no. toIndex=1 (steps[1].at=24>12)
- // to={at:24,index:1}, from={at:0,index:0}
- // dur=24, start=0, t=out(clamp01((12-0)/24))=out(0.5)=0.875
- // position = 0 + (1-0)*0.875 = 0.875
const steps: StepperStep[] = [{ at: 0, index: 0 }, { at: 24, index: 1 }];
it("raw=12 gives position=0.875 (out-eased, not linear 0.5)", () => {
@@ -454,7 +347,6 @@ describe("stepperStyleAt: mid-window uses easings.out (non-linear)", () => {
});
describe("stepperStyleAt: at last step boundary — pastLast → t=1", () => {
- // raw=24: steps[1].at=24, pastLast = raw(24) >= 24 = true → t=1 → position=1
const steps: StepperStep[] = [{ at: 0, index: 0 }, { at: 24, index: 1 }];
it("raw=24 exactly at last step → position=1", () => {
@@ -463,12 +355,6 @@ describe("stepperStyleAt: at last step boundary — pastLast → t=1", () => {
});
describe("stepperStyleAt: two-step multi-segment timeline", () => {
- // steps=[{at:0,index:0},{at:24,index:1},{at:48,index:2}]
- // raw=36 (mid of second segment [24→48], dur=24):
- // toIndex search: steps[2].at=48>36 → toIndex=2
- // pastLast: 36>=48? no. to={at:48,index:2}, from={at:24,index:1}
- // dur=24, start=24, t=out((36-24)/24)=out(0.5)=0.875
- // position = 1 + (2-1)*0.875 = 1.875
const steps: StepperStep[] = [
{ at: 0, index: 0 },
{ at: 24, index: 1 },
@@ -480,16 +366,11 @@ describe("stepperStyleAt: two-step multi-segment timeline", () => {
});
it("raw=24 (start of second segment boundary) → pastLast=false, t=out(0)=0 → position=1", () => {
- // steps[2].at=48>24 → toIndex=2; start=48-24=24; t=out((24-24)/24)=out(0)=0
- // position = 1 + (2-1)*0 = 1
expect(stepperStyleAt(steps, 24).position).toBeCloseTo(1, 10);
});
});
describe("stepperStyleAt: custom duration on a step", () => {
- // steps=[{at:0,index:0},{at:12,index:1,duration:12}]
- // raw=6: toIndex=1, dur=12, start=0, t=out(6/12)=out(0.5)=0.875
- // position=0+(1-0)*0.875=0.875
const steps: StepperStep[] = [{ at: 0, index: 0 }, { at: 12, index: 1, duration: 12 }];
it("custom duration=12: raw=6 gives position=0.875", () => {
@@ -510,7 +391,6 @@ describe("stepperStyleAt: past last with three steps", () => {
});
describe("stepperStyleAt: single-step timeline (no from step)", () => {
- // Only one step: hold at its index before and after
const steps: StepperStep[] = [{ at: 0, index: 1 }];
it("raw=0 (at first.at) → holds at position=1", () => {
@@ -522,10 +402,6 @@ describe("stepperStyleAt: single-step timeline (no from step)", () => {
});
});
-// ===========================================================================
-// 8. stepperConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("stepperConfig.controls.activeIndex", () => {
it("is a number control", () => {
expect(stepperConfig.controls.activeIndex.type).toBe("number");
@@ -570,10 +446,6 @@ describe("stepperConfig.controls.mode", () => {
});
});
-// ===========================================================================
-// 9. stepperConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("stepperConfig.snippet: import line", () => {
it("includes 'import { Stepper }' from the correct path", () => {
const out = snippet({ activeIndex: 1 });
@@ -610,7 +482,6 @@ describe("stepperConfig.snippet: activeIndex is always emitted", () => {
});
it("emits activeIndex={0} when activeIndex is omitted from values (falls back to 0)", () => {
- // snippet uses `activeIndex ?? 0`
expect(snippet({})).toContain("activeIndex={0}");
});
});
diff --git a/registry/remocn-ui/stepper/index.tsx b/registry/remocn-ui/stepper/index.tsx
index 29f9c964..c0e4d927 100644
--- a/registry/remocn-ui/stepper/index.tsx
+++ b/registry/remocn-ui/stepper/index.tsx
@@ -2,77 +2,36 @@
import { clamp01, mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Stepper visual — the COMPLETE animated look for a moment in time. The animated
-// channel is a single CONTINUOUS float `position` (the value-channel deviation
-// §0, like progress): every circle's fill/color/check and every connector's
-// primary fill derive PURELY from `position` in the render. `useStepperTransition`
-// feeds an interpolated `StepperStyle` through `style`; the component never reads
-// the frame.
-// ===========================================================================
-
export interface StepperStyle {
- /**
- * Continuous active-step index (0..n-1, float). The ONLY animated field — each
- * circle and connector is a pure function of it, so a lerp advances the stepper
- * smoothly (checks draw, connectors fill) without jumps.
- */
position: number;
}
export type StepperOrientation = "horizontal" | "vertical";
export interface StepperProps {
- /** Step labels. Their count is the step count. */
steps?: string[];
- /**
- * Active step index (snap path). Ignored when `style` is supplied. May be a
- * float, but is typically an integer for the snap form.
- */
activeIndex?: number;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `activeIndex` — feed it an interpolated `StepperStyle` from `useStepperTransition`.
- */
style?: StepperStyle;
- /**
- * Layout. Only `"horizontal"` is implemented this wave; `"vertical"` is
- * accepted but falls back to horizontal.
- */
orientation?: StepperOrientation;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Default onboarding steps. */
const DEFAULT_STEPS = ["Account", "Plan", "Done"];
-/** Circle diameter (px). */
const CIRCLE = 36;
-/** Checkmark stroke length (svg path units), drives the draw-on animation. */
const CHECK_PATH_LENGTH = 14;
-/** Concrete colors for the active theme, resolved once per render. */
export interface StepperStyleContext {
- /** Completed/active accent (circles, connector fill, ring). */
primary: string;
- /** Check color on a completed circle. */
primaryFg: string;
- /** Future circle fill. */
mutedBg: string;
- /** Future circle border + empty connector. */
border: string;
- /** Future step number color. */
mutedFg: string;
- /** Active/completed number + label color. */
foreground: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result across every step's derivation.
- */
export function stepperStyleContext(theme: RemocnTheme): StepperStyleContext {
return {
primary: theme.primary,
@@ -84,45 +43,21 @@ export function stepperStyleContext(theme: RemocnTheme): StepperStyleContext {
};
}
-/**
- * The COMPLETE resting visual for an active index — a pure `(activeIndex) =>
- * StepperStyle` map. `position` IS the index (the smooth path feeds a float).
- */
export function stepperStyle(activeIndex: number): StepperStyle {
return { position: activeIndex };
}
-/**
- * The derived per-step visual at a given `position`. PURE — exported so tests can
- * assert the completed/active/future thresholds and the check draw without a
- * render.
- *
- * - completed: i + 1 <= position (fully reached the NEXT step) → filled primary
- * circle + drawn check (checkDraw 0→1 as position crosses i→i+1).
- * - active: the step `position` is currently sitting on/approaching.
- * - future: i not yet reached.
- *
- * `fill` 0→1 is how "done" step i is: clamp01(position - i). At fill>=1 the step
- * is completed (check drawn); below 1 it's the active/in-progress step.
- */
export function stepCircleAt(i: number, position: number): {
- /** 0→1 completion of this step. */
fill: number;
- /** Checkmark draw fraction 0→1 (only meaningful once fill reaches 1). */
checkDraw: number;
- /** True when the step is the current/active one (the integer position sits here). */
active: boolean;
} {
const fill = clamp01(position - i);
- // The check draws as the step crosses from active (fill→1) into completed.
const checkDraw = fill;
- // Active = the step the position currently rests on (its own integer slot),
- // before it has fully completed into the next.
const active = Math.floor(position) === i && fill < 1;
return { fill, checkDraw, active };
}
-/** Connector primary-fill fraction between step i and i+1. PURE; exported. */
export function connectorFillAt(i: number, position: number): number {
return clamp01(position - i);
}
@@ -159,10 +94,8 @@ export function Stepper({
{steps.map((label, i) => {
const { fill, checkDraw, active } = stepCircleAt(i, position);
const completed = fill >= 1;
- // Circle background interpolates muted → primary as the step fills.
const circleBg = mixOklch(ctx.mutedBg, ctx.primary, fill);
const circleBorder = mixOklch(ctx.border, ctx.primary, fill);
- // Number fades out as the check fades in (completed shows the check).
const numberOpacity = 1 - checkDraw;
const numberColor = active || completed ? ctx.foreground : ctx.mutedFg;
const isLast = i === steps.length - 1;
@@ -171,7 +104,7 @@ export function Stepper({
key={label}
style={{ display: "flex", alignItems: "flex-start" }}
>
- {/* Step circle + label below it. */}
+ {}
<div
style={{
display: "flex",
@@ -195,7 +128,7 @@ export function Stepper({
justifyContent: "center",
}}
>
- {/* Step number — fades out as the check draws in. */}
+ {}
<span
style={{
position: "absolute",
@@ -207,7 +140,7 @@ export function Stepper({
>
{i + 1}
</span>
- {/* Checkmark — stroke-dash draw (checkbox technique). */}
+ {}
<svg width={CIRCLE} height={CIRCLE} viewBox="0 0 24 24" fill="none">
<path
d="M5 12.5l4.5 4.5L19 7"
@@ -233,7 +166,7 @@ export function Stepper({
{label}
</span>
</div>
- {/* Connector to the next step — a muted rail with a primary fill. */}
+ {}
{!isLast && (
<div
style={{
diff --git a/registry/remocn-ui/stepper/preview.tsx b/registry/remocn-ui/stepper/preview.tsx
index 3c336416..6f013de0 100644
--- a/registry/remocn-ui/stepper/preview.tsx
+++ b/registry/remocn-ui/stepper/preview.tsx
@@ -8,16 +8,8 @@ export interface StepperPreviewProps {
mode?: "light" | "dark";
}
-/** Fixed demo steps for the customizer preview. */
const DEMO_STEPS = ["Account", "Plan", "Done"];
-/**
- * Preview-only wrapper for the customizer. The shipped `Stepper` is a wide,
- * placement-agnostic horizontal element; the customizer Player renders its
- * `component` as the composition root, so this thin wrapper centers it on a
- * theme-background stage and supplies a fixed demo `steps` set. NOT shipped: not
- * listed in registry.json files.
- */
export function StepperPreview({ activeIndex = 1, mode }: StepperPreviewProps) {
const theme = useRemocnTheme(undefined, mode);
diff --git a/registry/remocn-ui/stepper/use-stepper-transition.ts b/registry/remocn-ui/stepper/use-stepper-transition.ts
index d13f4509..06f83931 100644
--- a/registry/remocn-ui/stepper/use-stepper-transition.ts
+++ b/registry/remocn-ui/stepper/use-stepper-transition.ts
@@ -3,34 +3,21 @@
import { useCurrentFrame } from "remotion";
import { clamp01, type EasingName, easings } from "@/lib/remocn-ui";
import type { StepperStyle } from "@/components/remocn/stepper";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/**
- * A scripted active-step the stepper eases TO. The `position` tweens from the
- * previous step's index to this one over `[at, at + (duration ?? DEFAULT_DURATION))`.
- */
export interface StepperStep {
- /** LOCAL (Sequence-relative) authored frame the stepper finishes reaching `index`. */
at: number;
- /** Target active-step index (0..n-1). */
index: number;
- /** Frames the move INTO this index takes. Omitted → DEFAULT_DURATION. */
duration?: number;
- /** Override the easing for the move into this index. Default `out`. */
easing?: EasingName;
}
-/** Default frames for a move into a step when it omits `duration`. */
export const DEFAULT_DURATION = 24;
export interface StepperTransitionOptions {
- /** Playhead scale (effectiveFrame = useCurrentFrame() * speed). */
speed?: number;
- /** Move duration (frames) when a step omits `duration`. */
defaultDuration?: number;
}
-/** Blend two stepper visuals: the single `position` field lerps. */
export function tweenStepperStyle(
a: StepperStyle,
b: StepperStyle,
@@ -39,15 +26,6 @@ export function tweenStepperStyle(
return { position: a.position + (b.position - a.position) * t };
}
-/**
- * Resolve the stepper's `StepperStyle` for an index timeline. THIS is the only
- * frame-reading file — `<Stepper>` itself stays pure. Mirrors the value-channel
- * deviation (like progress's `useProgressTransition`): it folds a numeric index
- * path into a continuous `position`.
- *
- * The fold is a pure function of `raw = useCurrentFrame() * speed`; tests
- * replicate `stepperStyleAt(steps, raw, opts)` with the frame injected.
- */
export function useStepperTransition(
steps: StepperStep[],
opts: StepperTransitionOptions = {},
@@ -57,12 +35,6 @@ export function useStepperTransition(
return stepperStyleAt(steps, raw, opts);
}
-/**
- * Pure core of `useStepperTransition` with the effective frame injected as `raw`.
- * Kept separate so it can be unit-tested without a Remotion render.
- * `useStepperTransition` is exactly `stepperStyleAt(steps, useCurrentFrame() *
- * speed, opts)`.
- */
export function stepperStyleAt(
steps: StepperStep[],
raw: number,
@@ -72,14 +44,10 @@ export function stepperStyleAt(
if (steps.length === 0) return { position: 0 };
- // Authored order is the timeline order; `at` is the arrival frame of each step.
const first = steps[0];
- // Before the first arrival, hold at the first step's index (no teleport).
if (raw <= first.at) return { position: first.index };
- // Find the segment we're in: the move from step i-1 into step i, where i is
- // the first step with at > raw. If none, we're resting at the last step.
let toIndex = steps.length - 1;
for (let i = 1; i < steps.length; i++) {
if (steps[i].at > raw) {
@@ -93,7 +61,6 @@ export function stepperStyleAt(
const dur = to.duration ?? defaultDuration;
const ease = easings[to.easing ?? "out"];
- // The move runs over [start, to.at); start = to.at - dur.
const start = to.at - dur;
const t = pastLast || dur <= 0 ? 1 : ease(clamp01((raw - start) / dur));
const position = from.index + (to.index - from.index) * t;
diff --git a/registry/remocn-ui/switch/__tests__/switch.test.ts b/registry/remocn-ui/switch/__tests__/switch.test.ts
index abaee23a..ddd0ca04 100644
--- a/registry/remocn-ui/switch/__tests__/switch.test.ts
+++ b/registry/remocn-ui/switch/__tests__/switch.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `switch`.
- *
- * Scope:
- * - registry/remocn-ui/switch/index.tsx — SwitchState union membership,
- * switchStyleContext, switchStyle presets
- * - registry/remocn-ui/switch/use-switch-transition.ts — tweenSwitchStyle
- * - registry/remocn-ui/switch/config.ts — switchConfig.controls.state
- * wiring + switchConfig.snippet output (the state → JSX codegen)
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * State changes snap (no tweening inside the component). The smooth-path hook
- * `useSwitchTransition` reads `useCurrentFrame()` via `useStateTransition`
- * internally; it cannot run outside a Remotion render tree. So Switch render
- * is NOT exercised here. The pure-testable surface is the customizer wiring,
- * snippet codegen, style presets, and tween interpolation (below).
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/switch/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `SwitchState` from `@/registry/remocn-ui/switch`
- * and the pieces under test never CALL a Remotion runtime API at import time —
- * `switchConfig` is a plain object; `.snippet` is a pure string builder;
- * `switchStyle` and `tweenSwitchStyle` 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 {
@@ -40,17 +9,8 @@ import { tweenSwitchStyle } from "../use-switch-transition";
import { switchConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The SwitchState union, enumerated as a runtime list for membership checks.
- * Must stay in sync with `export type SwitchState` in index.tsx.
- */
const VALID_STATES: readonly SwitchState[] = ["unchecked", "checked"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
label?: string;
@@ -62,22 +22,14 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
switchConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. SwitchState union membership
-// ===========================================================================
-
describe("SwitchState 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 = switchConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(control.options).toEqual(["unchecked", "checked"]);
});
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 = switchConfig.controls.state;
if (control.type !== "select") throw new Error("state control must be a select");
expect(VALID_STATES).toHaveLength(2);
@@ -87,10 +39,6 @@ describe("SwitchState union", () => {
});
});
-// ===========================================================================
-// 2. switchConfig.controls.state — customizer control wiring
-// ===========================================================================
-
describe("switchConfig.controls.state", () => {
it("is a select control", () => {
expect(switchConfig.controls.state.type).toBe("select");
@@ -116,12 +64,6 @@ describe("switchConfig.controls.state", () => {
});
});
-// ===========================================================================
-// 3. switchConfig.snippet — pure string builder
-// State model: snippet emits `state="<state>"` as a bare JSX prop.
-// It NEVER emits `steps` or `action`.
-// ===========================================================================
-
describe("switchConfig.snippet: state prop emission", () => {
it("emits state=\"unchecked\" for the unchecked option", () => {
expect(snippet({ state: "unchecked" })).toContain('state="unchecked"');
@@ -164,7 +106,6 @@ describe("switchConfig.snippet: import line", () => {
});
describe("switchConfig.snippet: default props are omitted", () => {
- // Defaults: label="", size=default, mode=light, primary=#171717
const allDefaults = snippet({
state: "checked",
label: "",
@@ -224,15 +165,6 @@ describe("switchConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. switchStyle presets — pure (state, ctx) => SwitchStyle
-// switchStyleContext and switchStyle are now exported and frame-free.
-// Build one ctx from the default light theme, then assert the
-// numeric invariants for both states.
-// trackBackground is derived from the theme — asserted non-empty only
-// (exact value is an implementation detail of the theme).
-// ===========================================================================
-
const ctx = switchStyleContext(defaultLightTheme);
describe("switchStyle: unchecked state", () => {
@@ -273,14 +205,6 @@ describe("switchStyle: invariants — unchecked thumb at left, checked thumb at
});
});
-// ===========================================================================
-// 5. tweenSwitchStyle — pure linear interpolation between two SwitchStyles.
-// Numbers lerp linearly; colors via oklch mix → non-empty string at all t.
-// Concrete expectations: unchecked→checked for midpoint math.
-// unchecked: thumbOffset=0
-// checked: thumbOffset=1
-// ===========================================================================
-
describe("tweenSwitchStyle: t=0 returns values equal to `a`", () => {
const a = switchStyle("unchecked", ctx);
const b = switchStyle("checked", ctx);
@@ -312,8 +236,6 @@ describe("tweenSwitchStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenSwitchStyle: t=0.5 midpoint numeric lerp (unchecked → checked)", () => {
- // unchecked: thumbOffset=0
- // checked: thumbOffset=1
const a = switchStyle("unchecked", ctx);
const b = switchStyle("checked", ctx);
const r = tweenSwitchStyle(a, b, 0.5);
diff --git a/registry/remocn-ui/switch/config.ts b/registry/remocn-ui/switch/config.ts
index fbf022bc..08ec02e7 100644
--- a/registry/remocn-ui/switch/config.ts
+++ b/registry/remocn-ui/switch/config.ts
@@ -14,7 +14,6 @@ export const switchConfig: ComponentConfig = {
},
state: {
type: "select",
- // Default to `checked` so the preview shows the filled track + slid thumb.
default: "checked",
options: ["unchecked", "checked"],
label: "State",
diff --git a/registry/remocn-ui/switch/index.tsx b/registry/remocn-ui/switch/index.tsx
index aec7916e..9370ffba 100644
--- a/registry/remocn-ui/switch/index.tsx
+++ b/registry/remocn-ui/switch/index.tsx
@@ -7,18 +7,11 @@ export type SwitchState = "unchecked" | "checked";
type SwitchSize = "sm" | "default" | "lg";
export interface SwitchProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: SwitchState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `SwitchStyle` from `useSwitchTransition`.
- */
style?: SwitchStyle;
- /** Optional text label rendered next to the track. */
label?: string;
size?: SwitchSize;
theme?: Partial<RemocnTheme>;
- /** Convenience override for the `primary` theme token — merged into `theme`. */
primary?: string;
mode?: "light" | "dark";
className?: string;
@@ -33,35 +26,17 @@ const SIZE_STYLES: Record<
lg: { trackW: 52, trackH: 28, thumb: 24, pad: 2, fontSize: 17, gap: 12 },
};
-// ===========================================================================
-// Switch visual — the COMPLETE animated look for a moment in time. A `state`
-// is a named preset of this visual (`switchStyle`); the smooth path feeds an
-// interpolated `SwitchStyle` straight through. The component is a pure
-// renderer of whichever `SwitchStyle` it receives.
-// ===========================================================================
-
export interface SwitchStyle {
- /** Animated track fill color (a concrete color, never "transparent"). */
trackBackground: string;
- /**
- * Thumb position fraction 0→1: fraction of `travel` the thumb has slid.
- * 0 = unchecked (left), 1 = checked (right).
- */
thumbOffset: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface SwitchStyleContext {
uncheckedTrack: string;
checkedTrack: string;
- /** Static thumb fill color (never animated). */
thumbColor: string;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `switchStyle(state, ctx)` preset.
- */
export function switchStyleContext(theme: RemocnTheme): SwitchStyleContext {
return {
uncheckedTrack: theme.input,
@@ -70,10 +45,6 @@ export function switchStyleContext(theme: RemocnTheme): SwitchStyleContext {
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => SwitchStyle`
- * map. To change how a state looks, edit one entry.
- */
export function switchStyle(
state: SwitchState,
ctx: SwitchStyleContext,
@@ -134,7 +105,7 @@ export function Switch({
gap: sizeStyle.gap,
}}
>
- {/* The track — animated fill; the thumb slides inside it. */}
+ {}
<span
style={{
position: "relative",
@@ -146,7 +117,7 @@ export function Switch({
background: v.trackBackground,
}}
>
- {/* The thumb — translates horizontally by thumbOffset * travel. */}
+ {}
<span
style={{
position: "absolute",
diff --git a/registry/remocn-ui/switch/use-switch-transition.ts b/registry/remocn-ui/switch/use-switch-transition.ts
index 054f344c..ac86fc64 100644
--- a/registry/remocn-ui/switch/use-switch-transition.ts
+++ b/registry/remocn-ui/switch/use-switch-transition.ts
@@ -14,12 +14,9 @@ import {
type SwitchState,
type SwitchStyle,
} from "@/components/remocn/switch";
-// ^ 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 switch visuals: numbers lerp, colors via oklch mix. */
export function tweenSwitchStyle(
a: SwitchStyle,
b: SwitchStyle,
@@ -39,11 +36,6 @@ export interface SwitchTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) SwitchStyle. The CALLER invokes this;
- * it reads the frame, the `<Switch>` component does not. Feed the result to
- * `<Switch style={...} />` for smooth toggle transitions.
- */
export function useSwitchTransition(
steps: Step<SwitchState>[],
opts: SwitchTransitionOptions = {},
diff --git a/registry/remocn-ui/tabs/__tests__/tabs.test.ts b/registry/remocn-ui/tabs/__tests__/tabs.test.ts
index d36549f1..45efdd93 100644
--- a/registry/remocn-ui/tabs/__tests__/tabs.test.ts
+++ b/registry/remocn-ui/tabs/__tests__/tabs.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `tabs`.
- *
- * Scope:
- * - registry/remocn-ui/tabs/index.tsx — TabsState type, tabsStyle presets,
- * tabsStyleContext
- * - registry/remocn-ui/tabs/config.ts — tabsConfig.controls wiring
- * + tabsConfig.snippet output (the state → JSX codegen)
- * - registry/remocn-ui/tabs/use-tabs-transition.ts
- * — tweenTabsStyle interpolation, DEFAULT_DURATION
- *
- * The render path (index.tsx) is a PURE-STATE model: `(state) => visual`.
- * `<Tabs>` 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/tabs/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * `config.ts` imports `TabsState` from `@/registry/remocn-ui/tabs` and the
- * pieces under test never CALL a Remotion runtime API at import time —
- * `tabsConfig` is a plain object; `.snippet` is a pure string builder;
- * `tabsStyle` and `tweenTabsStyle` 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 {
@@ -40,17 +9,8 @@ import { tweenTabsStyle, DEFAULT_DURATION } from "../use-tabs-transition";
import { tabsConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The canonical tab label list — mirrors DEFAULT_ITEMS in index.tsx and the
- * config.controls.state.options list. Must stay in sync.
- */
const VALID_STATES: readonly TabsState[] = ["Account", "Password", "Settings"];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
variant?: string;
@@ -60,17 +20,8 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
tabsConfig.snippet(values as Record<string, unknown>);
-/**
- * A shared TabsStyleContext built from the default items + "pill" variant +
- * default light theme. Mirrors how the component builds its own context
- * internally.
- */
const ctx = tabsStyleContext(["Account", "Password", "Settings"], "pill", defaultLightTheme);
-// ===========================================================================
-// 1. TabsState / state options
-// ===========================================================================
-
describe("TabsState / state options", () => {
it("controls.state is a select control", () => {
expect(tabsConfig.controls.state.type).toBe("select");
@@ -96,10 +47,6 @@ describe("TabsState / state options", () => {
});
});
-// ===========================================================================
-// 2. tabsConfig.controls.variant — customizer control wiring
-// ===========================================================================
-
describe("tabsConfig.controls.variant", () => {
it("is a select control", () => {
expect(tabsConfig.controls.variant.type).toBe("select");
@@ -116,12 +63,6 @@ describe("tabsConfig.controls.variant", () => {
});
});
-// ===========================================================================
-// 3. tabsConfig.snippet — pure string builder
-// State model: snippet ALWAYS emits `state="<state>"` as a bare JSX prop.
-// It NEVER emits `steps`.
-// ===========================================================================
-
describe("tabsConfig.snippet: state prop emission", () => {
it("emits state=\"Account\" for the Account option", () => {
expect(snippet({ state: "Account" })).toContain('state="Account"');
@@ -162,7 +103,6 @@ describe("tabsConfig.snippet: import line", () => {
});
describe("tabsConfig.snippet: default props are omitted", () => {
- // Defaults: variant="pill", mode="light"
const allDefaults = snippet({
state: "Account",
variant: "pill",
@@ -206,14 +146,6 @@ describe("tabsConfig.snippet: structural round-trip", () => {
});
});
-// ===========================================================================
-// 4. tabsStyle presets — pure (state, ctx) => TabsStyle
-// tabsStyleContext and tabsStyle are exported and frame-free.
-// Build one ctx from the default items + "pill" variant + default light
-// theme, then assert indicatorOffset for every named state.
-// Unknown state → 0 (the documented safe fallback).
-// ===========================================================================
-
describe("tabsStyle: Account state", () => {
it("indicatorOffset is 0 (first tab)", () => {
expect(tabsStyle("Account", ctx).indicatorOffset).toBe(0);
@@ -244,7 +176,6 @@ describe("tabsStyle: unknown state", () => {
describe("tabsStyle: each item maps to its own index", () => {
const items = ["Account", "Password", "Settings"];
- // Loop asserting index round-trip
for (let i = 0; i < items.length; i++) {
const item = items[i];
it(`${item} → indicatorOffset ${i}`, () => {
@@ -273,16 +204,9 @@ describe("tabsStyle: indicatorOffset invariant across variants", () => {
});
});
-// ===========================================================================
-// 5. tweenTabsStyle — pure linear interpolation between two TabsStyles.
-// `indicatorOffset` is the ONLY field; it lerps linearly.
-// Concrete expectations: offset 0 (Account) → offset 2 (Settings)
-// and the reverse direction.
-// ===========================================================================
-
describe("tweenTabsStyle: t=0 returns values equal to `a`", () => {
- const a = tabsStyle("Account", ctx); // indicatorOffset: 0
- const b = tabsStyle("Settings", ctx); // indicatorOffset: 2
+ const a = tabsStyle("Account", ctx);
+ const b = tabsStyle("Settings", ctx);
const r = tweenTabsStyle(a, b, 0);
it("indicatorOffset equals a.indicatorOffset at t=0", () => {
@@ -291,8 +215,8 @@ describe("tweenTabsStyle: t=0 returns values equal to `a`", () => {
});
describe("tweenTabsStyle: t=1 returns values equal to `b`", () => {
- const a = tabsStyle("Account", ctx); // indicatorOffset: 0
- const b = tabsStyle("Settings", ctx); // indicatorOffset: 2
+ const a = tabsStyle("Account", ctx);
+ const b = tabsStyle("Settings", ctx);
const r = tweenTabsStyle(a, b, 1);
it("indicatorOffset equals b.indicatorOffset at t=1", () => {
@@ -301,8 +225,6 @@ describe("tweenTabsStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenTabsStyle: t=0.5 midpoint numeric lerp (Account → Settings)", () => {
- // Account: indicatorOffset=0, Settings: indicatorOffset=2
- // Midpoint: 1
const a = tabsStyle("Account", ctx);
const b = tabsStyle("Settings", ctx);
const r = tweenTabsStyle(a, b, 0.5);
@@ -313,8 +235,6 @@ describe("tweenTabsStyle: t=0.5 midpoint numeric lerp (Account → Settings)", (
});
describe("tweenTabsStyle: t=0.5 midpoint numeric lerp (Settings → Account)", () => {
- // Settings: indicatorOffset=2, Account: indicatorOffset=0
- // Midpoint: 1
const a = tabsStyle("Settings", ctx);
const b = tabsStyle("Account", ctx);
const r = tweenTabsStyle(a, b, 0.5);
@@ -324,10 +244,6 @@ describe("tweenTabsStyle: t=0.5 midpoint numeric lerp (Settings → Account)", (
});
});
-// ===========================================================================
-// 6. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
diff --git a/registry/remocn-ui/tabs/index.tsx b/registry/remocn-ui/tabs/index.tsx
index 2733e7d5..0b7e0beb 100644
--- a/registry/remocn-ui/tabs/index.tsx
+++ b/registry/remocn-ui/tabs/index.tsx
@@ -2,28 +2,15 @@
import { mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
-/** Active tab — one of the `items` VALUES (the label string). */
export type TabsState = string;
type TabsVariant = "pill" | "underline";
export interface TabsProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: TabsState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `TabsStyle` from `useTabsTransition`.
- */
style?: TabsStyle;
- /** Tab labels (and values). The active `state` is one of these. */
items?: string[];
- /** Panel body text per tab — parallel to `items`. */
contents?: string[];
- /**
- * Natural height (px) of the panel body box. The panels stack in a fixed
- * `contentHeight` box — Remotion's headless render can't measure auto height,
- * so the resting height is authored, not measured.
- */
contentHeight?: number;
variant?: TabsVariant;
theme?: Partial<RemocnTheme>;
@@ -31,59 +18,32 @@ export interface TabsProps {
className?: string;
}
-/** Widget width (px) of the rendered tabs. */
const WIDTH = 440;
-/** Default tab labels. */
const DEFAULT_ITEMS = ["Account", "Password", "Settings"];
-/** Default panel body text, parallel to `DEFAULT_ITEMS`. */
const DEFAULT_CONTENTS = [
"Make changes to your account here.",
"Change your password here.",
"Manage your notification settings.",
];
-// ===========================================================================
-// Tabs visual — the COMPLETE animated look for a moment in time. A `state` is a
-// named preset of this visual (`tabsStyle`); the smooth path feeds an
-// interpolated `TabsStyle` straight through. The component is a pure renderer of
-// whichever `TabsStyle` it receives. Everything else (indicator x/width,
-// per-label color, panel crossfade) DERIVES from `indicatorOffset` in render.
-// ===========================================================================
-
export interface TabsStyle {
- /**
- * Float index (0,1,2…) of where the active indicator sits. The only animated
- * field — the indicator position, label colors, and panel opacities all
- * derive from it inside the pure render.
- */
indicatorOffset: number;
}
-/** Concrete colors for the active variant/theme, resolved once per render. */
export interface TabsStyleContext {
- /** Tab labels/values — the indicator and panels are indexed against this. */
items: string[];
variant: TabsVariant;
- /** Track background behind the pill indicator (underline: unused). */
trackBg: string;
- /** Active label color. */
activeFg: string;
- /** Inactive label color. */
inactiveFg: string;
- /** Indicator fill (pill: card bg; underline: the bar color). */
indicatorBg: string;
border: string;
radius: number;
- /** Panel body text color. */
panelFg: string;
}
-/**
- * Derive the concrete colors for a variant/theme. Pure — call it once and reuse
- * the result for every `tabsStyle(state, ctx)` preset.
- */
export function tabsStyleContext(
items: string[],
variant: TabsVariant,
@@ -94,10 +54,7 @@ export function tabsStyleContext(
variant,
trackBg: theme.muted,
activeFg: theme.foreground,
- // Pill: muted-foreground for the resting labels. Underline: same.
inactiveFg: theme.mutedForeground,
- // Pill: a concrete card bg lifts the active tab off the muted track.
- // Underline: the primary bar along the bottom edge.
indicatorBg: variant === "underline" ? theme.primary : theme.background,
border: theme.border,
radius: theme.radius,
@@ -105,11 +62,6 @@ export function tabsStyleContext(
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) => TabsStyle`
- * map. `indicatorOffset` is the index of `state` in `ctx.items` (safe lookup:
- * unknown state → 0).
- */
export function tabsStyle(state: TabsState, ctx: TabsStyleContext): TabsStyle {
const i = ctx.items.indexOf(state);
return { indicatorOffset: i < 0 ? 0 : i };
@@ -132,7 +84,6 @@ export function Tabs({
const v = style ?? tabsStyle(state, ctx);
const isPill = ctx.variant === "pill";
- // Pill rests on a padded muted track; underline runs flush to the edges.
const trackPad = isPill ? 4 : 0;
const innerWidth = WIDTH - trackPad * 2;
const segmentWidth = innerWidth / items.length;
@@ -148,14 +99,13 @@ export function Tabs({
display: "flex",
alignItems: "center",
justifyContent: "center",
- // OPAQUE wrapper — tabs is a self-contained widget, not a modal layer.
background: theme.background,
fontFamily:
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
}}
>
<div style={{ width: WIDTH }}>
- {/* Tab row — equal-width segments with the sliding indicator behind. */}
+ {}
<div
style={{
position: "relative",
@@ -168,7 +118,7 @@ export function Tabs({
borderBottom: isPill ? undefined : `1px solid ${ctx.border}`,
}}
>
- {/* Sliding indicator — pill: a rounded card; underline: a 2px bar. */}
+ {}
<div
style={
isPill
@@ -192,7 +142,7 @@ export function Tabs({
}
}
/>
- {/* Labels stay in normal flow defining the segment widths. */}
+ {}
{items.map((item, i) => {
const proximity = Math.max(0, 1 - Math.abs(i - v.indicatorOffset));
return (
@@ -215,7 +165,7 @@ export function Tabs({
);
})}
</div>
- {/* Panel — all panels stacked in a fixed box; opacity crossfades them. */}
+ {}
<div
style={{
position: "relative",
diff --git a/registry/remocn-ui/tabs/use-tabs-transition.ts b/registry/remocn-ui/tabs/use-tabs-transition.ts
index 7fa5b167..4c5716fb 100644
--- a/registry/remocn-ui/tabs/use-tabs-transition.ts
+++ b/registry/remocn-ui/tabs/use-tabs-transition.ts
@@ -13,15 +13,11 @@ import {
type TabsState,
type TabsStyle,
} from "@/components/remocn/tabs";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default tab labels — mirrors the component's default `items`. */
const DEFAULT_ITEMS = ["Account", "Password", "Settings"];
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 14;
-/** Blend two tabs visuals: `indicatorOffset` lerps (it's the only field). */
export function tweenTabsStyle(
a: TabsStyle,
b: TabsStyle,
@@ -42,11 +38,6 @@ export interface TabsTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) TabsStyle. The CALLER invokes this; it
- * reads the frame, the `<Tabs>` component does not. Feed the result to
- * `<Tabs style={...} />` for a smooth sliding indicator.
- */
export function useTabsTransition(
steps: Step<TabsState>[],
opts: TabsTransitionOptions = {},
diff --git a/registry/remocn-ui/toast/__tests__/toast.test.ts b/registry/remocn-ui/toast/__tests__/toast.test.ts
index 3822b103..1a7b2764 100644
--- a/registry/remocn-ui/toast/__tests__/toast.test.ts
+++ b/registry/remocn-ui/toast/__tests__/toast.test.ts
@@ -1,35 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `toast`.
- *
- * Scope:
- * - registry/remocn-ui/toast/index.tsx
- * toastStyleContext(variant, theme) — pure icon-color derivation
- * toastStyle(state) — complete state→visual preset map
- * - registry/remocn-ui/toast/use-toast-transition.ts
- * tweenToastStyle(a, b, t) — pure lerp across every field
- * DEFAULT_DURATION constant
- * useToastTransition resolver — mirrored as resolveToastTransition
- * with frame injected as `raw` (annotated source lines)
- * - registry/remocn-ui/toast/config.ts
- * toastConfig.controls wiring + toastConfig.snippet codegen
- *
- * The render path (index.tsx) imports `useRemocnTheme` which requires React
- * context — it is NOT exercised here. The pure-testable surface is everything
- * above.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/toast/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports from component source; `@/lib/remocn-ui` alias for core.
- * Neither `toastStyle`, `toastStyleContext`, nor `tweenToastStyle` call
- * `useCurrentFrame()` at import or call time — they are pure value functions.
- * `useToastTransition` IS a hook (calls `useStateTransition` → `useCurrentFrame`)
- * and is NOT imported; we mirror its pure resolver body below.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -46,14 +14,9 @@ import { toastConfig } from "../config";
import { defaultLightTheme, defaultDarkTheme, easings, clamp01 } from "@/lib/remocn-ui";
import type { Step } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
const VALID_STATES: readonly ToastState[] = ["hidden", "visible"];
const VALID_VARIANTS: readonly ToastVariant[] = ["default", "success", "error"];
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
state?: string;
title?: string;
@@ -64,21 +27,12 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
toastConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is 12 frames", () => {
expect(DEFAULT_DURATION).toBe(12);
});
});
-// ===========================================================================
-// 2. toastStyle — pure (state) => ToastStyle map
-// MIRROR of index.tsx lines 69-76
-// ===========================================================================
-
describe("toastStyle: hidden state — off-screen keyframe", () => {
const s = toastStyle("hidden");
@@ -137,11 +91,6 @@ describe("toastStyle: both states are complete keyframes", () => {
});
});
-// ===========================================================================
-// 3. toastStyleContext — pure variant × theme → { iconColor }
-// MIRROR of index.tsx lines 55-62
-// ===========================================================================
-
describe("toastStyleContext: default variant", () => {
const ctx = toastStyleContext("default", defaultLightTheme);
@@ -195,11 +144,6 @@ describe("toastStyleContext: all variants return an object with only iconColor",
});
});
-// ===========================================================================
-// 4. tweenToastStyle — pure lerp across all three fields
-// MIRROR of use-toast-transition.ts lines 23-33
-// ===========================================================================
-
describe("tweenToastStyle: t=0 returns values equal to `a`", () => {
const a = toastStyle("hidden");
const b = toastStyle("visible");
@@ -237,9 +181,6 @@ describe("tweenToastStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenToastStyle: t=0.5 midpoint (hidden → visible)", () => {
- // hidden: opacity=0, translateY=16, scale=0.97
- // visible: opacity=1, translateY=0, scale=1
- // midpoint: opacity=0.5, translateY=8, scale=0.985
const a = toastStyle("hidden");
const b = toastStyle("visible");
const r = tweenToastStyle(a, b, 0.5);
@@ -258,8 +199,6 @@ describe("tweenToastStyle: t=0.5 midpoint (hidden → visible)", () => {
});
describe("tweenToastStyle: t=0.5 midpoint (visible → hidden, dismiss direction)", () => {
- // Reverse direction: visible→hidden
- // midpoint: opacity=0.5, translateY=8, scale=0.985
const a = toastStyle("visible");
const b = toastStyle("hidden");
const r = tweenToastStyle(a, b, 0.5);
@@ -294,9 +233,6 @@ describe("tweenToastStyle: identity (a === b, any t)", () => {
});
describe("tweenToastStyle: t=0.25 quarter-point (hidden → visible)", () => {
- // opacity: 0 + 0.25*(1-0) = 0.25
- // translateY: 16 + 0.25*(0-16) = 12
- // scale: 0.97 + 0.25*(1-0.97) = 0.97+0.0075 = 0.9775
const a = toastStyle("hidden");
const b = toastStyle("visible");
const r = tweenToastStyle(a, b, 0.25);
@@ -314,36 +250,14 @@ describe("tweenToastStyle: t=0.25 quarter-point (hidden → visible)", () => {
});
});
-// ===========================================================================
-// 5. useToastTransition resolver replica
-// MIRRORS use-toast-transition.ts lines 47-60.
-// `useToastTransition` calls `useStateTransition` (which reads
-// `useCurrentFrame()`) then applies `easings.out(progress)` and
-// `tweenToastStyle`. We inject `raw` in place of `useCurrentFrame()`.
-//
-// This replica re-derives only the logic BEYOND the core
-// `useStateTransition` (already tested in core/__tests__/timeline.test.ts).
-// The key additional contract: progress is eased with `easings.out` before
-// the tween, so the visible field values are out-eased, not linear.
-//
-// MAINTENANCE CONTRACT: if use-toast-transition.ts lines 47-60 change,
-// update this replica in lockstep. Annotated source lines below.
-// ===========================================================================
-
-/** MIRROR of core/timeline.ts:clamp01. */
function clamp01Mirror(t: number): number {
return Math.max(0, Math.min(1, t));
}
-/** MIRROR of core/motion.ts:easings.out (cubic ease-out). */
function easingOut(t: number): number {
return 1 - (1 - t) ** 3;
}
-/**
- * MIRROR of timeline.ts:useStateTransition pure resolver body
- * (lines 55-73 of core/timeline.ts), with `raw` injected.
- */
function resolveStateTransition<S extends string>(
raw: number,
steps: Step<S>[],
@@ -365,42 +279,28 @@ function resolveStateTransition<S extends string>(
return { from: from ? from.state : defaultState, to: to.state, progress };
}
-/**
- * MIRROR of use-toast-transition.ts:useToastTransition (lines 47-60).
- * `raw` is injected in place of useCurrentFrame().
- * Annotated source lines:
- * line 51: destructure speed + defaultDuration from opts
- * line 52-57: call useStateTransition (mirrored as resolveStateTransition)
- * line 58: t = easings.out(progress) ← MIRROR line 58
- * line 59: tweenToastStyle(from, to, t) ← MIRROR line 59
- */
function resolveToastTransition(
raw: number, // injected useCurrentFrame() — MIRROR line 52
steps: Step<ToastState>[],
speed = 1,
defaultDuration = DEFAULT_DURATION,
): { style: ReturnType<typeof tweenToastStyle>; progress: number; from: ToastState; to: ToastState } {
- const { from, to, progress } = resolveStateTransition( // MIRROR lines 52-57
+ const { from, to, progress } = resolveStateTransition(
raw,
steps,
"hidden",
speed,
defaultDuration,
);
- const t = easingOut(progress); // MIRROR line 58
- const style = tweenToastStyle(toastStyle(from as ToastState), toastStyle(to as ToastState), t); // MIRROR line 59
+ const t = easingOut(progress);
+ const style = tweenToastStyle(toastStyle(from as ToastState), toastStyle(to as ToastState), t);
return { style, progress, from: from as ToastState, to: to as ToastState };
}
-// ---------------------------------------------------------------------------
-// Before any step: holds at hidden (progress=1, tween(hidden,hidden,out(1)))
-// ---------------------------------------------------------------------------
-
describe("resolveToastTransition: before any step — holds at hidden", () => {
it("returns the hidden style when no steps have started", () => {
const { style } = resolveToastTransition(0, []);
const hidden = toastStyle("hidden");
- // out(1)=1, so tween(hidden,hidden,1) = hidden
expect(style.opacity).toBeCloseTo(hidden.opacity, 10);
expect(style.translateY).toBeCloseTo(hidden.translateY, 10);
expect(style.scale).toBeCloseTo(hidden.scale, 10);
@@ -413,17 +313,12 @@ describe("resolveToastTransition: before any step — holds at hidden", () => {
});
});
-// ---------------------------------------------------------------------------
-// Exactly at a step boundary: progress=0, t=easings.out(0)=0
-// ---------------------------------------------------------------------------
-
describe("resolveToastTransition: exactly at hidden→visible step boundary", () => {
const steps: Step<ToastState>[] = [{ at: 10, state: "visible" }];
it("at raw=10 exactly, progress=0, t=out(0)=0 → style equals hidden (from)", () => {
const { style, progress } = resolveToastTransition(10, steps);
expect(progress).toBe(0);
- // t = out(0) = 0, so style = tween(hidden, visible, 0) = hidden
const hidden = toastStyle("hidden");
expect(style.opacity).toBeCloseTo(hidden.opacity, 10);
expect(style.translateY).toBeCloseTo(hidden.translateY, 10);
@@ -437,25 +332,19 @@ describe("resolveToastTransition: exactly at hidden→visible step boundary", ()
});
});
-// ---------------------------------------------------------------------------
-// Mid-window: easings.out applied to progress (non-linear)
-// ---------------------------------------------------------------------------
-
describe("resolveToastTransition: mid-window uses easings.out (not linear)", () => {
- // step at=0, defaultDuration=12. At raw=6: linear progress=0.5, out(0.5)≈0.875
- // opacity: tween(0, 1, 0.875) = 0.875
const steps: Step<ToastState>[] = [{ at: 0, state: "visible" }];
it("opacity at raw=6 is tween(0,1,out(0.5)) ≈ 0.875 (not linear 0.5)", () => {
const { style } = resolveToastTransition(6, steps, 1, 12);
- const expectedT = easingOut(0.5); // ≈ 0.875
+ const expectedT = easingOut(0.5);
expect(style.opacity).toBeCloseTo(expectedT, 8);
});
it("translateY at raw=6 is tween(16,0,out(0.5)): 16*(1-out(0.5))", () => {
const { style } = resolveToastTransition(6, steps, 1, 12);
const t = easingOut(0.5);
- const expected = 16 * (1 - t); // lerp(16, 0, t)
+ const expected = 16 * (1 - t);
expect(style.translateY).toBeCloseTo(expected, 8);
});
@@ -467,10 +356,6 @@ describe("resolveToastTransition: mid-window uses easings.out (not linear)", ()
});
});
-// ---------------------------------------------------------------------------
-// Past the window: progress=1, t=out(1)=1 → fully visible
-// ---------------------------------------------------------------------------
-
describe("resolveToastTransition: past the transition window → fully visible", () => {
const steps: Step<ToastState>[] = [{ at: 0, state: "visible" }];
@@ -490,12 +375,7 @@ describe("resolveToastTransition: past the transition window → fully visible",
});
});
-// ---------------------------------------------------------------------------
-// Speed contract
-// ---------------------------------------------------------------------------
-
describe("resolveToastTransition: speed contract", () => {
- // step at=12. speed=2: effectiveFrame = raw*2 → fires at raw=6.
const steps: Step<ToastState>[] = [{ at: 12, state: "visible" }];
it("speed=2: step at=12 fires at raw=6 (eff=12)", () => {
@@ -509,10 +389,6 @@ describe("resolveToastTransition: speed contract", () => {
});
});
-// ===========================================================================
-// 6. toastConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("toastConfig.controls: state", () => {
it("state is a select control", () => {
expect(toastConfig.controls.state.type).toBe("select");
@@ -591,10 +467,6 @@ describe("toastConfig.controls: title and description", () => {
});
});
-// ===========================================================================
-// 7. toastConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("toastConfig.snippet: import line", () => {
it("includes 'import { Toast }' from the correct path", () => {
const out = snippet({ state: "visible" });
@@ -619,8 +491,6 @@ describe("toastConfig.snippet: structural invariants", () => {
});
describe("toastConfig.snippet: title is always emitted", () => {
- // title is required on <Toast> so the snippet always includes it — even for
- // the default value (unlike optional props in other components).
it("emits title='Changes saved' when title is the default", () => {
const out = snippet({ state: "visible", title: "Changes saved" });
expect(out).toContain('title="Changes saved"');
@@ -638,8 +508,6 @@ describe("toastConfig.snippet: title is always emitted", () => {
});
describe("toastConfig.snippet: default props are omitted", () => {
- // Defaults: variant=success (the config default), mode=light
- // description is omitted when equal to the default string
it("omits variant when it equals the default 'success'", () => {
const out = snippet({ state: "visible", variant: "success" });
diff --git a/registry/remocn-ui/toast/config.ts b/registry/remocn-ui/toast/config.ts
index 438fdc5e..b3f8f040 100644
--- a/registry/remocn-ui/toast/config.ts
+++ b/registry/remocn-ui/toast/config.ts
@@ -22,7 +22,6 @@ export const toastConfig: ComponentConfig = {
},
state: {
type: "select",
- // Default to `visible` so the preview shows the resting toast.
default: "visible",
options: ["hidden", "visible"],
label: "State",
@@ -45,7 +44,6 @@ export const toastConfig: ComponentConfig = {
const variant = values.variant as string | undefined;
const mode = values.mode as string | undefined;
- // `title` is required, so it is always emitted.
const props: string[] = [
` state="${state}"`,
` title="${title ?? DEFAULT_TITLE}"`,
diff --git a/registry/remocn-ui/toast/index.tsx b/registry/remocn-ui/toast/index.tsx
index 96804b82..13377aca 100644
--- a/registry/remocn-ui/toast/index.tsx
+++ b/registry/remocn-ui/toast/index.tsx
@@ -7,16 +7,10 @@ export type ToastState = "hidden" | "visible";
export type ToastVariant = "default" | "success" | "error";
export interface ToastProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: ToastState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `ToastStyle` from `useToastTransition`.
- */
style?: ToastStyle;
title: string;
description?: string;
- /** Changes the leading icon and its color. `default` shows a neutral info dot. */
variant?: ToastVariant;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
@@ -26,24 +20,15 @@ export interface ToastProps {
const TOAST_WIDTH = 356;
export interface ToastStyle {
- /** Whole-toast opacity 0→1. */
opacity: number;
- /** Enter offset in px (+16 below rest → 0 at rest). */
translateY: number;
- /** Enter scale (0.97 → 1). */
scale: number;
}
-/** Concrete per-variant visuals, resolved once per render. */
export interface ToastStyleContext {
- /** Leading icon color for the active variant (a concrete color). */
iconColor: string;
}
-/**
- * Derive the concrete per-variant colors for a theme. Pure — `success`/`error`
- * tint the icon; `default` uses the muted foreground.
- */
export function toastStyleContext(
variant: ToastVariant,
theme: RemocnTheme,
@@ -53,11 +38,6 @@ export function toastStyleContext(
return { iconColor: theme.mutedForeground };
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state) => ToastStyle` map.
- * Both presets are full keyframes; the toast enters from 16px below at 0.97
- * scale and rests at 0/1. To change how a state looks, edit one entry.
- */
export function toastStyle(state: ToastState): ToastStyle {
switch (state) {
case "visible":
@@ -102,7 +82,6 @@ function ToastIcon({
</svg>
);
}
- // default — neutral info circle.
return (
<svg width={18} height={18} viewBox="0 0 24 24" fill="none">
<circle cx="12" cy="12" r="9" stroke={color} strokeWidth="2" />
@@ -112,12 +91,6 @@ function ToastIcon({
);
}
-/**
- * A deterministic toast. Pure renderer of whatever `ToastStyle` it receives — it
- * reads no frame, holds no state, runs no effects. Snap (`state`) and smooth
- * (`style`) share one render path. Placement (e.g. bottom-right) is the caller's
- * job; the toast renders inside a transparent wrapper.
- */
export function Toast({
state = "hidden",
style,
@@ -160,8 +133,6 @@ export function Toast({
display: "flex",
alignItems: "center",
justifyContent: "center",
- // flexShrink: 0,
- // Nudge the icon onto the title's optical line when stacked.
marginTop: description ? 1 : 0,
}}
>
diff --git a/registry/remocn-ui/toast/preview.tsx b/registry/remocn-ui/toast/preview.tsx
index 2389f93c..e2fc6794 100644
--- a/registry/remocn-ui/toast/preview.tsx
+++ b/registry/remocn-ui/toast/preview.tsx
@@ -15,15 +15,6 @@ export interface ToastPreviewProps {
mode?: "light" | "dark";
}
-/**
- * Preview-only wrapper for the customizer. The shipped `Toast` is a
- * placement-agnostic card — it renders inside a transparent wrapper and the
- * caller positions it (e.g. bottom-right, see the example). The customizer
- * Player renders its `component` as the composition root, so a bare `Toast`
- * would sit in normal flow and stretch; this thin wrapper centers it on a
- * theme-background stage just for the preview. NOT shipped: not listed in
- * registry.json files; users position the toast themselves.
- */
export function ToastPreview({
title = "Changes saved",
description = "Your profile has been updated.",
diff --git a/registry/remocn-ui/toast/use-toast-transition.ts b/registry/remocn-ui/toast/use-toast-transition.ts
index e0321b7b..d23c07a3 100644
--- a/registry/remocn-ui/toast/use-toast-transition.ts
+++ b/registry/remocn-ui/toast/use-toast-transition.ts
@@ -10,16 +10,9 @@ import {
type ToastState,
type ToastStyle,
} from "@/components/remocn/toast";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 12;
-/**
- * Blend two toast visuals: every field lerps. `ToastStyle` carries no animated
- * colors (only transform + opacity), so there is no `mixOklch` here — but every
- * field is covered so neither enter nor dismiss freezes a channel.
- */
export function tweenToastStyle(
a: ToastStyle,
b: ToastStyle,
@@ -38,12 +31,6 @@ export interface ToastTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) ToastStyle. The CALLER invokes this; it
- * reads the frame, the `<Toast>` component does not. Feed the result to
- * `<Toast style={...} />`. Both the enter (hidden→visible) and the auto-dismiss
- * (visible→hidden) read from the same eased tween, so both look smooth.
- */
export function useToastTransition(
steps: Step<ToastState>[],
opts: ToastTransitionOptions = {},
diff --git a/registry/remocn-ui/toggle-group/__tests__/toggle-group.test.ts b/registry/remocn-ui/toggle-group/__tests__/toggle-group.test.ts
index 833e3e8f..0cb690b6 100644
--- a/registry/remocn-ui/toggle-group/__tests__/toggle-group.test.ts
+++ b/registry/remocn-ui/toggle-group/__tests__/toggle-group.test.ts
@@ -1,34 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `toggle-group`.
- *
- * Scope:
- * - registry/remocn-ui/toggle-group/index.tsx — ToggleGroupState type,
- * toggleGroupStyle presets, toggleGroupStyleContext
- * - registry/remocn-ui/toggle-group/use-toggle-group-transition.ts
- * — tweenToggleGroupStyle interpolation, DEFAULT_DURATION,
- * pure replica of useToggleGroupTransition
- * - registry/remocn-ui/toggle-group/config.ts — toggleGroupConfig.controls
- * wiring + toggleGroupConfig.snippet output (the state → JSX codegen)
- *
- * The render path (index.tsx) is a PURE-STATE model: `(style) => visual`.
- * `<ToggleGroup>` 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 + context builder + tween +
- * customizer wiring + snippet codegen.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/toggle-group/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * All imports use RELATIVE paths matching the existing test suite pattern.
- * `config.ts` imports `ToggleGroupState` from the toggle-group registry path;
- * none of the pieces under test call a Remotion runtime API at import time —
- * `toggleGroupConfig` is a plain object; `.snippet` is a pure string builder;
- * `toggleGroupStyle` and `tweenToggleGroupStyle` are pure value functions.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -44,20 +13,11 @@ import {
import { toggleGroupConfig } from "../config";
import { defaultLightTheme } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
-/**
- * The canonical two-item list — mirrors DEFAULT_ITEMS in index.tsx and the
- * config.controls.state.options list. Must stay in sync.
- */
const DEFAULT_ITEMS: ToggleGroupItem[] = [
{ value: "Monthly", label: "Monthly" },
{ value: "Yearly", label: "Yearly" },
];
-/** Minimal shape mirroring the customizer's value bag passed to snippet(). */
type SnippetValues = {
state?: string;
size?: string;
@@ -67,17 +27,8 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
toggleGroupConfig.snippet(values as Record<string, unknown>);
-/**
- * A shared ToggleGroupStyleContext built from the default items + default
- * light theme. Mirrors how the component builds its own context internally.
- * Note: toggleGroupStyleContext takes (items, theme) — no variant argument.
- */
const ctx = toggleGroupStyleContext(DEFAULT_ITEMS, defaultLightTheme);
-// ===========================================================================
-// 1. DEFAULT_DURATION — sanity check the exported constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is a positive number", () => {
expect(typeof DEFAULT_DURATION).toBe("number");
@@ -89,13 +40,6 @@ describe("DEFAULT_DURATION", () => {
});
});
-// ===========================================================================
-// 2. toggleGroupStyleContext — token mapping and round-trips
-// The context is pure: (items, theme) => ToggleGroupStyleContext.
-// Token map: trackBg=muted, thumbBg=background, activeFg=foreground,
-// inactiveFg=mutedForeground, radius=radius.
-// ===========================================================================
-
describe("toggleGroupStyleContext: token mapping (light theme)", () => {
it("trackBg equals theme.muted", () => {
expect(ctx.trackBg).toBe(defaultLightTheme.muted);
@@ -138,7 +82,6 @@ describe("toggleGroupStyleContext: items round-trip", () => {
describe("toggleGroupStyleContext: light and dark produce independent token sets", () => {
it("a dark-mode theme produces a different trackBg than the light theme", () => {
- // Build a minimal dark theme by overriding the key tokens
const darkTheme = {
...defaultLightTheme,
muted: "hsl(217 33% 17%)",
@@ -147,17 +90,10 @@ describe("toggleGroupStyleContext: light and dark produce independent token sets
mutedForeground: "hsl(215 20% 65%)",
};
const darkCtx = toggleGroupStyleContext(DEFAULT_ITEMS, darkTheme);
- // trackBg maps to muted, which we overrode
expect(darkCtx.trackBg).not.toBe(ctx.trackBg);
});
});
-// ===========================================================================
-// 3. toggleGroupStyle presets — pure (state, ctx) => ToggleGroupStyle
-// indicatorOffset is the ONLY field.
-// Monthly → 0 (index 0), Yearly → 1 (index 1), unknown → 0 (safe fallback).
-// ===========================================================================
-
describe("toggleGroupStyle: Monthly state", () => {
it("indicatorOffset is 0 (first item, index 0)", () => {
expect(toggleGroupStyle("Monthly", ctx).indicatorOffset).toBe(0);
@@ -220,15 +156,9 @@ describe("toggleGroupStyle: 3-item list index round-trip", () => {
});
});
-// ===========================================================================
-// 4. tweenToggleGroupStyle — pure linear interpolation between two styles.
-// indicatorOffset is the ONLY field; it lerps linearly.
-// a={indicatorOffset:0} (Monthly), b={indicatorOffset:1} (Yearly).
-// ===========================================================================
-
describe("tweenToggleGroupStyle: t=0 returns values equal to a", () => {
- const a = toggleGroupStyle("Monthly", ctx); // indicatorOffset: 0
- const b = toggleGroupStyle("Yearly", ctx); // indicatorOffset: 1
+ const a = toggleGroupStyle("Monthly", ctx);
+ const b = toggleGroupStyle("Yearly", ctx);
const r = tweenToggleGroupStyle(a, b, 0);
it("indicatorOffset equals a.indicatorOffset at t=0", () => {
@@ -237,8 +167,8 @@ describe("tweenToggleGroupStyle: t=0 returns values equal to a", () => {
});
describe("tweenToggleGroupStyle: t=1 returns values equal to b", () => {
- const a = toggleGroupStyle("Monthly", ctx); // indicatorOffset: 0
- const b = toggleGroupStyle("Yearly", ctx); // indicatorOffset: 1
+ const a = toggleGroupStyle("Monthly", ctx);
+ const b = toggleGroupStyle("Yearly", ctx);
const r = tweenToggleGroupStyle(a, b, 1);
it("indicatorOffset equals b.indicatorOffset at t=1", () => {
@@ -247,8 +177,6 @@ describe("tweenToggleGroupStyle: t=1 returns values equal to b", () => {
});
describe("tweenToggleGroupStyle: t=0.5 midpoint (Monthly → Yearly)", () => {
- // Monthly: indicatorOffset=0, Yearly: indicatorOffset=1
- // Midpoint: 0 + (1-0)*0.5 = 0.5
const a = toggleGroupStyle("Monthly", ctx);
const b = toggleGroupStyle("Yearly", ctx);
const r = tweenToggleGroupStyle(a, b, 0.5);
@@ -259,8 +187,6 @@ describe("tweenToggleGroupStyle: t=0.5 midpoint (Monthly → Yearly)", () => {
});
describe("tweenToggleGroupStyle: t=0.5 midpoint (Yearly → Monthly, reverse)", () => {
- // Yearly: indicatorOffset=1, Monthly: indicatorOffset=0
- // Midpoint: 1 + (0-1)*0.5 = 0.5
const a = toggleGroupStyle("Yearly", ctx);
const b = toggleGroupStyle("Monthly", ctx);
const r = tweenToggleGroupStyle(a, b, 0.5);
@@ -280,7 +206,6 @@ describe("tweenToggleGroupStyle: identity (a === b)", () => {
});
describe("tweenToggleGroupStyle: t=0.25 quarter-way", () => {
- // a=0, b=1, t=0.25 → 0.25
const a = toggleGroupStyle("Monthly", ctx);
const b = toggleGroupStyle("Yearly", ctx);
const r = tweenToggleGroupStyle(a, b, 0.25);
@@ -290,25 +215,6 @@ describe("tweenToggleGroupStyle: t=0.25 quarter-way", () => {
});
});
-// ===========================================================================
-// 5. resolveToggleGroupTransition — pure replica of useToggleGroupTransition
-//
-// useToggleGroupTransition is impure (calls useRemocnTheme + useStateTransition).
-// We mirror its logic as a pure function with `frame` injected as `raw`,
-// then assert the easing contract: easings.out(t) = 1-(1-t)^3.
-//
-// The replica mirrors lines 57–82 of use-toggle-group-transition.ts.
-// Default state is items[0].value = "Monthly".
-// ===========================================================================
-
-/**
- * Pure replica of useToggleGroupTransition for testing.
- *
- * Mirrors the impure hook with `frame` injected as `raw` so we can test the
- * easing contract without a Remotion render context.
- *
- * Annotated lines match the source in use-toggle-group-transition.ts:
- */
function resolveToggleGroupTransition(
steps: Array<{ from: number; state: ToggleGroupState; duration?: number }>,
frame: number, // injected as `raw` — mirrors useCurrentFrame() in the real hook
@@ -316,11 +222,9 @@ function resolveToggleGroupTransition(
speed: number = 1,
defaultDuration: number = DEFAULT_DURATION,
) {
- const localCtx = toggleGroupStyleContext(items, defaultLightTheme); // mirrors line 69
- const defaultState: ToggleGroupState = items[0].value; // mirrors line 73
+ const localCtx = toggleGroupStyleContext(items, defaultLightTheme);
+ const defaultState: ToggleGroupState = items[0].value;
- // Mirror the step-fold logic from useStateTransition:
- // find the two enclosing steps and compute raw linear progress [0,1].
let from: ToggleGroupState = defaultState;
let to: ToggleGroupState = defaultState;
let progress = 0;
@@ -333,7 +237,6 @@ function resolveToggleGroupTransition(
const next = steps[si + 1];
if (frame < stepStart) {
- // Before this step — stay at default (or previous state already set)
break;
}
@@ -342,20 +245,16 @@ function resolveToggleGroupTransition(
to = next?.state ?? step.state;
if (frame >= stepEnd || !next) {
- // Past this window — snap to end state, progress = 1
from = next?.state ?? step.state;
to = from;
progress = 0;
} else {
- // Inside the transition window
progress = (frame - stepStart) / stepDuration;
}
}
}
- // mirrors line 76: const t = easings.out(progress)
const t = 1 - (1 - progress) ** 3;
- // mirrors lines 77-81: tweenToggleGroupStyle(toggleGroupStyle(from, ctx), toggleGroupStyle(to, ctx), t)
return tweenToggleGroupStyle(
toggleGroupStyle(from, localCtx),
toggleGroupStyle(to, localCtx),
@@ -364,7 +263,6 @@ function resolveToggleGroupTransition(
}
describe("resolveToggleGroupTransition: before first step", () => {
- // At frame 0, before any step at frame=10 fires — default state "Monthly"
const steps = [{ from: 10, state: "Yearly" as ToggleGroupState }];
const r = resolveToggleGroupTransition(steps, 0);
@@ -374,7 +272,6 @@ describe("resolveToggleGroupTransition: before first step", () => {
});
describe("resolveToggleGroupTransition: at boundary (progress=0, t=0)", () => {
- // At frame=10 exactly, progress=0 → easings.out(0) = 0 → still at Monthly
const steps = [{ from: 10, state: "Yearly" as ToggleGroupState, duration: 14 }];
const r = resolveToggleGroupTransition(steps, 10);
@@ -384,10 +281,6 @@ describe("resolveToggleGroupTransition: at boundary (progress=0, t=0)", () => {
});
describe("resolveToggleGroupTransition: mid-window eased (frame 7 of 14)", () => {
- // Steps: Monthly at t=0, Yearly at t=0 with duration=14.
- // Frame=7 of a 14-frame window → progress=7/14=0.5
- // easings.out(0.5) = 1-(1-0.5)^3 = 1-0.125 = 0.875
- // tween({indicatorOffset:0}, {indicatorOffset:1}, 0.875) → indicatorOffset=0.875
const steps = [
{ from: 0, state: "Monthly" as ToggleGroupState, duration: 14 },
{ from: 14, state: "Yearly" as ToggleGroupState },
@@ -400,7 +293,6 @@ describe("resolveToggleGroupTransition: mid-window eased (frame 7 of 14)", () =>
});
describe("resolveToggleGroupTransition: past window snaps to target state", () => {
- // Past the 14-frame window from Monthly→Yearly, should be fully at Yearly
const steps = [
{ from: 0, state: "Monthly" as ToggleGroupState, duration: 14 },
{ from: 14, state: "Yearly" as ToggleGroupState },
@@ -413,8 +305,6 @@ describe("resolveToggleGroupTransition: past window snaps to target state", () =
});
describe("resolveToggleGroupTransition: speed contract", () => {
- // Speed=2 halves the effective duration: 14/2=7 frames to complete.
- // At frame=3.5 (half of 7-frame window), progress=0.5, eased=0.875.
const steps = [
{ from: 0, state: "Monthly" as ToggleGroupState, duration: 14 },
{ from: 7, state: "Yearly" as ToggleGroupState },
@@ -422,17 +312,10 @@ describe("resolveToggleGroupTransition: speed contract", () => {
const r = resolveToggleGroupTransition(steps, 3, /* items */ DEFAULT_ITEMS, /* speed */ 2);
it("speed=2 accelerates transition: indicatorOffset is closer to 1 at frame 3", () => {
- // At frame 3 with speed=2, progress=3/7≈0.4286, eased≈0.73
- // Without speed=2 at frame 3 of 14: progress=3/14≈0.214, eased≈0.57
- // So the eased value should be greater with speed=2
expect(r.indicatorOffset).toBeGreaterThan(0.6);
});
});
-// ===========================================================================
-// 6. toggleGroupConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("toggleGroupConfig.controls.state", () => {
it("is a select control", () => {
expect(toggleGroupConfig.controls.state.type).toBe("select");
@@ -481,15 +364,6 @@ describe("toggleGroupConfig.controls.mode", () => {
});
});
-// ===========================================================================
-// 7. toggleGroupConfig.snippet — pure string builder
-//
-// Invariant: state is ALWAYS emitted.
-// Invariant: items inline literal is ALWAYS emitted (regardless of values).
-// Default omission: size omitted when "default"; mode omitted when "light".
-// Non-default emission: size emitted when "sm"; mode emitted when "dark".
-// ===========================================================================
-
describe("toggleGroupConfig.snippet: import line", () => {
it("includes `import { ToggleGroup }` from the correct path", () => {
const out = snippet({ state: "Monthly" });
diff --git a/registry/remocn-ui/toggle-group/index.tsx b/registry/remocn-ui/toggle-group/index.tsx
index f5af59f1..3c2d3807 100644
--- a/registry/remocn-ui/toggle-group/index.tsx
+++ b/registry/remocn-ui/toggle-group/index.tsx
@@ -3,38 +3,27 @@
import type { ReactNode } from "react";
import { mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
-/** Active segment — one of the `items` VALUES. */
export type ToggleGroupState = string;
export type ToggleGroupSize = "default" | "sm";
-/** One segment of the group. */
export interface ToggleGroupItem {
value: string;
label: string;
- /** Optional leading icon node. */
icon?: ReactNode;
}
export interface ToggleGroupProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: ToggleGroupState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `ToggleGroupStyle` from `useToggleGroupTransition`.
- */
style?: ToggleGroupStyle;
- /** Segments (value + label, optional icon). The active `state` is one value. */
items?: ToggleGroupItem[];
size?: ToggleGroupSize;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
- /** Horizontal placement of the track within its (full-width) slot. */
align?: "start" | "center" | "end";
className?: string;
}
-/** Map an `align` value to a flexbox `justifyContent`. */
function justify(align: "start" | "center" | "end"): string {
return align === "start"
? "flex-start"
@@ -43,7 +32,6 @@ function justify(align: "start" | "center" | "end"): string {
: "center";
}
-/** Default segments. */
const DEFAULT_ITEMS: ToggleGroupItem[] = [
{ value: "Monthly", label: "Monthly" },
{ value: "Yearly", label: "Yearly" },
@@ -57,43 +45,19 @@ const SIZE_STYLES: Record<
default: { height: 36, segMinWidth: 88, fontSize: 14, pad: 4, gap: 8 },
};
-// ===========================================================================
-// Toggle-group visual — the COMPLETE animated look for a moment in time. A
-// `state` is a named preset of this visual (`toggleGroupStyle`); the smooth path
-// feeds an interpolated `ToggleGroupStyle` straight through. The component is a
-// pure renderer of whichever style it receives. The sliding thumb's position +
-// width and the per-label color all DERIVE from `indicatorOffset` in render —
-// mirrors the Tabs indicator (so position AND width move without jumps).
-// ===========================================================================
-
export interface ToggleGroupStyle {
- /**
- * Float index (0,1,2…) of where the active thumb sits. The only animated
- * field — the thumb position/width and label colors derive from it inside the
- * pure render, so a lerp of this single value slides the thumb smoothly.
- */
indicatorOffset: number;
}
-/** Concrete colors for the active theme, resolved once per render. */
export interface ToggleGroupStyleContext {
- /** Segment values — the thumb is indexed against this. */
items: ToggleGroupItem[];
- /** Container track background. */
trackBg: string;
- /** Active (raised) thumb surface. */
thumbBg: string;
- /** Active label color. */
activeFg: string;
- /** Inactive label color. */
inactiveFg: string;
radius: number;
}
-/**
- * Derive the concrete colors for a theme. Pure — call it once and reuse the
- * result for every `toggleGroupStyle(state, ctx)` preset.
- */
export function toggleGroupStyleContext(
items: ToggleGroupItem[],
theme: RemocnTheme,
@@ -101,7 +65,6 @@ export function toggleGroupStyleContext(
return {
items,
trackBg: theme.muted,
- // A concrete surface lifts the active segment off the muted track.
thumbBg: theme.background,
activeFg: theme.foreground,
inactiveFg: theme.mutedForeground,
@@ -109,11 +72,6 @@ export function toggleGroupStyleContext(
};
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state, ctx) =>
- * ToggleGroupStyle` map. `indicatorOffset` is the index of `state` in
- * `ctx.items` (safe lookup: unknown state → 0).
- */
export function toggleGroupStyle(
state: ToggleGroupState,
ctx: ToggleGroupStyleContext,
@@ -138,8 +96,6 @@ export function ToggleGroup({
const sizeStyle = SIZE_STYLES[size];
const { pad } = sizeStyle;
- // Equal-width segments; the thumb spans exactly one segment and slides by the
- // float `indicatorOffset`, so both position AND width track without jumps.
const segmentWidth = sizeStyle.segMinWidth;
const thumbX = pad + v.indicatorOffset * segmentWidth;
@@ -152,7 +108,6 @@ export function ToggleGroup({
display: "flex",
alignItems: "center",
justifyContent: justify(align),
- // OPAQUE wrapper — a self-contained widget, not a modal layer (like Tabs).
background: theme.background,
fontFamily:
"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
@@ -169,7 +124,7 @@ export function ToggleGroup({
borderRadius: ctx.radius,
}}
>
- {/* Sliding thumb — a raised surface spanning one segment. */}
+ {}
<div
style={{
position: "absolute",
@@ -182,7 +137,7 @@ export function ToggleGroup({
boxShadow: "0 1px 2px rgba(0,0,0,0.1)",
}}
/>
- {/* Labels stay in normal flow defining the segment widths. */}
+ {}
{items.map((item, i) => {
const proximity = Math.max(0, 1 - Math.abs(i - v.indicatorOffset));
return (
diff --git a/registry/remocn-ui/toggle-group/use-toggle-group-transition.ts b/registry/remocn-ui/toggle-group/use-toggle-group-transition.ts
index e79f0184..f41dc600 100644
--- a/registry/remocn-ui/toggle-group/use-toggle-group-transition.ts
+++ b/registry/remocn-ui/toggle-group/use-toggle-group-transition.ts
@@ -14,22 +14,14 @@ import {
type ToggleGroupState,
type ToggleGroupStyle,
} from "@/components/remocn/toggle-group";
-// ^ install path; resolves in-repo via the @/components/remocn/* tsconfig alias.
-/** Default segments — mirrors the component's default `items`. */
const DEFAULT_ITEMS: ToggleGroupItem[] = [
{ value: "Monthly", label: "Monthly" },
{ value: "Yearly", label: "Yearly" },
];
-/** Default transition length (frames) when a step omits `duration`. Tune to taste. */
export const DEFAULT_DURATION = 14;
-/**
- * Blend two toggle-group visuals: `indicatorOffset` lerps (it's the only field).
- * The thumb position AND width, plus the label colors, all derive from this
- * single value inside the pure render — so a lerp slides the thumb without jumps.
- */
export function tweenToggleGroupStyle(
a: ToggleGroupStyle,
b: ToggleGroupStyle,
@@ -49,11 +41,6 @@ export interface ToggleGroupTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) ToggleGroupStyle. The CALLER invokes
- * this; it reads the frame, the `<ToggleGroup>` component does not. Feed the
- * result to `<ToggleGroup style={...} />` for a smooth sliding thumb.
- */
export function useToggleGroupTransition(
steps: Step<ToggleGroupState>[],
opts: ToggleGroupTransitionOptions = {},
diff --git a/registry/remocn-ui/tooltip/__tests__/tooltip.test.ts b/registry/remocn-ui/tooltip/__tests__/tooltip.test.ts
index 9a84327a..8397b4f2 100644
--- a/registry/remocn-ui/tooltip/__tests__/tooltip.test.ts
+++ b/registry/remocn-ui/tooltip/__tests__/tooltip.test.ts
@@ -1,38 +1,3 @@
-/**
- * Verification tests for the PURE / DETERMINISTIC parts of `tooltip`.
- *
- * Scope:
- * - registry/remocn-ui/tooltip/index.tsx
- * tooltipStyle(state) — complete state→visual preset map
- * (no tooltipStyleContext — Tooltip uses theme.primary/primaryForeground
- * directly; no pure style-context export on this component)
- * - registry/remocn-ui/tooltip/use-tooltip-transition.ts
- * tweenTooltipStyle(a, b, t) — pure lerp across every field
- * DEFAULT_DURATION constant
- * useTooltipTransition resolver — mirrored as resolveTooltipTransition
- * with frame injected as `raw` (annotated source lines)
- * - registry/remocn-ui/tooltip/config.ts
- * tooltipConfig.controls wiring + tooltipConfig.snippet codegen
- *
- * The render path (index.tsx) imports `useRemocnTheme` which requires React
- * context — it is NOT exercised here. `offsetFor` is a module-private function
- * (not exported) — its logic is covered indirectly through the component render
- * path and documented in the README; pure assertions on `tooltipStyle` cover the
- * full pure surface.
- *
- * Runner: Bun's built-in test runner (TypeScript-native, no framework dep).
- * bun test registry/remocn-ui/tooltip/__tests__
- *
- * --------------------------------------------------------------------------
- * IMPORT STRATEGY
- * --------------------------------------------------------------------------
- * Relative imports from component source; `@/lib/remocn-ui` alias for core.
- * `tooltipStyle` and `tweenTooltipStyle` are pure value functions — they call
- * neither `useCurrentFrame()` nor `useRemocnTheme` at import or call time.
- * `useTooltipTransition` IS a hook (calls `useStateTransition` → `useCurrentFrame`)
- * and is NOT imported; we mirror its pure resolver body below.
- * --------------------------------------------------------------------------
- */
import { describe, expect, it } from "bun:test";
import {
@@ -48,14 +13,9 @@ import { tooltipConfig } from "../config";
import { defaultLightTheme, defaultDarkTheme, easings } from "@/lib/remocn-ui";
import type { Step } from "@/lib/remocn-ui";
-// ===========================================================================
-// Shared fixtures
-// ===========================================================================
-
const VALID_STATES: readonly TooltipState[] = ["hidden", "visible"];
const VALID_SIDES: readonly TooltipSide[] = ["top", "bottom", "left", "right"];
-/** Convenience wrapper for snippet(). */
type SnippetValues = {
state?: string;
label?: string;
@@ -65,21 +25,12 @@ type SnippetValues = {
const snippet = (values: SnippetValues): string =>
tooltipConfig.snippet(values as Record<string, unknown>);
-// ===========================================================================
-// 1. DEFAULT_DURATION constant
-// ===========================================================================
-
describe("DEFAULT_DURATION", () => {
it("is 8 frames", () => {
expect(DEFAULT_DURATION).toBe(8);
});
});
-// ===========================================================================
-// 2. tooltipStyle — pure (state) => TooltipStyle map
-// MIRROR of index.tsx lines 59-66
-// ===========================================================================
-
describe("tooltipStyle: hidden state — off-screen keyframe", () => {
const s = tooltipStyle("hidden");
@@ -139,18 +90,11 @@ describe("tooltipStyle: both states are complete keyframes", () => {
});
describe("tooltipStyle: unknown state falls through to hidden preset", () => {
- // The switch has no explicit 'hidden' arm — only 'visible'; default → hidden
it("'hidden' returns opacity=0 (via default arm)", () => {
expect(tooltipStyle("hidden").opacity).toBe(0);
});
});
-// ===========================================================================
-// 3. tweenTooltipStyle — pure lerp across all three fields
-// MIRROR of use-tooltip-transition.ts lines 24-33
-// All fields are numeric (no animated colors); no mixOklch call.
-// ===========================================================================
-
describe("tweenTooltipStyle: t=0 returns values equal to `a`", () => {
const a = tooltipStyle("hidden");
const b = tooltipStyle("visible");
@@ -188,9 +132,6 @@ describe("tweenTooltipStyle: t=1 returns values equal to `b`", () => {
});
describe("tweenTooltipStyle: t=0.5 midpoint (hidden → visible)", () => {
- // hidden: opacity=0, scale=0.96, translate=4
- // visible: opacity=1, scale=1, translate=0
- // midpoint: opacity=0.5, scale=0.98, translate=2
const a = tooltipStyle("hidden");
const b = tooltipStyle("visible");
const r = tweenTooltipStyle(a, b, 0.5);
@@ -209,8 +150,6 @@ describe("tweenTooltipStyle: t=0.5 midpoint (hidden → visible)", () => {
});
describe("tweenTooltipStyle: t=0.5 midpoint (visible → hidden, dismiss direction)", () => {
- // Reverse direction: visible→hidden
- // midpoint: opacity=0.5, scale=0.98, translate=2
const a = tooltipStyle("visible");
const b = tooltipStyle("hidden");
const r = tweenTooltipStyle(a, b, 0.5);
@@ -245,9 +184,6 @@ describe("tweenTooltipStyle: identity (a === b, any t)", () => {
});
describe("tweenTooltipStyle: t=0.25 quarter-point (hidden → visible)", () => {
- // opacity: 0 + 0.25*(1-0) = 0.25
- // scale: 0.96 + 0.25*(1-0.96) = 0.96 + 0.01 = 0.97
- // translate: 4 + 0.25*(0-4) = 4 - 1 = 3
const a = tooltipStyle("hidden");
const b = tooltipStyle("visible");
const r = tweenTooltipStyle(a, b, 0.25);
@@ -265,36 +201,14 @@ describe("tweenTooltipStyle: t=0.25 quarter-point (hidden → visible)", () => {
});
});
-// ===========================================================================
-// 4. useTooltipTransition resolver replica
-// MIRRORS use-tooltip-transition.ts lines 48-61.
-// `useTooltipTransition` calls `useStateTransition` (which reads
-// `useCurrentFrame()`) then applies `easings.out(progress)` and
-// `tweenTooltipStyle`. We inject `raw` in place of `useCurrentFrame()`.
-//
-// This replica re-derives only the logic BEYOND the core
-// `useStateTransition` (already tested in core/__tests__/timeline.test.ts).
-// The key additional contract: progress is eased with `easings.out` before
-// the tween, so field values are out-eased, not linear.
-//
-// MAINTENANCE CONTRACT: if use-tooltip-transition.ts lines 48-61 change,
-// update this replica in lockstep. Annotated source lines below.
-// ===========================================================================
-
-/** MIRROR of core/timeline.ts:clamp01. */
function clamp01Mirror(t: number): number {
return Math.max(0, Math.min(1, t));
}
-/** MIRROR of core/motion.ts:easings.out (cubic ease-out). */
function easingOut(t: number): number {
return 1 - (1 - t) ** 3;
}
-/**
- * MIRROR of timeline.ts:useStateTransition pure resolver body,
- * with `raw` injected.
- */
function resolveStateTransition<S extends string>(
raw: number,
steps: Step<S>[],
@@ -316,42 +230,28 @@ function resolveStateTransition<S extends string>(
return { from: from ? from.state : defaultState, to: to.state, progress };
}
-/**
- * MIRROR of use-tooltip-transition.ts:useTooltipTransition (lines 48-61).
- * `raw` is injected in place of useCurrentFrame().
- * Annotated source lines:
- * line 52: destructure speed + defaultDuration from opts
- * line 53-58: call useStateTransition (mirrored as resolveStateTransition)
- * line 59: t = easings.out(progress) ← MIRROR line 59
- * line 60: tweenTooltipStyle(from, to, t) ← MIRROR line 60
- */
function resolveTooltipTransition(
raw: number, // injected useCurrentFrame() — MIRROR line 53
steps: Step<TooltipState>[],
speed = 1,
defaultDuration = DEFAULT_DURATION,
): { style: ReturnType<typeof tweenTooltipStyle>; progress: number; from: TooltipState; to: TooltipState } {
- const { from, to, progress } = resolveStateTransition( // MIRROR lines 53-58
+ const { from, to, progress } = resolveStateTransition(
raw,
steps,
"hidden",
speed,
defaultDuration,
);
- const t = easingOut(progress); // MIRROR line 59
- const style = tweenTooltipStyle(tooltipStyle(from as TooltipState), tooltipStyle(to as TooltipState), t); // MIRROR line 60
+ const t = easingOut(progress);
+ const style = tweenTooltipStyle(tooltipStyle(from as TooltipState), tooltipStyle(to as TooltipState), t);
return { style, progress, from: from as TooltipState, to: to as TooltipState };
}
-// ---------------------------------------------------------------------------
-// Before any step: holds at hidden (progress=1, tween(hidden,hidden,out(1)))
-// ---------------------------------------------------------------------------
-
describe("resolveTooltipTransition: before any step — holds at hidden", () => {
it("returns the hidden style when no steps have started", () => {
const { style } = resolveTooltipTransition(0, []);
const hidden = tooltipStyle("hidden");
- // out(1)=1, so tween(hidden,hidden,1) = hidden
expect(style.opacity).toBeCloseTo(hidden.opacity, 10);
expect(style.scale).toBeCloseTo(hidden.scale, 10);
expect(style.translate).toBeCloseTo(hidden.translate, 10);
@@ -364,17 +264,12 @@ describe("resolveTooltipTransition: before any step — holds at hidden", () =>
});
});
-// ---------------------------------------------------------------------------
-// Exactly at a step boundary: progress=0, t=easings.out(0)=0
-// ---------------------------------------------------------------------------
-
describe("resolveTooltipTransition: exactly at hidden→visible step boundary", () => {
const steps: Step<TooltipState>[] = [{ at: 10, state: "visible" }];
it("at raw=10 exactly, progress=0, t=out(0)=0 → style equals hidden (from)", () => {
const { style, progress } = resolveTooltipTransition(10, steps);
expect(progress).toBe(0);
- // t = out(0) = 0, so style = tween(hidden, visible, 0) = hidden
const hidden = tooltipStyle("hidden");
expect(style.opacity).toBeCloseTo(hidden.opacity, 10);
expect(style.scale).toBeCloseTo(hidden.scale, 10);
@@ -388,42 +283,30 @@ describe("resolveTooltipTransition: exactly at hidden→visible step boundary",
});
});
-// ---------------------------------------------------------------------------
-// Mid-window: easings.out applied to progress (non-linear)
-// ---------------------------------------------------------------------------
-
describe("resolveTooltipTransition: mid-window uses easings.out (not linear)", () => {
- // step at=0, defaultDuration=8. At raw=4: linear progress=0.5, out(0.5)=0.875
- // opacity: tween(0, 1, 0.875) = 0.875
- // scale: tween(0.96, 1, 0.875) = 0.96 + 0.04*0.875 = 0.995
- // translate: tween(4, 0, 0.875) = 4*(1-0.875) = 0.5
const steps: Step<TooltipState>[] = [{ at: 0, state: "visible" }];
it("opacity at raw=4 is tween(0,1,out(0.5)) ≈ 0.875 (not linear 0.5)", () => {
const { style } = resolveTooltipTransition(4, steps, 1, 8);
- const expectedT = easingOut(0.5); // 0.875
+ const expectedT = easingOut(0.5);
expect(style.opacity).toBeCloseTo(expectedT, 8);
});
it("scale at raw=4 is tween(0.96,1,out(0.5)): 0.96 + 0.04*0.875 = 0.995", () => {
const { style } = resolveTooltipTransition(4, steps, 1, 8);
const t = easingOut(0.5);
- const expected = 0.96 + (1 - 0.96) * t; // 0.995
+ const expected = 0.96 + (1 - 0.96) * t;
expect(style.scale).toBeCloseTo(expected, 8);
});
it("translate at raw=4 is tween(4,0,out(0.5)): 4*(1-0.875) = 0.5", () => {
const { style } = resolveTooltipTransition(4, steps, 1, 8);
const t = easingOut(0.5);
- const expected = 4 * (1 - t); // 0.5
+ const expected = 4 * (1 - t);
expect(style.translate).toBeCloseTo(expected, 8);
});
});
-// ---------------------------------------------------------------------------
-// Past the window: progress=1, t=out(1)=1 → fully visible
-// ---------------------------------------------------------------------------
-
describe("resolveTooltipTransition: past the transition window → fully visible", () => {
const steps: Step<TooltipState>[] = [{ at: 0, state: "visible" }];
@@ -443,12 +326,7 @@ describe("resolveTooltipTransition: past the transition window → fully visible
});
});
-// ---------------------------------------------------------------------------
-// Speed contract
-// ---------------------------------------------------------------------------
-
describe("resolveTooltipTransition: speed contract", () => {
- // step at=8. speed=2: effectiveFrame = raw*2 → fires at raw=4.
const steps: Step<TooltipState>[] = [{ at: 8, state: "visible" }];
it("speed=2: step at=8 fires at raw=4 (eff=8)", () => {
@@ -462,10 +340,6 @@ describe("resolveTooltipTransition: speed contract", () => {
});
});
-// ===========================================================================
-// 5. tooltipConfig.controls — customizer control wiring
-// ===========================================================================
-
describe("tooltipConfig.controls: state", () => {
it("state is a select control", () => {
expect(tooltipConfig.controls.state.type).toBe("select");
@@ -540,10 +414,6 @@ describe("tooltipConfig.controls: label", () => {
});
});
-// ===========================================================================
-// 6. tooltipConfig.snippet — pure JSX string builder
-// ===========================================================================
-
describe("tooltipConfig.snippet: import line", () => {
it("includes 'import { Tooltip }' from the correct path", () => {
const out = snippet({ state: "visible" });
@@ -572,7 +442,6 @@ describe("tooltipConfig.snippet: structural invariants", () => {
});
describe("tooltipConfig.snippet: label is always emitted", () => {
- // label is required on <Tooltip>, always emitted even for the default.
it("emits label='Add to library' when label is the default", () => {
const out = snippet({ state: "visible", label: "Add to library" });
expect(out).toContain('label="Add to library"');
@@ -590,7 +459,6 @@ describe("tooltipConfig.snippet: label is always emitted", () => {
});
describe("tooltipConfig.snippet: default props are omitted", () => {
- // Defaults: side=top, mode=light
it("omits side when it equals the default 'top'", () => {
const out = snippet({ state: "visible", side: "top" });
diff --git a/registry/remocn-ui/tooltip/config.ts b/registry/remocn-ui/tooltip/config.ts
index e29046e6..9567ad9c 100644
--- a/registry/remocn-ui/tooltip/config.ts
+++ b/registry/remocn-ui/tooltip/config.ts
@@ -16,7 +16,6 @@ export const tooltipConfig: ComponentConfig = {
},
state: {
type: "select",
- // Default to `visible` so the preview shows the resting tooltip.
default: "visible",
options: ["hidden", "visible"],
label: "State",
diff --git a/registry/remocn-ui/tooltip/index.tsx b/registry/remocn-ui/tooltip/index.tsx
index 22811393..4449e888 100644
--- a/registry/remocn-ui/tooltip/index.tsx
+++ b/registry/remocn-ui/tooltip/index.tsx
@@ -7,55 +7,23 @@ export type TooltipState = "hidden" | "visible";
export type TooltipSide = "top" | "bottom" | "left" | "right";
export interface TooltipProps {
- /** Current visual state (snap path). State changes snap (no enter-tweens). */
state?: TooltipState;
- /**
- * Resolved animated visual (smooth path). When provided, takes precedence over
- * `state` — feed it an interpolated `TooltipStyle` from `useTooltipTransition`.
- */
style?: TooltipStyle;
- /** Tooltip text. */
label: string;
- /**
- * Which side of the anchor the tooltip sits on. STATIC — it sets the enter
- * translate axis/sign (the bubble slides in toward the anchor) and which edge
- * the arrow points from. Not animated.
- */
side?: TooltipSide;
theme?: Partial<RemocnTheme>;
mode?: "light" | "dark";
className?: string;
}
-/** Arrow half-size (px); the diamond is `ARROW` square, rotated 45°. */
const ARROW = 10;
-// ===========================================================================
-// Tooltip visual — the COMPLETE animated look for a moment in time. A `state` is
-// a named preset of this visual (`tooltipStyle`); the smooth path feeds an
-// interpolated `TooltipStyle` straight through. The component is a pure renderer
-// of whichever `TooltipStyle` it receives. `translate` is a single magnitude in
-// px; the component applies it on the axis/sign chosen by `side`.
-// ===========================================================================
-
export interface TooltipStyle {
- /** Whole-tooltip opacity 0→1. */
opacity: number;
- /** Enter zoom 0.96→1. */
scale: number;
- /**
- * Enter offset MAGNITUDE in px (4 hidden → 0 visible). The component turns
- * this into a translateX/Y with the sign that slides the bubble in toward the
- * anchor for the active `side`.
- */
translate: number;
}
-/**
- * The COMPLETE resting visual for a state — a pure `(state) => TooltipStyle` map.
- * Both presets are full keyframes; the tooltip enters from 4px offset at 0.96
- * scale and rests at 0/1. To change how a state looks, edit one entry.
- */
export function tooltipStyle(state: TooltipState): TooltipStyle {
switch (state) {
case "visible":
@@ -65,11 +33,6 @@ export function tooltipStyle(state: TooltipState): TooltipStyle {
}
}
-/**
- * Resolve the `translate` magnitude into a CSS transform offset for a side. The
- * bubble starts `translate` px on its OWN side away from the anchor and slides
- * back toward it: side "top" (bubble above) enters moving up (+Y → 0), etc.
- */
function offsetFor(
side: TooltipSide,
translate: number,
@@ -84,7 +47,7 @@ function offsetFor(
return { x: translate, y: 0 };
case "right":
return { x: -translate, y: 0 };
- default: // top
+ default:
return { x: 0, y: translate };
}
}
@@ -101,20 +64,15 @@ export function Tooltip({
const theme = useRemocnTheme(themeOverride, mode);
const v = style ?? tooltipStyle(state);
- // Actual current shadcn tooltip look: an INVERTED bubble — `bg-foreground` +
- // `text-background` (dark-on-light in light mode), not the primary accent.
const bg = theme.foreground;
const fg = theme.background;
const { x, y } = offsetFor(side, v.translate);
- // The arrow diamond is centered on the edge facing the anchor. We position it
- // by the side opposite to `side` (top tooltip → arrow on its bottom edge).
const arrowStyle: React.CSSProperties = {
position: "absolute",
width: ARROW,
height: ARROW,
background: bg,
- // shadcn arrow is a rotated square with softly rounded corners (rounded-[2px]).
borderRadius: 2,
transform: "rotate(45deg)",
...(side === "top" && {
@@ -163,15 +121,13 @@ export function Tooltip({
fontWeight: 500,
lineHeight: 1.3,
letterSpacing: "-0.005em",
- // shadcn `rounded-xl` ≈ theme.radius + 4 (repo radius ~8 → ~12).
borderRadius: theme.radius + 4,
whiteSpace: "nowrap",
boxShadow: "0 4px 12px -4px rgba(0,0,0,0.25)",
}}
>
{label}
- {/* The arrow sits OUTSIDE the bubble's rounded box but behind its text;
- it is clipped to a small diamond and shares the bubble background. */}
+ {}
<span style={arrowStyle} />
</div>
</div>
diff --git a/registry/remocn-ui/tooltip/preview.tsx b/registry/remocn-ui/tooltip/preview.tsx
index 655bc94a..e9aa5010 100644
--- a/registry/remocn-ui/tooltip/preview.tsx
+++ b/registry/remocn-ui/tooltip/preview.tsx
@@ -14,14 +14,6 @@ export interface TooltipPreviewProps {
mode?: "light" | "dark";
}
-/**
- * Preview-only wrapper for the customizer. The shipped `Tooltip` is a small
- * placement-agnostic bubble 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 `Tooltip` 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 TooltipPreview({
label = "Add to library",
side = "top",
diff --git a/registry/remocn-ui/tooltip/use-tooltip-transition.ts b/registry/remocn-ui/tooltip/use-tooltip-transition.ts
index 5729546f..341a83a3 100644
--- a/registry/remocn-ui/tooltip/use-tooltip-transition.ts
+++ b/registry/remocn-ui/tooltip/use-tooltip-transition.ts
@@ -10,17 +10,9 @@ import {
type TooltipState,
type TooltipStyle,
} from "@/components/remocn/tooltip";
-// ^ 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 = 8;
-/**
- * Blend two tooltip visuals: every field lerps. `TooltipStyle` carries no
- * animated colors (the bubble bg/fg are static per theme), so there is no
- * `mixOklch` here — but every field is covered so neither show nor hide freezes
- * a channel.
- */
export function tweenTooltipStyle(
a: TooltipStyle,
b: TooltipStyle,
@@ -39,12 +31,6 @@ export interface TooltipTransitionOptions {
defaultDuration?: number;
}
-/**
- * Timeline → resolved (eased, tweened) TooltipStyle. The CALLER invokes this; it
- * reads the frame, the `<Tooltip>` component does not. Feed the result to
- * `<Tooltip style={...} />`. Both the show (hidden→visible) and the hide
- * (visible→hidden) read from the same eased tween, so both look smooth.
- */
export function useTooltipTransition(
steps: Step<TooltipState>[],
opts: TooltipTransitionOptions = {},