mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-21 01:53:57 +00:00
feat: added functionality to collapse/expand pinned list in user profile
This commit is contained in:
30
src/renderer/src/hooks/use-section-collapse.ts
Normal file
30
src/renderer/src/hooks/use-section-collapse.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useState, useCallback } from "react";
|
||||
|
||||
interface SectionCollapseState {
|
||||
pinned: boolean;
|
||||
library: boolean;
|
||||
}
|
||||
|
||||
export function useSectionCollapse() {
|
||||
const [collapseState, setCollapseState] = useState<SectionCollapseState>({
|
||||
pinned: false,
|
||||
library: false,
|
||||
});
|
||||
|
||||
const toggleSection = useCallback(
|
||||
(section: keyof SectionCollapseState) => {
|
||||
setCollapseState(prevState => ({
|
||||
...prevState,
|
||||
[section]: !prevState[section],
|
||||
}));
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
return {
|
||||
collapseState,
|
||||
toggleSection,
|
||||
isPinnedCollapsed: collapseState.pinned,
|
||||
isLibraryCollapsed: collapseState.library,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user