_button-filled-theme.scss 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // Copyright 2021 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 'sass:map';
  25. @use '@material/feature-targeting/feature-targeting';
  26. @use '@material/tokens/resolvers';
  27. @use '@material/theme/keys';
  28. @use '@material/theme/theme';
  29. @use './button-shared-theme';
  30. $custom-property-prefix: 'filled-button';
  31. $light-theme: (
  32. container-color: primary,
  33. container-elevation: 0,
  34. container-height: button-shared-theme.$height,
  35. container-shadow-color: null,
  36. container-shape: button-shared-theme.$shape-radius,
  37. disabled-container-color: button-shared-theme.$disabled-container-color,
  38. disabled-container-elevation: 0,
  39. disabled-label-text-color: button-shared-theme.$disabled-ink-color,
  40. focus-container-elevation: 0,
  41. focus-label-text-color: null,
  42. focus-state-layer-color: on-primary,
  43. focus-state-layer-opacity: 0.24,
  44. hover-container-elevation: 0,
  45. hover-label-text-color: null,
  46. hover-state-layer-color: on-primary,
  47. hover-state-layer-opacity: 0.08,
  48. /// Prevent the increased touch target from being reseted if the
  49. /// container-height differs from the default (36px)
  50. keep-touch-target: false,
  51. label-text-color: on-primary,
  52. label-text-font: button-font-family,
  53. label-text-size: button-font-size,
  54. label-text-tracking: button-letter-spacing,
  55. label-text-transform: button-text-transform,
  56. label-text-weight: button-font-weight,
  57. pressed-container-elevation: 0,
  58. pressed-label-text-color: null,
  59. pressed-state-layer-color: on-primary,
  60. pressed-state-layer-opacity: 0.24,
  61. with-icon-disabled-icon-color: null,
  62. with-icon-focus-icon-color: null,
  63. with-icon-hover-icon-color: null,
  64. with-icon-icon-color: null,
  65. with-icon-icon-size: 18px,
  66. with-icon-pressed-icon-color: null,
  67. );
  68. /// Sets theme based on provided theme configuration.
  69. /// Only emits theme related styles.
  70. /// @param {Map} $theme - Theme configuration to use.
  71. @mixin theme($theme, $resolver: resolvers.$material) {
  72. @include theme.validate-theme($light-theme, $theme);
  73. $theme: button-shared-theme.resolve-theme-elevation-keys(
  74. $theme,
  75. $resolver: $resolver
  76. );
  77. @include keys.declare-custom-properties($theme, $custom-property-prefix);
  78. }
  79. @mixin theme-styles(
  80. $theme,
  81. $resolver: resolvers.$material,
  82. $query: feature-targeting.all()
  83. ) {
  84. @include theme.validate-theme($light-theme, $theme);
  85. $theme: keys.create-theme-properties(
  86. $theme,
  87. $prefix: $custom-property-prefix
  88. );
  89. @include button-shared-theme.theme-styles($theme, $resolver, $query: $query);
  90. }
  91. @mixin deprecated-theme-styles($query: feature-targeting.all()) {
  92. .mdc-button--raised,
  93. .mdc-button--unelevated {
  94. $theme: map.merge(
  95. $light-theme,
  96. (
  97. focus-state-layer-color: null,
  98. focus-state-layer-opacity: null,
  99. hover-state-layer-color: null,
  100. hover-state-layer-opacity: null,
  101. pressed-state-layer-color: null,
  102. pressed-state-layer-opacity: null,
  103. label-text-font: null,
  104. label-text-size: null,
  105. label-text-tracking: null,
  106. label-text-transform: null,
  107. label-text-weight: null,
  108. )
  109. );
  110. @include button-shared-theme.theme-styles(
  111. $theme,
  112. resolvers.$material,
  113. $query: $query
  114. );
  115. }
  116. }