Skip to content

🎥 Make videos programmatically with React

`@remotion/mac-cursors`: Default cursor after reset (#10423)

Jonny Burgerd4ed2619ba83
diff --git a/packages/mac-cursors/src/MacOSCursor.tsx b/packages/mac-cursors/src/MacOSCursor.tsx
index 559123d191..cf7e449d11 100644
--- a/packages/mac-cursors/src/MacOSCursor.tsx
+++ b/packages/mac-cursors/src/MacOSCursor.tsx
@@ -9,7 +9,7 @@ import {Interactive, Sequence} from 'remotion';
import {macOSCursorNames, resolveCursor} from './resolve-cursor';
export type MacOSCursorProps = InteractiveBaseProps & {
- readonly cursor: string;
+ readonly cursor?: string;
readonly customCursor?: string;
readonly className?: string;
readonly style?: CSSProperties;
@@ -43,7 +43,7 @@ export const macOSCursorSchema = {
const MacOSCursorInner: React.FC<
MacOSCursorProps & {readonly controls: SequenceControls | undefined}
> = ({
- cursor,
+ cursor = 'default',
customCursor,
className,
style,
diff --git a/packages/mac-cursors/src/test/resolve-cursor.test.ts b/packages/mac-cursors/src/test/resolve-cursor.test.ts
index 59c2092406..80a58fdc01 100644
--- a/packages/mac-cursors/src/test/resolve-cursor.test.ts
+++ b/packages/mac-cursors/src/test/resolve-cursor.test.ts
@@ -1,5 +1,8 @@
import {expect, test} from 'bun:test';
-import {macOSCursorSchema} from '../MacOSCursor';
+import React from 'react';
+import {renderToString} from 'react-dom/server';
+import {Internals} from 'remotion';
+import {MacOSCursor, macOSCursorSchema} from '../MacOSCursor';
import {resolveCursor} from '../resolve-cursor';
test('resolves named, custom, hidden, and unknown cursors', () => {
@@ -58,3 +61,65 @@ test('cursor schema exposes named cursors as a keyframable enum', () => {
expect(macOSCursorSchema['style.scale'].type).toBe('scale');
expect(macOSCursorSchema['style.rotate'].type).toBe('rotation-css');
});
+
+test('<MacOSCursor> renders the default cursor when the cursor prop is omitted', () => {
+ const compositionMetadata = {
+ defaultCodec: null,
+ defaultOutName: null,
+ defaultPixelFormat: null,
+ defaultProResProfile: null,
+ defaultSampleRate: null,
+ defaultVideoImageFormat: null,
+ durationInFrames: 100,
+ fps: 30,
+ height: 1080,
+ width: 1920,
+ props: {},
+ };
+ const compositionManager = {
+ compositions: [
+ {
+ id: 'comp',
+ durationInFrames: 100,
+ component: () => null,
+ defaultProps: {},
+ folderName: null,
+ fps: 30,
+ height: 1080,
+ width: 1920,
+ parentFolderName: null,
+ nonce: [[0, 0]],
+ calculateMetadata: null,
+ schema: null,
+ stack: null,
+ },
+ ],
+ folders: [],
+ canvasContent: {type: 'composition' as const, compositionId: 'comp'},
+ currentCompositionMetadata: compositionMetadata,
+ } as React.ContextType<typeof Internals.CompositionManager>;
+ const timeline = {
+ frame: {comp: 0},
+ playing: false,
+ imperativePlaying: {current: false},
+ audioAndVideoTags: {current: []},
+ } as React.ContextType<typeof Internals.TimelineContext>;
+ const markup = renderToString(
+ React.createElement(
+ Internals.CanUseRemotionHooks.Provider,
+ {value: true},
+ React.createElement(
+ Internals.CompositionManager.Provider,
+ {value: compositionManager},
+ React.createElement(
+ Internals.TimelineContext.Provider,
+ {value: timeline},
+ React.createElement(MacOSCursor),
+ ),
+ ),
+ ),
+ );
+
+ expect(markup).toContain('width:32px');
+ expect(markup).toContain('height:32px');
+});