_fab-small-theme.scss 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Copyright 2021 Google Inc.
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. // THE SOFTWARE.
  20. @use '@material/theme/keys';
  21. @use '@material/theme/theme';
  22. @use '@material/theme/theme-color';
  23. @use '@material/tokens/resolvers';
  24. @use './fab-theme';
  25. @use 'sass:map';
  26. $height: 56px !default;
  27. $mini-height: 40px !default;
  28. $shape-radius: 50% !default;
  29. $ripple-target: '.mdc-fab__ripple';
  30. $_light-theme: (
  31. container-color: secondary,
  32. container-elevation: 6,
  33. container-height: 40px,
  34. container-shadow-color: black,
  35. container-shape: $shape-radius,
  36. container-width: 40px,
  37. focus-container-elevation: null,
  38. focus-icon-color: null,
  39. focus-outline-color: null,
  40. focus-outline-width: null,
  41. focus-state-layer-color: theme-color.$primary,
  42. focus-state-layer-opacity: null,
  43. hover-container-elevation: null,
  44. hover-icon-color: null,
  45. hover-state-layer-color: theme-color.$primary,
  46. hover-state-layer-opacity: null,
  47. icon-color: on-secondary,
  48. icon-size: 24px,
  49. lowered-container-elevation: null,
  50. lowered-focus-container-elevation: null,
  51. lowered-hover-container-elevation: null,
  52. lowered-pressed-container-elevation: null,
  53. pressed-container-elevation: null,
  54. pressed-icon-color: null,
  55. pressed-ripple-color: null,
  56. pressed-ripple-opacity: null,
  57. pressed-state-layer-color: theme-color.$primary,
  58. pressed-state-layer-opacity: null,
  59. );
  60. $custom-property-prefix: 'fab-small';
  61. ///
  62. /// Applies the given theme as custom properties without any selectors.
  63. ///
  64. /// @param {Map} $theme - Theme configuration to use for theming the small fab.
  65. /// @param {Map} $resolvers [resolvers.$material] - map of resolver functions
  66. /// that resolve token names to a valid Material theme config.
  67. @mixin theme($theme, $resolvers: resolvers.$material) {
  68. @include theme.validate-theme($_light-theme, $theme);
  69. $resolved-theme: fab-theme.resolve-theme($theme, $resolvers);
  70. @include keys.declare-custom-properties(
  71. $resolved-theme,
  72. $prefix: $custom-property-prefix
  73. );
  74. }
  75. ///
  76. /// Applies the themable styles for small fabs and exposes CSS custom properties
  77. /// as well as selectors.
  78. ///
  79. /// @param {Map} $theme - Theme configuration to use for theming the small fab.
  80. /// @param {Map} $resolvers [resolvers.$material] - map of resolver functions
  81. /// that resolve token names to a valid Material theme config.
  82. ///
  83. @mixin theme-styles($theme, $resolvers: resolvers.$material) {
  84. @include theme.validate-theme($_light-theme, $theme);
  85. $theme: keys.create-theme-properties(
  86. $theme,
  87. $prefix: $custom-property-prefix
  88. );
  89. @include fab-theme.base-theme-styles($theme, $resolvers: $resolvers);
  90. $shape-radius: map.get($theme, container-shape);
  91. @if $shape-radius {
  92. @include fab-theme.shape-radius($shape-radius);
  93. }
  94. }