Skip to content

Instantly share code, notes, and snippets.

@cameron-martin
Created July 24, 2019 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameron-martin/0b549b4e862b91f1732cbf4468820fe9 to your computer and use it in GitHub Desktop.
Save cameron-martin/0b549b4e862b91f1732cbf4468820fe9 to your computer and use it in GitHub Desktop.
Javascript CSS Preprocessor

Why?

Existing CSS preprocessors kinda suck:

  • Values cannot be easily shared between javascript and CSS, sometimes resulting in duplication
  • They're not suited to doing complicated computation. Want to do trigonometry in SASS? Not super easy. Moreover, writing
  • Modules don't exist for library code.

How?

NAME is a domain specific language embedded in javascript that compiles to CSS.

import { set, decl } from 'foo';
set(class('foo'), () => {
decl.textAlign('center');
decl.padding(1, 0, 0);
});
import { rule, decl } from 'foo';
export default rule(class('foo'), [
decl.textAlign('center'),
decl.padding(1, 0, 0),
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment