feat: redesign navs
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Consumers use pathname to pick the active slot for title (save status, Save) and Edit/View menus (undo, redo, etc.).
|
||||
*/
|
||||
|
||||
import React, { createContext, useCallback, useContext, useRef, useState } from 'react'
|
||||
import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react'
|
||||
import { useLocation, useParams } from 'react-router-dom'
|
||||
import type { SaveStatus } from '@/app/canvas/useCanvasGraph'
|
||||
import {
|
||||
@@ -130,6 +130,22 @@ export function RecollectionActionsProvider({ children }: { children: React.Reac
|
||||
setLogosSlotState(() => slot)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const onKeyDown = (ev: KeyboardEvent) => {
|
||||
const mod = ev.ctrlKey || ev.metaKey
|
||||
if (mod && ev.key.toLowerCase() === 's') {
|
||||
const slot = activeSlot
|
||||
if (slot?.onSave && slot?.canSave) {
|
||||
ev.preventDefault()
|
||||
ev.stopPropagation()
|
||||
slot.onSave()
|
||||
}
|
||||
}
|
||||
}
|
||||
window.addEventListener('keydown', onKeyDown, true)
|
||||
return () => window.removeEventListener('keydown', onKeyDown, true)
|
||||
}, [activeSlot])
|
||||
|
||||
const onExport = useCallback(() => {
|
||||
if (!recollectionId) return
|
||||
const graph = getGraph(recollectionId)
|
||||
|
||||
Reference in New Issue
Block a user