_menusurface-theme.scss 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // Copyright 2023 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/animation/variables' as animation-variables;
  26. @use '@material/theme/custom-properties';
  27. @use '@material/theme/theme';
  28. @use '@material/shape/mixins' as shape-mixins;
  29. $fade-in-duration: 0.03s !default;
  30. $fade-out-duration: 0.075s !default;
  31. $scale-duration: 0.12s !default;
  32. $min-distance-from-edge: 32px !default;
  33. $z-index: 8 !default; // One above mdc-dialog
  34. $shape-radius: medium !default;
  35. @mixin theme-styles($query: feature-targeting.all()) {
  36. $feat-structure: feature-targeting.create-target($query, structure);
  37. $feat-animation: feature-targeting.create-target($query, animation);
  38. // postcss-bem-linter: define menu-surface
  39. .mdc-menu-surface {
  40. @include feature-targeting.targets($feat-structure) {
  41. $max-width: custom-properties.create(
  42. --mdc-menu-max-width,
  43. calc(100vw - #{$min-distance-from-edge})
  44. );
  45. @include theme.property(max-width, $max-width);
  46. $max-height: custom-properties.create(
  47. --mdc-menu-max-height,
  48. calc(100vh - #{$min-distance-from-edge})
  49. );
  50. @include theme.property(max-height, $max-height);
  51. z-index: $z-index;
  52. }
  53. @include feature-targeting.targets($feat-animation) {
  54. transition: opacity $fade-in-duration linear,
  55. transform $scale-duration
  56. animation-variables.$deceleration-curve-timing-function,
  57. height 250ms animation-variables.$deceleration-curve-timing-function;
  58. }
  59. &--animating-closed {
  60. @include feature-targeting.targets($feat-animation) {
  61. transition: opacity $fade-out-duration linear;
  62. }
  63. }
  64. @include fill-color(surface, $query);
  65. @include ink-color(on-surface, $query);
  66. @include shape-radius($shape-radius, false, $query);
  67. }
  68. // postcss-bem-linter: end
  69. }
  70. @mixin ink-color($color, $query: feature-targeting.all()) {
  71. $feat-color: feature-targeting.create-target($query, color);
  72. @include feature-targeting.targets($feat-color) {
  73. @include theme.property(color, $color);
  74. }
  75. }
  76. @mixin fill-color($color, $query: feature-targeting.all()) {
  77. $feat-color: feature-targeting.create-target($query, color);
  78. @include feature-targeting.targets($feat-color) {
  79. @include theme.property(background-color, $color);
  80. }
  81. }
  82. @mixin shape-radius(
  83. $radius,
  84. $rtl-reflexive: false,
  85. $query: feature-targeting.all()
  86. ) {
  87. @include shape-mixins.radius($radius, $rtl-reflexive, $query: $query);
  88. }