-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/tabs/sass color mixins #1801
Conversation
BREAKING CHANGE: Remove classes mdc-tab-bar--indicator-primary and mdc-tab-bar--indicator-accent
Codecov Report
@@ Coverage Diff @@
## master #1801 +/- ##
=======================================
Coverage 99.44% 99.44%
=======================================
Files 84 84
Lines 3626 3626
Branches 456 456
=======================================
Hits 3606 3606
Misses 20 20 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start, left some comments.
I about to head out on holidays, so take my feedback into consideration, but get the rest of the team to help you while Im out.
packages/mdc-checkbox/_mixins.scss
Outdated
@@ -156,8 +156,8 @@ | |||
&-checked-unchecked, | |||
&-indeterminate-unchecked { | |||
.mdc-checkbox__background { | |||
animation-duration: $mdc-checkbox-transition-duration * 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be in this PR
packages/mdc-tabs/README.md
Outdated
@@ -51,9 +51,16 @@ icon-only, and text with icon. An example of each is available on the demo site. | |||
</nav> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should either
A) Send out a "pre-PR" which refactors the Tabs README to fit wit our REAMDE standards:
https://github.com/material-components/material-components-web/blob/master/docs/code/readme_standards.md
B) OR only update the mdc-tabs/README.md around the Sass mixins you add in this PR
packages/mdc-tabs/_mixins.scss
Outdated
@include mdc-theme-prop(background-color, $color); | ||
} | ||
|
||
&:not(.mdc-tab-bar-upgraded) .mdc-tab { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if you change the color of mdc-tab-bar__indicator
...you also need to change the opacity of mdc-tab
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right confusing. I think it is better to go with something like:
@mixin mdc-tab-indicator-ink-color($color, $opacity);
@mixin mdc-tab-label-ink-color($color, $opacity);
@mixin mdc-tab-icon-ink-color($color, $opacity);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind...we don't need $opacity. Developers and clients can just go like:
@include mdc-tab-indicator-ink-color(rgba(0,0,0, 0.9))
packages/mdc-tabs/_mixins.scss
Outdated
@include mdc-theme-prop(color, $color); | ||
} | ||
|
||
@include mdc-tab-icon-ink-color($color); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think you want to call mdc-tab-icon-ink-color
from within mdc-tab-label-ink-color
. This makes it impossible to customize the ink color of the icon separate from the ink color of the label.
Instead, have:
mdc-tab-label-ink-color
as a mixin which only sets the label ink colormdc-tab-icon-ink-color
as a mixin which only sets the icon ink colormdc-tab-ink-color
which sets all ink color within the tab to the same color (right now thats label and icon, but someday we might add another subelement to tab, which would qualify as "ink")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way actually works where you can customize the ink and the icon color with these two mixins. But I agree it isn't clear. I'll go with the three mixins.
packages/mdc-tabs/_mixins.scss
Outdated
@import "../variables"; | ||
|
||
@mixin mdc-tab-label-ink-color($color) { | ||
.mdc-tab:not(.mdc-tab--active) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I go back and forth on the best way to support states within an element. In this case its how to support customization of both the inactive and active state of a tab.
In mdc-button, we did not want to allow customization of the disabled button, so we added a :not(:disabled)
to our public mixins.
However, in this mdc-tab case, I think we want to support customization of active and inactive tabs separately.
I propose this:
- one public sass mixins
mdc-tab-label-ink-color
- drop
mdc-tab-label-activated-ink-color
- change mdc-tab-bar.scss to have:
.mdc-tab {
@include mdc-tab-label-ink-color(text-secondary-on-light);
}
.mdc-tab--active {
@include mdc-tab-label-ink-color(text-primary-on-light);
}
Then clients should override the the active inactive state like this
.foo-tab:not(.mdc-tab--active) {
@include mdc-tab-label-ink-color(pink);
}
.foo-tab.mdc-tab--active {
@include mdc-tab-label-ink-color(purple);
}
I think it is more important that clients keep their active and inactive states in sync, then it is for clients to keep their subcomponents in sync. For example this makes a lot of sense:
.foo-tab:not(.mdc-tab--active) {
@include mdc-tab-label-ink-color(pink);
@include mdc-tab-icon-ink-color(pink);
}
.foo-tab.mdc-tab--active {
@include mdc-tab-label-ink-color(purple);
@include mdc-tab-icon-ink-color(purple);
}
But this is harder to read
.foo-tab {
@include mdc-tab-label-ink-color(pink /*inactive color*/, purple /*active color*/);
@include mdc-tab-icon-ink-color(pink /*inactive color*/, purple /*active color*/);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go that route won't have mixins on the parent class, which I thought was what we wanted. Also the label-ink-color mixin would be a proxy to mdc-theme-prop:
@mixin mdc-tab-label-ink-color($color) {
@include mdc-theme-prop(color, $color);
}
The icon would also just be:
@mixin mdc-tab-icon-ink-color($color) {
@include mdc-theme-prop(color, $color);
}
What is the main purpose for these scss mixins? Is it to allow clients to customize the components quicker? To make our styles DRY'er? In either case if our scss mixins for other components are designed to live on the parent class, we should try to be consistent here as well. Clients and external developers can easily see the mixins we've created and know where to put them for quick configuration.
I'll probably pose the question on theming since you are on vacayy ;)
packages/mdc-tabs/_mixins.scss
Outdated
} | ||
} | ||
|
||
@mixin mdc-tab-indicator-height($height) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, don't bother with indicator height and width right now. just focus on the color mixins for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok will remove from PR
Closing as I am addressing changes in #1851 |
fixes: #1152