// // Copyright 2018 Google Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // @import "@material/density/functions"; @import "@material/feature-targeting/functions"; @import "@material/feature-targeting/mixins"; @import "@material/ripple/mixins"; @import "@material/theme/mixins"; @import "./variables"; @mixin mdc-icon-button-core-styles($query: mdc-feature-all()) { @include mdc-icon-button-without-ripple($query); @include mdc-icon-button-ripple($query); } @mixin mdc-icon-button-without-ripple($query: mdc-feature-all()) { $feat-structure: mdc-feature-create-target($query, structure); // postcss-bem-linter: define icon-button .mdc-icon-button { @include mdc-icon-button-base_($query: $query); @include mdc-icon-button-density(0, $query: $query); } .mdc-icon-button__icon { @include mdc-feature-targets($feat-structure) { display: inline-block; } // stylelint-disable-next-line plugin/selector-bem-pattern &.mdc-icon-button__icon--on { @include mdc-feature-targets($feat-structure) { display: none; } } } .mdc-icon-button--on { .mdc-icon-button__icon { @include mdc-feature-targets($feat-structure) { display: none; } // stylelint-disable-next-line plugin/selector-bem-pattern &.mdc-icon-button__icon--on { @include mdc-feature-targets($feat-structure) { display: inline-block; } } } } // postcss-bem-linter: end } @mixin mdc-icon-button-ripple($query: mdc-feature-all()) { @include mdc-ripple-common($query); .mdc-icon-button { @include mdc-ripple-surface($query: $query); @include mdc-ripple-radius-unbounded($query: $query); @include mdc-states($query: $query); } } /// /// Sets the density scale for icon button. /// /// @param {Number | String} $density-scale - Density scale value for component. /// Supported density scale values range from `-5` to `0`, with `0` being the default. /// @mixin mdc-icon-button-density($density-scale, $query: mdc-feature-all()) { $size: mdc-density-prop-value( $density-config: $mdc-icon-button-density-config, $density-scale: $density-scale, $property-name: size, ); @include mdc-icon-button-size($size, $query: $query); } /// /// Sets the size of the icon-button. /// /// @param {Number} $size - Size value for icon-button. /// Size will set the width, height, and padding for the overall component. /// @mixin mdc-icon-button-size($size, $query: mdc-feature-all()) { $feat-structure: mdc-feature-create-target($query, structure); @include mdc-feature-targets($feat-structure) { width: $size; height: $size; padding: ($size - $mdc-icon-button-icon-size) / 2; } } /// /// Sets the width, height and padding of icon button. Also changes the size of /// the icon itself based on button size. /// /// @param {Number} $width - Width value for icon-button. /// @param {Number} $height - Height value for icon-button. (default: $width) /// @param {Number} $padding - Padding value for icon-button. (default: max($width, $height) / 2) /// @deprecated /// This mixin provides too much of low level customization. /// Please use mdc-icon-button-size instead. /// @mixin mdc-icon-button-icon-size($width, $height: $width, $padding: max($width,$height)/2, $query: mdc-feature-all()) { $feat-structure: mdc-feature-create-target($query, structure); @include mdc-feature-targets($feat-structure) { width: $width + $padding * 2; height: $height + $padding * 2; padding: $padding; font-size: max($width, $height); } // stylelint-disable-next-line selector-max-type svg, img { @include mdc-feature-targets($feat-structure) { width: $width; height: $height; } } } @mixin mdc-icon-button-ink-color($color, $query: mdc-feature-all()) { $feat-color: mdc-feature-create-target($query, color); @include mdc-feature-targets($feat-color) { @include mdc-theme-prop(color, $color); } @include mdc-states($color, $query: $query); } @mixin mdc-icon-button-base_($query: mdc-feature-all()) { $feat-color: mdc-feature-create-target($query, color); $feat-structure: mdc-feature-create-target($query, structure); @include mdc-feature-targets($feat-structure) { display: inline-block; position: relative; box-sizing: border-box; border: none; outline: none; background-color: transparent; fill: currentColor; color: inherit; font-size: $mdc-icon-button-icon-size; text-decoration: none; cursor: pointer; user-select: none; } // stylelint-disable-next-line selector-max-type svg, img { @include mdc-feature-targets($feat-structure) { width: $mdc-icon-button-icon-size; height: $mdc-icon-button-icon-size; } } &:disabled { @include mdc-feature-targets($feat-color) { @include mdc-theme-prop(color, text-disabled-on-light); } @include mdc-feature-targets($feat-structure) { cursor: default; pointer-events: none; } } }