_button.scss 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // Copyright 2020 Google Inc.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. // stylelint-disable selector-class-pattern --
  23. // Selector '.mdc-*' should only be used in this project.
  24. @use '@material/feature-targeting/feature-targeting';
  25. @use '@material/rtl/rtl';
  26. @use '@material/touch-target/mixins' as touch-target-mixins;
  27. @use '@material/typography/typography';
  28. @use './button-base';
  29. @use './button-filled';
  30. @use './button-filled-theme';
  31. @use './button-outlined';
  32. @use './button-outlined-theme';
  33. @use './button-protected';
  34. @use './button-protected-theme';
  35. @use './button-ripple';
  36. @use './button-text';
  37. @use './button-text-theme';
  38. @use './button-theme';
  39. @use './button-shared-theme';
  40. // For backwards compatibility.
  41. @forward './button-base' show deprecated-base, base, icon, icon-trailing, icon-svg, icon-contained, icon-contained-trailing, deprecated-icon, deprecated-icon-trailing, deprecated-icon-svg, deprecated-icon-contained, deprecated-icon-contained-trailing;
  42. @mixin styles($query: feature-targeting.all()) {
  43. @include static-styles($query: $query);
  44. @include theme-styles($query: $query);
  45. }
  46. @mixin theme-styles($query: feature-targeting.all()) {
  47. .mdc-button {
  48. @include button-text-theme.theme-styles(
  49. button-text-theme.$light-theme,
  50. $query: $query
  51. );
  52. }
  53. .mdc-button--unelevated {
  54. @include button-filled-theme.theme-styles(
  55. button-filled-theme.$light-theme,
  56. $query: $query
  57. );
  58. }
  59. .mdc-button--raised {
  60. @include button-protected-theme.theme-styles(
  61. button-protected-theme.$light-theme,
  62. $query: $query
  63. );
  64. }
  65. .mdc-button--outlined {
  66. @include button-outlined-theme.theme-styles(
  67. button-outlined-theme.$light-theme,
  68. $query: $query
  69. );
  70. }
  71. }
  72. @mixin static-styles($query: feature-targeting.all()) {
  73. @include static-styles-without-ripple($query: $query);
  74. @include button-ripple.static-styles($query: $query);
  75. }
  76. @mixin static-styles-without-ripple($query: feature-targeting.all()) {
  77. @include button-base.static-styles($query: $query);
  78. @include button-text.static-styles-without-ripple($query: $query);
  79. @include button-filled.static-styles-without-ripple($query: $query);
  80. @include button-protected.static-styles-without-ripple($query: $query);
  81. @include button-outlined.static-styles-without-ripple($query: $query);
  82. }
  83. // Legacy mixins
  84. @mixin without-ripple($query: feature-targeting.all()) {
  85. @include button-base.deprecated-static-styles-without-ripple($query: $query);
  86. @include button-text.static-styles-without-ripple($query: $query);
  87. @include button-filled.static-styles-without-ripple($query: $query);
  88. @include button-protected.static-styles-without-ripple($query: $query);
  89. @include button-outlined.static-styles-without-ripple($query: $query);
  90. @include _theme-styles-without-ripple($query: $query);
  91. }
  92. @mixin _theme-styles-without-ripple($query: feature-targeting.all()) {
  93. @include button-text-theme.deprecated-theme-styles($query: $query);
  94. @include button-filled-theme.deprecated-theme-styles($query: $query);
  95. @include button-outlined-theme.deprecated-theme-styles($query: $query);
  96. // Elevation has been recategorized into theme styles. Keeping old elevation
  97. // styles here for backwards compatibility.
  98. .mdc-button--raised {
  99. @include button-protected.raised($query: $query);
  100. }
  101. }
  102. // @deprecated - use styles() instead.
  103. @mixin core-styles($query: feature-targeting.all()) {
  104. @include styles($query: $query);
  105. // TODO: remove this rule since padding now takes care of icon margins.
  106. $feat-structure: feature-targeting.create-target($query, structure);
  107. .mdc-button--raised,
  108. .mdc-button--unelevated,
  109. .mdc-button--outlined {
  110. .mdc-button__icon {
  111. @include feature-targeting.targets($feat-structure) {
  112. // Icons inside contained buttons have different styles due to increased button padding
  113. @include button-base.icon-contained;
  114. }
  115. }
  116. .mdc-button__label + .mdc-button__icon {
  117. @include feature-targeting.targets($feat-structure) {
  118. @include button-base.icon-contained-trailing;
  119. }
  120. }
  121. }
  122. }