-
Notifications
You must be signed in to change notification settings - Fork 8
Description
It would be useful to provide as a companion library functions that tweak colors (lighten('#f00', 0.2)) and do arithmetic on sizes (add('2em', '0.5em') or mul('3px', 2)).
This issue is there to discuss the specifics. I'd like to keep the gzipped size as small as possible, of course.
addandsubtake two measures with the same unit.mulanddivtake a measure and a number.
both return a measure of the same unit as the input.
- the color functions take a color and a number, and output either a
#ff0000formated color of possible andrgba()otherwise.
Taking inspiration on the Sass standard library, I'd borrow adjust-color, scale-color and change-color but split them into *-rgba and *-hsla versions. You can't change both rgb and hsl using the original, anyway, and the long parameter list makes them unusable in practice.
Maybe also provide rgba and hsla constructors (the a being optional)? Do they return color strings or {r, g, b, a} / {h, s, l, a} objects? The former means that their output can be fed to j2c, but the latter means that we can skip the parse step in the color modifying functions. We could use valueOf to make '' + rgba(...) return a string. Make them accept color strings, and they also do the job of the rgba and hsl getters of Sass.
Feedback most welcome :-)