Skip to content

🎥 Make videos programmatically with React

@remotion/shapes: Add interactive Explorer demo for Arrow shape

copilot-swe-agent[bot]a98621d65f0e
diff --git a/packages/docs/components/demos/Arrow.tsx b/packages/docs/components/demos/Arrow.tsx
new file mode 100644
index 0000000000..38aaedcd6c
--- /dev/null
+++ b/packages/docs/components/demos/Arrow.tsx
@@ -0,0 +1,47 @@
+import type {ArrowProps} from '@remotion/shapes';
+import {Arrow} from '@remotion/shapes';
+import React from 'react';
+import {AbsoluteFill} from 'remotion';
+
+export const ArrowDemo: React.FC<{
+ readonly length: number;
+ readonly headWidth: number;
+ readonly headLength: number;
+ readonly shaftWidth: number;
+ readonly edgeRoundness: number;
+ readonly darkMode: boolean;
+ readonly direction: ArrowProps['direction'];
+ readonly cornerRadius: number;
+}> = ({
+ length,
+ headWidth,
+ headLength,
+ shaftWidth,
+ edgeRoundness,
+ direction,
+ cornerRadius,
+ darkMode,
+}) => {
+ const safeShaftWidth = Math.min(shaftWidth, headWidth);
+ const safeHeadLength = Math.min(headLength, length);
+
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}
+ >
+ <Arrow
+ fill={darkMode ? 'white' : 'var(--ifm-link-color)'}
+ length={length}
+ headWidth={headWidth}
+ headLength={safeHeadLength}
+ shaftWidth={safeShaftWidth}
+ edgeRoundness={edgeRoundness}
+ direction={direction}
+ cornerRadius={cornerRadius}
+ />
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/docs/components/demos/index.tsx b/packages/docs/components/demos/index.tsx
index d9f2a56065..b013a83328 100644
--- a/packages/docs/components/demos/index.tsx
+++ b/packages/docs/components/demos/index.tsx
@@ -6,6 +6,7 @@ import {Control} from './control';
import type {DemoType} from './types';
import {
animationMathDemo,
+ arrowDemo,
circleDemo,
clockWipePresentationDemo,
cubePresentationDemo,
@@ -52,6 +53,7 @@ const container: React.CSSProperties = {
const demos: DemoType[] = [
noiseDemo,
+ arrowDemo,
triangleDemo,
rectDemo,
circleDemo,
diff --git a/packages/docs/components/demos/types.ts b/packages/docs/components/demos/types.ts
index b64b2df69c..92185d2da7 100644
--- a/packages/docs/components/demos/types.ts
+++ b/packages/docs/components/demos/types.ts
@@ -11,6 +11,7 @@ import {
SlideDemoLongDurationRest,
WipeDemo,
} from '../transitions/previews';
+import {ArrowDemo} from './Arrow';
import {CircleDemo} from './Circle';
import {EllipseDemo} from './Ellipse';
import {HeartDemo} from './Heart';
@@ -75,6 +76,80 @@ export type DemoType = {
controls: boolean;
};
+export const arrowDemo: DemoType = {
+ comp: ArrowDemo,
+ compWidth: 1280,
+ compHeight: 400,
+ durationInFrames: 150,
+ fps: 30,
+ id: 'arrow',
+ autoPlay: false,
+ controls: false,
+ options: [
+ {
+ default: 300,
+ max: 1000,
+ step: 5,
+ min: 1,
+ type: 'numeric',
+ name: 'length',
+ optional: 'no',
+ },
+ {
+ default: 120,
+ max: 400,
+ step: 5,
+ min: 1,
+ type: 'numeric',
+ name: 'headWidth',
+ optional: 'no',
+ },
+ {
+ default: 120,
+ max: 400,
+ step: 5,
+ min: 1,
+ type: 'numeric',
+ name: 'headLength',
+ optional: 'no',
+ },
+ {
+ default: 60,
+ max: 400,
+ step: 5,
+ min: 1,
+ type: 'numeric',
+ name: 'shaftWidth',
+ optional: 'no',
+ },
+ {
+ name: 'direction',
+ type: 'enum',
+ default: 'right',
+ values: ['up', 'down', 'left', 'right'],
+ optional: 'no',
+ },
+ {
+ name: 'cornerRadius',
+ default: 0,
+ max: 100,
+ min: 0,
+ step: 1,
+ type: 'numeric',
+ optional: 'no',
+ },
+ {
+ name: 'edgeRoundness',
+ default: 1,
+ max: 2,
+ min: -2,
+ step: 0.01,
+ type: 'numeric',
+ optional: 'default-disabled',
+ },
+ ],
+};
+
export const rectDemo: DemoType = {
comp: RectDemo,
compWidth: 1280,
diff --git a/packages/docs/docs/shapes/arrow.mdx b/packages/docs/docs/shapes/arrow.mdx
index 394102b786..303bb6f801 100644
--- a/packages/docs/docs/shapes/arrow.mdx
+++ b/packages/docs/docs/shapes/arrow.mdx
@@ -9,6 +9,10 @@ _Part of the [` @remotion/shapes`](/docs/shapes) package._
Renders an SVG element containing an arrow shape.
+## Explorer
+
+<Demo type="arrow" />
+
## Example
```tsx twoslash title="src/Arrow.tsx"