π₯ Make videos programmatically with React
Show Shift icon in keyboard shortcuts
JonnyBurgere9827997c6ce
diff --git a/packages/studio/src/components/ActionTooltip.tsx b/packages/studio/src/components/ActionTooltip.tsxindex 7b773f2f37..ba1e4ebefb 100644--- a/packages/studio/src/components/ActionTooltip.tsx+++ b/packages/studio/src/components/ActionTooltip.tsx@@ -6,12 +6,9 @@ import React, {useState,} from 'react';import {createPortal} from 'react-dom';-import {- TIMELINE_BACKGROUND_COLOR,- WHITE_ALPHA_10,- WHITE_ALPHA_90,-} from '../helpers/colors';+import {TIMELINE_BACKGROUND_COLOR, WHITE_ALPHA_90} from '../helpers/colors';import {useZIndex} from '../state/z-index';+import {KeyboardShortcutLabel} from './KeyboardShortcutLabel';import {getPortal} from './Menu/portals';import {SHADOW_TOWARDS_TOP} from './Menu/styles';@@ -43,11 +40,8 @@ const labelStyle: React.CSSProperties = {const shortcutStyle: React.CSSProperties = {...labelStyle,- backgroundColor: WHITE_ALPHA_10,- borderRadius: 3,- padding: '0 4px',- minWidth: 16,- textAlign: 'center',+ backgroundColor: 'transparent',+ opacity: 0.6,whiteSpace: 'nowrap',flexShrink: 0,};@@ -239,7 +233,11 @@ export const ActionTooltip: React.FC<{}}><span style={labelStyle}>{label}</span>- {shortcut ? <kbd style={shortcutStyle}>{shortcut}</kbd> : null}+ {shortcut ? (+ <kbd style={shortcutStyle}>+ <KeyboardShortcutLabel shortcut={shortcut} style={null} />+ </kbd>+ ) : null}</div>,getPortal(currentZIndex),)diff --git a/packages/studio/src/components/KeyboardShortcutLabel.tsx b/packages/studio/src/components/KeyboardShortcutLabel.tsxnew file mode 100644index 0000000000..b4acf78a67--- /dev/null+++ b/packages/studio/src/components/KeyboardShortcutLabel.tsx@@ -0,0 +1,43 @@+import React from 'react';+import {ShiftIcon} from '../icons/keys';++const shortcutLabel: React.CSSProperties = {+ alignItems: 'baseline',+ display: 'inline-flex',+ font: 'inherit',+ whiteSpace: 'nowrap',+};++export const KeyboardShortcutLabel: React.FC<{+ readonly shortcut: string;+ readonly style: React.CSSProperties | null;+}> = ({shortcut, style}) => {+ const visualShortcut = shortcut.replaceAll('β+', 'β');+ const parts: React.ReactNode[] = [];+ let previousEnd = 0;+ for (const match of visualShortcut.matchAll(/\bShift(\+)?/g)) {+ const matchStart = match.index;+ parts.push(visualShortcut.slice(previousEnd, matchStart));+ parts.push(+ <span+ key={`shift-${matchStart}`}+ style={{+ alignItems: 'baseline',+ display: 'inline-flex',+ marginRight: match[1] ? 1 : 0,+ }}+ >+ <ShiftIcon color={style?.color ?? null} />+ </span>,+ );+ previousEnd = matchStart + match[0].length;+ }++ parts.push(visualShortcut.slice(previousEnd));++ return (+ <span aria-label={shortcut} style={{...shortcutLabel, ...style}}>+ {parts}+ </span>+ );+};diff --git a/packages/studio/src/components/KeyboardShortcutsSettings.tsx b/packages/studio/src/components/KeyboardShortcutsSettings.tsxindex 1642122122..a611454193 100644--- a/packages/studio/src/components/KeyboardShortcutsSettings.tsx+++ b/packages/studio/src/components/KeyboardShortcutsSettings.tsx@@ -37,6 +37,7 @@ import {keyboardShortcutsOverlap,shortcutFromKeyboardEvent,} from './keyboard-shortcuts';+import {KeyboardShortcutLabel} from './KeyboardShortcutLabel';import {Spacing} from './layout';import type {ComboboxValue} from './NewComposition/ComboBox';import {ValidationMessage} from './NewComposition/ValidationMessage';@@ -173,7 +174,7 @@ const ShortcutChords: React.FC<{<span style={chord}>{keys.map((keyboardKey) => (<kbd key={keyboardKey} style={key}>- {keyboardKey}+ <KeyboardShortcutLabel shortcut={keyboardKey} style={null} /></kbd>))}</span>diff --git a/packages/studio/src/components/Menu/MenuSubItem.tsx b/packages/studio/src/components/Menu/MenuSubItem.tsxindex e80984b515..844fc38bd3 100644--- a/packages/studio/src/components/Menu/MenuSubItem.tsx+++ b/packages/studio/src/components/Menu/MenuSubItem.tsx@@ -7,6 +7,7 @@ import {useMobileLayout} from '../../helpers/mobile-layout';import {areKeyboardShortcutsDisabled} from '../../helpers/use-keybinding';import {CaretRight} from '../../icons/caret';import {useZIndex} from '../../state/z-index';+import {KeyboardShortcutLabel} from '../KeyboardShortcutLabel';import {Row, Spacing} from '../layout';import type {SubMenu} from '../NewComposition/ComboBox';import {MENU_ITEM_CLASSNAME} from './is-menu-item';@@ -205,7 +206,7 @@ export const MenuSubItem: React.FC<{<div style={labelStyle}>{label}</div> <Spacing x={2} />{subMenu ? <CaretRight /> : null}{keyHint && !areKeyboardShortcutsDisabled() ? (- <span style={keyHintCss}>{keyHint}</span>+ <KeyboardShortcutLabel shortcut={keyHint} style={keyHintCss} />) : null}{portalStyle && subMenu? ReactDOM.createPortal(diff --git a/packages/studio/src/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.tsx b/packages/studio/src/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.tsxindex 1f03edff99..c7dd699379 100644--- a/packages/studio/src/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.tsx+++ b/packages/studio/src/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.tsx@@ -17,6 +17,7 @@ import {SetSelectedModalContext} from '../../state/modals';import {ActionTooltip} from '../ActionTooltip';import type {RenderInlineAction} from '../InlineAction';import {InlineDropdown} from '../InlineDropdown';+import {KeyboardShortcutLabel} from '../KeyboardShortcutLabel';import type {ComboboxValue} from '../NewComposition/ComboBox';import type {QuickSwitcherMode} from './NoResults';@@ -97,7 +98,10 @@ export const ExplorerQuickSwitcherTrigger: React.FC<{{showShortcut &&!areKeyboardShortcutsDisabled() &&quickSwitcherShortcut !== '' ? (- <span style={shortcutLabel}>{quickSwitcherShortcut}</span>+ <KeyboardShortcutLabel+ shortcut={quickSwitcherShortcut}+ style={shortcutLabel}+ />) : null}</button><ActionTooltipdiff --git a/packages/studio/src/icons/keys.tsx b/packages/studio/src/icons/keys.tsxindex 49f92ed532..462f201511 100644--- a/packages/studio/src/icons/keys.tsx+++ b/packages/studio/src/icons/keys.tsx@@ -6,12 +6,30 @@ const iconStyle: React.CSSProperties = {display: 'inline',};-export const ShiftIcon: React.FC = () => {+const shiftIconStyle: React.CSSProperties = {+ display: 'inline-block',+ height: 12,+ verticalAlign: 'baseline',+ width: 12,+};++export const ShiftIcon: React.FC<{+ readonly color: string | null;+}> = ({color}) => {return (- <svg style={iconStyle} viewBox="0 0 448 512">+ <svg+ aria-hidden="true"+ focusable="false"+ style={shiftIconStyle}+ viewBox="0 0 12 12"+ ><path- fill={CURRENT_COLOR}- d="M48.048 304h73.798v128c0 26.51 21.49 48 48 48h108.308c26.51 0 48-21.49 48-48V304h73.789c42.638 0 64.151-51.731 33.941-81.941l-175.943-176c-18.745-18.745-49.137-18.746-67.882 0l-175.952 176C-16.042 252.208 5.325 304 48.048 304zM224 80l176 176H278.154v176H169.846V256H48L224 80z"+ d="M4.5 11.5V8.5H1.5L6 3.5L10.5 8.5H7.5V11.5"+ fill="none"+ stroke={color ?? CURRENT_COLOR}+ strokeLinecap="square"+ strokeLinejoin="miter"+ strokeWidth="1"/></svg>);