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