_button-text-theme.scss 4.1 KB

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