@nex-ui/system
Version:
A lightweight and performant styling library based on Emotion, focusing on component architecture and developer experience.
34 lines (30 loc) • 1.22 kB
JavaScript
;
var utils$1 = require('@nex-ui/utils');
var utils = require('./utils.cjs');
const toMediaKey = (value)=>`@media (min-width:${value})`;
const createBreakpoints = (breakpoints)=>{
const breakpointMap = new Map();
const selectorMap = new Map();
let index = 0;
for(const breakpointKey in breakpoints){
// istanbul ignore if
if (!Object.hasOwn(breakpoints, breakpointKey)) continue;
const breakpointValue = breakpoints[breakpointKey];
if (!utils.isValidBreakpointValue(breakpointValue)) {
if (utils$1.__DEV__) {
console.error(`[Nex UI] system: Expect the breakpoint value to be a string, but what is currently received is %o.`, breakpointValue);
}
continue;
}
breakpointMap.set(breakpointKey, breakpointValue);
breakpointMap.set(index, breakpointValue);
selectorMap.set(breakpointKey, toMediaKey(breakpointValue));
selectorMap.set(index, toMediaKey(breakpointValue));
index += 1;
}
return {
getMediaSelectors: ()=>Object.fromEntries(selectorMap.entries())
};
};
exports.createBreakpoints = createBreakpoints;
exports.toMediaKey = toMediaKey;