feat: structure 2
This commit is contained in:
55
frontend/src/hooks/useKeyboardShortcuts.ts
Normal file
55
frontend/src/hooks/useKeyboardShortcuts.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { useHotkeys } from 'react-hotkeys-hook'
|
||||
|
||||
interface KeyboardShortcutsProps {
|
||||
onToggleLeftSidebar: () => void
|
||||
onToggleRightSidebar: () => void
|
||||
}
|
||||
|
||||
export function useKeyboardShortcuts(props: KeyboardShortcutsProps) {
|
||||
const { onToggleLeftSidebar, onToggleRightSidebar } = props
|
||||
|
||||
// Toggle sidebars
|
||||
useHotkeys('tab', (e) => {
|
||||
e.preventDefault()
|
||||
onToggleLeftSidebar()
|
||||
})
|
||||
|
||||
useHotkeys('i', (e) => {
|
||||
e.preventDefault()
|
||||
onToggleRightSidebar()
|
||||
})
|
||||
|
||||
// Navigation shortcuts
|
||||
useHotkeys('g', () => {
|
||||
// Go to grid view
|
||||
console.log('Grid view')
|
||||
})
|
||||
|
||||
useHotkeys('e', () => {
|
||||
// Go to loupe view
|
||||
console.log('Loupe view')
|
||||
})
|
||||
|
||||
// Rating shortcuts
|
||||
useHotkeys('1,2,3,4,5', (_e, handler) => {
|
||||
const rating = parseInt(handler.keys![0])
|
||||
console.log('Set rating:', rating)
|
||||
})
|
||||
|
||||
useHotkeys('0', () => {
|
||||
console.log('Remove rating')
|
||||
})
|
||||
|
||||
// Flag shortcuts
|
||||
useHotkeys('p', () => {
|
||||
console.log('Pick photo')
|
||||
})
|
||||
|
||||
useHotkeys('x', () => {
|
||||
console.log('Reject photo')
|
||||
})
|
||||
|
||||
useHotkeys('u', () => {
|
||||
console.log('Unflag photo')
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user