INNER CODE UNIT · TypeScript
getBreakpointFromWidth
libnyanpasu/clash-nyanpasu · frontend/hooks/src/index.ts:56
const getBreakpointFromWidth = (width: number): Breakpoint => {
for (let i = BREAKPOINT_ORDER.length - 1; i >= 0; i--) {
const breakpoint = BREAKPOINT_ORDER[i]
if (width >= BREAKPOINT_VALUES[breakpoint]) {
return breakpoint
}
}
return 'xs'
}
const resolveBreakpointValue = <T>(
breakpoint: Breakpoint,
values: BreakpointValues<T>,
defaultValue?: T,
): T => {
const value = values[breakpoint]