UNPKG

aliascss

Version:

AliasCSS is a CSS post processor.

27 lines (26 loc) 1.09 kB
const element = { test: /^_[_]?[A-Za-z0-9_\.,]+(?=[_[-])/, process(className) { const match = className.match(this.test); if (match) { const alias = match[0]; if (match) if (alias) { const result = alias .replace('next', ' + ') .replace('child', ' > ') .replace('siblings', ' ~') .replace(/____/g, ' ~ ') .replace(/___/g, ' + ') .replace(/__/g, ' > ') .replace(/_/g, ' ') .replace(/[\s]all/, ' * ') .replace(/[\s](dot)/g, (e, a) => { return ' .' + a.toLowerCase(); }) // .replace(/[\s]([A-Z])/g, (e, a) => { return ' .' + a.toLowerCase();}) .replace(/[\s]+/g, " ").trim(); return [className.replace(alias, (/[^_][_]$/.test(alias) ? '_' : '')), ' ' + result]; } } } }; export default element;