mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 08:43:48 +03:00
feat: add keyboard control for sidebar size adjustment
This commit is contained in:
parent
ba7e4c979d
commit
e0ec79b105
@ -68,6 +68,22 @@ export function Sidebar() {
|
|||||||
sidebarRef.current?.clientWidth || SIDEBAR_INITIAL_WIDTH;
|
sidebarRef.current?.clientWidth || SIDEBAR_INITIAL_WIDTH;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleKeyDown: React.KeyboardEventHandler<HTMLButtonElement> = (
|
||||||
|
event
|
||||||
|
) => {
|
||||||
|
const { key } = event;
|
||||||
|
|
||||||
|
if (key === "ArrowRight") {
|
||||||
|
setSidebarWidth((prevWidth) =>
|
||||||
|
prevWidth < SIDEBAR_INITIAL_WIDTH ? SIDEBAR_INITIAL_WIDTH : SIDEBAR_MAX_WIDTH
|
||||||
|
);
|
||||||
|
} else if (key === "ArrowLeft") {
|
||||||
|
setSidebarWidth((prevWidth) =>
|
||||||
|
prevWidth > SIDEBAR_INITIAL_WIDTH ? SIDEBAR_INITIAL_WIDTH : SIDEBAR_MIN_WIDTH
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleFilter: React.ChangeEventHandler<HTMLInputElement> = (event) => {
|
const handleFilter: React.ChangeEventHandler<HTMLInputElement> = (event) => {
|
||||||
setFilteredLibrary(
|
setFilteredLibrary(
|
||||||
sortedLibrary.filter((game) =>
|
sortedLibrary.filter((game) =>
|
||||||
@ -246,6 +262,7 @@ export function Sidebar() {
|
|||||||
type="button"
|
type="button"
|
||||||
className={styles.handle}
|
className={styles.handle}
|
||||||
onMouseDown={handleMouseDown}
|
onMouseDown={handleMouseDown}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user