Skip to content
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

Closed
wants to merge 14 commits into from
Closed

Conversation

moog16
Copy link
Contributor

@moog16 moog16 commented Dec 19, 2017

fixes: #1152

@codecov-io
Copy link

codecov-io commented Dec 19, 2017

Codecov Report

Merging #1801 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd5ea7b...c0bf0de. Read the comment docs.

Copy link
Contributor

@lynnmercier lynnmercier left a 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.

@@ -156,8 +156,8 @@
&-checked-unchecked,
&-indeterminate-unchecked {
.mdc-checkbox__background {
animation-duration: $mdc-checkbox-transition-duration * 2;
Copy link
Contributor

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

@@ -51,9 +51,16 @@ icon-only, and text with icon. An example of each is available on the demo site.
</nav>
Copy link
Contributor

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

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

&:not(.mdc-tab-bar-upgraded) .mdc-tab {
Copy link
Contributor

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?

Copy link
Contributor Author

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);

Copy link
Contributor Author

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))

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

@include mdc-tab-icon-ink-color($color);
Copy link
Contributor

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 color
  • mdc-tab-icon-ink-color as a mixin which only sets the icon ink color
  • mdc-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")

Copy link
Contributor Author

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.

@import "../variables";

@mixin mdc-tab-label-ink-color($color) {
.mdc-tab:not(.mdc-tab--active) {
Copy link
Contributor

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*/);
}

Copy link
Contributor Author

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 ;)

}
}

@mixin mdc-tab-indicator-height($height) {
Copy link
Contributor

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

Copy link
Contributor Author

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

@moog16 moog16 changed the title Feat/tabs/sass color mixins feat/tabs/sass color mixins Jan 2, 2018
@moog16
Copy link
Contributor Author

moog16 commented Jan 3, 2018

Closing as I am addressing changes in #1851

@moog16 moog16 closed this Jan 3, 2018
@moog16 moog16 deleted the feat/tabs/sass-color-mixins branch January 3, 2018 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Sass color mixin to tabs
3 participants