Skip to content

Commit

Permalink
feat(switch): add ripple opacity customization mixins (material-compo…
Browse files Browse the repository at this point in the history
  • Loading branch information
allan-chen authored Oct 2, 2019
1 parent d7e2848 commit 8c0273f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/mdc-switch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Mixin | Description
`mdc-switch-toggled-off-thumb-color($color)` | Sets color of the thumb when the switch is toggled off.
`mdc-switch-toggled-on-ripple-color($color)` | Sets the color of the ripple surrounding the thumb when the switch is toggled on.
`mdc-switch-toggled-off-ripple-color($color)` | Sets the color of the ripple surrounding the thumb when the switch is toggled off.
`mdc-switch-ripple-states-opacity($opacity-map)` | Sets the opacity of the ripple surrounding the thumb in any of the `hover`, `focus`, or `press` states. The `opacity-map` can specify any of these states as keys. States not specified in the map resort to default opacity values.

## `MDCSwitch` Properties and Methods

Expand Down
20 changes: 20 additions & 0 deletions packages/mdc-switch/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,26 @@
}
}

/// Customizes ripple opacities surrounding the thumb in `hover`, `focus`, or `press` states
/// The customizations apply to both on and off switches to ensure symmetry
/// @param {map} $opacity-map - map specifying custom opacity of zero or more states
@mixin mdc-switch-ripple-states-opacity($opacity-map: (), $query: mdc-feature-all()) {
// Ensure sufficient specificity to override base state opacities
&.mdc-switch .mdc-switch__thumb-underlay {
@if map-has-key($opacity-map, "hover") {
@include mdc-states-hover-opacity(map-get($opacity-map, "hover"), $query);
}

@if map-has-key($opacity-map, "focus") {
@include mdc-states-focus-opacity(map-get($opacity-map, "focus"), $query);
}

@if map-has-key($opacity-map, "press") {
@include mdc-states-press-opacity(map-get($opacity-map, "press"), $query);
}
}
}

//
// Private
//
Expand Down

0 comments on commit 8c0273f

Please sign in to comment.