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(feature-targeting): target top-level styles for elevation, ripple, #4383

Merged
merged 5 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
41 changes: 30 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions packages/mdc-elevation/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@
@import "@material/theme/variables";
@import "./variables";

@mixin mdc-elevation-core-styles($query: mdc-feature-all()) {
$feat-animation: mdc-feature-create-target($query, animation);
$feat-structure: mdc-feature-create-target($query, structure);

@for $z-value from 0 through 24 {
.mdc-elevation--z#{$z-value} {
@include mdc-elevation($z-value, $query: $query);
}
}

.mdc-elevation-transition {
@include mdc-feature-targets($feat-animation) {
transition: mdc-elevation-transition-value();
mmalerba marked this conversation as resolved.
Show resolved Hide resolved
}

@include mdc-feature-targets($feat-structure) {
will-change: $mdc-elevation-property;
}
}
}

// Applies the correct CSS rules to an element to give it the elevation specified by $z-value.
// The $z-value must be between 0 and 24.
// If $color has an alpha channel, it will be ignored and overridden. To increase the opacity of the shadow, use
Expand Down
12 changes: 1 addition & 11 deletions packages/mdc-elevation/mdc-elevation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,4 @@
//

@import "./mixins";

@for $z-value from 0 through 24 {
.mdc-elevation--z#{$z-value} {
@include mdc-elevation($z-value);
}
}

.mdc-elevation-transition {
transition: mdc-elevation-transition-value();
will-change: $mdc-elevation-property;
}
@include mdc-elevation-core-styles;
37 changes: 37 additions & 0 deletions packages/mdc-ripple/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// THE SOFTWARE.
//

@import "@material/animation/functions";
@import "@material/animation/variables";
@import "@material/base/mixins";
@import "@material/feature-targeting/functions";
Expand All @@ -29,6 +30,42 @@
@import "./keyframes";
@import "./variables";

@mixin mdc-ripple-core-styles($query: mdc-feature-all()) {
// postcss-bem-linter: define ripple-surface

$feat-structure: mdc-feature-create-target($query, structure);

.mdc-ripple-surface {
@include mdc-ripple-surface($query: $query);
@include mdc-states($query: $query);
@include mdc-ripple-radius-bounded($query: $query);

@include mdc-feature-targets($feat-structure) {
position: relative;
outline: none;
overflow: hidden;
}

&[data-mdc-ripple-is-unbounded] {
@include mdc-ripple-radius-unbounded($query: $query);

@include mdc-feature-targets($feat-structure) {
overflow: visible;
}
}

&--primary {
@include mdc-states(primary, $query: $query);
}

&--accent {
@include mdc-states(secondary, $query: $query);
}
}

// postcss-bem-linter: end
}

@mixin mdc-ripple-common($query: mdc-feature-all()) {
$feat-animation: mdc-feature-create-target($query, animation);
$feat-structure: mdc-feature-create-target($query, structure);
Expand Down
34 changes: 2 additions & 32 deletions packages/mdc-ripple/mdc-ripple.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,6 @@
// THE SOFTWARE.
//

@import "@material/animation/functions";
@import "@material/theme/mixins";
@import "./common";
mmalerba marked this conversation as resolved.
Show resolved Hide resolved
@import "./mixins";
@import "./variables";

// postcss-bem-linter: define ripple-surface

.mdc-ripple-surface {
@include mdc-ripple-surface;
@include mdc-states;
@include mdc-ripple-radius-bounded;

position: relative;
outline: none;
overflow: hidden;

&[data-mdc-ripple-is-unbounded] {
@include mdc-ripple-radius-unbounded;

overflow: visible;
}

&--primary {
@include mdc-states(primary);
}

&--accent {
@include mdc-states(secondary);
}
}

// postcss-bem-linter: end
@include mdc-ripple-common;
@include mdc-ripple-core-styles;
43 changes: 41 additions & 2 deletions packages/mdc-theme/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,47 @@
// THE SOFTWARE.
//

@import "@material/feature-targeting/functions";
mmalerba marked this conversation as resolved.
Show resolved Hide resolved
@import "@material/feature-targeting/mixins";
@import "./variables";

@mixin mdc-theme-core-styles($query: mdc-feature-all()) {
$feat-color: mdc-feature-create-target($query, color);

:root {
@include mdc-feature-targets($feat-color) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this feature-targets is outside the @each but the ones below are inside?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one doesn't have any selectors inside of it, just properties

@each $style in map-keys($mdc-theme-property-values) {
--mdc-theme-#{$style}: #{map-get($mdc-theme-property-values, $style)};
}
}
}

@each $style in map-keys($mdc-theme-property-values) {
@if $style != "background" and $style != "surface" {
.mdc-theme--#{$style} {
@include mdc-feature-targets($feat-color) {
@include mdc-theme-prop(color, $style, true);
}
}
} @else {
.mdc-theme--#{$style} {
@include mdc-feature-targets($feat-color) {
@include mdc-theme-prop(background-color, $style);
}
}
}
}

// CSS rules for using primary and secondary (plus light/dark variants) as background colors.
@each $style in ("primary", "secondary") {
.mdc-theme--#{$style}-bg {
@include mdc-feature-targets($feat-color) {
@include mdc-theme-prop(background-color, $style, true);
}
}
}
}

// Applies the correct theme color style to the specified property.
// $property is typically color or background-color, but can be any CSS property that accepts color values.
// $style should be one of the map keys in $mdc-theme-property-values (_variables.scss), or a color value.
Expand All @@ -47,7 +86,7 @@
@if $edgeOptOut {
// stylelint-disable max-nesting-depth
@at-root {
@supports not (-ms-ime-align:auto) {
@supports not (-ms-ime-align: auto) {
// stylelint-disable scss/selector-no-redundant-nesting-selector
& {
/* @alternate */
Expand All @@ -67,7 +106,7 @@
@if $edgeOptOut {
// stylelint-disable max-nesting-depth
@at-root {
@supports not (-ms-ime-align:auto) {
@supports not (-ms-ime-align: auto) {
// stylelint-disable scss/selector-no-redundant-nesting-selector
& {
/* @alternate */
Expand Down
26 changes: 1 addition & 25 deletions packages/mdc-theme/mdc-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,4 @@
//

@import "./mixins";

:root {
@each $style in map-keys($mdc-theme-property-values) {
--mdc-theme-#{$style}: #{map-get($mdc-theme-property-values, $style)};
}
}

@each $style in map-keys($mdc-theme-property-values) {
@if $style != "background" and $style != "surface" {
.mdc-theme--#{$style} {
@include mdc-theme-prop(color, $style, true);
}
} @else {
.mdc-theme--#{$style} {
@include mdc-theme-prop(background-color, $style);
}
}
}

// CSS rules for using primary and secondary (plus light/dark variants) as background colors.
@each $style in ("primary", "secondary") {
.mdc-theme--#{$style}-bg {
@include mdc-theme-prop(background-color, $style, true);
}
}
@include mdc-theme-core-styles;
3 changes: 3 additions & 0 deletions packages/mdc-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"repository": {
"type": "git",
"url": "https://github.com/material-components/material-components-web.git"
},
"dependencies": {
"@material/feature-targeting": "^0.44.0"
}
}
Loading