π₯ Make videos programmatically with React
import React, {useMemo} from 'react';
import {isMac} from '../../helpers/is-mac';
import {areKeyboardShortcutsDisabled} from '../../helpers/use-keybinding';
export const cmdOrCtrlCharacter = isMac ? 'β' : 'Ctrl';
const container: React.CSSProperties = {
display: 'inline-block',
marginLeft: 3,
opacity: 0.6,
verticalAlign: 'middle',
fontSize: 'inherit',
};
export const ShortcutHint: React.FC<{
readonly keyToPress: string;
readonly cmdOrCtrl: boolean;
}> = ({keyToPress, cmdOrCtrl}) => {
const style = useMemo((): React.CSSProperties => {
if (keyToPress === 'β΅') {
return {
display: 'inline-block',
transform: `translateY(2px)`,
fontSize: 'inherit',
};
}
return {
fontSize: 'inherit',
};
}, [keyToPress]);
if (areKeyboardShortcutsDisabled()) {
return null;
}
return (
<span style={container}>
{cmdOrCtrl ? `${cmdOrCtrlCharacter}${isMac ? '' : '+'}` : ''}
<span style={style}>{keyToPress.toUpperCase()}</span>
</span>
);
};