postcss / postcss-simple-vars

PostCSS plugin for Sass-like variables
MIT License
415 stars 36 forks source link

sass !default behaviour #52

Closed sekoyo closed 8 years ago

sekoyo commented 8 years ago

Hi,

I was wondering if there's any intention or interest in adding a !default keyword to this plugin?

It's a powerful feature for theming meaning a component (e.g. one in node_modules) can declare variables with the !default keyword, and then even if the component is included AFTER overrides it will not override them (it uses the first definition of the variable):

$primary-color: blue;
$primary-color: green !default; // Ignored

It means theming can be done with more confidence without worrying that the base theme (default/white-label) won't accidentally override the branding theme.

ai commented 8 years ago

PostCSS try to keep CSS simple and declarative. If you want complicated logic (like prefixes) you should do it in JS.

This is why I don't like !default - it force you to put logic to CSS and make it hard to read.

If you have use case, I can show you some other ways.