connorskees / grass

A Sass compiler written purely in Rust
https://docs.rs/grass/
MIT License
499 stars 38 forks source link

handling named color aliases #100

Closed guppy0130 closed 3 months ago

guppy0130 commented 3 months ago

hello, was modifying a zola theme when I got

Error: Failed to build the site
Error: Error: $color: cyan is not a color.
   ╷
30 │     (red($n) * 299)+ (green($n) * 587)+ (blue($n) * 114)/1000
   │      ^^^^^^^
   ╵

turns out [cyan is an alias of aqua](https://developer.mozilla.org/en-US/docs/Web/CSS/named-color#:~:text=%23dc143c-,cyan,-%2300ffff%20(synonym%20of ), so updating my value to aqua was sufficient, but wanted to know if there's interest in handling color aliases? e.g., if after

https://github.com/connorskees/grass/blob/05e3c94e001c3446823d365fc25a0a228ccd56e7/crates/compiler/src/color/name.rs#L42

adding cyan would be sufficient.

if so, there may be an interesting quirk with respect to expanded/compressed CSS output; the expanded CSS output will be cyan, and the compressed aqua, at least according to this scss-lang.org playground example. I haven't looked into what would be needed to make this happen though.

connorskees commented 3 months ago

Hi,

Thank you for such a nice bug report! It does seem the color mapping is missing all of the aliased CSS colors. I've added them in https://github.com/connorskees/grass/commit/1afbacb7c172d5eb41e89e16cefe29bc3b482f59, which should be released to crates.io in a bugfix version sometime soon

connorskees commented 3 months ago

This change has been released to crates.io in version 0.13.4