UNPKG

@bianic-ui/media-query

Version:

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

34 lines (24 loc) 718 B
"use strict"; exports.__esModule = true; exports.getClosestValue = getClosestValue; var _utils = require("@bianic-ui/utils"); function getClosestValue(values, breakpoint) { var index = Object.keys(values).indexOf(breakpoint); if (index !== -1) return values[breakpoint]; var stopIndex = _utils.breakpoints.indexOf(breakpoint); var hasFound = false; while (stopIndex >= 0 && !hasFound) { var key = _utils.breakpoints[stopIndex]; if (values[key] != null) { index = stopIndex; hasFound = true; } stopIndex--; } if (index !== -1) { var _key = _utils.breakpoints[index]; return values[_key]; } return undefined; } //# sourceMappingURL=media-query.utils.js.map