UNPKG

@nex-ui/system

Version:

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

27 lines (24 loc) 895 B
import { forEach, isString } from '@nex-ui/utils'; function createSelectors({ selectors, getMediaSelectors }) { const selectorMap = new Map(); forEach(selectors, (value, key)=>{ if (!isString(value)) { console.error(`[Nex UI] system: Expect the selector value to be a string, but what is currently received is %o.`, value); return; } selectorMap.set(`_${key}`, value); }); const mediaSelectors = getMediaSelectors(); forEach(mediaSelectors, (selector, key)=>{ const k = `_${key}`; if (selectorMap.get(k)) { console.error('[Nex UI] system: The selector %s has already been defined in the breakpoint.', selector); return; } selectorMap.set(k, selector); }); return { getCustomizedSelector: (key)=>selectorMap.get(key) }; } export { createSelectors };