mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-15 13:43:39 +01:00
14 lines
515 B
TypeScript
14 lines
515 B
TypeScript
import { useCallback, useMemo } from 'react';
|
|
import { useLocalStorage } from 'react-use';
|
|
import { useActiveWorkspace } from './useActiveWorkspace';
|
|
|
|
export function useSidebarWidth() {
|
|
const activeWorkspace = useActiveWorkspace();
|
|
const [width, setWidth] = useLocalStorage<number>(
|
|
`sidebar_width::${activeWorkspace?.id ?? 'n/a'}`,
|
|
250,
|
|
);
|
|
const resetWidth = useCallback(() => setWidth(250), [setWidth]);
|
|
return useMemo(() => ({ width, setWidth, resetWidth }), [width, setWidth, resetWidth]);
|
|
}
|