Skip to content

Commit

Permalink
feat: Let them start by setting up shortcuts in the settings layer
Browse files Browse the repository at this point in the history
  • Loading branch information
ronparkdev committed Jul 9, 2024
1 parent c50752d commit efa5699
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/components/TargetEditLayer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export const TargetEditLayer: FC<Props> = ({ onChangeHighlight, onClose, default

const [isHotKeyListening, setHotKeyListening] = useState(false)

useEffect(() => {
keyRef.current?.focus()
}, [])

useEffect(() => {
onChangeHighlight(selector)
}, [selector])
Expand Down Expand Up @@ -80,6 +84,28 @@ export const TargetEditLayer: FC<Props> = ({ onChangeHighlight, onClose, default
)}
centered>
<Form layout="vertical">
<Form.Item
label={
<Flex vertical>
<Text strong style={{ fontSize: '16px' }}>
Shortcut Key
</Text>
<Paragraph>Press the keys you want to set as a shortcut for this item.</Paragraph>
</Flex>
}
style={{ marginBottom: 12 }}>
<Button
ref={keyRef}
onFocus={() => setHotKeyListening(true)}
onBlur={() => setHotKeyListening(false)}
type={isHotKeyListening ? 'primary' : undefined}>
{hotKey
? HotKeyService.getText(hotKey)
: isHotKeyListening
? 'Press keys to record shortcut'
: 'Click here to record shortcut'}
</Button>
</Form.Item>
<Form.Item
label={
<Flex vertical>
Expand Down Expand Up @@ -123,28 +149,6 @@ export const TargetEditLayer: FC<Props> = ({ onChangeHighlight, onClose, default
tooltip={{ open: false }}
/>
</Form.Item>
<Form.Item
label={
<Flex vertical>
<Text strong style={{ fontSize: '16px' }}>
Shortcut Key
</Text>
<Paragraph>Press the keys you want to set as a shortcut for this item.</Paragraph>
</Flex>
}
style={{ marginBottom: 12 }}>
<Button
ref={keyRef}
onFocus={() => setHotKeyListening(true)}
onBlur={() => setHotKeyListening(false)}
type={isHotKeyListening ? 'primary' : undefined}>
{hotKey
? HotKeyService.getText(hotKey)
: isHotKeyListening
? 'Press keys to record shortcut'
: 'Click here to record shortcut'}
</Button>
</Form.Item>
</Form>
</Modal>
)
Expand Down

0 comments on commit efa5699

Please sign in to comment.