Skip to content

Commit

Permalink
refactor: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto committed Jan 20, 2019
1 parent dc24250 commit 7d64bdc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
58 changes: 30 additions & 28 deletions packages/mdc-switch/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
//

@import "@material/theme/mixins";
@import "@material/ripple/common";
@import "@material/ripple/mixins";
@import "@material/rtl/mixins";
@import "@material/elevation/mixins";
Expand All @@ -35,12 +34,14 @@
// Public
//
@mixin mdc-switch($query: mdc-feature-all()) {
// postcss-bem-linter: define checkbox
// postcss-bem-linter: define switch

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

@include mdc-ripple-common($query);

.mdc-switch {
@include mdc-feature-targets($feat-structure) {
@include mdc-switch-base_;
Expand All @@ -51,7 +52,7 @@
@include mdc-switch-toggled-on-thumb-color($mdc-switch-baseline-theme-color);
@include mdc-switch-toggled-off-track-color($mdc-switch-toggled-off-track-color);
@include mdc-switch-toggled-off-thumb-color($mdc-switch-toggled-off-thumb-color);
@include mdc-switch-toggled-off-ripple-color($mdc-switch-toggled-off-ripple-color);
@include mdc-switch-toggled-off-ripple-color($mdc-switch-toggled-off-ripple-color, $query);
}
}

Expand All @@ -64,7 +65,9 @@
}

.mdc-switch__native-control {
@include mdc-switch__native-control_($query);
@include mdc-feature-targets($feat-structure) {
@include mdc-switch__native-control_;
}
}

.mdc-switch__thumb {
Expand Down Expand Up @@ -104,16 +107,16 @@
// postcss-bem-linter: end
}

@mixin mdc-switch-toggled-on-color($color) {
@mixin mdc-switch-toggled-on-color($color, $query: mdc-feature-all()) {
@include mdc-switch-toggled-on-track-color($color);
@include mdc-switch-toggled-on-thumb-color($color);
@include mdc-switch-toggled-on-ripple-color($color);
@include mdc-switch-toggled-on-ripple-color($color, $query);
}

@mixin mdc-switch-toggled-off-color($color) {
@mixin mdc-switch-toggled-off-color($color, $query: mdc-feature-all()) {
@include mdc-switch-toggled-off-track-color($color);
@include mdc-switch-toggled-off-thumb-color($color);
@include mdc-switch-toggled-off-ripple-color($color);
@include mdc-switch-toggled-off-ripple-color($color, $query);
}

@mixin mdc-switch-toggled-on-track-color($color) {
Expand All @@ -130,9 +133,9 @@
}
}

@mixin mdc-switch-toggled-on-ripple-color($color) {
@mixin mdc-switch-toggled-on-ripple-color($color, $query: mdc-feature-all()) {
&.mdc-switch--checked .mdc-switch__thumb-underlay {
@include mdc-states($color);
@include mdc-states($color, false, $query);
}
}

Expand All @@ -150,9 +153,9 @@
}
}

@mixin mdc-switch-toggled-off-ripple-color($color) {
@mixin mdc-switch-toggled-off-ripple-color($color, $query: mdc-feature-all()) {
&:not(.mdc-switch--checked) .mdc-switch__thumb-underlay {
@include mdc-states($color);
@include mdc-states($color, false, $query);
}
}

Expand Down Expand Up @@ -198,7 +201,7 @@

@include mdc-feature-targets($feat-structure) {
@include mdc-rtl-reflexive-position(left, $mdc-switch-tap-target-initial-position);
@include mdc-ripple-surface();
@include mdc-ripple-surface($query);
@include mdc-ripple-radius-unbounded;

display: flex;
Expand All @@ -220,29 +223,28 @@
}
}

@mixin mdc-switch__native-control_($query: mdc-feature-all()) {
$feat-structure: mdc-feature-create-target($query, structure);

@include mdc-feature-targets($feat-structure) {
@include mdc-rtl-reflexive-position(left, 0);

position: absolute;
top: 0;
width: $mdc-switch-native-control-width;
height: $mdc-switch-tap-target-size;
margin: 0;
opacity: 0;
cursor: pointer;
pointer-events: auto;
}
@mixin mdc-switch__native-control_ {
@include mdc-rtl-reflexive-position(left, 0);

position: absolute;
top: 0;
width: $mdc-switch-native-control-width;
height: $mdc-switch-tap-target-size;
margin: 0;
opacity: 0;
cursor: pointer;
pointer-events: auto;
}

@mixin mdc-switch__thumb_($query: mdc-feature-all()) {
$feat-structure: mdc-feature-create-target($query, structure);
$feat-color: mdc-feature-create-target($query, color);

@include mdc-feature-targets($feat-structure) {
@include mdc-elevation(2);
}

@include mdc-feature-targets($feat-structure) {
box-sizing: border-box;
width: $mdc-switch-thumb-diameter;
height: $mdc-switch-thumb-diameter;
Expand Down
2 changes: 2 additions & 0 deletions test/scss/feature-targeting.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "@material/feature-targeting/functions";
@import "@material/button/mixins";
@import "@material/switch/mixins";
@include mdc-button($query: mdc-feature-any());
@include mdc-switch($query: mdc-feature-any());

0 comments on commit 7d64bdc

Please sign in to comment.