feat: add keyboard shortcut help modal triggered by ? key
This commit is contained in:
13
src/App.tsx
13
src/App.tsx
@@ -8,6 +8,7 @@ import { BoardView } from "@/components/board/BoardView";
|
||||
import { CommandPalette } from "@/components/command-palette/CommandPalette";
|
||||
import { SettingsDialog } from "@/components/settings/SettingsDialog";
|
||||
import { ToastContainer } from "@/components/toast/ToastContainer";
|
||||
import { ShortcutHelpModal } from "@/components/shortcuts/ShortcutHelpModal";
|
||||
import { useKeyboardShortcuts } from "@/hooks/useKeyboardShortcuts";
|
||||
|
||||
export default function App() {
|
||||
@@ -16,6 +17,7 @@ export default function App() {
|
||||
const view = useAppStore((s) => s.view);
|
||||
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const [shortcutHelpOpen, setShortcutHelpOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
init();
|
||||
@@ -42,6 +44,16 @@ export default function App() {
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
function handleOpenShortcutHelp() {
|
||||
setShortcutHelpOpen(true);
|
||||
}
|
||||
document.addEventListener("open-shortcut-help", handleOpenShortcutHelp);
|
||||
return () => {
|
||||
document.removeEventListener("open-shortcut-help", handleOpenShortcutHelp);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleOpenSettings = useCallback(() => {
|
||||
setSettingsOpen(true);
|
||||
}, []);
|
||||
@@ -66,6 +78,7 @@ export default function App() {
|
||||
<CommandPalette onOpenSettings={handleOpenSettings} />
|
||||
<SettingsDialog open={settingsOpen} onOpenChange={setSettingsOpen} />
|
||||
<ToastContainer />
|
||||
<ShortcutHelpModal open={shortcutHelpOpen} onOpenChange={setShortcutHelpOpen} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user