mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
feat: retain side nav collapse/expand status between sessions (#714)
Stores the collapse vs expand status of the side navigation in local storage so it's carried across browser windows/sessions. Ref: HDX-1539
This commit is contained in:
parent
e884d85354
commit
957925131d
2 changed files with 11 additions and 5 deletions
5
.changeset/neat-scissors-hope.md
Normal file
5
.changeset/neat-scissors-hope.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@hyperdx/app": minor
|
||||
---
|
||||
|
||||
Stores the collapse vs expand status of the side navigation in local storage so it's carried across browser windows/sessions.
|
||||
|
|
@ -372,12 +372,13 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
|
|||
);
|
||||
const { width } = useWindowSize();
|
||||
|
||||
const [isPreferCollapsed, setIsPreferCollapsed] = useState<
|
||||
undefined | boolean
|
||||
>(undefined);
|
||||
const [isPreferCollapsed, setIsPreferCollapsed] = useLocalStorage<boolean>(
|
||||
'isNavCollapsed',
|
||||
false,
|
||||
);
|
||||
|
||||
const isSmallScreen = (width ?? 1000) < 900;
|
||||
const isCollapsed = isPreferCollapsed ?? isSmallScreen;
|
||||
const isCollapsed = isSmallScreen || isPreferCollapsed;
|
||||
|
||||
const navWidth = isCollapsed ? 50 : 230;
|
||||
|
||||
|
|
@ -595,7 +596,7 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
|
|||
className={isCollapsed ? 'mt-4' : ''}
|
||||
style={{ marginRight: -4 }}
|
||||
title="Collapse/Expand Navigation"
|
||||
onClick={() => setIsPreferCollapsed(v => !v)}
|
||||
onClick={() => setIsPreferCollapsed((v: boolean) => !v)}
|
||||
>
|
||||
<i className="bi bi-layout-sidebar"></i>
|
||||
</Button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue