For a while, color arithmetic in SASS has been deprecated and not available in newer versions of the tool. I am currently migrating an older project which had color arithmetic.
For example, the older scss files has something like this:
background: $body-bg-color-dark-light + 10;
$body-bg-color-dark-light
is a simple RGB value (like #FF1100)
What is the alternative using the new SASS color functions to reproduce the exact same functionality as above? Note that we are adding a simple integer and not a percentage.
Alternative I have tried is:
background: lighten($body-bg-color-dark-light, 10);
// Note that '10' is not a percentage in the previous example
This does not produce the desired color. Also, since lighten
and darken
accept only percentages I am confused about the values that are greater than 100
in the code base that I am migrating.
The other problem is I am not able to obtain an older version of SASS (or locate which version for that matter) to figure what exactly was produced by simply adding an integer to a color so that I could apply the new color functions to produce the same result.
Edit:
I managed to dig up an old compiled version of that SCSS. One original value in that sample was #020507
.
Adding 10
to that produced a result of #0c0f11
. Looks like it is adding 10
(or A
in hex) to every color channel.