@smart-react-components/ui
Version:
SRC UI includes React and Styled components.
33 lines (32 loc) • 1.21 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBreakpointValue = void 0;
/**
* Gets the breakpoint value according to the given breakpoints and the window size.
* Breakpoints are given as an array from small to large - [xs, sm, md, lg, xl]
*/
const getBreakpointValue = (xProps, yProps, theme) => {
let x;
let y;
const width = window.innerWidth;
if (width > theme.$.length.breakpoint.xlarge) {
x = xProps[4];
y = yProps[4];
}
if (width > theme.$.length.breakpoint.large) {
x !== null && x !== void 0 ? x : (x = xProps[3]);
y !== null && y !== void 0 ? y : (y = yProps[3]);
}
if (width > theme.$.length.breakpoint.medium) {
x !== null && x !== void 0 ? x : (x = xProps[2]);
y !== null && y !== void 0 ? y : (y = yProps[2]);
}
if (width > theme.$.length.breakpoint.small) {
x !== null && x !== void 0 ? x : (x = xProps[1]);
y !== null && y !== void 0 ? y : (y = yProps[1]);
}
x !== null && x !== void 0 ? x : (x = xProps[0]);
y !== null && y !== void 0 ? y : (y = yProps[0]);
return { x, y };
};
exports.getBreakpointValue = getBreakpointValue;
;