feat: added windows support for shortcut

This commit is contained in:
wonderlandpark 2021-03-04 20:57:08 +09:00
parent 481c60ac09
commit cbc23a63a1
3 changed files with 29 additions and 3 deletions

View File

@ -0,0 +1,13 @@
import { ReactNode } from 'react'
const PlatformDisplay = ({ osx, children }:PlatformDisplayProps): JSX.Element => {
const isOSX = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)
return <>{isOSX ? osx ?? children : children}</>
}
interface PlatformDisplayProps {
osx?: ReactNode
children: ReactNode
}
export default PlatformDisplay

View File

@ -24,6 +24,7 @@ import 'core-js/es/map'
import '../app.css'
import '../github-markdown.css'
import '@fortawesome/fontawesome-free/css/all.css'
import PlatformDisplay from '@components/PlatformDisplay'
init()
@ -83,11 +84,20 @@ export default function App({ Component, pageProps, err }: KoreanbotsProps): JSX
<ul>
<li className='pt-2'>
<h4 className='text-gray-500 dark:text-gray-400 text-xs'> </h4>
<kbd>CMD</kbd> <kbd>/</kbd>
<kbd>
<PlatformDisplay osx='CMD'>
Ctrl
</PlatformDisplay>
</kbd> <kbd>/</kbd>
</li>
<li className='pt-2'>
<h4 className='text-gray-500 dark:text-gray-400 text-xs'> </h4>
<kbd>CMD</kbd> <kbd>K</kbd>
<kbd>
<PlatformDisplay osx='CMD'>
Ctrl
</PlatformDisplay>
</kbd>
<kbd>Shift</kbd> <kbd>D</kbd>
</li>
</ul>
</div>
@ -95,11 +105,13 @@ export default function App({ Component, pageProps, err }: KoreanbotsProps): JSX
<GlobalHotKeys keyMap={shortcutKeyMap} handlers={{
SHORTCUT_HELP: () => {
setShortcutModal(value => !value)
return
},
CHANGE_THEME: () => {
const overwrite = (localStorage.theme || systemTheme()) === 'dark' ? 'light' : 'dark'
setTheme(overwrite)
localStorage.setItem('theme', overwrite)
return
}
}} />
</div>

View File

@ -216,7 +216,8 @@ export const KoreanbotsEmoji = [{
}]
export const shortcutKeyMap: KeyMap = {
CHANGE_THEME: 'command+k'
SHORTCUT_HELP: ['command+/', 'ctrl+/'],
CHANGE_THEME: ['command+shift+d', 'ctrl+shift+d']
}
export const ErrorText = {