MCPcopy
hub / github.com/coder/mux / resolveInitialResizableSidebarWidth

Function resolveInitialResizableSidebarWidth

src/browser/hooks/useResizableSidebar.ts:59–78  ·  view source on GitHub ↗
(args: {
  storedValue: string | null;
  defaultWidth: number;
  minWidth: number;
  maxWidth: number;
})

Source from the content-addressed store, hash-verified

57}
58
59export function resolveInitialResizableSidebarWidth(args: {
60 storedValue: string | null;
61 defaultWidth: number;
62 minWidth: number;
63 maxWidth: number;
64}): number {
65 const effectiveMaxWidth = Math.max(args.minWidth, args.maxWidth);
66 const fallbackWidth = Math.max(args.minWidth, Math.min(effectiveMaxWidth, args.defaultWidth));
67
68 if (!args.storedValue) {
69 return fallbackWidth;
70 }
71
72 const parsedWidth = Number.parseInt(args.storedValue, 10);
73 if (!Number.isFinite(parsedWidth)) {
74 return fallbackWidth;
75 }
76
77 return Math.max(args.minWidth, Math.min(effectiveMaxWidth, parsedWidth));
78}
79
80export function useResizableSidebar({
81 enabled,

Callers 2

useResizableSidebarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected