import * as React from 'react'; import { Grid, GridItem } from '@patternfly/react-core'; import { ShortcutCommand } from './ShortcutCommand'; import './KeyboardShortcutHint.scss'; export interface ShortcutEntry { keys: string; macKeys?: string; description: string; } interface KeyboardShortcutHintProps { shortcuts: ShortcutEntry[]; title?: string; helperText?: string; } const isMac = (): boolean => { if (typeof navigator === 'undefined') return false; return /Mac|iPhone|iPad|iPod/i.test(navigator.userAgent); }; export const KeyboardShortcutHint: React.FC = ({ shortcuts, title, helperText, }) => { return (
{title &&
{title}
} {shortcuts.map((shortcut) => { const displayKeys = isMac() && shortcut.macKeys ? shortcut.macKeys : shortcut.keys; return ( {shortcut.description} ); })} {helperText &&
{helperText}
}
); };