Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle Side menu with keyboard shortcuts #81

Merged
merged 9 commits into from
Jun 30, 2024
87 changes: 3 additions & 84 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions src/frontend/_layouts/app/NavigationSideBar/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useSessionStorage } from "react-use";
import { useAppConfiguration } from "frontend/hooks/configuration/configuration.store";
import { CRUD_CONFIG_NOT_FOUND } from "frontend/lib/crud-config";
import { typescriptSafeObjectDotEntries } from "shared/lib/objects";
import { useCallback, useEffect } from "react";
import {
NAVIGATION_MENU_ENDPOINT,
SIDE_BAR_WIDTH_VARIATIONS,
Expand Down Expand Up @@ -49,6 +50,22 @@ export function SideBar({ isFullWidth, setIsFullWidth }: IProps) {
setActiveItem$1(newValueFiltered);
};

const handleKeyPress = useCallback(
(event: KeyboardEvent) => {
if ((event.ctrlKey || event.metaKey) && event.keyCode === 66) {
setIsFullWidth(!isFullWidth);
}
},
[isFullWidth]
);

useEffect(() => {
document.addEventListener("keydown", handleKeyPress);

return () => {
document.removeEventListener("keydown", handleKeyPress);
};
}, [handleKeyPress]);
thrownullexception marked this conversation as resolved.
Show resolved Hide resolved
return (
<div
className="fixed transition-all min-h-dvh"
Expand Down
Loading