Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Align shortcut settings columns

JonnyBurgeraf31404b6cda
diff --git a/packages/example/e2e/studio.test.mts b/packages/example/e2e/studio.test.mts
index f0e5ac9e6a..d66d78a6ad 100644
--- a/packages/example/e2e/studio.test.mts
+++ b/packages/example/e2e/studio.test.mts
@@ -1842,6 +1842,27 @@ test.describe('visual mode', () => {
await expect(
dialog.getByRole('list', {name: 'Playback', exact: true}),
).toBeVisible();
+ const fixedShortcutRow = dialog
+ .getByRole('listitem')
+ .filter({hasText: '1 second back'});
+ const fixedShortcutBox = await fixedShortcutRow
+ .locator('kbd')
+ .last()
+ .boundingBox();
+ const fixedLabelBox = await fixedShortcutRow
+ .getByText('Fixed', {exact: true})
+ .boundingBox();
+ if (fixedShortcutBox === null || fixedLabelBox === null) {
+ throw new Error('Expected shortcut and Fixed label to have boxes');
+ }
+
+ expect(
+ Math.abs(
+ fixedShortcutBox.y +
+ fixedShortcutBox.height / 2 -
+ (fixedLabelBox.y + fixedLabelBox.height / 2),
+ ),
+ ).toBeLessThan(1);
const playPauseShortcut = dialog.getByRole('button', {
name: 'Change shortcut for Play / Pause',
});
diff --git a/packages/studio/src/components/KeyboardShortcutsSettings.tsx b/packages/studio/src/components/KeyboardShortcutsSettings.tsx
index 0a8b7bf258..b4744b2362 100644
--- a/packages/studio/src/components/KeyboardShortcutsSettings.tsx
+++ b/packages/studio/src/components/KeyboardShortcutsSettings.tsx
@@ -51,9 +51,9 @@ const shortcutSectionTitle: React.CSSProperties = {
const shortcutRow: React.CSSProperties = {
alignItems: 'center',
borderBottom: BORDER_WHITE_ALPHA_12,
- display: 'flex',
- gap: 16,
- justifyContent: 'space-between',
+ columnGap: 12,
+ display: 'grid',
+ gridTemplateColumns: 'minmax(0, 1fr) minmax(76px, max-content) 94px',
margin: '0 16px',
minHeight: 42,
};
@@ -70,17 +70,26 @@ const actionName: React.CSSProperties = {
minWidth: 0,
};
-const actions: React.CSSProperties = {
+const shortcutCell: React.CSSProperties = {
+ alignItems: 'center',
+ display: 'flex',
+ justifyContent: 'flex-end',
+ minWidth: 0,
+};
+
+const actionCell: React.CSSProperties = {
alignItems: 'center',
display: 'flex',
- flexShrink: 0,
gap: 6,
+ justifyContent: 'flex-start',
+ whiteSpace: 'nowrap',
};
const chords: React.CSSProperties = {
alignItems: 'center',
display: 'flex',
gap: 6,
+ whiteSpace: 'nowrap',
};
const chord: React.CSSProperties = {
@@ -123,6 +132,12 @@ const smallButton: React.CSSProperties = {
padding: '4px',
};
+const fixedLabel: React.CSSProperties = {
+ color: LIGHT_TEXT,
+ fontSize: 11,
+ padding: '4px',
+};
+
const alternative: React.CSSProperties = {
color: LIGHT_TEXT,
fontSize: 11,
@@ -294,20 +309,25 @@ export const KeyboardShortcutsSettings: React.FC = () => {
}
>
<span style={actionName}>{shortcut.action}</span>
- <span style={actions}>
- {shortcut.actionId === null || isBrowserStudio ? (
- <span title={shortcut.fixedReason}>
+ {shortcut.actionId === null || isBrowserStudio ? (
+ <>
+ <span style={shortcutCell}>
<ShortcutChords values={shortcutValues} />
+ </span>
+ <span style={actionCell}>
{shortcut.actionId === null ? (
- <span style={smallButton}>Fixed</span>
+ <span style={fixedLabel} title={shortcut.fixedReason}>
+ Fixed
+ </span>
) : null}
</span>
- ) : (
- <>
+ </>
+ ) : (
+ <>
+ <span style={shortcutCell}>
<button
type="button"
style={chordButton}
- title="Click, then press a new shortcut"
aria-label={`Change shortcut for ${shortcut.action}`}
onClick={() => {
setError(null);
@@ -360,6 +380,8 @@ export const KeyboardShortcutsSettings: React.FC = () => {
<ShortcutChords values={shortcutValues} />
)}
</button>
+ </span>
+ <span style={actionCell}>
{configured ? (
<button
type="button"
@@ -393,9 +415,9 @@ export const KeyboardShortcutsSettings: React.FC = () => {
Disable
</button>
) : null}
- </>
- )}
- </span>
+ </span>
+ </>
+ )}
</div>
);
})}