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

feat(menu-surface): add feature targeting for styles #4279

Merged

Conversation

crisbeto
Copy link
Collaborator

Sets up style feature targeting for mdc-menu-surface.

@crisbeto crisbeto force-pushed the menu-surface-style-targeting branch from aed775f to 9e1bc4e Compare January 21, 2019 22:03
Copy link
Collaborator

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

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

I may try to take a stab at writing some kind of test or something to detect these nested mdc-feature-target mixins and complain about them, I think this would lead to unexpected results.

@include mdc-feature-targets($feat-structure) {
@include mdc-rtl-reflexive-property(transform-origin, top left, top right);
@include mdc-menu-surface-shape-radius(medium);
@include mdc-menu-surface-base_($query);
Copy link
Collaborator

Choose a reason for hiding this comment

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

move out of this $feat-structure block

}

.mdc-menu-surface--anchor {
@include mdc-feature-targets($feat-structure) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if you move this mdc-feature-targets up a level you can surround this rule and the one below

transform: scale(.8);
opacity: 0;

@include mdc-feature-targets($feat-animation) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

move out of this $feat-structure block

display: inline-block;
opacity: 0;

@include mdc-feature-targets($feat-animation) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

move out of this $feat-structure block

@crisbeto
Copy link
Collaborator Author

For what it's worth, I did try out the nested mdc-feature-target and it seemed to work as expected. That being said, after sleeping on it, it seems like a bad idea, because it means that you can't include the animation styles without including the structure.

@mmalerba
Copy link
Collaborator

Yeah I think it works in certain situations, but not others. If you want to sanity check your PRs, cherry pick in #4281 where I made it an error.

@crisbeto crisbeto force-pushed the menu-surface-style-targeting branch from 9e1bc4e to 12a162a Compare January 22, 2019 18:35
@crisbeto
Copy link
Collaborator Author

I've addressed the feedback @mmalerba.

@mmalerba
Copy link
Collaborator

The CSS diff shows that some rules changed order (possibly ok), but some also gained additional specificity which we probably don't want:

menu-surface-before.css
menu-surface-after.css

packages/mdc-menu-surface/_mixins.scss Outdated Show resolved Hide resolved
packages/mdc-menu-surface/_mixins.scss Outdated Show resolved Hide resolved
@crisbeto crisbeto force-pushed the menu-surface-style-targeting branch from 12a162a to 39ddcf1 Compare January 25, 2019 20:19
@crisbeto
Copy link
Collaborator Author

crisbeto commented Jan 25, 2019

@kfranqueiro I've rebased, fixed the redundant selectors and specificity changes.

@crisbeto crisbeto force-pushed the menu-surface-style-targeting branch from 39ddcf1 to aa3b943 Compare January 26, 2019 15:03
Copy link
Contributor

@kfranqueiro kfranqueiro left a comment

Choose a reason for hiding this comment

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

LGTM now, thanks!

}

// postcss-bem-linter: end
}

@mixin mdc-menu-surface-ink-color($color) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on the discussion from the switch PR it sounds like we want to add $query support to all of the public mixins, that would mean these 3 too (and make sure to add them to the test file)

@crisbeto
Copy link
Collaborator Author

@mmalerba I've addressed the feedback.

@crisbeto crisbeto force-pushed the menu-surface-style-targeting branch from 5a93a03 to 04f9171 Compare January 31, 2019 21:54
}
}

@include mdc-feature-targets($feat-structure) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Invert these to put the feature-targets within each selector. Same for within base_.

@@ -53,4 +54,9 @@
@include mdc-typography-overflow-ellipsis($query: mdc-feature-any());
@include mdc-typography-baseline-top(0, $query: mdc-feature-any());
@include mdc-typography-baseline-bottom(0, $query: mdc-feature-any());

// Menu surface
Copy link
Contributor

Choose a reason for hiding this comment

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

This section is missing a call to the baseline mdc-menu-surface mixin. Also can we insert this after menu rather than at the end?

.mdc-menu-surface {
@include mdc-menu-surface-base_($query);
@include mdc-elevation($z-value: 8, $query: $query);

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove empty line (fails lint)

@crisbeto crisbeto force-pushed the menu-surface-style-targeting branch from 04f9171 to 1239b9f Compare February 2, 2019 11:50
@crisbeto
Copy link
Collaborator Author

crisbeto commented Feb 2, 2019

@kfranqueiro the latest set of feedback is addressed.

@crisbeto crisbeto force-pushed the menu-surface-style-targeting branch from 1239b9f to c1e3272 Compare February 2, 2019 11:59
@kfranqueiro
Copy link
Contributor

Diff looks fine; I ran the mdc-menu screenshot tests and no changes were found. https://storage.googleapis.com/mdc-web-screenshot-tests/kfranqueiro/2019/02/04/15_38_21_044/report/report.html

@kfranqueiro kfranqueiro merged commit 56b8467 into material-components:master Feb 4, 2019
@jamesmfriedman jamesmfriedman mentioned this pull request Feb 5, 2019
24 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants