UNPKG

@nex-ui/system

Version:

A lightweight and performant styling library based on Emotion, focusing on component architecture and developer experience.

37 lines (33 loc) 1.33 kB
'use strict'; var utils = require('@nex-ui/utils'); function createSelectors({ selectors, getMediaSelectors }) { const selectorMap = new Map(); for(const selectorKey in selectors){ // istanbul ignore if if (!Object.hasOwn(selectors, selectorKey)) continue; const selectorValue = selectors[selectorKey]; if (!utils.isString(selectorValue)) { console.error(`[Nex UI] system: Expect the selector value to be a string, but what is currently received is %o.`, selectorValue); continue; } selectorMap.set(`_${selectorKey}`, selectorValue); } const mediaSelectors = getMediaSelectors(); for(const selectorKey in mediaSelectors){ // istanbul ignore if if (!Object.hasOwn(mediaSelectors, selectorKey)) continue; const selectorValue = mediaSelectors[selectorKey]; const key = `_${selectorKey}`; if (selectorMap.get(key)) { if (utils.__DEV__) { console.error('[Nex UI] system: The selector %s has already been defined in the breakpoint.', selectorValue); } continue; } selectorMap.set(key, selectorValue); } return { getCustomizedSelector: (key)=>selectorMap.get(key) }; } exports.createSelectors = createSelectors;