/* @flow */ import Lozenge from '@atlaskit/lozenge'; import React, { Component } from 'react'; import { Dialog } from '../../base/dialog'; import { translate } from '../../base/i18n'; /** * The type of the React {@code Component} props of * {@link KeyboardShortcutsDialog}. */ type Props = { /** * A Map with keyboard keys as keys and translation keys as values. */ shortcutDescriptions: Object, /** * Invoked to obtain translated strings. */ t: Function }; /** * Implements a React {@link Component} which displays a dialog describing * registered keyboard shortcuts. * * @extends Component */ class KeyboardShortcutsDialog extends Component { /** * Implements React's {@link Component#render()}. * * @inheritdoc * @returns {ReactElement} */ render() { const shortcuts = Array.from(this.props.shortcutDescriptions) .map(description => this._renderShortcutsListItem(...description)); return (
    { shortcuts }
); } /** * Creates a {@code ReactElement} for describing a single keyboard shortcut. * * @param {string} keyboardKey - The keyboard key that triggers an action. * @param {string} translationKey - A description of what the action does. * @private * @returns {ReactElement} */ _renderShortcutsListItem(keyboardKey, translationKey) { return (
  • { this.props.t(translationKey) } { keyboardKey }
  • ); } } export default translate(KeyboardShortcutsDialog);