compile nested css rules
npm install nested-csscompile nested css rules
npm i nested-css | pnpm add nested-css | yarn add nested-css |
& {
}
css(parts, values) – Factory a {@link NestedCSSCompiler} for the given string.cssToJs(input) – Convert a CSS string to a {@link NestedCSSDeclaration}. string#
input –
cssToJs(input) =>
jsToCss(rules, rootSelector, aliasMap) – Compile a JS nested rules {@link NestedCSSDeclaration} to a CSS string.
Examples:
``ts
jsToCss({ '.foo': { color: 'blue' } })
// => .foo{color:blue}
// custom root
jsToCss({ color: 'red' }, '.my-button')
// => .my-button{color:red}
// with substitution
jsToCss({ '.foo': { color: 'blue' } }, null, new Map([['foo', 'bar']]))
// => .bar{color:blue}
``
rules – Rules objectPartial<CSSStyleDeclaration>
rootSelector – Top level rules will use this selectornull | string
aliasMap – Alias identifiers (i.e for .foo to become .barfoo=bar entry)Map<string, string>
jsToCss(rules, rootSelector, aliasMap) =>
- tokenizer-next by stagas – iterator based tokenizer for writing parsers
All contributions are welcome!