| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- //
- // Copyright 2020 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.
- //
- // stylelint-disable selector-class-pattern --
- // Selector '.mdc-*' should only be used in this project.
- @use '@material/elevation/elevation';
- @use '@material/elevation/elevation-theme';
- @use '@material/feature-targeting/feature-targeting';
- @use '@material/ripple/ripple-theme';
- @use '@material/rtl/rtl';
- @use '@material/dom/dom';
- @use '@material/touch-target/touch-target';
- @use '@material/focus-ring/focus-ring';
- @use '@material/typography/typography';
- @use './button-shared-theme';
- @mixin static-styles($query: feature-targeting.all()) {
- @include _static-styles-base($query: $query);
- @include _typography-styles($query: $query);
- }
- @mixin _static-styles-base($query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- @include touch-target.wrapper($query); // COPYBARA_COMMENT_THIS_LINE
- // prettier-ignore
- @include elevation.overlay-common($query); // COPYBARA_COMMENT_THIS_LINE
- // postcss-bem-linter: define button
- .mdc-button {
- @include _root-structure($query);
- // The icon CSS class overrides styles defined in the .material-icons CSS
- // class, which is loaded separately so the order of CSS definitions is not
- // guaranteed. Therefore, increase specifity by nesting this class to ensure
- // overrides apply.
- .mdc-button__icon {
- @include feature-targeting.targets($feat-structure) {
- @include _icon-structure;
- }
- }
- .mdc-button__progress-indicator {
- @include feature-targeting.targets($feat-structure) {
- font-size: 0;
- position: absolute;
- @include rtl.ignore-next-line();
- transform: translate(-50%, -50%);
- top: 50%;
- @include rtl.ignore-next-line();
- left: 50%;
- line-height: initial;
- }
- }
- .mdc-button__label {
- @include feature-targeting.targets($feat-structure) {
- // Necessary such that label is stacked on top of ripple
- // (since ripple is a positioned element, non-positioned elements
- // appear under it).
- position: relative;
- }
- }
- .mdc-button__focus-ring {
- @include focus-ring.focus-ring($query: $query);
- @include feature-targeting.targets($feat-structure) {
- display: none;
- }
- }
- @include ripple-theme.focus {
- .mdc-button__focus-ring {
- @include dom.forced-colors-mode($exclude-ie11: true) {
- @include feature-targeting.targets($feat-structure) {
- display: block;
- }
- }
- }
- }
- .mdc-button__touch {
- @include touch-target.touch-target($query: $query);
- }
- }
- .mdc-button__label + .mdc-button__icon {
- @include feature-targeting.targets($feat-structure) {
- @include icon-trailing;
- }
- }
- svg.mdc-button__icon {
- @include feature-targeting.targets($feat-structure) {
- @include icon-svg;
- }
- }
- .mdc-button--touch {
- // Touch target doesn't change with height. It simply gets removed if
- // density (height) changes. Therefore, it is a static style.
- @include touch-target.margin(
- $component-height: button-shared-theme.$height,
- $query: $query
- );
- }
- // postcss-bem-linter: end
- }
- @mixin _typography-styles($query) {
- .mdc-button {
- // Exclude properties declared in theme styles.
- @include typography.typography(
- button,
- $exclude-props: (
- font-size,
- line-height,
- font-weight,
- letter-spacing,
- text-transform
- ),
- $query: $query
- );
- }
- }
- /// @deprecated Contains typography declarations now part of theme-styles.
- @mixin deprecated-static-styles-without-ripple(
- $query: feature-targeting.all()
- ) {
- @include _deprecated-typography-styles($query: $query);
- @include _static-styles-base($query: $query);
- }
- @mixin _deprecated-typography-styles($query) {
- .mdc-button {
- @include typography.typography(button, $query);
- }
- }
- @mixin deprecated-base($query) {
- @include base($query);
- }
- @mixin base($query) {
- @include typography.typography(button, $query);
- @include _root-structure($query: $query);
- }
- @mixin _root-structure($query) {
- $feat-structure: feature-targeting.create-target($query, structure);
- @include elevation-theme.overlay-surface-position($query: $query);
- @include elevation-theme.overlay-dimensions(100%, $query: $query);
- @include feature-targeting.targets($feat-structure) {
- display: inline-flex;
- // position: relative; already set in mdc-elevation-overlay-surface-position
- align-items: center;
- justify-content: center;
- box-sizing: border-box;
- min-width: 64px;
- border: none;
- outline: none;
- /* @alternate */
- line-height: inherit;
- user-select: none;
- -webkit-appearance: none;
- // Even though `visible` is the default, IE 11 computes the property as
- // `hidden` in some cases, unless it's explicitly defined here.
- overflow: visible;
- vertical-align: middle;
- background: transparent;
- }
- &::-moz-focus-inner {
- @include feature-targeting.targets($feat-structure) {
- padding: 0;
- border: 0;
- }
- }
- // postcss-bem-linter: ignore
- &:active {
- @include feature-targeting.targets($feat-structure) {
- outline: none;
- }
- }
- &:hover {
- @include feature-targeting.targets($feat-structure) {
- cursor: pointer;
- }
- }
- &:disabled {
- @include feature-targeting.targets($feat-structure) {
- cursor: default;
- pointer-events: none;
- }
- }
- &[hidden] {
- @include feature-targeting.targets($feat-structure) {
- display: none;
- }
- }
- }
- @mixin icon {
- @include _icon-structure;
- @include _icon-size(18px);
- }
- @mixin _icon-structure {
- @include rtl.reflexive-box(margin, right, 8px);
- display: inline-block;
- position: relative;
- vertical-align: top;
- }
- @mixin _icon-size($size-px) {
- $icon-size: typography.px-to-rem($size-px);
- font-size: $icon-size;
- height: $icon-size;
- width: $icon-size;
- }
- @mixin icon-trailing {
- @include rtl.reflexive-box(margin, left, 8px);
- }
- @mixin icon-svg {
- fill: currentColor;
- }
- @mixin icon-contained {
- @include rtl.reflexive-property(margin, -4px, 8px);
- }
- @mixin icon-contained-trailing {
- @include rtl.reflexive-property(margin, 8px, -4px);
- }
- @mixin raised-transition($query: feature-targeting.all()) {
- $feat-animation: feature-targeting.create-target($query, animation);
- @include feature-targeting.targets($feat-animation) {
- transition: elevation-theme.transition-value();
- }
- }
- /// @deprecated Private style mixin for partners; not available for public use.
- @mixin deprecated-icon {
- @include icon;
- }
- /// @deprecated Private style mixin for partners; not available for public use.
- @mixin deprecated-icon-trailing {
- @include icon-trailing;
- }
- /// @deprecated Private style mixin for partners; not available for public use.
- @mixin deprecated-icon-svg {
- @include icon-svg;
- }
- /// @deprecated Private style mixin for partners; not available for public use.
- @mixin deprecated-icon-contained {
- @include icon-contained;
- }
- /// @deprecated Private style mixin for partners; not available for public use.
- @mixin deprecated-icon-contained-trailing {
- @include icon-contained-trailing;
- }
|