Production-ready animations, transitions, backgrounds, and scenes for Remotion
select-menu — verification tests
Pure / deterministic verification for the select-menu component
(registry/remocn-ui/select-menu/). The RENDER path needs Remotion's
useCurrentFrame() and cannot run headless, so the render is NOT exercised
here. This suite covers the pieces that ARE pure: selectMenuStyle presets,
selectMenuStyleContext theming, tweenSelectMenuStyle interpolation, and
selectMenuConfig control/snippet wiring.
Animation model — pure snap + opt-in smooth path
SelectMenu ships two complementary paths:
Snap path (selectedIndex?: number / state?: string prop): SelectMenu is
a frame-free pure renderer. The selection is fully controlled. selectedIndex
maps straight to a complete resting visual via the exported pure function
selectMenuStyle(selectedIndex, ctx) => SelectMenuStyle. Selection changes snap
instantly — no tweening inside the component. state is an alias that resolves
an option value back to an index.
Smooth path (style?: SelectMenuStyle prop): callers opt in to a smooth
sliding highlight by passing a pre-interpolated SelectMenuStyle to the style
prop. The caller — typically useSelectMenuTransition — reads
useCurrentFrame() and calls useStateTransition from core/timeline.ts to
compute { from, to, progress }, then blends the two presets via
tweenSelectMenuStyle(from, to, t). The component itself remains frame-free; it
simply renders whatever SelectMenuStyle it receives.
The three animated fields are:
indicatorOffset— a float row index. Tweening it glides the highlight bar and the left accent between rows with no jump. Per-row label color and weight derive fromproximity = 1 - |i - indicatorOffset|, exactly liketoggle-group's labels, so the emphasis crossfades as the highlight arrives.press— transient 0..1 press depth of the row under the indicator. Rises and falls inside the click window (clickAt→clickAt + clickDuration) and drives a quick scale dip + highlight darkening, likeselect-item's press state.0at rest; snap styles always report0.selectProgress— 0..1 selectedness. Rises over the release portion of the click window (the check mark fades in on the row's right edge), holds at1while selected, and eases back to0after ahold/decayDurationcycle so a selecting loop can restart cleanly. Snap styles report1(fully selected). Without aclickAt, bothpressandselectProgressstay0(pure glide, no click effect).
How to run
The repo uses Bun, which has a built-in test runner — runs TypeScript natively, no test-framework dep.
bun install
bun test registry/remocn-ui/select-menu/__tests__
select-menu.test.ts imports bun:test (not vitest/jest), so no test script
or framework dep is added to package.json.
What is covered
selectMenuStyle— exported pure(index, ctx) => SelectMenuStylemap. Asserts an index maps to an equalindicatorOffset, index 0 maps to offset 0, negative indices clamp to 0, out-of-range indices clamp to the last row, an unknown state value (index -1 fromoptions.indexOf) clamps to 0, and the snap result reportsselectProgress: 1+press: 0(fully selected).selectMenuStyleContext— exported pure(options, variant, theme) => ctx. Asserts the option list is carried through, the soft variant derives its highlight/accent from theme accent + primary, the solid variant fills withtheme.primary+theme.primaryForeground, and the themeforegroundis carried for the press darkening.computeSelectMenuClick— exported pure(frame, clickAt, clickDuration, { hold, decayDuration })piecewise click timeline. Asserts it is at rest before the window,presspeaks at the press/release boundary and zeroes by the window end,selectProgressrises over the release and stays selected, and — withhold/decayDuration— eases back to0without ever replaying the press.tweenSelectMenuStyle— exported pure(a, b, t) => SelectMenuStyle. Asserts t=0 equalsa, t=1 equalsb, t=0.5 is the exact midpoint forindicatorOffset,press, andselectProgress, a same-row tween stays put, and both click fields interpolate linearly.selectMenuConfig.controls—selectedIndexis anumbercontrol clamped to the option range (0–3, default 1);variantis anenumcontrol withsoft/solidoptions.selectMenuConfig.snippet— REAL pure string builder (high value). Asserts: includesimport { SelectMenu }from@/components/remocn/select-menu; always emitsselectedIndex={n}(the primary controlled prop); emits non-defaultselectedIndex; omits default-equalvariant="soft"; emitsvariant="solid"when non-default; includes the defaultoptions; ends with/>.
SelectMenu render is a pure (selectedIndex | state | style) => visual
observable only via Remotion render, not unit-tested here.
Import strategy
select-menu.test.ts imports via a mix of relative paths and the
@/lib/remocn-ui tsconfig alias:
../index— relative, forSelectMenuStyle,selectMenuStyle,selectMenuStyleContext../use-select-menu-transition— relative, fortweenSelectMenuStyle,computeSelectMenuClick,DEFAULT_DURATION../config— relative, forselectMenuConfig@/lib/remocn-ui— alias (resolves toregistry/remocn-ui/core/index.ts), fordefaultLightTheme
Importing index.tsx and use-select-menu-transition.ts pulls the remotion
module (and React), but selectMenuStyle, selectMenuStyleContext,
tweenSelectMenuStyle, and computeSelectMenuClick never call
useCurrentFrame() at import time or at call time — they are pure value
functions. bun test resolves tsconfig paths, so the alias works without
additional config.
Determinism grep checklist (run manually; must print NOTHING)
SelectMenu is frame-free. The component must contain none of the following:
grep -nE "useCurrentFrame|useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \
registry/remocn-ui/select-menu/index.tsx
Expected: no output. Any match is a determinism violation.
use-select-menu-transition.ts is the CALLER hook that intentionally reads
useCurrentFrame() (via useStateTransition). It is not a render component;
the smooth-path design isolates all frame-reading to the hook, keeping
SelectMenu pure.
Tier-wide sweep:
grep -nE "useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \
registry/remocn-ui/select-menu/index.tsx registry/remocn-ui/core/*.ts