2017-03-28 22:45:23 +00:00
|
|
|
import React, {PropTypes, PureComponent} from 'react';
|
2017-05-26 18:17:35 +00:00
|
|
|
import {ALT_SYM, CTRL_SYM, isMac, joinHotKeys, MOD_SYM, SHIFT_SYM} from '../../common/constants';
|
2017-03-28 22:45:23 +00:00
|
|
|
|
|
|
|
class Hotkey extends PureComponent {
|
|
|
|
render () {
|
2017-05-26 18:17:35 +00:00
|
|
|
const {char, shift, alt, ctrl, className} = this.props;
|
2017-03-28 22:45:23 +00:00
|
|
|
const chars = [ ];
|
|
|
|
|
|
|
|
alt && chars.push(ALT_SYM);
|
|
|
|
shift && chars.push(SHIFT_SYM);
|
2017-05-26 18:17:35 +00:00
|
|
|
ctrl && chars.push(CTRL_SYM);
|
|
|
|
!ctrl && chars.push(MOD_SYM);
|
2017-03-28 22:45:23 +00:00
|
|
|
chars.push(char);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<span className={`${isMac() ? 'font-normal' : ''} ${className}`}>
|
|
|
|
{joinHotKeys(chars)}
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Hotkey.propTypes = {
|
|
|
|
char: PropTypes.string.isRequired,
|
|
|
|
|
|
|
|
// Optional
|
|
|
|
alt: PropTypes.bool,
|
|
|
|
shift: PropTypes.bool,
|
2017-05-26 18:17:35 +00:00
|
|
|
ctrl: PropTypes.bool,
|
2017-03-28 22:45:23 +00:00
|
|
|
className: PropTypes.string
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Hotkey;
|