You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
add and sub take two measures with the same unit.
mul and div take 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 #ff0000 formated color of possible and rgba() 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 :-)
The text was updated successfully, but these errors were encountered:
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')
ormul('3px', 2)
).This issue is there to discuss the specifics. I'd like to keep the gzipped size as small as possible, of course.
add
andsub
take two measures with the same unit.mul
anddiv
take a measure and a number.both return a measure of the same unit as the input.
#ff0000
formated color of possible andrgba()
otherwise.Taking inspiration on the Sass standard library, I'd borrow
adjust-color
,scale-color
andchange-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
andhsla
constructors (thea
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 usevalueOf
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 :-)
The text was updated successfully, but these errors were encountered: