@findify/react-components
Version:
Findify react UI components
15 lines (14 loc) • 575 B
JavaScript
var isFunction = function isFunction(check) {
return check && {}.toString.call(check) === '[object Function]';
};
export default (function (breakpoints) {
var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerWidth;
if (!breakpoints) return undefined;
if (isFunction(breakpoints)) return breakpoints(width);
var points = Object.keys(breakpoints);
return points.sort(function (a, b) {
return parseInt(a, 10) - parseInt(b, 10);
}).filter(function (point) {
return Number(point) <= width;
}).pop() || points[0];
});