UNPKG

@dotconnor/grommet

Version:

focus on the essential experience

51 lines (41 loc) 1.68 kB
"use strict"; exports.__esModule = true; exports.getBreakpointStyle = exports.getDeviceBreakpoint = exports.getBreakpoint = void 0; var getBreakpoint = function getBreakpoint(windowWidth, theme) { var result; var sortedBreakpoints = Object.keys(theme.global.breakpoints).sort(function (a, b) { var first = theme.global.breakpoints[a]; var second = theme.global.breakpoints[b]; if (!first) return 1; if (!second) return -1; if (!first.value) return 1; if (!second.value) return -1; return first.value - second.value; }); // the last breakpoint on the sorted array should have // no windowWidth boundaries var lastBreakpoint = sortedBreakpoints[sortedBreakpoints.length - 1]; sortedBreakpoints.some(function (name) { var breakpoint = theme.global.breakpoints[name]; if (breakpoint) { if (!breakpoint.value || breakpoint.value >= windowWidth) { result = name; return true; } } return false; }); return result || lastBreakpoint; }; exports.getBreakpoint = getBreakpoint; var getDeviceBreakpoint = function getDeviceBreakpoint(type, theme) { return theme.global.deviceBreakpoints[type]; }; exports.getDeviceBreakpoint = getDeviceBreakpoint; var getBreakpointStyle = function getBreakpointStyle(theme, breakpointSize) { var breakpoint = breakpointSize && theme.global.breakpoints[breakpointSize] || {}; if (!breakpoint.edgeSize) breakpoint.edgeSize = theme.global.edgeSize; if (!breakpoint.borderSize) breakpoint.borderSize = theme.global.borderSize; if (!breakpoint.size) breakpoint.size = theme.global.size; return breakpoint; }; exports.getBreakpointStyle = getBreakpointStyle;