MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / useBreakpoint

Function useBreakpoint

apps/start/src/hooks/use-breakpoint.ts:16–32  ·  view source on GitHub ↗
(breakpointKey: K)

Source from the content-addressed store, hash-verified

14type ScreensConfig = typeof breakpoints;
15
16export function useBreakpoint<K extends string>(breakpointKey: K) {
17 const breakpointValue = breakpoints[breakpointKey as keyof ScreensConfig];
18 const bool = useMediaQuery({
19 query: `(max-width: ${breakpointValue as string})`,
20 });
21 const capitalizedKey =
22 breakpointKey[0]?.toUpperCase() + breakpointKey.substring(1);
23
24 type KeyAbove = `isAbove${Capitalize<K>}`;
25 type KeyBelow = `isBelow${Capitalize<K>}`;
26
27 return {
28 [breakpointKey]: Number(String(breakpointValue).replace(/[^0-9]/g, '')),
29 [`isAbove${capitalizedKey}`]: !bool,
30 [`isBelow${capitalizedKey}`]: bool,
31 } as Record<K, number> & Record<KeyAbove | KeyBelow, boolean>;
32}

Callers 1

DateRangerPickerFunction · 0.90

Calls 2

useMediaQueryFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected