Skip to content

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

feat: setup icon infra

dev_wandrye50e2a1c24ef
diff --git a/bun.lock b/bun.lock
index 958f1124..a4d4a337 100644
--- a/bun.lock
+++ b/bun.lock
@@ -10,6 +10,7 @@
"@paper-design/shaders-react": "0.0.76",
"@remotion/bundler": "4.0.473",
"@remotion/google-fonts": "4.0.473",
+ "@remotion/paths": "4.0.473",
"@remotion/player": "4.0.473",
"@remotion/renderer": "4.0.473",
"@remotion/transitions": "4.0.473",
diff --git a/package.json b/package.json
index de0befdd..0b531712 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,7 @@
"@paper-design/shaders-react": "0.0.76",
"@remotion/bundler": "4.0.473",
"@remotion/google-fonts": "4.0.473",
+ "@remotion/paths": "4.0.473",
"@remotion/player": "4.0.473",
"@remotion/renderer": "4.0.473",
"@remotion/transitions": "4.0.473",
diff --git a/public/r/drift.json b/public/r/drift.json
new file mode 100644
index 00000000..8e50c276
--- /dev/null
+++ b/public/r/drift.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "drift",
+ "title": "Drift",
+ "description": "A slow linear camera push-in wrapper that scales its scene from 1 to 1+grow across the sequence so no frame is ever static.",
+ "dependencies": ["remotion"],
+ "files": [
+ {
+ "path": "registry/remocn/drift/index.tsx",
+ "content": "\"use client\";\n\nimport type React from \"react\";\nimport { AbsoluteFill, interpolate, useCurrentFrame, useVideoConfig } from \"remotion\";\n\nexport interface DriftProps {\n children: React.ReactNode;\n grow?: number;\n}\n\nexport function Drift({ children, grow = 0.035 }: DriftProps) {\n const frame = useCurrentFrame();\n const { durationInFrames } = useVideoConfig();\n const scale = interpolate(frame, [0, durationInFrames], [1, 1 + grow]);\n return (\n <AbsoluteFill style={{ transform: `scale(${scale})` }}>\n {children}\n </AbsoluteFill>\n );\n}\n",
+ "type": "registry:component",
+ "target": "components/remocn/drift.tsx"
+ }
+ ],
+ "type": "registry:component"
+}
diff --git a/public/r/icons-core.json b/public/r/icons-core.json
new file mode 100644
index 00000000..5afee734
--- /dev/null
+++ b/public/r/icons-core.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "icons-core",
+ "title": "Icons Core",
+ "description": "Shared animation contract, pure frame-to-phase timeline, and SVG path-draw helpers for remocn icons.",
+ "dependencies": ["remotion", "@remotion/paths"],
+ "files": [
+ {
+ "path": "registry/remocn/icons-core/index.ts",
+ "content": "import { evolvePath } from \"@remotion/paths\";\nimport { spring, useCurrentFrame, useVideoConfig } from \"remotion\";\n\nexport interface IconAnimationProps {\n animation?: \"draw\" | \"action\" | \"both\";\n loop?: boolean;\n speed?: number;\n size?: number;\n color?: string;\n strokeWidth?: number;\n className?: string;\n}\n\nexport interface IconTimings {\n drawDurationInFrames?: number;\n actionDelayInFrames?: number;\n actionDurationInFrames?: number;\n loop?: boolean;\n}\n\nexport interface IconTimeline {\n drawProgress: number;\n scaleIn: number;\n actionFrame: number;\n actionProgress: number;\n cycleIndex: number;\n}\n\nfunction clamp01(t: number): number {\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nfunction easeOut(t: number): number {\n return 1 - (1 - t) ** 3;\n}\n\nexport function iconTimeline(\n frame: number,\n fps: number,\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const animation = props.animation ?? \"both\";\n const loop = props.loop ?? timings.loop ?? false;\n const drawDuration = timings.drawDurationInFrames ?? 14;\n const actionDelay = timings.actionDelayInFrames ?? 2;\n const actionDuration = timings.actionDurationInFrames ?? 20;\n\n const drawProgress =\n animation === \"action\"\n ? 1\n : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));\n\n const scaleIn = clamp01(\n spring({\n frame,\n fps,\n config: { damping: 18, stiffness: 220, mass: 0.7 },\n durationInFrames: Math.max(1, drawDuration),\n }),\n );\n\n const actionStart =\n animation === \"action\" ? 0 : drawDuration + actionDelay;\n const sinceStart = frame - actionStart;\n\n if (animation === \"draw\" || sinceStart < 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 0,\n cycleIndex: 0,\n };\n }\n\n if (actionDuration <= 0) {\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: 1,\n cycleIndex: 0,\n };\n }\n\n if (loop) {\n const cycleIndex = Math.floor(sinceStart / actionDuration);\n const local = sinceStart - cycleIndex * actionDuration;\n return {\n drawProgress,\n scaleIn,\n actionFrame: local,\n actionProgress: local / actionDuration,\n cycleIndex,\n };\n }\n\n return {\n drawProgress,\n scaleIn,\n actionFrame: sinceStart,\n actionProgress: clamp01(sinceStart / actionDuration),\n cycleIndex: 0,\n };\n}\n\nexport function useIconAnimation(\n props: IconAnimationProps,\n timings: IconTimings,\n): IconTimeline {\n const frame = useCurrentFrame();\n const { fps } = useVideoConfig();\n const speed = props.speed ?? 1;\n return iconTimeline(frame * speed, fps, props, timings);\n}\n\nexport function staggeredProgress(\n progress: number,\n index: number,\n count: number,\n overlap = 0.5,\n): number {\n if (count <= 1) return clamp01(progress);\n const o = clamp01(overlap);\n const width = 1 / (count - (count - 1) * o);\n const start = index * width * (1 - o);\n return clamp01((progress - start) / width);\n}\n\nexport function drawnPathProps(\n d: string,\n progress: number,\n): { strokeDasharray: string; strokeDashoffset: number } {\n return evolvePath(clamp01(progress), d);\n}\n",
+ "type": "registry:lib",
+ "target": "lib/remocn-icons/index.ts"
+ }
+ ],
+ "type": "registry:lib"
+}
diff --git a/public/r/registry.json b/public/r/registry.json
index 31242e5e..96118f01 100644
--- a/public/r/registry.json
+++ b/public/r/registry.json
@@ -3,6 +3,20 @@
"name": "remocn",
"homepage": "https://remocn.dev",
"items": [
+ {
+ "name": "icons-core",
+ "title": "Icons Core",
+ "description": "Shared animation contract, pure frame-to-phase timeline, and SVG path-draw helpers for remocn icons.",
+ "dependencies": ["remotion", "@remotion/paths"],
+ "files": [
+ {
+ "path": "registry/remocn/icons-core/index.ts",
+ "type": "registry:lib",
+ "target": "lib/remocn-icons/index.ts"
+ }
+ ],
+ "type": "registry:lib"
+ },
{
"name": "soft-blur-in",
"title": "Soft Blur In",
@@ -866,6 +880,48 @@
],
"type": "registry:component"
},
+ {
+ "name": "zoom-blur",
+ "title": "Zoom Blur",
+ "description": "A depth punch-in transition that pushes the outgoing scene through the viewer while the incoming one resolves out of blur.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "files": [
+ {
+ "path": "registry/remocn/zoom-blur/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/zoom-blur.tsx"
+ }
+ ],
+ "type": "registry:component"
+ },
+ {
+ "name": "rolodex-flip",
+ "title": "Rolodex Flip",
+ "description": "Cycles a word through a list of values with a 3D rolodex card flip while an invisible sizer keeps the line width and baseline stable.",
+ "dependencies": ["remotion"],
+ "files": [
+ {
+ "path": "registry/remocn/rolodex-flip/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/rolodex-flip.tsx"
+ }
+ ],
+ "type": "registry:component"
+ },
+ {
+ "name": "value-swap",
+ "title": "Value Swap",
+ "description": "Swaps a value in place with a vertical slide — the old value exits up as the new one enters from below while an invisible sizer keeps the width stable.",
+ "dependencies": ["remotion"],
+ "files": [
+ {
+ "path": "registry/remocn/value-swap/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/value-swap.tsx"
+ }
+ ],
+ "type": "registry:component"
+ },
{
"name": "chat-to-preview-layout",
"title": "Chat to Preview Layout",
@@ -1255,6 +1311,20 @@
],
"type": "registry:component"
},
+ {
+ "name": "drift",
+ "title": "Drift",
+ "description": "A slow linear camera push-in wrapper that scales its scene from 1 to 1+grow across the sequence so no frame is ever static.",
+ "dependencies": ["remotion"],
+ "files": [
+ {
+ "path": "registry/remocn/drift/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/drift.tsx"
+ }
+ ],
+ "type": "registry:component"
+ },
{
"name": "logo-enter",
"title": "Logo Enter",
diff --git a/public/r/rolodex-flip.json b/public/r/rolodex-flip.json
new file mode 100644
index 00000000..a5d60b75
--- /dev/null
+++ b/public/r/rolodex-flip.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "rolodex-flip",
+ "title": "Rolodex Flip",
+ "description": "Cycles a word through a list of values with a 3D rolodex card flip while an invisible sizer keeps the line width and baseline stable.",
+ "dependencies": ["remotion"],
+ "files": [
+ {
+ "path": "registry/remocn/rolodex-flip/index.tsx",
+ "content": "\"use client\";\n\nimport type React from \"react\";\nimport { Easing, interpolate, useCurrentFrame } from \"remotion\";\n\nconst clampOpts = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\n\nexport interface RolodexFlipProps {\n items: string[];\n from?: number;\n interval?: number;\n flipDuration?: number;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function RolodexFlip({\n items,\n from = 0,\n interval = 20,\n flipDuration = 10,\n className,\n style,\n}: RolodexFlipProps) {\n const frame = useCurrentFrame();\n const sizer = items.reduce((a, b) => (b.length > a.length ? b : a), \"\");\n return (\n <span\n className={className}\n style={{\n position: \"relative\",\n display: \"inline-block\",\n perspective: 420,\n verticalAlign: \"bottom\",\n ...style,\n }}\n >\n <span style={{ visibility: \"hidden\" }}>{sizer}</span>\n {items.map((item, i) => {\n const inStart = from + (i - 1) * interval + flipDuration / 2;\n const outStart = from + i * interval;\n\n let rotate = 0;\n let y = 0;\n let opacity = 1;\n\n if (i > 0) {\n const pIn = interpolate(\n frame,\n [inStart, inStart + flipDuration],\n [0, 1],\n { ...clampOpts, easing: Easing.out(Easing.cubic) },\n );\n rotate = (1 - pIn) * -85;\n y = (1 - pIn) * 20;\n opacity = pIn;\n }\n if (i < items.length - 1) {\n const pOut = interpolate(\n frame,\n [outStart, outStart + flipDuration],\n [0, 1],\n { ...clampOpts, easing: Easing.in(Easing.cubic) },\n );\n rotate += pOut * 85;\n y -= pOut * 20;\n opacity *= 1 - pOut;\n }\n if (opacity <= 0.001) return null;\n\n return (\n <span\n key={`${i}-${item}`}\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n whiteSpace: \"nowrap\",\n opacity,\n transform: `translateY(${y}px) rotateX(${rotate}deg)`,\n transformOrigin: \"50% 50%\",\n backfaceVisibility: \"hidden\",\n }}\n >\n {item}\n </span>\n );\n })}\n </span>\n );\n}\n",
+ "type": "registry:component",
+ "target": "components/remocn/rolodex-flip.tsx"
+ }
+ ],
+ "type": "registry:component"
+}
diff --git a/public/r/value-swap.json b/public/r/value-swap.json
new file mode 100644
index 00000000..ca1f2772
--- /dev/null
+++ b/public/r/value-swap.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "value-swap",
+ "title": "Value Swap",
+ "description": "Swaps a value in place with a vertical slide — the old value exits up as the new one enters from below while an invisible sizer keeps the width stable.",
+ "dependencies": ["remotion"],
+ "files": [
+ {
+ "path": "registry/remocn/value-swap/index.tsx",
+ "content": "\"use client\";\n\nimport type React from \"react\";\nimport { Easing, interpolate, useCurrentFrame } from \"remotion\";\n\nconst clampOpts = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\n\nexport interface ValueSwapProps {\n values: string[];\n at: number | number[];\n duration?: number;\n distance?: number;\n direction?: \"up\" | \"down\";\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function ValueSwap({\n values,\n at,\n duration = 10,\n distance = 12,\n direction = \"up\",\n className,\n style,\n}: ValueSwapProps) {\n const frame = useCurrentFrame();\n const ats = Array.isArray(at) ? at : [at];\n const d = direction === \"down\" ? -distance : distance;\n const count = Math.min(values.length, ats.length + 1);\n const rendered = values.slice(0, count);\n const sizer = rendered.reduce((a, b) => (b.length > a.length ? b : a), \"\");\n const swapP = (start: number) =>\n interpolate(frame, [start, start + duration], [0, 1], {\n ...clampOpts,\n easing: Easing.inOut(Easing.cubic),\n });\n return (\n <span\n className={className}\n style={{\n position: \"relative\",\n display: \"inline-block\",\n ...style,\n }}\n >\n <span style={{ visibility: \"hidden\" }}>{sizer}</span>\n {rendered.map((value, i) => {\n const pIn = i > 0 ? swapP(ats[i - 1]) : 1;\n const pOut = i < count - 1 ? swapP(ats[i]) : 0;\n const opacity = pIn * (1 - pOut);\n if (opacity <= 0.001) return null;\n const y = (1 - pIn) * d + pOut * -d;\n return (\n <span\n key={`${i}-${value}`}\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n whiteSpace: \"nowrap\",\n opacity,\n transform: `translateY(${y}px)`,\n }}\n >\n {value}\n </span>\n );\n })}\n </span>\n );\n}\n",
+ "type": "registry:component",
+ "target": "components/remocn/value-swap.tsx"
+ }
+ ],
+ "type": "registry:component"
+}
diff --git a/public/r/zoom-blur.json b/public/r/zoom-blur.json
new file mode 100644
index 00000000..6d56e733
--- /dev/null
+++ b/public/r/zoom-blur.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "zoom-blur",
+ "title": "Zoom Blur",
+ "description": "A depth punch-in transition that pushes the outgoing scene through the viewer while the incoming one resolves out of blur.",
+ "dependencies": ["remotion", "@remotion/transitions"],
+ "files": [
+ {
+ "path": "registry/remocn/zoom-blur/index.tsx",
+ "content": "\"use client\";\n\nimport type {\n TransitionPresentation,\n TransitionPresentationComponentProps,\n} from \"@remotion/transitions\";\nimport type React from \"react\";\nimport { AbsoluteFill } from \"remotion\";\n\nexport type ZoomBlurProps = {\n blur?: number;\n rise?: number;\n};\n\nconst ZoomBlurPresentation: React.FC<\n TransitionPresentationComponentProps<ZoomBlurProps>\n> = ({\n children,\n presentationProgress,\n presentationDirection,\n passedProps,\n}) => {\n const { blur = 16, rise = 0 } = passedProps;\n const entering = presentationDirection === \"entering\";\n const p = presentationProgress;\n\n const style: React.CSSProperties = entering\n ? {\n opacity: p,\n transform: `scale(${0.9 + p * 0.1})${\n rise > 0 ? ` translateY(${(1 - p) * rise}px)` : \"\"\n }`,\n filter: p < 1 ? `blur(${(1 - p) * blur}px)` : undefined,\n }\n : {\n opacity: 1 - p,\n transform: `scale(${1 + p * 0.12})${\n rise > 0 ? ` translateY(${-p * rise}px)` : \"\"\n }`,\n filter: p > 0 ? `blur(${p * blur}px)` : undefined,\n };\n\n return <AbsoluteFill style={style}>{children}</AbsoluteFill>;\n};\n\nexport function zoomBlur(\n props: ZoomBlurProps = {},\n): TransitionPresentation<ZoomBlurProps> {\n return {\n component: ZoomBlurPresentation,\n props,\n };\n}\n",
+ "type": "registry:component",
+ "target": "components/remocn/zoom-blur.tsx"
+ }
+ ],
+ "type": "registry:component"
+}
diff --git a/registry/remocn/icons-core/__tests__/icons-core.test.ts b/registry/remocn/icons-core/__tests__/icons-core.test.ts
new file mode 100644
index 00000000..92974d84
--- /dev/null
+++ b/registry/remocn/icons-core/__tests__/icons-core.test.ts
@@ -0,0 +1,167 @@
+import { describe, expect, it } from "bun:test";
+
+import {
+ drawnPathProps,
+ iconTimeline,
+ staggeredProgress,
+} from "../index";
+
+const FPS = 30;
+const props = (over: Partial<Parameters<typeof iconTimeline>[2]> = {}) => over;
+const timings = (over: Partial<Parameters<typeof iconTimeline>[3]> = {}) => ({
+ drawDurationInFrames: 14,
+ actionDelayInFrames: 2,
+ actionDurationInFrames: 20,
+ ...over,
+});
+
+describe("iconTimeline draw phase", () => {
+ it("starts at 0 draw and reaches 1 by the draw duration", () => {
+ expect(iconTimeline(0, FPS, props(), timings()).drawProgress).toBe(0);
+ expect(
+ iconTimeline(14, FPS, props(), timings()).drawProgress,
+ ).toBeCloseTo(1, 6);
+ });
+
+ it("clamps drawProgress to 1 past the draw window", () => {
+ expect(iconTimeline(40, FPS, props(), timings()).drawProgress).toBe(1);
+ });
+
+ it("never goes negative before frame 0", () => {
+ expect(iconTimeline(-5, FPS, props(), timings()).drawProgress).toBe(0);
+ });
+});
+
+describe("iconTimeline animation modes", () => {
+ it('action mode: drawProgress is 1 at frame 0 and action starts immediately', () => {
+ const t = iconTimeline(0, FPS, props({ animation: "action" }), timings());
+ expect(t.drawProgress).toBe(1);
+ expect(t.actionFrame).toBe(0);
+ expect(t.actionProgress).toBe(0);
+ });
+
+ it("draw mode: action never progresses", () => {
+ const late = iconTimeline(100, FPS, props({ animation: "draw" }), timings());
+ expect(late.drawProgress).toBe(1);
+ expect(late.actionProgress).toBe(0);
+ expect(late.cycleIndex).toBe(0);
+ });
+
+ it("both mode: action is gated behind draw + delay", () => {
+ const before = iconTimeline(15, FPS, props({ animation: "both" }), timings());
+ expect(before.actionFrame).toBeLessThan(0);
+ expect(before.actionProgress).toBe(0);
+
+ const atStart = iconTimeline(16, FPS, props({ animation: "both" }), timings());
+ expect(atStart.actionFrame).toBe(0);
+ expect(atStart.actionProgress).toBe(0);
+ });
+});
+
+describe("iconTimeline non-loop action", () => {
+ it("progresses linearly then freezes at 1", () => {
+ const half = iconTimeline(16 + 10, FPS, props(), timings());
+ expect(half.actionProgress).toBeCloseTo(0.5, 6);
+ const done = iconTimeline(16 + 20, FPS, props(), timings());
+ expect(done.actionProgress).toBe(1);
+ const past = iconTimeline(16 + 60, FPS, props(), timings());
+ expect(past.actionProgress).toBe(1);
+ expect(past.cycleIndex).toBe(0);
+ });
+});
+
+describe("iconTimeline loop action", () => {
+ it("wraps actionProgress and increments cycleIndex", () => {
+ const opts = props({ loop: true });
+ const start = iconTimeline(16, FPS, opts, timings());
+ expect(start.cycleIndex).toBe(0);
+ expect(start.actionProgress).toBe(0);
+
+ const mid = iconTimeline(16 + 10, FPS, opts, timings());
+ expect(mid.cycleIndex).toBe(0);
+ expect(mid.actionProgress).toBeCloseTo(0.5, 6);
+
+ const wrap = iconTimeline(16 + 20, FPS, opts, timings());
+ expect(wrap.cycleIndex).toBe(1);
+ expect(wrap.actionProgress).toBe(0);
+ expect(wrap.actionFrame).toBe(0);
+
+ const secondMid = iconTimeline(16 + 30, FPS, opts, timings());
+ expect(secondMid.cycleIndex).toBe(1);
+ expect(secondMid.actionProgress).toBeCloseTo(0.5, 6);
+ });
+
+ it("timings.loop is overridden by the prop", () => {
+ const t = iconTimeline(16 + 25, FPS, props({ loop: false }), timings({ loop: true }));
+ expect(t.cycleIndex).toBe(0);
+ expect(t.actionProgress).toBe(1);
+ });
+});
+
+describe("iconTimeline defaults and guards", () => {
+ it("applies the documented defaults when timings are empty", () => {
+ const t = iconTimeline(14, FPS, props(), {});
+ expect(t.drawProgress).toBeCloseTo(1, 6);
+ });
+
+ it("treats a zero action duration as instantly complete", () => {
+ const t = iconTimeline(20, FPS, props(), timings({ actionDurationInFrames: 0 }));
+ expect(t.actionProgress).toBe(1);
+ });
+
+ it("scaleIn stays within 0..1", () => {
+ for (const f of [-2, 0, 7, 14, 40]) {
+ const s = iconTimeline(f, FPS, props(), timings()).scaleIn;
+ expect(s).toBeGreaterThanOrEqual(0);
+ expect(s).toBeLessThanOrEqual(1);
+ }
+ });
+});
+
+describe("staggeredProgress", () => {
+ it("returns the raw progress for a single stroke", () => {
+ expect(staggeredProgress(0.4, 0, 1)).toBeCloseTo(0.4, 6);
+ expect(staggeredProgress(1.5, 0, 1)).toBe(1);
+ });
+
+ it("tiles windows with no overlap", () => {
+ expect(staggeredProgress(0.25, 0, 2, 0)).toBeCloseTo(0.5, 6);
+ expect(staggeredProgress(0.25, 1, 2, 0)).toBe(0);
+ expect(staggeredProgress(0.75, 1, 2, 0)).toBeCloseTo(0.5, 6);
+ });
+
+ it("makes all strokes simultaneous at full overlap", () => {
+ expect(staggeredProgress(0.3, 0, 3, 1)).toBeCloseTo(0.3, 6);
+ expect(staggeredProgress(0.3, 2, 3, 1)).toBeCloseTo(0.3, 6);
+ });
+
+ it("staggers earlier strokes ahead of later ones", () => {
+ const first = staggeredProgress(0.5, 0, 3, 0.5);
+ const last = staggeredProgress(0.5, 2, 3, 0.5);
+ expect(first).toBeGreaterThan(last);
+ });
+
+ it("clamps every window to 0..1", () => {
+ for (let i = 0; i < 4; i++) {
+ const v = staggeredProgress(0.6, i, 4, 0.5);
+ expect(v).toBeGreaterThanOrEqual(0);
+ expect(v).toBeLessThanOrEqual(1);
+ }
+ });
+});
+
+describe("drawnPathProps", () => {
+ const d = "M0 0 L10 0 L10 10";
+
+ it("has a fully hidden stroke at progress 0 and a closed offset at 1", () => {
+ const hidden = drawnPathProps(d, 0);
+ expect(hidden.strokeDasharray.length).toBeGreaterThan(0);
+ const shown = drawnPathProps(d, 1);
+ expect(shown.strokeDashoffset).toBeCloseTo(0, 6);
+ });
+
+ it("clamps out-of-range progress", () => {
+ expect(drawnPathProps(d, 2).strokeDashoffset).toBeCloseTo(0, 6);
+ expect(() => drawnPathProps(d, -1)).not.toThrow();
+ });
+});
diff --git a/registry/remocn/icons-core/index.ts b/registry/remocn/icons-core/index.ts
new file mode 100644
index 00000000..db0a8a31
--- /dev/null
+++ b/registry/remocn/icons-core/index.ts
@@ -0,0 +1,136 @@
+import { evolvePath } from "@remotion/paths";
+import { spring, useCurrentFrame, useVideoConfig } from "remotion";
+
+export interface IconAnimationProps {
+ animation?: "draw" | "action" | "both";
+ loop?: boolean;
+ speed?: number;
+ size?: number;
+ color?: string;
+ strokeWidth?: number;
+ className?: string;
+}
+
+export interface IconTimings {
+ drawDurationInFrames?: number;
+ actionDelayInFrames?: number;
+ actionDurationInFrames?: number;
+ loop?: boolean;
+}
+
+export interface IconTimeline {
+ drawProgress: number;
+ scaleIn: number;
+ actionFrame: number;
+ actionProgress: number;
+ cycleIndex: number;
+}
+
+function clamp01(t: number): number {
+ return t < 0 ? 0 : t > 1 ? 1 : t;
+}
+
+function easeOut(t: number): number {
+ return 1 - (1 - t) ** 3;
+}
+
+export function iconTimeline(
+ frame: number,
+ fps: number,
+ props: IconAnimationProps,
+ timings: IconTimings,
+): IconTimeline {
+ const animation = props.animation ?? "both";
+ const loop = props.loop ?? timings.loop ?? false;
+ const drawDuration = timings.drawDurationInFrames ?? 14;
+ const actionDelay = timings.actionDelayInFrames ?? 2;
+ const actionDuration = timings.actionDurationInFrames ?? 20;
+
+ const drawProgress =
+ animation === "action"
+ ? 1
+ : easeOut(clamp01(drawDuration > 0 ? frame / drawDuration : 1));
+
+ const scaleIn = clamp01(
+ spring({
+ frame,
+ fps,
+ config: { damping: 18, stiffness: 220, mass: 0.7 },
+ durationInFrames: Math.max(1, drawDuration),
+ }),
+ );
+
+ const actionStart =
+ animation === "action" ? 0 : drawDuration + actionDelay;
+ const sinceStart = frame - actionStart;
+
+ if (animation === "draw" || sinceStart < 0) {
+ return {
+ drawProgress,
+ scaleIn,
+ actionFrame: sinceStart,
+ actionProgress: 0,
+ cycleIndex: 0,
+ };
+ }
+
+ if (actionDuration <= 0) {
+ return {
+ drawProgress,
+ scaleIn,
+ actionFrame: sinceStart,
+ actionProgress: 1,
+ cycleIndex: 0,
+ };
+ }
+
+ if (loop) {
+ const cycleIndex = Math.floor(sinceStart / actionDuration);
+ const local = sinceStart - cycleIndex * actionDuration;
+ return {
+ drawProgress,
+ scaleIn,
+ actionFrame: local,
+ actionProgress: local / actionDuration,
+ cycleIndex,
+ };
+ }
+
+ return {
+ drawProgress,
+ scaleIn,
+ actionFrame: sinceStart,
+ actionProgress: clamp01(sinceStart / actionDuration),
+ cycleIndex: 0,
+ };
+}
+
+export function useIconAnimation(
+ props: IconAnimationProps,
+ timings: IconTimings,
+): IconTimeline {
+ const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+ const speed = props.speed ?? 1;
+ return iconTimeline(frame * speed, fps, props, timings);
+}
+
+export function staggeredProgress(
+ progress: number,
+ index: number,
+ count: number,
+ overlap = 0.5,
+): number {
+ if (count <= 1) return clamp01(progress);
+ const o = clamp01(overlap);
+ const width = 1 / (count - (count - 1) * o);
+ const start = index * width * (1 - o);
+ return clamp01((progress - start) / width);
+}
+
+export function drawnPathProps(
+ d: string,
+ progress: number,
+): { strokeDasharray: string; strokeDashoffset: number } {
+ return evolvePath(clamp01(progress), d);
+}
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index d0bebc54..fedf1129 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -3,6 +3,20 @@
"name": "remocn",
"homepage": "https://remocn.dev",
"items": [
+ {
+ "name": "icons-core",
+ "type": "registry:lib",
+ "title": "Icons Core",
+ "description": "Shared animation contract, pure frame-to-phase timeline, and SVG path-draw helpers for remocn icons.",
+ "dependencies": ["remotion", "@remotion/paths"],
+ "files": [
+ {
+ "path": "icons-core/index.ts",
+ "type": "registry:lib",
+ "target": "lib/remocn-icons/index.ts"
+ }
+ ]
+ },
{
"name": "soft-blur-in",
"type": "registry:component",
diff --git a/tsconfig.json b/tsconfig.json
index 07009988..f96f3252 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -20,6 +20,7 @@
}
],
"paths": {
+ "@/lib/remocn-icons": ["./registry/remocn/icons-core/index.ts"],
"@/lib/remocn-ui": ["./registry/remocn-ui/core/index.ts"],
"@/lib/remocn-ui/*": ["./registry/remocn-ui/core/*"],
"@/components/remocn/use-cursor-path": [