Color swatches generated with Sass maps
I've updated this to auto generate rgba() and hlsa() color codes with Sass.
Notes:
-
This assumes color swatches without transparency. If you declare color variables in rgba, hsla, or use the Sass rgba or hsla functions on color variables to generate new colors, then the first value in the swatch output will not be a hex value.
-
Sass is weird in that if a color matches one of the many
HTML color names
or
X11 color names
, it will output that name instead of the hex value. This is super annoying to me, and I don't undertand why Sass does this, even when they
try to explain it
. A lot of people feel the same way, apparently, and it looks like they are
fixing it for Sass 3.4
.
-
For the hsla() color code values, Sass was generating some crazy decimals, so I set those to round. This may or may not shift the hsla() color values a tiny bit that you'll probably never notice. Colors look way different on different screens anyway, so it's pretty much pointless to even worry about.
-
I have been informed
that in order to get rid of the "deg" that Sass outputs next to the hue value for hsl, all I need to do is divide it by 1deg. I had a crazy strip units function in there because I didn't know it was that simple.
-
I realized that CSS generated content is not selectable, which gives me a sad because it would be handy in this case to be able to select and copy the color values. I'm sure I could probably do some JS contortions to convert the generated text values into actual DOM text...maybe later.