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