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.

Button hover colors should be in _variables.scss file

See original GitHub issue

The mixin for button-variant is defined like this:

@mixin button-variant($background, $border, $active-background: darken($background, 7.5%), $active-border: darken($border, 10%))

Because of this, if you want to have the active background 10% darker or 7.5% lighter (for example) you either have to change the mixin file or write more custom css. This could be easily fixed:

/mixins/_buttons.scss

@mixin button-variant($background, $border, $active-background, $active-border)

_variables.scss

$active-background: darken($background, 7.5%);
$active-border: darken($border, 10%);

It looks as though this was probably the original intent, but somebody forgot to move those variables out of the mixin file.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
flachwarecommented, Nov 3, 2017

@andresgalante I find myself struggling with the button mixins often enough with the need to modify some states (especially the hard-coded percentages and ‘lighten’ vs ‘darken’). As far as I can see the approach of the opening comment wouldn’t work, not so much because of the confusion, but because the $background variable is undefined until it gets set in the @each loop in /scss/_buttons.scss

How about a solution along these lines – this approach would users let easily adjust the percentages as well as the color function:

/scss/mixins/_buttons.scss

@mixin button-variant(
  $background,
  $border,
  $change,
  $btn-hover-change-bg,
  $btn-hover-change-border,
  $btn-active-change-bg,
  $btn-active-change-border) {
    @if $change == "darken" {
      $hover-bg:     darken($background, $btn-hover-change-bg);
      $hover-border: darken($border, $btn-hover-change-border);
      $active-bg:    darken($background, $btn-active-change-bg);
      $active-bg:    darken($border, $btn-active-change-border);
    } else {
      $hover-bg:     lighten($background, $btn-hover-change-bg);
      $hover-border: lighten($border, $btn-hover-change-border);
      $active-bg:    lighten($background, $btn-active-change-bg);
      $active-bg:    lighten($border, $btn-active-change-border);
    }
    
    ...

  }
}

/scss/_variables.scss

$btn-change: "darken";
$btn-hover-change-bg: 7.5%;
$btn-hover-change-border: 10%;
$btn-active-change-bg: 10%;
$btn-active-change-border: 12.5%;
2reactions
cdikibocommented, Sep 25, 2017

Can I do this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

All buttons hover styling in Twitter Bootstrap - Stack Overflow
Let's assume I would like to make it lighter. I looked at Buttons Less variables but I don't see button hover styling option....
Read more >
How to change correctly color variable with SASS (for button
Go to sass/mdb/free/colors.scss file and find "success-color" variable. Change it, compile scss file to new css file and it will work. Add ...
Read more >
How to apply hover effect over button using SASS
When hovering the opacity of the background color of buttons, it will slightly increase the width from 1px to 200px depending upon the...
Read more >
Customizing the color scheme or typography - IBM
You can customize the color scheme to display different colors and typography by using Sass. Do not modify CSS files directly. You can...
Read more >
What do you name color variables? | CSS-Tricks
The first thing I wanted to do was variablize my colors. From my naming-things-in-HTML skillz, I knew to avoid classes like .header-blue-left- ...
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