UNPKG

@bianic-ui/media-query

Version:

A React hook for changing properties or visibility of a component based on css media query

26 lines (21 loc) 621 B
import { breakpoints } from "@bianic-ui/utils"; export function getClosestValue(values, breakpoint) { var index = Object.keys(values).indexOf(breakpoint); if (index !== -1) return values[breakpoint]; var stopIndex = breakpoints.indexOf(breakpoint); var hasFound = false; while (stopIndex >= 0 && !hasFound) { var key = breakpoints[stopIndex]; if (values[key] != null) { index = stopIndex; hasFound = true; } stopIndex--; } if (index !== -1) { var _key = breakpoints[index]; return values[_key]; } return undefined; } //# sourceMappingURL=media-query.utils.js.map