-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25d3f7d
commit dba4289
Showing
7 changed files
with
100 additions
and
20 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/components/molecules/HotkeyLabel/HotkeyLabel.styled.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Command = styled.div` | ||
background: #30716e; | ||
padding: 2px 4px; | ||
border-radius: 4px; | ||
font-size: 12px; | ||
font-weight: 700; | ||
`; | ||
|
||
export const CommandsContainer = styled.div` | ||
display: flex; | ||
gap: 5px; | ||
`; | ||
|
||
export const HotkeyLabelContainer = styled.div` | ||
display: flex; | ||
gap: 10px; | ||
align-items: center; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import hotkeys, {Hotkey} from '@constants/hotkeys'; | ||
|
||
import {defineHotkey} from '@utils/defineHotkey'; | ||
|
||
import * as S from './HotkeyLabel.styled'; | ||
|
||
interface IProps { | ||
name: Hotkey; | ||
text: string; | ||
} | ||
|
||
const HotkeyLabel: React.FC<IProps> = props => { | ||
const {name, text} = props; | ||
|
||
const hotkey = hotkeys[name]; | ||
|
||
if (!hotkey) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<S.HotkeyLabelContainer> | ||
{text} | ||
|
||
<S.CommandsContainer> | ||
{defineHotkey(hotkey.key) | ||
.split(',') | ||
.filter((item: string) => item) | ||
.map(command => | ||
command | ||
.split('+') | ||
.map(keyboardKey => ( | ||
<S.Command key={`${command}-${keyboardKey}`}> | ||
{keyboardKey === 'command' | ||
? 'Cmd' | ||
: keyboardKey.charAt(0).toUpperCase() + keyboardKey.slice(1) || '+'} | ||
</S.Command> | ||
)) | ||
)} | ||
</S.CommandsContainer> | ||
</S.HotkeyLabelContainer> | ||
); | ||
}; | ||
|
||
export default HotkeyLabel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {default} from './HotkeyLabel'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters