studiometa / scss-toolkit

A small and configurable SCSS Toolkit to boost your project! 🚀
MIT License
5 stars 0 forks source link

Framework / Colors #15

Closed notjb closed 5 years ago

notjb commented 5 years ago

When using the color function, i'm getting the following error :

SCSS


$colors: (
  'grey': #f4f7fb,
  'white': #fff,
  'green': #86bc25,
);

color(white);

Error

Error: node_modules/@studiometa/scss-toolkit/src/framework/_colors.scss
  Error: No color found in the `$colors` map for `white`.
          on line 20 of node_modules/@studiometa/scss-toolkit/src/framework/_colors.scss, in function `color`
          from line 4 of web/wp-content/themes/es-photovoltaique/assets/src/styles/components/_cta-button.scss
          from line 17 of web/wp-content/themes/es-photovoltaique/assets/src/styles/app.scss
  >>     @error 'No color found in the `$colors` map for `#{$color}`.';
     ----^

Main issue : no fallback is made to the default $colors map. Bugfix : The problem can be solved by only using strings as parameter of the function. Potential Feature request : make both strings and keys usable or fallback to default $colors map

titouanmathis commented 5 years ago

The problem was coming from the key white also being a CSS color keyword. The type of $color in the function was then color instead of string, which made it throw an error.

Casting the parameter as a string seems to resolve the issue. Will be fixed in the 1.2.0 release 😉