_button-protected-theme.scss 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. @use '@material/feature-targeting/feature-targeting';
  23. @use '@material/theme/keys';
  24. @use '@material/theme/theme';
  25. @use '@material/tokens/resolvers';
  26. @use './button-shared-theme';
  27. $custom-property-prefix: 'protected-button';
  28. $light-theme: (
  29. container-color: primary,
  30. container-elevation: 2,
  31. container-height: button-shared-theme.$height,
  32. container-shadow-color: black,
  33. container-shape: button-shared-theme.$shape-radius,
  34. disabled-container-color: button-shared-theme.$disabled-container-color,
  35. disabled-container-elevation: 0,
  36. disabled-label-text-color: button-shared-theme.$disabled-ink-color,
  37. focus-container-elevation: 4,
  38. focus-label-text-color: null,
  39. focus-state-layer-color: on-primary,
  40. focus-state-layer-opacity: 0.24,
  41. hover-container-elevation: 4,
  42. hover-label-text-color: null,
  43. hover-state-layer-color: on-primary,
  44. hover-state-layer-opacity: 0.08,
  45. /// Prevent the increased touch target from being reseted if the
  46. /// container-height differs from the default (36px)
  47. keep-touch-target: false,
  48. label-text-color: on-primary,
  49. label-text-font: button-font-family,
  50. label-text-size: button-font-size,
  51. label-text-tracking: button-letter-spacing,
  52. label-text-transform: button-text-transform,
  53. label-text-weight: button-font-weight,
  54. pressed-container-elevation: 8,
  55. pressed-label-text-color: null,
  56. pressed-state-layer-color: on-primary,
  57. pressed-state-layer-opacity: 0.24,
  58. with-icon-disabled-icon-color: null,
  59. with-icon-focus-icon-color: null,
  60. with-icon-hover-icon-color: null,
  61. with-icon-icon-color: null,
  62. with-icon-icon-size: 18px,
  63. with-icon-pressed-icon-color: null,
  64. );
  65. /// Sets theme based on provided theme configuration.
  66. /// Only emits theme related styles.
  67. /// @param {Map} $theme - Theme configuration to use.
  68. @mixin theme($theme, $resolver: resolvers.$material) {
  69. @include theme.validate-theme($light-theme, $theme);
  70. $theme: button-shared-theme.resolve-theme-elevation-keys(
  71. $theme,
  72. $resolver: $resolver
  73. );
  74. @include keys.declare-custom-properties($theme, $custom-property-prefix);
  75. }
  76. @mixin theme-styles(
  77. $theme,
  78. $resolver: resolvers.$material,
  79. $query: feature-targeting.all()
  80. ) {
  81. @include theme.validate-theme($light-theme, $theme);
  82. $theme: keys.create-theme-properties(
  83. $theme,
  84. $prefix: $custom-property-prefix
  85. );
  86. @include button-shared-theme.theme-styles($theme, $resolver, $query: $query);
  87. }