Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

feat(tab): Add Tab Sass mixins targeting active state colors #4522

Merged
merged 8 commits into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions demos/tab-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@
@include mdc-tab-text-label-color($material-color-blue-600);
@include mdc-tab-icon-color($material-color-blue-600);
@include mdc-tab-states-color($material-color-yellow-700);
}

.mdc-tab--active {
@include mdc-tab-text-label-color($material-color-blue-900);
@include mdc-tab-icon-color($material-color-blue-900);
@include mdc-tab-active-text-label-color($material-color-blue-900);
@include mdc-tab-active-icon-color($material-color-blue-900);
}

.mdc-tab-indicator {
Expand Down
3 changes: 3 additions & 0 deletions packages/mdc-tab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,11 @@ Mixin | Description
`mdc-tab-icon-color($color)` | Customizes the color of the tab icon.
`mdc-tab-states-color($color)`| Customizes the base states color, which affects hover/focus states and the press ripple.
`mdc-tab-ink-color($color)` | Customizes the text label, icon, and base states color.
`mdc-tab-active-text-label-color($color)` | Customizes the color of the active tab's text label.
`mdc-tab-active-icon-color($color)` | Customizes the color of the active tab's icon.
`mdc-tab-parent-positioning` | Sets the positioning of the MDCTab's parent element so that `MDCTab.computeDimensions()` reports the same values in all browsers.
`mdc-tab-fixed-width($width)` | Sets the fixed width of the tab. The tab will never be smaller than the given width.
`mdc-tab-text-transform($transform)` | Sets the `text-transform` CSS property of the tab element.

## `MDCTab` Properties and Methods

Expand Down
17 changes: 17 additions & 0 deletions packages/mdc-tab/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,27 @@
@include mdc-tab-text-label-color($color);
}

@mixin mdc-tab-active-text-label-color($color) {
&.mdc-tab--active .mdc-tab__text-label {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these mixins just do what was being done in tab-bar.scss before and reuse other mixins within &.mdc-tab--active? That way there's no risk of updating one mixin and forgetting to update these other mixins in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean omitting &.mdc-tab--active here and requiring developers to specify it themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh nevermind, I get it, reuse mdc-tab-text-label-color. Of course, will make the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@include mdc-theme-prop(color, $color);
}
}

@mixin mdc-tab-active-icon-color($color) {
&.mdc-tab--active .mdc-tab__icon {
@include mdc-theme-prop(color, $color);
}
}

@mixin mdc-tab-parent-positioning {
position: relative;
}

@mixin mdc-tab-fixed-width($width) {
flex: 0 1 $width;
}

@mixin mdc-tab-text-transform($transform) {
text-transform: $transform;
}