Skip to content

🎥 Make videos programmatically with React

`remotion`: Add border radius controls (#9728)

Jonny Burger86d87ce01ed3
diff --git a/packages/brand/src/3DContext/Div3D.tsx b/packages/brand/src/3DContext/Div3D.tsx
index b57f030f66..f9dddb9e06 100644
--- a/packages/brand/src/3DContext/Div3D.tsx
+++ b/packages/brand/src/3DContext/Div3D.tsx
@@ -131,6 +131,7 @@ const extrudeDivSchema = {
...Interactive.transformSchema,
...Interactive.backgroundSchema,
...Interactive.borderSchema,
+ ...Interactive.borderRadiusSchema,
} as const satisfies InteractivitySchema;
const setRef = <ElementType,>(
diff --git a/packages/brand/src/Compose/WhatIsRemotion.tsx b/packages/brand/src/Compose/WhatIsRemotion.tsx
index 2f6520208c..5dc1701371 100644
--- a/packages/brand/src/Compose/WhatIsRemotion.tsx
+++ b/packages/brand/src/Compose/WhatIsRemotion.tsx
@@ -45,6 +45,7 @@ const labelSchema = {
...Interactive.textSchema,
...Interactive.backgroundSchema,
...Interactive.borderSchema,
+ ...Interactive.borderRadiusSchema,
children: {
type: 'text-content',
default: '',
diff --git a/packages/core/src/HtmlInCanvas.tsx b/packages/core/src/HtmlInCanvas.tsx
index e1cdc59965..0c9a50f64f 100644
--- a/packages/core/src/HtmlInCanvas.tsx
+++ b/packages/core/src/HtmlInCanvas.tsx
@@ -23,6 +23,7 @@ import type {
import {
backgroundSchema,
baseSchema,
+ borderRadiusSchema,
borderSchema,
cropSchema,
transformSchema,
@@ -832,6 +833,7 @@ export const htmlInCanvasSchema = {
...transformSchema,
...backgroundSchema,
...borderSchema,
+ ...borderRadiusSchema,
...cropSchema,
} as const satisfies InteractivitySchema;
diff --git a/packages/core/src/Img.tsx b/packages/core/src/Img.tsx
index 697cf12cee..d23d1da098 100644
--- a/packages/core/src/Img.tsx
+++ b/packages/core/src/Img.tsx
@@ -25,6 +25,7 @@ import type {
import {
backgroundSchema,
baseSchema,
+ borderRadiusSchema,
borderSchema,
cropSchema,
premountSchema,
@@ -460,6 +461,7 @@ export const imgSchema = {
...transformSchema,
...backgroundSchema,
...borderSchema,
+ ...borderRadiusSchema,
} as const satisfies InteractivitySchema;
const imgCanvasFallbackIncompatibleProps = new Set([
diff --git a/packages/core/src/Interactive.tsx b/packages/core/src/Interactive.tsx
index 39077394d8..f787e358ba 100644
--- a/packages/core/src/Interactive.tsx
+++ b/packages/core/src/Interactive.tsx
@@ -7,6 +7,7 @@ import {addSequenceStackTraces} from './enable-sequence-stack-traces.js';
import {
backgroundSchema,
baseSchema,
+ borderRadiusSchema,
captionsSchema,
borderSchema,
cropSchema,
@@ -160,6 +161,7 @@ const interactiveBackgroundElementSchema = {
const interactiveBorderElementSchema = {
...interactiveBackgroundElementSchema,
...borderSchema,
+ ...borderRadiusSchema,
} as const satisfies InteractivitySchema;
const interactiveTextElementSchema = {
@@ -323,6 +325,7 @@ export const Interactive = {
textSchema,
backgroundSchema,
borderSchema,
+ borderRadiusSchema,
cropSchema,
svgPaintSchema,
svgStrokeSchema,
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsx
index f160d78b86..70fe2516b9 100644
--- a/packages/core/src/Sequence.tsx
+++ b/packages/core/src/Sequence.tsx
@@ -546,7 +546,7 @@ const RegularSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
right: resolvedCropRight,
top: resolvedCropTop,
bottom: resolvedCropBottom,
- borderRadius: styleIfThere?.borderRadius,
+ style: styleIfThere,
});
const sequenceRef = useCallback(
diff --git a/packages/core/src/animated-image/AnimatedImage.tsx b/packages/core/src/animated-image/AnimatedImage.tsx
index 6846165f0c..e8793f4f3d 100644
--- a/packages/core/src/animated-image/AnimatedImage.tsx
+++ b/packages/core/src/animated-image/AnimatedImage.tsx
@@ -19,6 +19,7 @@ import {Freeze} from '../freeze.js';
import {
backgroundSchema,
baseSchema,
+ borderRadiusSchema,
borderSchema,
cropSchema,
premountSchema,
@@ -68,6 +69,7 @@ export const animatedImageSchema = {
...transformSchema,
...backgroundSchema,
...borderSchema,
+ ...borderRadiusSchema,
} as const satisfies InteractivitySchema;
const getCanvasPropsFromSequenceProps = (
diff --git a/packages/core/src/canvas-image/CanvasImage.tsx b/packages/core/src/canvas-image/CanvasImage.tsx
index 11a4e34f8f..f87fe728ab 100644
--- a/packages/core/src/canvas-image/CanvasImage.tsx
+++ b/packages/core/src/canvas-image/CanvasImage.tsx
@@ -23,6 +23,7 @@ import {Freeze} from '../freeze.js';
import {
backgroundSchema,
baseSchema,
+ borderRadiusSchema,
borderSchema,
cropSchema,
premountSchema,
@@ -57,6 +58,7 @@ export const canvasImageSchema = {
...transformSchema,
...backgroundSchema,
...borderSchema,
+ ...borderRadiusSchema,
} as const satisfies InteractivitySchema;
type LoadedImage = {
diff --git a/packages/core/src/effects/Solid.tsx b/packages/core/src/effects/Solid.tsx
index ec38bfa0da..22686cc6f8 100644
--- a/packages/core/src/effects/Solid.tsx
+++ b/packages/core/src/effects/Solid.tsx
@@ -16,6 +16,7 @@ import type {
import {
backgroundSchema,
baseSchema,
+ borderRadiusSchema,
borderSchema,
cropSchema,
transformSchema,
@@ -107,6 +108,7 @@ export const solidSchema = {
...transformSchema,
...backgroundSchema,
...borderSchema,
+ ...borderRadiusSchema,
...cropSchema,
} as const satisfies InteractivitySchema;
diff --git a/packages/core/src/interactivity-schema.ts b/packages/core/src/interactivity-schema.ts
index 7ba380fd43..191a1f7a4e 100644
--- a/packages/core/src/interactivity-schema.ts
+++ b/packages/core/src/interactivity-schema.ts
@@ -384,6 +384,50 @@ export const borderSchema = {
},
} as const satisfies InteractivitySchema;
+export const borderRadiusSchema = {
+ 'style.borderRadius': {
+ type: 'number',
+ default: 0,
+ min: 0,
+ step: 1,
+ description: 'Border radius',
+ hiddenFromList: false,
+ keyframable: true,
+ },
+ 'style.borderTopLeftRadius': {
+ type: 'number',
+ default: 0,
+ min: 0,
+ step: 1,
+ description: 'Top left radius',
+ hiddenFromList: false,
+ },
+ 'style.borderTopRightRadius': {
+ type: 'number',
+ default: 0,
+ min: 0,
+ step: 1,
+ description: 'Top right radius',
+ hiddenFromList: false,
+ },
+ 'style.borderBottomRightRadius': {
+ type: 'number',
+ default: 0,
+ min: 0,
+ step: 1,
+ description: 'Bottom right radius',
+ hiddenFromList: false,
+ },
+ 'style.borderBottomLeftRadius': {
+ type: 'number',
+ default: 0,
+ min: 0,
+ step: 1,
+ description: 'Bottom left radius',
+ hiddenFromList: false,
+ },
+} as const satisfies InteractivitySchema;
+
export const backgroundSchema = {
'style.backgroundColor': {
type: 'color',
@@ -503,6 +547,7 @@ export const sequenceStyleSchema = {
...transformSchema,
...backgroundSchema,
...borderSchema,
+ ...borderRadiusSchema,
...sequencePremountSchema,
} as const satisfies InteractivitySchema;
diff --git a/packages/core/src/sequence-crop.ts b/packages/core/src/sequence-crop.ts
index 6d85d07f7c..e2a3284010 100644
--- a/packages/core/src/sequence-crop.ts
+++ b/packages/core/src/sequence-crop.ts
@@ -1,3 +1,5 @@
+import type {CSSProperties} from 'react';
+
export type ResolvedSequenceCrop = {
readonly left: number;
readonly right: number;
@@ -5,8 +7,8 @@ export type ResolvedSequenceCrop = {
readonly bottom: number;
};
-type ResolvedSequenceCropWithBorderRadius = ResolvedSequenceCrop & {
- readonly borderRadius?: string | number;
+type ResolvedSequenceCropWithStyle = ResolvedSequenceCrop & {
+ readonly style: CSSProperties | null | undefined;
};
export type SequenceCropInput = {
@@ -51,14 +53,26 @@ export const getSequenceCropClipPath = ({
right,
top,
bottom,
- borderRadius,
-}: ResolvedSequenceCropWithBorderRadius): string | null => {
+ style,
+}: ResolvedSequenceCropWithStyle): string | null => {
if (left === 0 && right === 0 && top === 0 && bottom === 0) {
return null;
}
+ const serializeRadius = (radius: string | number | undefined) =>
+ typeof radius === 'number' ? `${radius}px` : radius;
+ const shorthand = serializeRadius(style?.borderRadius);
+ const longhands = [
+ style?.borderTopLeftRadius,
+ style?.borderTopRightRadius,
+ style?.borderBottomRightRadius,
+ style?.borderBottomLeftRadius,
+ ];
const serializedBorderRadius =
- typeof borderRadius === 'number' ? `${borderRadius}px` : borderRadius;
+ shorthand ||
+ (longhands.some((radius) => radius !== undefined)
+ ? longhands.map((radius) => serializeRadius(radius) ?? '0px').join(' ')
+ : undefined);
const rounded = serializedBorderRadius
? ` round ${serializedBorderRadius}`
: '';
diff --git a/packages/core/src/test/find-props-to-delete.test.ts b/packages/core/src/test/find-props-to-delete.test.ts
index 8a30ae791f..f1cd38caa3 100644
--- a/packages/core/src/test/find-props-to-delete.test.ts
+++ b/packages/core/src/test/find-props-to-delete.test.ts
@@ -47,6 +47,11 @@ test('find right values to delete when upgrading a discriminated union', () => {
'style.borderWidth',
'style.borderStyle',
'style.borderColor',
+ 'style.borderRadius',
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
'premountFor',
'postmountFor',
]);
diff --git a/packages/core/src/test/sequence-crop.test.tsx b/packages/core/src/test/sequence-crop.test.tsx
index fe9cbd9dca..04f20859b1 100644
--- a/packages/core/src/test/sequence-crop.test.tsx
+++ b/packages/core/src/test/sequence-crop.test.tsx
@@ -47,6 +47,29 @@ test('preserves a string border radius on the cropped rectangle', () => {
expect(sequence.style.clipPath).toBe('inset(20% 0% 0% 0% round 20% / 10%)');
});
+test('preserves individual border radii on the cropped rectangle', () => {
+ const {container} = render(
+ <WrapSequenceContext>
+ <Sequence
+ cropRight={0.2}
+ style={{
+ borderTopLeftRadius: 8,
+ borderTopRightRadius: 16,
+ borderBottomRightRadius: 24,
+ borderBottomLeftRadius: 32,
+ }}
+ >
+ Content
+ </Sequence>
+ </WrapSequenceContext>,
+ );
+
+ const sequence = container.firstElementChild as HTMLDivElement;
+ expect(sequence.style.clipPath).toBe(
+ 'inset(0% 20% 0% 0% round 8px 16px 24px 32px)',
+ );
+});
+
test('does not override a custom clip path when no crop is applied', () => {
const {container} = render(
<WrapSequenceContext>
diff --git a/packages/core/src/test/use-crop-style.test.tsx b/packages/core/src/test/use-crop-style.test.tsx
index d6bd06a06b..9e4939ca6f 100644
--- a/packages/core/src/test/use-crop-style.test.tsx
+++ b/packages/core/src/test/use-crop-style.test.tsx
@@ -57,3 +57,22 @@ test('preserves the inline border radius on the cropped rectangle', () => {
clipPath: 'inset(0% 25% 0% 0% round 12px 24px)',
});
});
+
+test('preserves individual inline corner radii on the cropped rectangle', () => {
+ const {result} = renderHook(() =>
+ useCropStyle({
+ cropBottom: 0.25,
+ style: {
+ borderTopLeftRadius: 12,
+ borderBottomRightRadius: '25%',
+ },
+ componentName: '<Test />',
+ }),
+ );
+
+ expect(result.current).toEqual({
+ borderTopLeftRadius: 12,
+ borderBottomRightRadius: '25%',
+ clipPath: 'inset(0% 0% 25% 0% round 12px 0px 25% 0px)',
+ });
+});
diff --git a/packages/core/src/test/with-interactivity-schema-helpers.test.ts b/packages/core/src/test/with-interactivity-schema-helpers.test.ts
index 8839275298..7a3f0a3a76 100644
--- a/packages/core/src/test/with-interactivity-schema-helpers.test.ts
+++ b/packages/core/src/test/with-interactivity-schema-helpers.test.ts
@@ -14,6 +14,7 @@ import {Interactive} from '../Interactive.js';
import {
backgroundSchema,
baseSchema,
+ borderRadiusSchema,
borderSchema,
captionsSchema,
cropSchema,
@@ -44,6 +45,7 @@ test('sequenceStyleSchema contains visual style and premount fields', () => {
...Object.keys(transformSchema),
...Object.keys(backgroundSchema),
...Object.keys(borderSchema),
+ ...Object.keys(borderRadiusSchema),
...Object.keys(sequencePremountSchema),
].sort(),
);
@@ -62,6 +64,11 @@ test('CSS box component schemas expose background and border controls', () => {
expect('style.borderWidth' in schema).toBe(true);
expect('style.borderStyle' in schema).toBe(true);
expect('style.borderColor' in schema).toBe(true);
+ expect('style.borderRadius' in schema).toBe(true);
+ expect('style.borderTopLeftRadius' in schema).toBe(true);
+ expect('style.borderTopRightRadius' in schema).toBe(true);
+ expect('style.borderBottomRightRadius' in schema).toBe(true);
+ expect('style.borderBottomLeftRadius' in schema).toBe(true);
}
});
@@ -206,6 +213,11 @@ test('getFlatSchema(sequenceSchema) exposes every variant key', () => {
'style.borderWidth',
'style.borderStyle',
'style.borderColor',
+ 'style.borderRadius',
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
'premountFor',
'postmountFor',
'durationInFrames',
@@ -378,10 +390,11 @@ test('textSchema exposes common text style fields', () => {
});
});
-test('borderSchema exposes the longhand border style fields', () => {
+test('borderSchema exposes the longhand border fields', () => {
expect(Object.keys(borderSchema).sort()).toEqual(
['style.borderColor', 'style.borderStyle', 'style.borderWidth'].sort(),
);
+
expect(borderSchema['style.borderWidth']).toMatchObject({
type: 'number',
default: undefined,
@@ -411,6 +424,36 @@ test('borderSchema exposes the longhand border style fields', () => {
});
});
+test('borderRadiusSchema exposes the shorthand and four corner radius fields', () => {
+ expect(Interactive.borderRadiusSchema).toBe(borderRadiusSchema);
+ expect(Object.keys(borderRadiusSchema).sort()).toEqual(
+ [
+ 'style.borderRadius',
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
+ ].sort(),
+ );
+ for (const radius of [
+ 'style.borderRadius',
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
+ ] as const) {
+ expect(borderRadiusSchema[radius]).toMatchObject({
+ type: 'number',
+ default: 0,
+ min: 0,
+ step: 1,
+ hiddenFromList: false,
+ });
+ }
+
+ expect(borderRadiusSchema['style.borderRadius'].keyframable).toBe(true);
+});
+
test('backgroundSchema exposes the background color style field', () => {
expect(Object.keys(backgroundSchema)).toEqual(['style.backgroundColor']);
expect(backgroundSchema['style.backgroundColor']).toMatchObject({
@@ -529,6 +572,11 @@ test('selectActiveKeys exposes style.* keys when layout=absolute-fill', () => {
'style.borderWidth',
'style.borderStyle',
'style.borderColor',
+ 'style.borderRadius',
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
'premountFor',
'postmountFor',
].sort(),
diff --git a/packages/core/src/use-crop-style.ts b/packages/core/src/use-crop-style.ts
index b1b768b00c..da8ba9e347 100644
--- a/packages/core/src/use-crop-style.ts
+++ b/packages/core/src/use-crop-style.ts
@@ -26,7 +26,7 @@ export const useCropStyle = ({
return useMemo(() => {
const cropClipPath = getSequenceCropClipPath({
...resolveSequenceCrop({cropLeft, cropRight, cropTop, cropBottom}),
- borderRadius: style?.borderRadius,
+ style,
});
if (cropClipPath === null) {
diff --git a/packages/docs/docs/interactive.mdx b/packages/docs/docs/interactive.mdx
index 793620c9b2..5bd65a979e 100644
--- a/packages/docs/docs/interactive.mdx
+++ b/packages/docs/docs/interactive.mdx
@@ -135,6 +135,16 @@ The longhand properties are used rather than the `border` shorthand, because Rea
Use it for components that accept a `style` prop and render a border.
+### `Interactive.borderRadiusSchema`<AvailableFrom v="4.0.501" />
+
+Controls for `style.borderRadius` and its four corner longhands: `style.borderTopLeftRadius`, `style.borderTopRightRadius`, `style.borderBottomRightRadius` and `style.borderBottomLeftRadius`.
+
+The Studio shows either the shorthand or the four longhands. Mixing `style.borderRadius` with a corner longhand is treated as computed and cannot be edited visually.
+
+When `style.borderRadius` is a number or contains one to four pixel values, the Studio expands it into the four longhand properties when you edit a corner. Complex values such as percentages and elliptical radii are not editable.
+
+Use it for components that accept a `style` prop and render rounded corners.
+
### `Interactive.svgPaintSchema`<AvailableFrom v="4.0.499" />
Controls for the SVG `fill`, `stroke` and `strokeWidth` props.
@@ -159,7 +169,7 @@ Use it for components that forward these props to a `<Sequence>`.
The schema used by [`<Sequence>`](/docs/sequence).
-It includes `Interactive.baseSchema` and a `layout` field. When `layout` is `"absolute-fill"`, the active fields include [`cropLeft`](/docs/sequence#cropleft), [`cropRight`](/docs/sequence#cropright), [`cropTop`](/docs/sequence#croptop), [`cropBottom`](/docs/sequence#cropbottom), `Interactive.transformSchema`, `Interactive.backgroundSchema`, `Interactive.borderSchema` and `Interactive.premountSchema`.
+It includes `Interactive.baseSchema` and a `layout` field. When `layout` is `"absolute-fill"`, the active fields include [`cropLeft`](/docs/sequence#cropleft), [`cropRight`](/docs/sequence#cropright), [`cropTop`](/docs/sequence#croptop), [`cropBottom`](/docs/sequence#cropbottom), `Interactive.transformSchema`, `Interactive.backgroundSchema`, `Interactive.borderSchema`, `Interactive.borderRadiusSchema` and `Interactive.premountSchema`.
### `Interactive.withSchema()`<AvailableFrom v="4.0.479" />
diff --git a/packages/docs/docs/interactivity-schema.mdx b/packages/docs/docs/interactivity-schema.mdx
index 42295da2b1..454ebc8200 100644
--- a/packages/docs/docs/interactivity-schema.mdx
+++ b/packages/docs/docs/interactivity-schema.mdx
@@ -73,6 +73,14 @@ Border-related style props: `style.borderWidth`, `style.borderStyle` and `style.
The longhand properties are used rather than the `border` shorthand, because React does not expand shorthands. This lets each control read its own value, and allows `style.borderWidth` and `style.borderColor` to be animated.
+### `Interactive.borderRadiusSchema`<AvailableFrom v="4.0.501" />
+
+Corner radius style props: `style.borderRadius`, `style.borderTopLeftRadius`, `style.borderTopRightRadius`, `style.borderBottomRightRadius` and `style.borderBottomLeftRadius`.
+
+The Studio shows either the shorthand or the four longhands. Mixing `style.borderRadius` with a corner longhand is treated as computed and cannot be edited visually.
+
+When `style.borderRadius` is a number or contains one to four pixel values, the Studio expands it into the four longhand properties when you edit a corner. Complex values such as percentages and elliptical radii are not editable.
+
### `Interactive.premountSchema`
Mounting props: `premountFor` and `postmountFor`.
diff --git a/packages/docs/docs/sequence.mdx b/packages/docs/docs/sequence.mdx
index 8d0f33c183..3969ef94e8 100644
--- a/packages/docs/docs/sequence.mdx
+++ b/packages/docs/docs/sequence.mdx
@@ -278,7 +278,7 @@ If `cropTop` and `cropBottom` overlap, both edges meet in the center.
All four crop props are only supported with `layout="absolute-fill"` and can be animated:
:::note
-If an inline [`style.borderRadius`](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius) is set, the cropped rectangle uses the same corner radius. A border radius applied through a CSS class is not inherited by the crop.
+If inline [`border-radius`](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius) styles are set using `style.borderRadius` or its four corner longhands, the cropped rectangle uses the same corner radii. Border radii applied through a CSS class are not inherited by the crop.
:::
```tsx twoslash title="MyVideo.tsx"
diff --git a/packages/gif/src/Gif.tsx b/packages/gif/src/Gif.tsx
index 8367e579f4..e360afb90e 100644
--- a/packages/gif/src/Gif.tsx
+++ b/packages/gif/src/Gif.tsx
@@ -47,6 +47,7 @@ export const gifSchema: InteractivitySchema = {
...Internals.transformSchema,
...Interactive.backgroundSchema,
...Interactive.borderSchema,
+ ...Interactive.borderRadiusSchema,
...Interactive.cropSchema,
} as const satisfies InteractivitySchema;
diff --git a/packages/light-leaks/src/LightLeak.tsx b/packages/light-leaks/src/LightLeak.tsx
index 8bc92c54aa..08f54b0039 100644
--- a/packages/light-leaks/src/LightLeak.tsx
+++ b/packages/light-leaks/src/LightLeak.tsx
@@ -254,6 +254,7 @@ export const lightLeakSchema: InteractivitySchema = {
...Internals.transformSchema,
...Interactive.backgroundSchema,
...Interactive.borderSchema,
+ ...Interactive.borderRadiusSchema,
...Internals.premountSchema,
} as const satisfies InteractivitySchema;
diff --git a/packages/media/src/test/border-schema.test.ts b/packages/media/src/test/border-schema.test.ts
index b4d23776ff..1492ef6ff3 100644
--- a/packages/media/src/test/border-schema.test.ts
+++ b/packages/media/src/test/border-schema.test.ts
@@ -7,6 +7,10 @@ test('Video exposes background and border controls', () => {
expect('style.borderWidth' in videoSchema).toBe(true);
expect('style.borderStyle' in videoSchema).toBe(true);
expect('style.borderColor' in videoSchema).toBe(true);
+ expect('style.borderTopLeftRadius' in videoSchema).toBe(true);
+ expect('style.borderTopRightRadius' in videoSchema).toBe(true);
+ expect('style.borderBottomRightRadius' in videoSchema).toBe(true);
+ expect('style.borderBottomLeftRadius' in videoSchema).toBe(true);
});
test('Video exposes crop controls', () => {
@@ -31,4 +35,8 @@ test('Audio does not expose visual background or border controls', () => {
expect('style.borderWidth' in audioSchema).toBe(false);
expect('style.borderStyle' in audioSchema).toBe(false);
expect('style.borderColor' in audioSchema).toBe(false);
+ expect('style.borderTopLeftRadius' in audioSchema).toBe(false);
+ expect('style.borderTopRightRadius' in audioSchema).toBe(false);
+ expect('style.borderBottomRightRadius' in audioSchema).toBe(false);
+ expect('style.borderBottomLeftRadius' in audioSchema).toBe(false);
});
diff --git a/packages/media/src/video/video.tsx b/packages/media/src/video/video.tsx
index 07bda80b31..073c50f5e0 100644
--- a/packages/media/src/video/video.tsx
+++ b/packages/media/src/video/video.tsx
@@ -54,6 +54,7 @@ export const videoSchema: InteractivitySchema = {
...Internals.transformSchema,
...Interactive.backgroundSchema,
...Interactive.borderSchema,
+ ...Interactive.borderRadiusSchema,
...Interactive.cropSchema,
} as const satisfies InteractivitySchema;
diff --git a/packages/rive/src/RemotionRiveCanvas.tsx b/packages/rive/src/RemotionRiveCanvas.tsx
index e23ae89e3d..40ccadaa6a 100644
--- a/packages/rive/src/RemotionRiveCanvas.tsx
+++ b/packages/rive/src/RemotionRiveCanvas.tsx
@@ -113,6 +113,7 @@ export const riveCanvasSchema: InteractivitySchema = {
...Internals.transformSchema,
...Interactive.backgroundSchema,
...Interactive.borderSchema,
+ ...Interactive.borderRadiusSchema,
...Interactive.cropSchema,
};
diff --git a/packages/rough-notation/src/Annotation.tsx b/packages/rough-notation/src/Annotation.tsx
index b577a4ab8b..6300e1f416 100644
--- a/packages/rough-notation/src/Annotation.tsx
+++ b/packages/rough-notation/src/Annotation.tsx
@@ -237,6 +237,7 @@ const sharedSchema = (defaultRoughness: number): InteractivitySchema => ({
...textContentSchema,
...Interactive.backgroundSchema,
...Interactive.borderSchema,
+ ...Interactive.borderRadiusSchema,
});
export const highlightSchema: InteractivitySchema = {
diff --git a/packages/shapes/src/components/schema.ts b/packages/shapes/src/components/schema.ts
index 30619d098a..9d77e513be 100644
--- a/packages/shapes/src/components/schema.ts
+++ b/packages/shapes/src/components/schema.ts
@@ -91,5 +91,6 @@ export const makeShapeSchema = (
...Internals.transformSchema,
...Interactive.backgroundSchema,
...Interactive.borderSchema,
+ ...Interactive.borderRadiusSchema,
};
};
diff --git a/packages/shapes/src/test/effects.test.tsx b/packages/shapes/src/test/effects.test.tsx
index 33e7160ec3..5a16e74e82 100644
--- a/packages/shapes/src/test/effects.test.tsx
+++ b/packages/shapes/src/test/effects.test.tsx
@@ -125,6 +125,12 @@ mock.module('remotion', () => {
'style.borderStyle': {},
'style.borderColor': {},
},
+ borderRadiusSchema: {
+ 'style.borderTopLeftRadius': {},
+ 'style.borderTopRightRadius': {},
+ 'style.borderBottomRightRadius': {},
+ 'style.borderBottomLeftRadius': {},
+ },
withSchema: mock(({Component}) => Component),
},
Sequence: ({
diff --git a/packages/starburst/src/Starburst.tsx b/packages/starburst/src/Starburst.tsx
index d8e96c551c..c42c49c03a 100644
--- a/packages/starburst/src/Starburst.tsx
+++ b/packages/starburst/src/Starburst.tsx
@@ -346,6 +346,7 @@ export const starburstSchema: InteractivitySchema = {
...Internals.transformSchema,
...Interactive.backgroundSchema,
...Interactive.borderSchema,
+ ...Interactive.borderRadiusSchema,
...Internals.premountSchema,
};
diff --git a/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts b/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts
index 221ceb8b35..55035dfe18 100644
--- a/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts
+++ b/packages/studio-server/src/codemods/update-sequence-props/update-sequence-props.ts
@@ -792,10 +792,12 @@ const migrateCssShorthand = ({
const shorthandValue =
property.value.type === 'StringLiteral'
? property.value.value
- : property.value.type === 'TemplateLiteral' &&
- property.value.expressions.length === 0
- ? (property.value.quasis[0]?.value.cooked ?? null)
- : null;
+ : property.value.type === 'NumericLiteral'
+ ? property.value.value
+ : property.value.type === 'TemplateLiteral' &&
+ property.value.expressions.length === 0
+ ? (property.value.quasis[0]?.value.cooked ?? null)
+ : null;
if (shorthandValue === null) {
continue;
}
diff --git a/packages/studio-server/src/helpers/css-shorthand-properties.ts b/packages/studio-server/src/helpers/css-shorthand-properties.ts
index 242abb730e..fe40107b75 100644
--- a/packages/studio-server/src/helpers/css-shorthand-properties.ts
+++ b/packages/studio-server/src/helpers/css-shorthand-properties.ts
@@ -1,4 +1,5 @@
import {parseBackgroundShorthand} from './parse-background-shorthand';
+import {parseBorderRadiusShorthand} from './parse-border-radius-shorthand';
import {parseBorderShorthand} from './parse-border-shorthand';
type ParsedCssShorthand = Readonly<Record<string, string | number>>;
@@ -7,7 +8,7 @@ export type CssShorthandProperty = {
readonly parentKey: string;
readonly shorthand: string;
readonly longhands: readonly string[];
- readonly parse: (value: string) => ParsedCssShorthand | null;
+ readonly parse: (value: unknown) => ParsedCssShorthand | null;
readonly isUnsupportedProperty: (propertyName: string) => boolean;
};
@@ -18,11 +19,26 @@ const borderShorthand = {
parentKey: 'style',
shorthand: 'border',
longhands: ['borderWidth', 'borderStyle', 'borderColor'],
- parse: parseBorderShorthand,
+ parse: (value) =>
+ typeof value === 'string' ? parseBorderShorthand(value) : null,
isUnsupportedProperty: (propertyName: string) =>
borderSidePropertyRegex.test(propertyName),
} as const satisfies CssShorthandProperty;
+const borderRadiusShorthand = {
+ parentKey: 'style',
+ shorthand: 'borderRadius',
+ longhands: [
+ 'borderTopLeftRadius',
+ 'borderTopRightRadius',
+ 'borderBottomRightRadius',
+ 'borderBottomLeftRadius',
+ ],
+ parse: parseBorderRadiusShorthand,
+ isUnsupportedProperty: (propertyName: string) =>
+ /^border(?:StartStart|StartEnd|EndStart|EndEnd)Radius$/.test(propertyName),
+} as const satisfies CssShorthandProperty;
+
const backgroundShorthand = {
parentKey: 'style',
shorthand: 'background',
@@ -36,13 +52,15 @@ const backgroundShorthand = {
'backgroundClip',
'backgroundAttachment',
],
- parse: parseBackgroundShorthand,
+ parse: (value) =>
+ typeof value === 'string' ? parseBackgroundShorthand(value) : null,
isUnsupportedProperty: () => false,
} as const satisfies CssShorthandProperty;
export const cssShorthandProperties = [
backgroundShorthand,
borderShorthand,
+ borderRadiusShorthand,
] as const satisfies readonly CssShorthandProperty[];
export const getCssShorthandForLonghand = ({
diff --git a/packages/studio-server/src/helpers/parse-border-radius-shorthand.ts b/packages/studio-server/src/helpers/parse-border-radius-shorthand.ts
new file mode 100644
index 0000000000..c982ae36ff
--- /dev/null
+++ b/packages/studio-server/src/helpers/parse-border-radius-shorthand.ts
@@ -0,0 +1,69 @@
+export type ParsedBorderRadiusShorthand = {
+ borderTopLeftRadius: number;
+ borderTopRightRadius: number;
+ borderBottomRightRadius: number;
+ borderBottomLeftRadius: number;
+};
+
+const parsePixelRadius = (value: string): number | null => {
+ if (value === '0') {
+ return 0;
+ }
+
+ const match = value.match(/^(\d+(?:\.\d+)?|\.\d+)px$/i);
+ return match ? Number(match[1]) : null;
+};
+
+const expandBorderRadius = (
+ values: readonly number[],
+): readonly [number, number, number, number] => {
+ if (values.length === 1) {
+ return [values[0], values[0], values[0], values[0]];
+ }
+
+ if (values.length === 2) {
+ return [values[0], values[1], values[0], values[1]];
+ }
+
+ if (values.length === 3) {
+ return [values[0], values[1], values[2], values[1]];
+ }
+
+ return [values[0], values[1], values[2], values[3]];
+};
+
+export const parseBorderRadiusShorthand = (
+ value: unknown,
+): ParsedBorderRadiusShorthand | null => {
+ let values: readonly number[];
+ if (typeof value === 'number') {
+ if (!Number.isFinite(value) || value < 0) {
+ return null;
+ }
+
+ values = [value];
+ } else if (typeof value === 'string') {
+ const tokens = value.trim().split(/\s+/);
+ if (tokens.length < 1 || tokens.length > 4) {
+ return null;
+ }
+
+ const parsed = tokens.map(parsePixelRadius);
+ if (parsed.some((radius) => radius === null)) {
+ return null;
+ }
+
+ values = parsed as number[];
+ } else {
+ return null;
+ }
+
+ const [topLeft, topRight, bottomRight, bottomLeft] =
+ expandBorderRadius(values);
+ return {
+ borderTopLeftRadius: topLeft,
+ borderTopRightRadius: topRight,
+ borderBottomRightRadius: bottomRight,
+ borderBottomLeftRadius: bottomLeft,
+ };
+};
diff --git a/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts b/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts
index 5a566738f0..20f2d16588 100644
--- a/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts
+++ b/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts
@@ -35,6 +35,7 @@ import {parseAst} from '../../codemods/parse-ast';
import {getCssShorthandForLonghand} from '../../helpers/css-shorthand-properties';
import {getAstNodePath} from '../../helpers/get-ast-node-path';
import {toImportAgnosticNodePath} from '../../helpers/import-agnostic-node-path';
+import {parseBorderRadiusShorthand} from '../../helpers/parse-border-radius-shorthand';
import {parseKeyframeEasingExpression} from '../../helpers/parse-keyframe-easing-expression';
import {resolveFileInsideProject} from '../../helpers/resolve-file-inside-project';
import {parseVideoConfigNumericExpression} from '../../helpers/video-config-numeric-expression';
@@ -959,6 +960,102 @@ const getObjectPropertyName = (property: ObjectProperty): string | null => {
return null;
};
+const BORDER_RADIUS_SHORTHAND = 'borderRadius';
+const BORDER_RADIUS_LONGHANDS = [
+ 'borderTopLeftRadius',
+ 'borderTopRightRadius',
+ 'borderBottomRightRadius',
+ 'borderBottomLeftRadius',
+] as const;
+const BORDER_RADIUS_PROPERTIES = new Set<string>([
+ BORDER_RADIUS_SHORTHAND,
+ ...BORDER_RADIUS_LONGHANDS,
+]);
+
+const hasMixedBorderRadiusRepresentation = (
+ jsxElement: JSXOpeningElement,
+): boolean => {
+ const style = jsxElement.attributes.find(
+ (attribute) =>
+ attribute.type === 'JSXAttribute' &&
+ attribute.name.type !== 'JSXNamespacedName' &&
+ attribute.name.name === 'style',
+ );
+ if (
+ !style ||
+ style.type !== 'JSXAttribute' ||
+ style.value?.type !== 'JSXExpressionContainer' ||
+ style.value.expression.type !== 'ObjectExpression'
+ ) {
+ return false;
+ }
+
+ let hasShorthand = false;
+ let hasLonghand = false;
+ for (const property of style.value.expression.properties) {
+ if (property.type !== 'ObjectProperty') {
+ continue;
+ }
+
+ const name = getObjectPropertyName(property);
+ hasShorthand ||= name === BORDER_RADIUS_SHORTHAND;
+ hasLonghand ||= BORDER_RADIUS_LONGHANDS.some(
+ (longhand) => longhand === name,
+ );
+ }
+
+ return hasShorthand && hasLonghand;
+};
+
+const getUniformBorderRadius = (value: unknown): number | null => {
+ const parsed = parseBorderRadiusShorthand(value);
+ if (!parsed) {
+ return null;
+ }
+
+ const values = Object.values(parsed);
+ return values.every((radius) => radius === values[0]) ? values[0] : null;
+};
+
+const getBorderRadiusShorthandStatus = ({
+ propValue,
+ ast,
+ videoConfigValues,
+}: {
+ propValue: Expression;
+ ast: File;
+ videoConfigValues: VideoConfigIdentifierValues;
+}): CanUpdatePropStatus => {
+ if (isStaticValue(propValue)) {
+ const uniform = getUniformBorderRadius(extractStaticValue(propValue));
+ return uniform === null ? computedStatus() : staticStatus(uniform, null);
+ }
+
+ const numericExpression = parseVideoConfigNumericExpression({
+ node: propValue,
+ videoConfigValues,
+ });
+ if (numericExpression !== null && numericExpression.value >= 0) {
+ return staticStatus(numericExpression.value, numericExpression);
+ }
+
+ const computed = getComputedStatus(propValue, ast, videoConfigValues);
+ if (
+ computed.status === 'keyframed' &&
+ computed.interpolationFunction === 'interpolate' &&
+ computed.keyframes.every(
+ (keyframe) =>
+ typeof keyframe.value === 'number' &&
+ Number.isFinite(keyframe.value) &&
+ keyframe.value >= 0,
+ )
+ ) {
+ return computed;
+ }
+
+ return computedStatus();
+};
+
const getNestedPropStatus = ({
jsxElement,
ast,
@@ -1051,10 +1148,6 @@ const getNestedPropStatus = ({
const staticShorthandValue = extractStaticValue(shorthandValue, {
allowSpecialValues: false,
});
- if (typeof staticShorthandValue !== 'string') {
- return computedStatus();
- }
-
const parsed = cssShorthand.parse(staticShorthandValue);
return parsed ? staticStatus(parsed[childKey], null) : computedStatus();
}
@@ -1065,6 +1158,14 @@ const getNestedPropStatus = ({
}
const propValue = prop.value as Expression;
+ if (parentKey === 'style' && childKey === BORDER_RADIUS_SHORTHAND) {
+ return getBorderRadiusShorthandStatus({
+ propValue,
+ ast,
+ videoConfigValues,
+ });
+ }
+
const staticValueOptions = {allowSpecialValues};
if (!isStaticValue(propValue, staticValueOptions)) {
const numericExpression = parseVideoConfigNumericExpression({
@@ -1128,7 +1229,17 @@ const computeSequenceOnlyPropsRecord = ({
assetKeys,
);
const filteredProps: Record<string, CanUpdatePropStatus> = {};
+ const mixedBorderRadius = hasMixedBorderRadiusRepresentation(jsxElement);
for (const key of keys) {
+ if (
+ mixedBorderRadius &&
+ key.startsWith('style.') &&
+ BORDER_RADIUS_PROPERTIES.has(key.slice('style.'.length))
+ ) {
+ filteredProps[key] = computedStatus();
+ continue;
+ }
+
if (key === 'children') {
const staticChildrenAttribute = getStaticJsxChildrenAttribute(jsxElement);
if (staticChildrenAttribute) {
diff --git a/packages/studio-server/src/test/compute-sequence-props-status.test.ts b/packages/studio-server/src/test/compute-sequence-props-status.test.ts
index f84a25f1a1..dc5f6f83b3 100644
--- a/packages/studio-server/src/test/compute-sequence-props-status.test.ts
+++ b/packages/studio-server/src/test/compute-sequence-props-status.test.ts
@@ -168,6 +168,191 @@ export const Example = () => {
});
});
+test('computeSequencePropsStatus should expand static border radius shorthands', () => {
+ const input = `import {AbsoluteFill} from 'remotion';
+
+export const Example = () => {
+ return (
+ <>
+ <AbsoluteFill style={{borderRadius: 12}} />
+ <AbsoluteFill style={{borderRadius: '10px 20px 30px 40px'}} />
+ </>
+ );
+};
+`;
+ const keys = [
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
+ ];
+ const numeric = computeSequencePropsStatusFromContent({
+ fileContents: input,
+ nodePath: getNodePathFromContent(input, 6),
+ componentIdentity: null,
+ keys,
+ effects: [],
+ videoConfigValues: null,
+ });
+ const pixelValues = computeSequencePropsStatusFromContent({
+ fileContents: input,
+ nodePath: getNodePathFromContent(input, 7),
+ componentIdentity: null,
+ keys,
+ effects: [],
+ videoConfigValues: null,
+ });
+
+ expect(numeric.props).toMatchObject({
+ 'style.borderTopLeftRadius': {status: 'static', codeValue: 12},
+ 'style.borderTopRightRadius': {status: 'static', codeValue: 12},
+ 'style.borderBottomRightRadius': {status: 'static', codeValue: 12},
+ 'style.borderBottomLeftRadius': {status: 'static', codeValue: 12},
+ });
+ expect(pixelValues.props).toMatchObject({
+ 'style.borderTopLeftRadius': {status: 'static', codeValue: 10},
+ 'style.borderTopRightRadius': {status: 'static', codeValue: 20},
+ 'style.borderBottomRightRadius': {status: 'static', codeValue: 30},
+ 'style.borderBottomLeftRadius': {status: 'static', codeValue: 40},
+ });
+});
+
+test('computeSequencePropsStatus should normalize uniform border radius shorthands', () => {
+ const input = `import {AbsoluteFill} from 'remotion';
+
+export const Example = () => {
+ return (
+ <>
+ <AbsoluteFill style={{borderRadius: 12}} />
+ <AbsoluteFill style={{borderRadius: '10px'}} />
+ <AbsoluteFill style={{borderRadius: '8px 8px 8px 8px'}} />
+ <AbsoluteFill style={{borderRadius: '10px 20px'}} />
+ </>
+ );
+};
+`;
+ const getStatus = (line: number) =>
+ computeSequencePropsStatusFromContent({
+ fileContents: input,
+ nodePath: getNodePathFromContent(input, line),
+ componentIdentity: null,
+ keys: [
+ 'style.borderRadius',
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
+ ],
+ effects: [],
+ videoConfigValues: null,
+ });
+
+ expect(getStatus(6).props['style.borderRadius']).toEqual({
+ status: 'static',
+ codeValue: 12,
+ });
+ expect(getStatus(7).props['style.borderRadius']).toEqual({
+ status: 'static',
+ codeValue: 10,
+ });
+ expect(getStatus(8).props['style.borderRadius']).toEqual({
+ status: 'static',
+ codeValue: 8,
+ });
+ expect(getStatus(9).props['style.borderRadius']).toEqual({
+ status: 'computed',
+ });
+ expect(getStatus(9).props['style.borderTopLeftRadius']).toEqual({
+ status: 'static',
+ codeValue: 10,
+ });
+});
+
+test('computeSequencePropsStatus should recognize numeric border radius keyframes', () => {
+ const input = `import {AbsoluteFill, interpolate, useCurrentFrame} from 'remotion';
+
+export const Example = () => {
+ const frame = useCurrentFrame();
+ return <AbsoluteFill style={{borderRadius: interpolate(frame, [0, 30], [0, 24])}} />;
+};
+`;
+ const result = computeSequencePropsStatusFromContent({
+ fileContents: input,
+ nodePath: getNodePathFromContent(input, 5),
+ componentIdentity: null,
+ keys: ['style.borderRadius'],
+ effects: [],
+ videoConfigValues: null,
+ });
+
+ expect(result.props['style.borderRadius']).toMatchObject({
+ status: 'keyframed',
+ interpolationFunction: 'interpolate',
+ keyframes: [
+ {frame: 0, value: 0},
+ {frame: 30, value: 24},
+ ],
+ });
+});
+
+test('computeSequencePropsStatus should not guess complex border radius shorthands', () => {
+ for (const borderRadius of ["'50%'", "'10px / 20px'", 'radius']) {
+ const input = `import {AbsoluteFill} from 'remotion';
+
+export const Example = ({radius}: {radius: string}) => {
+ return <AbsoluteFill style={{borderRadius: ${borderRadius}}} />;
+};
+`;
+ const result = computeSequencePropsStatusFromContent({
+ fileContents: input,
+ nodePath: getNodePathFromContent(input, 4),
+ componentIdentity: null,
+ keys: ['style.borderTopLeftRadius'],
+ effects: [],
+ videoConfigValues: null,
+ });
+
+ expect(result.props['style.borderTopLeftRadius']).toEqual({
+ status: 'computed',
+ });
+ }
+});
+
+test('computeSequencePropsStatus should reject mixed border radius representations', () => {
+ const input = `import {AbsoluteFill} from 'remotion';
+
+export const Example = () => {
+ return (
+ <>
+ <AbsoluteFill style={{borderTopLeftRadius: 8, borderRadius: 2}} />
+ <AbsoluteFill style={{borderRadius: 2, borderTopLeftRadius: 8}} />
+ </>
+ );
+};
+`;
+ const getStatus = (line: number) =>
+ computeSequencePropsStatusFromContent({
+ fileContents: input,
+ nodePath: getNodePathFromContent(input, line),
+ componentIdentity: null,
+ keys: [
+ 'style.borderRadius',
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
+ ],
+ effects: [],
+ videoConfigValues: null,
+ });
+
+ for (const line of [6, 7]) {
+ expect(Object.values(getStatus(line).props)).toEqual(
+ new Array(5).fill({status: 'computed'}),
+ );
+ }
+});
+
test('computeSequencePropsStatus should not guess a dynamic border shorthand', () => {
const input = `import {AbsoluteFill} from 'remotion';
diff --git a/packages/studio-server/src/test/css-shorthand-properties.test.ts b/packages/studio-server/src/test/css-shorthand-properties.test.ts
index c42a503812..8f800756cc 100644
--- a/packages/studio-server/src/test/css-shorthand-properties.test.ts
+++ b/packages/studio-server/src/test/css-shorthand-properties.test.ts
@@ -49,6 +49,27 @@ test('registers the background color longhand', () => {
expect(background?.isUnsupportedProperty('backgroundImage')).toBe(false);
});
+test('registers border radius longhands and logical-property blockers', () => {
+ const borderRadius = getCssShorthandForLonghand({
+ parentKey: 'style',
+ longhand: 'borderTopLeftRadius',
+ });
+
+ expect(borderRadius?.shorthand).toBe('borderRadius');
+ expect(borderRadius?.longhands).toEqual([
+ 'borderTopLeftRadius',
+ 'borderTopRightRadius',
+ 'borderBottomRightRadius',
+ 'borderBottomLeftRadius',
+ ]);
+ expect(borderRadius?.isUnsupportedProperty('borderStartStartRadius')).toBe(
+ true,
+ );
+ expect(borderRadius?.isUnsupportedProperty('borderTopLeftRadius')).toBe(
+ false,
+ );
+});
+
test('selects shorthand migrations from dot-notation update keys', () => {
expect(
getCssShorthandsForUpdates([
@@ -58,4 +79,9 @@ test('selects shorthand migrations from dot-notation update keys', () => {
]).map((property) => property.shorthand),
).toEqual(['background', 'border']);
expect(getCssShorthandsForUpdates(['style.opacity'])).toEqual([]);
+ expect(
+ getCssShorthandsForUpdates(['style.borderBottomRightRadius']).map(
+ (property) => property.shorthand,
+ ),
+ ).toEqual(['borderRadius']);
});
diff --git a/packages/studio-server/src/test/discriminated-union-update.test.ts b/packages/studio-server/src/test/discriminated-union-update.test.ts
index 37b2c42474..ce025b2b68 100644
--- a/packages/studio-server/src/test/discriminated-union-update.test.ts
+++ b/packages/studio-server/src/test/discriminated-union-update.test.ts
@@ -54,6 +54,7 @@ test('Should expose absolute-fill variant fields when active', () => {
'style.borderWidth',
'style.borderStyle',
'style.borderColor',
+ 'style.borderRadius',
'cropLeft',
'cropRight',
'cropTop',
diff --git a/packages/studio-server/src/test/get-all-schema-keys.test.ts b/packages/studio-server/src/test/get-all-schema-keys.test.ts
index b25619266d..975f96e25f 100644
--- a/packages/studio-server/src/test/get-all-schema-keys.test.ts
+++ b/packages/studio-server/src/test/get-all-schema-keys.test.ts
@@ -23,6 +23,11 @@ test('getAllSchemaKeys returns every key across all enum variants', () => {
'style.borderWidth',
'style.borderStyle',
'style.borderColor',
+ 'style.borderRadius',
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
'cropLeft',
'cropRight',
'cropTop',
diff --git a/packages/studio-server/src/test/parse-border-radius-shorthand.test.ts b/packages/studio-server/src/test/parse-border-radius-shorthand.test.ts
new file mode 100644
index 0000000000..d9f8f37978
--- /dev/null
+++ b/packages/studio-server/src/test/parse-border-radius-shorthand.test.ts
@@ -0,0 +1,45 @@
+import {expect, test} from 'bun:test';
+import {parseBorderRadiusShorthand} from '../helpers/parse-border-radius-shorthand';
+
+test('expands numeric and pixel border radius shorthands', () => {
+ expect(parseBorderRadiusShorthand(12)).toEqual({
+ borderTopLeftRadius: 12,
+ borderTopRightRadius: 12,
+ borderBottomRightRadius: 12,
+ borderBottomLeftRadius: 12,
+ });
+ expect(parseBorderRadiusShorthand('10px 20px')).toEqual({
+ borderTopLeftRadius: 10,
+ borderTopRightRadius: 20,
+ borderBottomRightRadius: 10,
+ borderBottomLeftRadius: 20,
+ });
+ expect(parseBorderRadiusShorthand('10px 20px 30px')).toEqual({
+ borderTopLeftRadius: 10,
+ borderTopRightRadius: 20,
+ borderBottomRightRadius: 30,
+ borderBottomLeftRadius: 20,
+ });
+ expect(parseBorderRadiusShorthand('10px 20px 30px 40px')).toEqual({
+ borderTopLeftRadius: 10,
+ borderTopRightRadius: 20,
+ borderBottomRightRadius: 30,
+ borderBottomLeftRadius: 40,
+ });
+});
+
+test('rejects complex and invalid border radius shorthands', () => {
+ for (const value of [
+ -1,
+ Number.POSITIVE_INFINITY,
+ '',
+ '10%',
+ '1rem',
+ '10px / 20px',
+ '1px 2px 3px 4px 5px',
+ 'inherit',
+ null,
+ ]) {
+ expect(parseBorderRadiusShorthand(value)).toBeNull();
+ }
+});
diff --git a/packages/studio-server/src/test/update-sequence-props.test.ts b/packages/studio-server/src/test/update-sequence-props.test.ts
index 7f37a42728..0da00bdb24 100644
--- a/packages/studio-server/src/test/update-sequence-props.test.ts
+++ b/packages/studio-server/src/test/update-sequence-props.test.ts
@@ -111,6 +111,87 @@ export const Example = () => {
expect(oldValueStrings).toEqual(['2']);
});
+test('updateSequenceProps should migrate border radius shorthand to longhands', async () => {
+ const input = `import {AbsoluteFill} from 'remotion';
+
+export const Example = () => {
+ return <AbsoluteFill style={{borderRadius: 12, opacity: 0.5}} />;
+};
+`;
+ const {output, oldValueStrings} = await updateSequenceProps({
+ videoConfigValues: null,
+ input,
+ nodePath: lineColumnToNodePath(input, 4),
+ updates: [
+ {
+ key: 'style.borderTopRightRadius',
+ value: 20,
+ defaultValue: undefined,
+ },
+ ],
+ schema: NoReactInternals.sequenceSchema,
+ prettierConfigOverride: null,
+ });
+
+ expect(output).not.toContain('borderRadius: 12');
+ expect(output).toContain('borderTopLeftRadius: 12');
+ expect(output).toContain('borderTopRightRadius: 20');
+ expect(output).toContain('borderBottomRightRadius: 12');
+ expect(output).toContain('borderBottomLeftRadius: 12');
+ expect(output).toContain('opacity: 0.5');
+ expect(oldValueStrings).toEqual(['12']);
+});
+
+test('updateSequenceProps should collapse equal border radius longhands to the shorthand', async () => {
+ const input = `import {AbsoluteFill} from 'remotion';
+
+export const Example = () => {
+ return <AbsoluteFill style={{borderTopLeftRadius: 12, borderTopRightRadius: 12, borderBottomRightRadius: 12, borderBottomLeftRadius: 12, opacity: 0.5}} />;
+};
+`;
+ const nodePath = lineColumnToNodePath(input, 4);
+ const updates = [
+ {
+ key: 'style.borderTopLeftRadius',
+ value: undefined,
+ defaultValue: undefined,
+ },
+ {
+ key: 'style.borderTopRightRadius',
+ value: undefined,
+ defaultValue: undefined,
+ },
+ {
+ key: 'style.borderBottomRightRadius',
+ value: undefined,
+ defaultValue: undefined,
+ },
+ {
+ key: 'style.borderBottomLeftRadius',
+ value: undefined,
+ defaultValue: undefined,
+ },
+ {key: 'style.borderRadius', value: 12, defaultValue: undefined},
+ ];
+ const {output} = await updateMultipleSequenceProps({
+ input,
+ changes: updates.map((update) => ({
+ nodePath,
+ updates: [update],
+ schema: NoReactInternals.sequenceSchema,
+ videoConfigValues: null,
+ })),
+ prettierConfigOverride: null,
+ });
+
+ expect(output).toContain('borderRadius: 12');
+ expect(output).not.toContain('borderTopLeftRadius');
+ expect(output).not.toContain('borderTopRightRadius');
+ expect(output).not.toContain('borderBottomRightRadius');
+ expect(output).not.toContain('borderBottomLeftRadius');
+ expect(output).toContain('opacity: 0.5');
+});
+
test('updateSequenceProps should migrate a color-only background shorthand', async () => {
const input = `import {AbsoluteFill} from 'remotion';
diff --git a/packages/studio-shared/src/index.ts b/packages/studio-shared/src/index.ts
index 5c80b3f391..13251c9d90 100644
--- a/packages/studio-shared/src/index.ts
+++ b/packages/studio-shared/src/index.ts
@@ -284,6 +284,11 @@ export {
StackFrame,
SymbolicatedStackFrame,
} from './stack-types';
+export {
+ BORDER_RADIUS_LONGHAND_KEYS,
+ BORDER_RADIUS_SHORTHAND_KEY,
+ getStylePropertyLonghandKeys,
+} from './style-property-relations';
export {EnumPath, stringifyDefaultProps} from './stringify-default-props';
export {
getStudioEntryPoints,
diff --git a/packages/studio-shared/src/schema-field-info.ts b/packages/studio-shared/src/schema-field-info.ts
index 95d80f54ae..4b97dbf36d 100644
--- a/packages/studio-shared/src/schema-field-info.ts
+++ b/packages/studio-shared/src/schema-field-info.ts
@@ -13,6 +13,10 @@ import type {
} from 'remotion';
import {Internals} from 'remotion';
import {NoReactInternals} from 'remotion/no-react';
+import {
+ BORDER_RADIUS_LONGHAND_KEYS,
+ BORDER_RADIUS_SHORTHAND_KEY,
+} from './style-property-relations';
export type {DragOverrides, PropStatuses, SequenceControls};
@@ -47,6 +51,7 @@ export type SchemaFieldGroup =
| 'transforms'
| 'background'
| 'border'
+ | 'border-radius'
| 'crop'
| 'text'
| 'layout';
@@ -63,6 +68,7 @@ export const SCHEMA_FIELD_GROUPS = [
{id: 'text', label: 'Text'},
{id: 'background', label: 'Background'},
{id: 'border', label: 'Border'},
+ {id: 'border-radius', label: 'Border radius'},
{id: 'crop', label: 'Crop'},
{id: 'layout', label: 'Layout'},
] as const satisfies readonly SchemaFieldGroupInfo[];
@@ -90,6 +96,56 @@ const CROP_FIELD_KEYS = new Set([
'cropBottom',
]);
+const BORDER_RADIUS_FIELD_KEYS = new Set([
+ 'style.borderRadius',
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
+]);
+
+const getBorderRadiusFieldKeysToShow = ({
+ activeSchema,
+ propStatuses,
+ nodePath,
+}: {
+ activeSchema: InteractivitySchema;
+ propStatuses: PropStatuses;
+ nodePath: SequencePropsSubscriptionKey;
+}): ReadonlySet<string> | null => {
+ if (!(BORDER_RADIUS_SHORTHAND_KEY in activeSchema)) {
+ return null;
+ }
+
+ const statuses = Internals.getPropStatusesCtx(propStatuses, nodePath);
+ const shorthand = statuses?.[BORDER_RADIUS_SHORTHAND_KEY];
+ const longhands = BORDER_RADIUS_LONGHAND_KEYS.map((key) => statuses?.[key]);
+
+ // A supported shorthand is canonical even though the server also reports its
+ // expanded longhand values. This keeps one Inspector row and one keyframe track.
+ if (shorthand?.status === 'keyframed') {
+ return new Set([BORDER_RADIUS_SHORTHAND_KEY]);
+ }
+
+ if (shorthand?.status === 'static' && shorthand.codeValue !== undefined) {
+ return new Set([BORDER_RADIUS_SHORTHAND_KEY]);
+ }
+
+ const hasEditableLonghand = longhands.some(
+ (status) =>
+ status?.status === 'keyframed' ||
+ (status?.status === 'static' && status.codeValue !== undefined),
+ );
+ if (hasEditableLonghand) {
+ return new Set(BORDER_RADIUS_LONGHAND_KEYS);
+ }
+
+ // No radius has been authored, an unsupported dynamic shorthand was authored,
+ // or shorthand and longhands were mixed. In all three cases, only show the
+ // shorthand row so duplicate representations never reach the Inspector/timeline.
+ return new Set([BORDER_RADIUS_SHORTHAND_KEY]);
+};
+
const BORDER_FIELD_KEYS = new Set([
'style.borderWidth',
'style.borderStyle',
@@ -125,6 +181,10 @@ export const getSchemaFieldGroup = (key: string): SchemaFieldGroup => {
return 'crop';
}
+ if (BORDER_RADIUS_FIELD_KEYS.has(key)) {
+ return 'border-radius';
+ }
+
if (BORDER_FIELD_KEYS.has(key)) {
return 'border';
}
@@ -284,9 +344,22 @@ export const getFieldsToShow = ({
schema,
(key) => valuesDotNotation[key],
);
+ const borderRadiusFieldKeysToShow = getBorderRadiusFieldKeysToShow({
+ activeSchema,
+ propStatuses,
+ nodePath,
+ });
const fields = Object.entries(activeSchema)
.map(([key, fieldSchema]): InteractivitySchemaFieldInfo | null => {
+ if (
+ BORDER_RADIUS_FIELD_KEYS.has(key) &&
+ borderRadiusFieldKeysToShow !== null &&
+ !borderRadiusFieldKeysToShow.has(key)
+ ) {
+ return null;
+ }
+
if (!isTimelineSchemaFieldSupported(fieldSchema)) {
return null;
}
diff --git a/packages/studio-shared/src/style-property-relations.ts b/packages/studio-shared/src/style-property-relations.ts
new file mode 100644
index 0000000000..90afa247c1
--- /dev/null
+++ b/packages/studio-shared/src/style-property-relations.ts
@@ -0,0 +1,15 @@
+export const BORDER_RADIUS_SHORTHAND_KEY = 'style.borderRadius';
+export const BORDER_RADIUS_LONGHAND_KEYS = [
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
+] as const;
+
+const STYLE_PROPERTY_LONGHANDS = new Map<string, readonly string[]>([
+ [BORDER_RADIUS_SHORTHAND_KEY, BORDER_RADIUS_LONGHAND_KEYS],
+]);
+
+export const getStylePropertyLonghandKeys = (
+ fieldKey: string,
+): readonly string[] => STYLE_PROPERTY_LONGHANDS.get(fieldKey) ?? [];
diff --git a/packages/studio-shared/src/test/keyframe-interpolation-function.test.ts b/packages/studio-shared/src/test/keyframe-interpolation-function.test.ts
index 081ebfcb55..76f721b884 100644
--- a/packages/studio-shared/src/test/keyframe-interpolation-function.test.ts
+++ b/packages/studio-shared/src/test/keyframe-interpolation-function.test.ts
@@ -9,7 +9,10 @@ import {
} from '../keyframe-interpolation-function';
test('border longhand fields keyframe width and color, but not style', () => {
- const schema = Interactive.borderSchema;
+ const schema = {
+ ...Interactive.borderSchema,
+ ...Interactive.borderRadiusSchema,
+ };
expect(isSchemaFieldKeyframable({schema, key: 'style.borderWidth'})).toBe(
true,
@@ -20,6 +23,12 @@ test('border longhand fields keyframe width and color, but not style', () => {
expect(isSchemaFieldKeyframable({schema, key: 'style.borderStyle'})).toBe(
false,
);
+ expect(isSchemaFieldKeyframable({schema, key: 'style.borderRadius'})).toBe(
+ true,
+ );
+ expect(
+ isSchemaFieldKeyframable({schema, key: 'style.borderTopLeftRadius'}),
+ ).toBe(true);
});
test('background color is keyframable', () => {
diff --git a/packages/studio-shared/src/test/schema-field-info.test.ts b/packages/studio-shared/src/test/schema-field-info.test.ts
index b66c8bfa43..6cb86f510f 100644
--- a/packages/studio-shared/src/test/schema-field-info.test.ts
+++ b/packages/studio-shared/src/test/schema-field-info.test.ts
@@ -62,6 +62,64 @@ const nodePath: SequencePropsSubscriptionKey = {
videoConfigValues: null,
};
+const borderRadiusSchema = {
+ 'style.borderRadius': {
+ type: 'number' as const,
+ default: undefined,
+ hiddenFromList: false,
+ },
+ 'style.borderTopLeftRadius': {
+ type: 'number' as const,
+ default: undefined,
+ hiddenFromList: false,
+ },
+ 'style.borderTopRightRadius': {
+ type: 'number' as const,
+ default: undefined,
+ hiddenFromList: false,
+ },
+ 'style.borderBottomRightRadius': {
+ type: 'number' as const,
+ default: undefined,
+ hiddenFromList: false,
+ },
+ 'style.borderBottomLeftRadius': {
+ type: 'number' as const,
+ default: undefined,
+ hiddenFromList: false,
+ },
+};
+
+const getBorderRadiusFields = (
+ props: Record<
+ string,
+ | {status: 'static'; codeValue: unknown}
+ | {status: 'computed'}
+ | {
+ status: 'keyframed';
+ interpolationFunction: 'interpolate';
+ keyframes: {frame: number; value: number}[];
+ easing: [];
+ clamping: {left: 'extend'; right: 'extend'};
+ posterize: undefined;
+ output: undefined;
+ }
+ >,
+) =>
+ getFieldsToShow({
+ schema: borderRadiusSchema,
+ currentRuntimeValueDotNotation: {},
+ getDragOverrides: () => ({}),
+ propStatuses: {
+ [Internals.makeSequencePropsSubscriptionKey(nodePath)]: {
+ canUpdate: true,
+ props,
+ effects: [],
+ },
+ },
+ nodePath,
+ })?.map((field) => field.key);
+
test('getEffectFieldsToShow uses the active enum variant', () => {
const fields = getEffectFieldsToShow({
effect,
@@ -244,6 +302,11 @@ test('getFieldsToShow sorts fields by inspector group order', () => {
type: 'color',
default: undefined,
},
+ 'style.borderTopLeftRadius': {
+ type: 'number',
+ default: undefined,
+ hiddenFromList: false,
+ },
volume: {
type: 'number',
default: 1,
@@ -298,6 +361,7 @@ test('getFieldsToShow sorts fields by inspector group order', () => {
'style.borderWidth',
'style.borderStyle',
'style.borderColor',
+ 'style.borderTopLeftRadius',
'cropLeft',
'layout',
'premountFor',
@@ -318,6 +382,7 @@ test('getFieldsToShow sorts fields by inspector group order', () => {
'border',
'border',
'border',
+ 'border-radius',
'crop',
'layout',
'layout',
@@ -330,6 +395,77 @@ test('groups Sequence crop controls into the Crop inspector section', () => {
).toEqual(['crop', 'crop', 'crop', 'crop']);
});
+test('groups border radius controls into their own inspector section', () => {
+ expect(
+ [
+ 'style.borderRadius',
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
+ ].map(getSchemaFieldGroup),
+ ).toEqual([
+ 'border-radius',
+ 'border-radius',
+ 'border-radius',
+ 'border-radius',
+ 'border-radius',
+ ]);
+});
+
+test('getFieldsToShow selects one border radius representation', () => {
+ expect(getBorderRadiusFields({})).toEqual(['style.borderRadius']);
+ expect(
+ getBorderRadiusFields({
+ 'style.borderRadius': {status: 'static', codeValue: 12},
+ 'style.borderTopLeftRadius': {status: 'static', codeValue: 12},
+ 'style.borderTopRightRadius': {status: 'static', codeValue: 12},
+ 'style.borderBottomRightRadius': {status: 'static', codeValue: 12},
+ 'style.borderBottomLeftRadius': {status: 'static', codeValue: 12},
+ }),
+ ).toEqual(['style.borderRadius']);
+ expect(
+ getBorderRadiusFields({
+ 'style.borderRadius': {status: 'static', codeValue: undefined},
+ 'style.borderTopLeftRadius': {status: 'static', codeValue: 4},
+ 'style.borderTopRightRadius': {status: 'static', codeValue: 8},
+ 'style.borderBottomRightRadius': {status: 'static', codeValue: 12},
+ 'style.borderBottomLeftRadius': {status: 'static', codeValue: 16},
+ }),
+ ).toEqual([
+ 'style.borderTopLeftRadius',
+ 'style.borderTopRightRadius',
+ 'style.borderBottomRightRadius',
+ 'style.borderBottomLeftRadius',
+ ]);
+ expect(
+ getBorderRadiusFields({
+ 'style.borderRadius': {
+ status: 'keyframed',
+ interpolationFunction: 'interpolate',
+ keyframes: [
+ {frame: 0, value: 0},
+ {frame: 30, value: 20},
+ ],
+ easing: [],
+ clamping: {left: 'extend', right: 'extend'},
+ posterize: undefined,
+ output: undefined,
+ },
+ }),
+ ).toEqual(['style.borderRadius']);
+ expect(
+ getBorderRadiusFields(
+ Object.fromEntries(
+ Object.keys(borderRadiusSchema).map((key) => [
+ key,
+ {status: 'computed'},
+ ]),
+ ),
+ ),
+ ).toEqual(['style.borderRadius']);
+});
+
test('groups Sequence layout controls into the final Layout inspector section', () => {
expect(['layout', 'premountFor'].map(getSchemaFieldGroup)).toEqual([
'layout',
diff --git a/packages/studio/src/components/FullscreenToggle.tsx b/packages/studio/src/components/FullscreenToggle.tsx
index e30e44d909..ac6fb9eb32 100644
--- a/packages/studio/src/components/FullscreenToggle.tsx
+++ b/packages/studio/src/components/FullscreenToggle.tsx
@@ -6,6 +6,7 @@ import {
areKeyboardShortcutsDisabled,
useKeybinding,
} from '../helpers/use-keybinding';
+import {FullscreenIcon} from '../icons/fullscreen';
import {drawRef} from '../state/canvas-ref';
import {ControlButton} from './ControlButton';
@@ -54,13 +55,7 @@ export const FullScreenToggle: React.FC<{}> = () => {
aria-label={accessibilityLabel}
onClick={onClick}
>
- <svg
- style={{width: 18, height: 18}}
- viewBox="0 0 448 512"
- fill={WHITE_HEX}
- >
- <path d="M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z" />
- </svg>
+ <FullscreenIcon color={WHITE_HEX} style={{width: 18, height: 18}} />
</ControlButton>
);
};
diff --git a/packages/studio/src/components/InlineAction.tsx b/packages/studio/src/components/InlineAction.tsx
index 0310f889ca..c6f7a7044f 100644
--- a/packages/studio/src/components/InlineAction.tsx
+++ b/packages/studio/src/components/InlineAction.tsx
@@ -49,6 +49,7 @@ export const InlineAction = ({
justifyContent: 'center',
alignItems: 'center',
borderRadius: 3,
+ opacity: disabled ? 0.5 : 1,
pointerEvents: disabled ? 'none' : 'auto',
};
}, [disabled, hovered]);
diff --git a/packages/studio/src/components/InspectorSequenceSection.tsx b/packages/studio/src/components/InspectorSequenceSection.tsx
index 1d6702142d..1596d1430d 100644
--- a/packages/studio/src/components/InspectorSequenceSection.tsx
+++ b/packages/studio/src/components/InspectorSequenceSection.tsx
@@ -1,6 +1,6 @@
import type {Caption} from '@remotion/captions';
import React, {useCallback, useContext, useMemo, useState} from 'react';
-import type {TSequence} from 'remotion';
+import {Internals, type TSequence} from 'remotion';
import type {CodePosition} from '../error-overlay/react-overlay/utils/get-source-map';
import {StudioServerConnectionCtx} from '../helpers/client-id';
import {LIGHT_TEXT, WHITE} from '../helpers/colors';
@@ -14,6 +14,8 @@ import {
type SchemaFieldGroupInfo,
type TimelineTreeNode,
} from '../helpers/timeline-layout';
+import {BorderRadiusIcon} from '../icons/border-radius';
+import {FullscreenIcon} from '../icons/fullscreen';
import {Plus} from '../icons/plus';
import {ModalsContext} from '../state/modals';
import {AssetFileIcon} from './AssetFileIcon';
@@ -22,6 +24,12 @@ import {InlineCaptionInspector} from './InlineCaptionInspector';
import {InspectorSection} from './InspectorPanel/common';
import {sectionHeaderRow, sectionHeaderTitle} from './InspectorPanel/styles';
import {getAssetSearchQueryForComponent} from './QuickSwitcher/asset-search';
+import {
+ BORDER_RADIUS_SHORTHAND_KEY,
+ getBorderRadiusConversion,
+ getBorderRadiusConversionChanges,
+} from './Timeline/border-radius-representation';
+import {saveSequenceProps} from './Timeline/save-sequence-prop';
import {
getTimelineAssetLinkInfo,
getTimelineAssetSrcFromSchema,
@@ -71,6 +79,12 @@ const plusIcon: React.CSSProperties = {
height: 15,
};
+const borderRadiusToggleIcon: React.CSSProperties = {
+ flexShrink: 0,
+ height: 15,
+ width: 15,
+};
+
const assetSelectorIcon: React.CSSProperties = {
flexShrink: 0,
height: 18,
@@ -217,7 +231,7 @@ export const InspectorSequenceSection: React.FC<{
keyframeDisplayOffset,
renderTransformControls,
}) => {
- const {tree} = useTimelineExpandedTree({
+ const {tree, propStatuses} = useTimelineExpandedTree({
sequence,
nodePathInfo,
includeTextContent: true,
@@ -227,6 +241,10 @@ export const InspectorSequenceSection: React.FC<{
loadInspectorCollapsedKeys,
);
const {previewServerState} = useContext(StudioServerConnectionCtx);
+ const {getDragOverrides} = useContext(
+ Internals.VisualModeDragOverridesContext,
+ );
+ const {setPropStatuses} = useContext(Internals.VisualModeSettersContext);
const {setSelectedModal} = useContext(ModalsContext);
const selectAsset = useSelectAsset();
const mediaSrc = getTimelineAssetSrcFromSchema(sequence.controls);
@@ -359,6 +377,20 @@ export const InspectorSequenceSection: React.FC<{
);
const {schema} = sequence.controls;
+ const borderRadiusGroup = controlGroups.find(
+ (group) => group.id === 'border-radius',
+ );
+ const borderRadiusUsesShorthand = borderRadiusGroup?.rows.some(
+ ({node}) =>
+ node.kind === 'field' && node.field?.key === BORDER_RADIUS_SHORTHAND_KEY,
+ );
+ const borderRadiusConversion = getBorderRadiusConversion(
+ Internals.getPropStatusesCtx(
+ propStatuses,
+ nodePathInfo.sequenceSubscriptionKey,
+ ),
+ getDragOverrides(nodePathInfo.sequenceSubscriptionKey),
+ );
const inlineCaptionValue =
schema.captions?.type === 'remotion-captions'
? sequence.controls.currentRuntimeValueDotNotation.captions
@@ -393,6 +425,71 @@ export const InspectorSequenceSection: React.FC<{
validatedLocation.source,
]);
+ const onConvertBorderRadius = useCallback(() => {
+ if (
+ borderRadiusConversion === null ||
+ previewServerState.type !== 'connected'
+ ) {
+ return;
+ }
+
+ const common = {
+ fileName: validatedLocation.source,
+ nodePath: nodePathInfo.sequenceSubscriptionKey,
+ defaultValue: null,
+ schema,
+ };
+ const changes = getBorderRadiusConversionChanges(
+ borderRadiusConversion,
+ ).map((change) => ({...common, ...change}));
+
+ saveSequenceProps({
+ changes,
+ addedKeyframes: null,
+ movedKeyframes: null,
+ setPropStatuses,
+ clientId: previewServerState.clientId,
+ undoLabel: 'Change border radius representation',
+ redoLabel: 'Change border radius representation again',
+ });
+ }, [
+ borderRadiusConversion,
+ nodePathInfo.sequenceSubscriptionKey,
+ previewServerState,
+ schema,
+ setPropStatuses,
+ validatedLocation.source,
+ ]);
+
+ const borderRadiusHeader = borderRadiusGroup ? (
+ <div style={sectionHeaderRow}>
+ <div style={effectsHeaderTitle}>Border radius</div>
+ <InlineAction
+ disabled={
+ borderRadiusConversion === null ||
+ previewServerState.type !== 'connected'
+ }
+ onClick={onConvertBorderRadius}
+ title={
+ borderRadiusConversion === null
+ ? borderRadiusUsesShorthand
+ ? 'A static border radius is required to use individual corners'
+ : 'All four corners must have the same static value'
+ : borderRadiusUsesShorthand
+ ? 'Use individual corner radii'
+ : 'Use one border radius value'
+ }
+ renderAction={(color) =>
+ borderRadiusUsesShorthand ? (
+ <FullscreenIcon color={color} style={borderRadiusToggleIcon} />
+ ) : (
+ <BorderRadiusIcon color={color} style={borderRadiusToggleIcon} />
+ )
+ }
+ />
+ </div>
+ ) : null;
+
const effectsHeader = (
<div style={sectionHeaderRow}>
<div style={effectsHeaderTitle}>Effects</div>
@@ -448,7 +545,14 @@ export const InspectorSequenceSection: React.FC<{
{controlRows.length > 0 ? (
<TimelineSelectionOrderProvider items={controlSelectableItems}>
{controlGroupsWithoutLayout.map((group) => (
- <InspectorSection key={group.id} header={group.label}>
+ <InspectorSection
+ key={group.id}
+ header={
+ group.id === 'border-radius'
+ ? borderRadiusHeader
+ : group.label
+ }
+ >
{group.id === 'transforms' ? renderTransformControls() : null}
{group.rows.map(renderRow)}
</InspectorSection>
diff --git a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
index 100b876b53..5e8ba4d2f6 100644
--- a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx
@@ -21,6 +21,7 @@ import {ContextMenu} from '../ContextMenu';
import {INSPECTOR_PANEL_HORIZONTAL_PADDING} from '../InspectorPanelLayout';
import type {ComboboxValue} from '../NewComposition/ComboBox';
import {callAddSequenceKeyframe} from './call-add-keyframe';
+import {getSequencePropResetChanges} from './get-sequence-prop-reset-changes';
import {saveSequenceProps} from './save-sequence-prop';
import {TimelineExpandArrowSpacer} from './TimelineExpandArrowButton';
import {TimelineFieldRowContent} from './TimelineFieldRowContent';
@@ -401,16 +402,14 @@ export const TimelineSequencePropItem: React.FC<{
saveSequenceProps({
addedKeyframes: null,
movedKeyframes: null,
- changes: [
- {
- fileName: validatedLocation.source,
- nodePath,
- fieldKey: field.key,
- value: field.fieldSchema.default,
- defaultValue,
- schema,
- },
- ],
+ changes: getSequencePropResetChanges({
+ fileName: validatedLocation.source,
+ nodePath,
+ fieldKey: field.key,
+ value: field.fieldSchema.default,
+ defaultValue,
+ schema,
+ }),
setPropStatuses,
clientId: previewServerState.clientId,
undoLabel: `Reset ${fieldLabel}`,
diff --git a/packages/studio/src/components/Timeline/border-radius-representation.ts b/packages/studio/src/components/Timeline/border-radius-representation.ts
new file mode 100644
index 0000000000..efa3383fc0
--- /dev/null
+++ b/packages/studio/src/components/Timeline/border-radius-representation.ts
@@ -0,0 +1,89 @@
+import {
+ BORDER_RADIUS_LONGHAND_KEYS,
+ BORDER_RADIUS_SHORTHAND_KEY,
+} from '@remotion/studio-shared';
+import type {CanUpdateSequencePropStatus, DragOverrideValue} from 'remotion';
+
+export {BORDER_RADIUS_LONGHAND_KEYS, BORDER_RADIUS_SHORTHAND_KEY};
+
+export type BorderRadiusConversion =
+ | {readonly type: 'individual'; readonly value: number}
+ | {readonly type: 'shorthand'; readonly value: number};
+
+export type BorderRadiusConversionChange = {
+ readonly fieldKey: string;
+ readonly value: number | undefined;
+};
+
+export const getBorderRadiusConversionChanges = (
+ conversion: BorderRadiusConversion,
+): BorderRadiusConversionChange[] => {
+ if (conversion.type === 'individual') {
+ return [
+ {fieldKey: BORDER_RADIUS_SHORTHAND_KEY, value: undefined},
+ ...BORDER_RADIUS_LONGHAND_KEYS.map((fieldKey) => ({
+ fieldKey,
+ value: conversion.value,
+ })),
+ ];
+ }
+
+ return [
+ ...BORDER_RADIUS_LONGHAND_KEYS.map((fieldKey) => ({
+ fieldKey,
+ value: undefined,
+ })),
+ {fieldKey: BORDER_RADIUS_SHORTHAND_KEY, value: conversion.value},
+ ];
+};
+
+export const getBorderRadiusConversion = (
+ props: Record<string, CanUpdateSequencePropStatus> | undefined,
+ dragOverrides: Record<string, DragOverrideValue> = {},
+): BorderRadiusConversion | null => {
+ const getStaticValue = (key: string) => {
+ const status = props?.[key];
+ if (status !== undefined && status.status !== 'static') {
+ return {isStatic: false as const, value: undefined};
+ }
+
+ const dragOverride = dragOverrides[key];
+ if (dragOverride?.type === 'keyframed') {
+ return {isStatic: false as const, value: undefined};
+ }
+
+ return {
+ isStatic: true as const,
+ value:
+ dragOverride?.type === 'static'
+ ? dragOverride.value
+ : status?.codeValue,
+ };
+ };
+
+ const shorthand = getStaticValue(BORDER_RADIUS_SHORTHAND_KEY);
+ if (shorthand.isStatic && typeof shorthand.value === 'number') {
+ return {type: 'individual', value: shorthand.value};
+ }
+
+ const longhands = BORDER_RADIUS_LONGHAND_KEYS.map(getStaticValue);
+ const hasNoAuthoredRadius = [shorthand, ...longhands].every(
+ (status) => status.isStatic && status.value === undefined,
+ );
+ if (hasNoAuthoredRadius) {
+ return {type: 'individual', value: 0};
+ }
+
+ if (
+ longhands.every(
+ (status) => status.isStatic && typeof status.value === 'number',
+ )
+ ) {
+ const values = longhands.map((status) => status.value);
+ if (values.every((value) => value === values[0])) {
+ return {type: 'shorthand', value: values[0] as number};
+ }
+ }
+
+ return null;
+};
diff --git a/packages/studio/src/components/Timeline/get-sequence-prop-reset-changes.ts b/packages/studio/src/components/Timeline/get-sequence-prop-reset-changes.ts
new file mode 100644
index 0000000000..fe41dc5a88
--- /dev/null
+++ b/packages/studio/src/components/Timeline/get-sequence-prop-reset-changes.ts
@@ -0,0 +1,62 @@
+import {getStylePropertyLonghandKeys} from '@remotion/studio-shared';
+import type {
+ InteractivitySchema,
+ InteractivitySchemaField,
+ SequencePropsSubscriptionKey,
+} from 'remotion';
+import {Internals} from 'remotion';
+import type {SaveSequencePropChange} from './save-sequence-prop';
+
+const isVisibleFieldSchema = (
+ fieldSchema: InteractivitySchemaField | undefined,
+): fieldSchema is Exclude<InteractivitySchemaField, {type: 'hidden'}> =>
+ fieldSchema !== undefined && fieldSchema.type !== 'hidden';
+
+const getDefaultValue = (
+ fieldSchema: Exclude<InteractivitySchemaField, {type: 'hidden'}>,
+) =>
+ fieldSchema.default !== undefined
+ ? JSON.stringify(fieldSchema.default)
+ : null;
+
+export const getSequencePropResetChanges = ({
+ fileName,
+ nodePath,
+ fieldKey,
+ value,
+ defaultValue,
+ schema,
+}: {
+ readonly fileName: string;
+ readonly nodePath: SequencePropsSubscriptionKey;
+ readonly fieldKey: string;
+ readonly value: unknown;
+ readonly defaultValue: string | null;
+ readonly schema: InteractivitySchema;
+}): SaveSequencePropChange[] => {
+ const flatSchema = Internals.getFlatSchemaWithAllKeys(schema);
+ const longhandChanges = getStylePropertyLonghandKeys(fieldKey).flatMap(
+ (longhandKey): SaveSequencePropChange[] => {
+ const fieldSchema = flatSchema[longhandKey];
+ if (!isVisibleFieldSchema(fieldSchema)) {
+ return [];
+ }
+
+ return [
+ {
+ fileName,
+ nodePath,
+ fieldKey: longhandKey,
+ value: fieldSchema.default,
+ defaultValue: getDefaultValue(fieldSchema),
+ schema,
+ },
+ ];
+ },
+ );
+
+ return [
+ {fileName, nodePath, fieldKey, value, defaultValue, schema},
+ ...longhandChanges,
+ ];
+};
diff --git a/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts b/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts
index 658419e967..35661acb83 100644
--- a/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts
+++ b/packages/studio/src/components/Timeline/reset-selected-timeline-props.ts
@@ -10,6 +10,7 @@ import type {
} from 'remotion';
import {Internals} from 'remotion';
import {findTrackForNodePathInfo} from './find-track-for-node-path-info';
+import {getSequencePropResetChanges} from './get-sequence-prop-reset-changes';
import {saveMultipleEffectProps} from './save-effect-prop';
import type {SetPropStatuses} from './save-sequence-prop';
import {saveSequenceProps} from './save-sequence-prop';
@@ -288,14 +289,9 @@ export const resetSelectedTimelineProps = ({
saveSequenceProps({
addedKeyframes: null,
movedKeyframes: null,
- changes: sequencePropTargets.map((target) => ({
- fileName: target.fileName,
- nodePath: target.nodePath,
- fieldKey: target.fieldKey,
- value: target.value,
- defaultValue: target.defaultValue,
- schema: target.schema,
- })),
+ changes: sequencePropTargets.flatMap((target) =>
+ getSequencePropResetChanges(target),
+ ),
setPropStatuses,
clientId,
undoLabel:
diff --git a/packages/studio/src/components/UndoRedoButtons.tsx b/packages/studio/src/components/UndoRedoButtons.tsx
index bd5f8fcf8a..7a8621fcb5 100644
--- a/packages/studio/src/components/UndoRedoButtons.tsx
+++ b/packages/studio/src/components/UndoRedoButtons.tsx
@@ -148,23 +148,13 @@ export const UndoRedoButtons: React.FC = () => {
? `Redo (${cmdOrCtrlCharacter}+Shift+Z)`
: `Redo (${cmdOrCtrlCharacter}+Y)`;
- const renderUndo: RenderInlineAction = useCallback(
- (color) => {
- return (
- <UndoIcon style={{...iconStyle, color, opacity: undoFile ? 1 : 0.5}} />
- );
- },
- [undoFile],
- );
+ const renderUndo: RenderInlineAction = useCallback((color) => {
+ return <UndoIcon style={{...iconStyle, color}} />;
+ }, []);
- const renderRedo: RenderInlineAction = useCallback(
- (color) => {
- return (
- <RedoIcon style={{...iconStyle, color, opacity: redoFile ? 1 : 0.5}} />
- );
- },
- [redoFile],
- );
+ const renderRedo: RenderInlineAction = useCallback((color) => {
+ return <RedoIcon style={{...iconStyle, color}} />;
+ }, []);
const canUndo = undoFile !== null;
const canRedo = redoFile !== null;
diff --git a/packages/studio/src/icons/border-radius.tsx b/packages/studio/src/icons/border-radius.tsx
new file mode 100644
index 0000000000..006c861cef
--- /dev/null
+++ b/packages/studio/src/icons/border-radius.tsx
@@ -0,0 +1,18 @@
+import type {SVGProps} from 'react';
+
+export const BorderRadiusIcon = ({
+ color,
+ ...props
+}: SVGProps<SVGSVGElement> & {readonly color: string}) => {
+ return (
+ <svg viewBox="0 0 16 16" fill="none" {...props}>
+ <path
+ d="M2.5 3.5H6.5C10.4 3.5 12.5 5.6 12.5 9.5V13.5"
+ stroke={color}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="2"
+ />
+ </svg>
+ );
+};
diff --git a/packages/studio/src/icons/fullscreen.tsx b/packages/studio/src/icons/fullscreen.tsx
new file mode 100644
index 0000000000..1dbd99ee63
--- /dev/null
+++ b/packages/studio/src/icons/fullscreen.tsx
@@ -0,0 +1,13 @@
+import type {SVGProps} from 'react';
+
+export const FullscreenIcon = ({
+ color,
+ ...props
+}: SVGProps<SVGSVGElement> & {readonly color: string}) => (
+ <svg viewBox="0 0 448 512" {...props}>
+ <path
+ fill={color}
+ d="M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z"
+ />
+ </svg>
+);
diff --git a/packages/studio/src/test/border-radius-representation.test.ts b/packages/studio/src/test/border-radius-representation.test.ts
new file mode 100644
index 0000000000..c0f7f4d99b
--- /dev/null
+++ b/packages/studio/src/test/border-radius-representation.test.ts
@@ -0,0 +1,187 @@
+import {expect, test} from 'bun:test';
+import {optimisticUpdateForPropStatuses} from '@remotion/studio-shared';
+import type {
+ CanUpdateSequencePropsResponse,
+ CanUpdateSequencePropStatus,
+} from 'remotion';
+import {NoReactInternals} from 'remotion/no-react';
+import {
+ BORDER_RADIUS_LONGHAND_KEYS,
+ BORDER_RADIUS_SHORTHAND_KEY,
+ getBorderRadiusConversion,
+ getBorderRadiusConversionChanges,
+} from '../components/Timeline/border-radius-representation';
+
+test('a static shorthand can be converted to individual corners', () => {
+ const conversion = getBorderRadiusConversion({
+ 'style.borderRadius': {status: 'static', codeValue: 12},
+ });
+ expect(conversion).toEqual({type: 'individual', value: 12});
+ if (conversion === null) {
+ throw new Error('Expected a border radius conversion');
+ }
+
+ const changes = getBorderRadiusConversionChanges(conversion);
+ expect(changes).toEqual([
+ {fieldKey: BORDER_RADIUS_SHORTHAND_KEY, value: undefined},
+ ...BORDER_RADIUS_LONGHAND_KEYS.map((fieldKey) => ({
+ fieldKey,
+ value: 12,
+ })),
+ ]);
+
+ const initial: CanUpdateSequencePropsResponse = {
+ canUpdate: true,
+ props: {
+ [BORDER_RADIUS_SHORTHAND_KEY]: {status: 'static', codeValue: 12},
+ ...Object.fromEntries(
+ BORDER_RADIUS_LONGHAND_KEYS.map((key) => [
+ key,
+ {status: 'static', codeValue: 12},
+ ]),
+ ),
+ },
+ effects: [],
+ };
+ const optimistic = changes.reduce<CanUpdateSequencePropsResponse>(
+ (previous, change) =>
+ optimisticUpdateForPropStatuses({
+ previous,
+ fieldKey: change.fieldKey,
+ value: change.value,
+ defaultValue: null,
+ schema: NoReactInternals.sequenceSchema,
+ }),
+ initial,
+ );
+ expect(optimistic.canUpdate).toBe(true);
+ if (optimistic.canUpdate) {
+ expect(optimistic.props[BORDER_RADIUS_SHORTHAND_KEY]).toEqual({
+ status: 'static',
+ codeValue: undefined,
+ });
+ }
+});
+
+test('an unauthored border radius can be converted to zero-valued corners', () => {
+ for (const props of [
+ undefined,
+ {},
+ {
+ [BORDER_RADIUS_SHORTHAND_KEY]: {
+ status: 'static' as const,
+ codeValue: undefined,
+ },
+ ...Object.fromEntries(
+ BORDER_RADIUS_LONGHAND_KEYS.map((key) => [
+ key,
+ {status: 'static' as const, codeValue: undefined},
+ ]),
+ ),
+ },
+ ]) {
+ const conversion = getBorderRadiusConversion(props);
+ expect(conversion).toEqual({type: 'individual', value: 0});
+ if (conversion === null) {
+ throw new Error('Expected an unauthored border radius conversion');
+ }
+
+ expect(getBorderRadiusConversionChanges(conversion)).toEqual([
+ {fieldKey: BORDER_RADIUS_SHORTHAND_KEY, value: undefined},
+ ...BORDER_RADIUS_LONGHAND_KEYS.map((fieldKey) => ({
+ fieldKey,
+ value: 0,
+ })),
+ ]);
+ }
+});
+
+test('four equal static longhands can be converted to a shorthand', () => {
+ expect(
+ getBorderRadiusConversion(
+ Object.fromEntries(
+ BORDER_RADIUS_LONGHAND_KEYS.map((key) => [
+ key,
+ {status: 'static', codeValue: 8},
+ ]),
+ ) as Record<string, CanUpdateSequencePropStatus>,
+ ),
+ ).toEqual({type: 'shorthand', value: 8});
+});
+
+test('static drag overrides determine the border radius conversion', () => {
+ expect(
+ getBorderRadiusConversion(
+ {
+ [BORDER_RADIUS_SHORTHAND_KEY]: {
+ status: 'static',
+ codeValue: 12,
+ },
+ },
+ {
+ [BORDER_RADIUS_SHORTHAND_KEY]: {type: 'static', value: 18},
+ },
+ ),
+ ).toEqual({type: 'individual', value: 18});
+
+ const unequalLonghands = Object.fromEntries(
+ BORDER_RADIUS_LONGHAND_KEYS.map((key, index) => [
+ key,
+ {status: 'static' as const, codeValue: index},
+ ]),
+ );
+ expect(
+ getBorderRadiusConversion(
+ unequalLonghands,
+ Object.fromEntries(
+ BORDER_RADIUS_LONGHAND_KEYS.map((key) => [
+ key,
+ {type: 'static' as const, value: 24},
+ ]),
+ ),
+ ),
+ ).toEqual({type: 'shorthand', value: 24});
+
+ expect(
+ getBorderRadiusConversion(
+ Object.fromEntries(
+ BORDER_RADIUS_LONGHAND_KEYS.map((key) => [
+ key,
+ {status: 'static' as const, codeValue: 8},
+ ]),
+ ),
+ {
+ [BORDER_RADIUS_LONGHAND_KEYS[0]]: {type: 'static', value: 9},
+ },
+ ),
+ ).toBe(null);
+});
+
+test('unequal, keyframed, and computed radii cannot be converted', () => {
+ expect(
+ getBorderRadiusConversion({
+ 'style.borderTopLeftRadius': {status: 'static', codeValue: 1},
+ 'style.borderTopRightRadius': {status: 'static', codeValue: 2},
+ 'style.borderBottomRightRadius': {status: 'static', codeValue: 1},
+ 'style.borderBottomLeftRadius': {status: 'static', codeValue: 2},
+ }),
+ ).toBe(null);
+ expect(
+ getBorderRadiusConversion({
+ 'style.borderRadius': {status: 'computed'},
+ }),
+ ).toBe(null);
+ expect(
+ getBorderRadiusConversion({
+ 'style.borderRadius': {
+ status: 'keyframed',
+ interpolationFunction: 'interpolate',
+ keyframes: [{frame: 0, value: 0}],
+ easing: [],
+ clamping: {left: 'extend', right: 'extend'},
+ posterize: undefined,
+ output: undefined,
+ },
+ }),
+ ).toBe(null);
+});
diff --git a/packages/studio/src/test/sequence-prop-reset-changes.test.ts b/packages/studio/src/test/sequence-prop-reset-changes.test.ts
new file mode 100644
index 0000000000..00e8402180
--- /dev/null
+++ b/packages/studio/src/test/sequence-prop-reset-changes.test.ts
@@ -0,0 +1,64 @@
+import {expect, test} from 'bun:test';
+import type {InteractivitySchema, SequencePropsSubscriptionKey} from 'remotion';
+import {getSequencePropResetChanges} from '../components/Timeline/get-sequence-prop-reset-changes';
+
+const nodePath: SequencePropsSubscriptionKey = {
+ absolutePath: '/project/src/Comp.tsx',
+ nodePath: ['body', 0],
+ sequenceKeys: [],
+ effectKeys: [],
+ videoConfigValues: null,
+};
+
+test('sequence prop resets expand style shorthands using each schema default', () => {
+ const schema = {
+ 'style.borderRadius': {
+ type: 'number',
+ default: 0,
+ hiddenFromList: false,
+ },
+ 'style.borderTopLeftRadius': {
+ type: 'number',
+ default: 1,
+ hiddenFromList: false,
+ },
+ 'style.borderTopRightRadius': {
+ type: 'number',
+ default: 2,
+ hiddenFromList: false,
+ },
+ 'style.borderBottomRightRadius': {
+ type: 'number',
+ default: 3,
+ hiddenFromList: false,
+ },
+ 'style.borderBottomLeftRadius': {
+ type: 'number',
+ default: 4,
+ hiddenFromList: false,
+ },
+ } satisfies InteractivitySchema;
+
+ const changes = getSequencePropResetChanges({
+ fileName: nodePath.absolutePath,
+ nodePath,
+ fieldKey: 'style.borderRadius',
+ value: 0,
+ defaultValue: '0',
+ schema,
+ });
+
+ expect(
+ changes.map(({fieldKey, value, defaultValue}) => ({
+ fieldKey,
+ value,
+ defaultValue,
+ })),
+ ).toEqual([
+ {fieldKey: 'style.borderRadius', value: 0, defaultValue: '0'},
+ {fieldKey: 'style.borderTopLeftRadius', value: 1, defaultValue: '1'},
+ {fieldKey: 'style.borderTopRightRadius', value: 2, defaultValue: '2'},
+ {fieldKey: 'style.borderBottomRightRadius', value: 3, defaultValue: '3'},
+ {fieldKey: 'style.borderBottomLeftRadius', value: 4, defaultValue: '4'},
+ ]);
+});
diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.ts
index 72cd6073ec..e0c24a56d4 100644
--- a/packages/studio/src/test/timeline-selection.test.ts
+++ b/packages/studio/src/test/timeline-selection.test.ts
@@ -5421,6 +5421,50 @@ test('Backspace reset targets stroke with the SVG default', () => {
]);
});
+test('Backspace reset targets border radius with the CSS default', () => {
+ const radiusNodePathInfo = makeNodePathInfo(
+ ['body', 0],
+ ['controls', 'style.borderRadius'],
+ );
+ const nodePath = radiusNodePathInfo.sequenceSubscriptionKey;
+ const propStatuses = {
+ [Internals.makeSequencePropsSubscriptionKey(nodePath)]: {
+ canUpdate: true,
+ props: {
+ 'style.borderRadius': {status: 'static', codeValue: 24},
+ },
+ effects: [],
+ },
+ } satisfies PropStatuses;
+
+ const resetTargets = getTimelinePropResetTargets({
+ selections: [
+ {
+ type: 'sequence-prop',
+ nodePathInfo: radiusNodePathInfo,
+ key: 'style.borderRadius',
+ },
+ ],
+ sequences: [
+ makeTimelineSequence({schema: NoReactInternals.sequenceSchema}),
+ ],
+ overrideIdsToNodePaths: {override: nodePath},
+ propStatuses,
+ });
+
+ expect(resetTargets).toEqual([
+ {
+ type: 'sequence-prop',
+ fileName: '/project/src/Comp.tsx',
+ nodePath,
+ fieldKey: 'style.borderRadius',
+ value: 0,
+ defaultValue: '0',
+ schema: NoReactInternals.sequenceSchema,
+ },
+ ]);
+});
+
test('Backspace reset targets selected keyframed sequence props', () => {
const schema = {
opacity: {type: 'number', default: 1, hiddenFromList: false},