Skip to content

Modify .card-header-tabs .nav-link.active colors#28833

Merged
MartijnCuppens merged 8 commits into
twbs:masterfrom
shaneparsons:patch-1
May 29, 2019
Merged

Modify .card-header-tabs .nav-link.active colors#28833
MartijnCuppens merged 8 commits into
twbs:masterfrom
shaneparsons:patch-1

Conversation

@shaneparsons

@shaneparsons shaneparsons commented May 27, 2019

Copy link
Copy Markdown
Contributor

Set .card-header-tabs .nav-link.active background / border colors to better match card.

Fixes #28820.

Set `.card-header-tabs .nav-link.active` background / border colors to better match card.
@shaneparsons shaneparsons requested a review from a team as a code owner May 27, 2019 15:31
@ysds ysds added the css label May 27, 2019
@ysds

ysds commented May 27, 2019

Copy link
Copy Markdown
Contributor

Should also care for hover?

…-tabs` changes

Use `border-bottom-color` instead of `border-color`, to ensure only the neccessary part of the border changes.
@shaneparsons

Copy link
Copy Markdown
Contributor Author

Since background-color isn't actually changed on hover, and the border-color changes are fine, I don't think any hover styles are needed.

I did make a change to my pull request though:

Previous:
border-color: $card-border-color $card-border-color $card-bg;

New:
border-bottom-color: $card-bg;

Now only the bottom border colour changes, to match the card background.

@shaneparsons

Copy link
Copy Markdown
Contributor Author

Here are some screenshots of the difference the pull request makes:

Before:
Screen Shot 2019-05-27 at 3 21 46 PM

After:
Screen Shot 2019-05-27 at 3 22 37 PM

Note: the first tab is active, the second tab is hovered.

@mdo mdo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I’m in favor of this. Feels like a helpful consideration for folks who may modify the $body-bg to be something different. Otherwise though, it’s unnecessary. Thoughts from @twbs/css-review for how to account for that and avoid including CSS that’s not used by default?

Comment thread scss/_card.scss Outdated
Use `background-color` instead of `background` so it doesn't override additional `background-` properties.

Co-Authored-By: Mark Otto <otto@github.com>
@shaneparsons

Copy link
Copy Markdown
Contributor Author

@mdo Indeed. Some frameworks like Laravel modify the $body-bg by default too, so it's one less thing that developers have to worry about.

@shaneparsons

shaneparsons commented May 28, 2019

Copy link
Copy Markdown
Contributor Author

There's probably a way to modify this to play nice with #background-and-color as well, but that's a seperate issue.

EDIT:
I've come up with a way to address a changing $body-bg while also playing nice with #background-and-color. It involves modifying the bg-variant mixin though, so I'm not sure how keen you guys will be on doing that for such a specific use case. Regardless here are the steps:

_card.scss:

.card-header-tabs {
  margin-right: -$card-spacer-x / 2;
  margin-bottom: -$card-spacer-y;
  margin-left: -$card-spacer-x / 2;
  border-bottom: 0;

  .nav-link {
    color: inherit;
    &:hover {
      border-color: $card-border-color $card-border-color transparent;
    }
    &.active {
      background-color: $card-bg;
      border-color: $card-border-color $card-border-color $card-bg;
      color: inherit;
    }
  }
}

_background-variant.scss:

@mixin bg-variant($parent, $color) {
  #{$parent}{
    background-color: $color !important;
    
    .card-header-tabs .nav-link.active {
      background-color: $color !important;
      border-bottom-color: $color !important;    
    }
  }
  a#{$parent},
  button#{$parent} {
    @include hover-focus {
      background-color: darken($color, 10%) !important;
    }
  }
}

The tabs will then inherit whatever colors you assign to the card:

Screen Shot 2019-05-28 at 1 09 21 PM

There's likely a better way of doing this... but let me know if you'd like any of the above included in this (or in a seperate) pull-request and I'll be happy to do so.

@ysds ysds left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts from @twbs/css-review for how to account for that and avoid including CSS that’s not used by default?

@shaneparsons Could you change as the follows? 😄

  .nav-link.active {
    background-color: $card-bg;
    border-bottom-color: $card-bg;
  }

to

  @if $nav-tabs-link-active-bg != $card-bg {
    .nav-link.active {
      background-color: $card-bg;
      border-bottom-color: $card-bg;
    }
  }

@shaneparsons

Copy link
Copy Markdown
Contributor Author

Thoughts from @twbs/css-review for how to account for that and avoid including CSS that’s not used by default?

@shaneparsons Could you change as the follows? 😄

  .nav-link.active {
    background-color: $card-bg;
    border-bottom-color: $card-bg;
  }

to

  @if $nav-tabs-link-active-bg != $card-bg {
    .nav-link.active {
      background-color: $card-bg;
      border-bottom-color: $card-bg;
    }
  }

Done!

See my edit to #28833 (comment) and let me know if the additions are of any interest to you.

@ysds

ysds commented May 28, 2019

Copy link
Copy Markdown
Contributor

I think it's over-engineering to integrate with the background utilities. It would be better to solve it with custom variables in the future (v6?)

@shaneparsons

shaneparsons commented May 28, 2019

Copy link
Copy Markdown
Contributor Author

I think it's over-engineering to integrate with the background utilities. It would be better to solve it with custom variables in the future (v6?)

Yeah I agree on that one. I don't have a ton of experience with advanced variables / utilities / mixins, so that was just my hacky take on the solution. I more so just intended to get the conversation started.

@mdo mdo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, everyone! <3

@twbs twbs deleted a comment from shaneparsons May 29, 2019
@XhmikosR

Copy link
Copy Markdown
Member

I assume we don't want this backported, right?

@XhmikosR XhmikosR added the v5 label May 29, 2019
@MartijnCuppens MartijnCuppens merged commit 4c70e96 into twbs:master May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Card Integrated Tabs" active background should default to $card-bg.

5 participants