question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v5: shift-color() not working correctly with dark default link color?

See original GitHub issue

If I want a dark color as my default link color (e.g. #111111), I would want its hover state to lighten the color instead of darkening it. It would appear that v5 accounts for this in its variables file, using the shift-color() function.

$link-color: $primary !default;
$link-decoration: underline !default;
$link-shade-percentage: 20% !default;
$link-hover-color: shift-color($link-color, $link-shade-percentage) !default;
$link-hover-decoration: null !default;

According to shift-color()’s comment , it should “Shade the color if the weight is positive, else tint it”. This sounds perfect and is exactly what I hope for. But if I pass a negative percentage like -20% to $link-shade-percentage in hopes of tinting it, I get a Sass compilation error: $weight: Expected -20% to be within 0% and 100%.

This aligns with that Sass says, that mix() only accepts 0% - 100% weight, but I don’t know. Am I doing this wrong? Thanks for your work getting v5 out!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DaleyKDcommented, Oct 20, 2021

When I try to set $link-shade-percentage: -20%; in hopes of lightening my link hover color, node-sass gives me:

ERROR in ./styles/app.scss (./styles/app.scss.webpack[javascript/auto]!=!./node_modules/css-loader/dist/cjs.js!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[0].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[0].use[3]!./styles/app.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: argument `$weight` of `mix($color-1, $color-2, $weight: 50%)` must be between -0 and 100
        on line 212 of node_modules/bootstrap/scss/_functions.scss, in function `mix`
        from line 212 of node_modules/bootstrap/scss/_functions.scss, in function `shade-color`
        from line 8 of node_modules/bootstrap/scss/helpers/_colored-links.scss, in function `if`
        from line 8 of node_modules/bootstrap/scss/helpers/_colored-links.scss
        from line 2 of node_modules/bootstrap/scss/_helpers.scss
        from line 49 of node_modules/bootstrap/scss/bootstrap.scss
        from line 19 of styles/app.scss
>>   @return mix(black, $color, $weight);

   ----------^

SassError: SassError: argument `$weight` of `mix($color-1, $color-2, $weight: 50%)` must be between -0 and 100
        on line 212 of node_modules/bootstrap/scss/_functions.scss, in function `mix`
        from line 212 of node_modules/bootstrap/scss/_functions.scss, in function `shade-color`
        from line 8 of node_modules/bootstrap/scss/helpers/_colored-links.scss, in function `if`
        from line 8 of node_modules/bootstrap/scss/helpers/_colored-links.scss
        from line 2 of node_modules/bootstrap/scss/_helpers.scss
        from line 49 of node_modules/bootstrap/scss/bootstrap.scss
        from line 19 of styles/app.scss
>>   @return mix(black, $color, $weight);

   ----------^

    at Object.callback (C:\src\ClientApp\node_modules\sass-loader\dist\index.js:54:16)
    at Object.done [as callback] (C:\src\ClientApp\node_modules\neo-async\async.js:8069:18)
    at options.error (C:\src\ClientApp\node_modules\node-sass\lib\index.js:293:32)
 @ ./styles/app.scss

Just figured I’d add my $0.02.

1reaction
ffooddcommented, Feb 19, 2021

Indeed, the goal is the same but the approach diverges. The variable is not the bug, but there’s something to clarify and improve for sure.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SASS/SCSS: Bootstrap 5 Color functions not working well?
I'm using SASS and bootstrap the new version V5 as CSS Framework in some of my academic project in color ...
Read more >
Discover how to override theme colors in Bootstrap 5 using Sass
1 Bootstrap Sass override variables by using the right import sequence ... //Bootstrap v5 $link-color: $primary !default;.
Read more >
Sass · Bootstrap v5.0
These functions will mix colors with black or white, unlike Sass' native lighten() and darken() functions which will change the lightness by a...
Read more >
Improved dark mode default styling with the color-scheme ...
Dark mode: Styles specified by the developer and the user agent. The text is white and the background is black as per the...
Read more >
Dark Mode to Change Color Schemes and CSS Properties
Developers are adding dark mode CSS on native applications to support their user preferences. Read to learn more about dark color schemes for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found