Remove color math
See original GitHub issueSass’s support for mathematical operations on RGB colors is misleading and not very useful. Channel-by-channel arithmetic is very difficult to use effectively when trying to produce a given human-comprehensible color transformation, and in all cases the color functions are better suited to the job.
We should begin by emitting a deprecation warning whenever a binary operation is performed for the +
, *
, -
, /
, or %
operators when one of the operands is a color and the other is either a color or a number. Once the deprecation period is up, we should make all previously-deprecated operations emit errors.
It would be more consistent with the behavior of +
, -
, and /
on other types to have them emit strings for colors once the deprecation period is over. Nevertheless, I think erroring out is the right thing to do. It makes it clearer that something’s going wrong for anyone who didn’t see the deprecation warnings, and I don’t think there are any real use-cases for using those operators in a stringifying way.
Tasks:
- Deprecate existing behavior in
stable
. - Remove behavior from
master
.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:11
- Comments:8
Top GitHub Comments
I’d like to dispute this change, if that is possible. As i’ve mentioned in my previous comment, i’d argue that color arithmetic does make sense and that it can reduce code footprint drastically. There was no reason for the removal of this feature, as i’d call it. My team has complained about having to change hundreds of lines of code only because a well-welcome feature was removed because some one thought it wouldn’t make sense.
I disagree with the reasons OP has given. While
#fff - 10%
might not look like it could make sense to anyone, it is quite obvious that it darkens it by 10%. It is much easier to type that thandarken(#fff, 10%)
. I think the feature should be depreciated, however i’d like some way to enable it for those who actually use it. We want to make styling apps easier and faster after all, right? I hope this is reconsidered to some extent, it would really cheer up my dev team and me.My 2 cents.