_menusurface.scss 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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/elevation/mixins' as elevation-mixins;
  26. @use '@material/rtl/rtl';
  27. @use './menusurface-theme';
  28. //
  29. // Public
  30. //
  31. @mixin core-styles($query: feature-targeting.all()) {
  32. @include static-styles($query);
  33. @include menusurface-theme.theme-styles($query);
  34. }
  35. @mixin static-styles($query: feature-targeting.all()) {
  36. $feat-structure: feature-targeting.create-target($query, structure);
  37. // postcss-bem-linter: define menu-surface
  38. .mdc-menu-surface {
  39. @include feature-targeting.targets($feat-structure) {
  40. display: none;
  41. position: absolute;
  42. box-sizing: border-box;
  43. margin: 0;
  44. padding: 0;
  45. transform: scale(1);
  46. transform-origin: top left;
  47. opacity: 0;
  48. overflow: auto;
  49. will-change: transform, opacity;
  50. }
  51. &:focus {
  52. @include feature-targeting.targets($feat-structure) {
  53. outline: none;
  54. }
  55. }
  56. &--animating-open {
  57. @include feature-targeting.targets($feat-structure) {
  58. display: inline-block;
  59. transform: scale(0.8);
  60. opacity: 0;
  61. }
  62. }
  63. // Render this after `--animating-open` to override `opacity` & `transform`
  64. // CSS properties.
  65. &--open {
  66. @include feature-targeting.targets($feat-structure) {
  67. display: inline-block;
  68. transform: scale(1);
  69. opacity: 1;
  70. }
  71. }
  72. &--animating-closed {
  73. @include feature-targeting.targets($feat-structure) {
  74. display: inline-block;
  75. opacity: 0;
  76. }
  77. }
  78. @include elevation-mixins.elevation($z-value: 8, $query: $query);
  79. @include feature-targeting.targets($feat-structure) {
  80. @include rtl.reflexive-property(transform-origin, top left, top right);
  81. }
  82. }
  83. .mdc-menu-surface--anchor {
  84. @include feature-targeting.targets($feat-structure) {
  85. position: relative;
  86. overflow: visible;
  87. }
  88. }
  89. .mdc-menu-surface--fixed {
  90. @include feature-targeting.targets($feat-structure) {
  91. position: fixed;
  92. }
  93. }
  94. .mdc-menu-surface--fullwidth {
  95. @include feature-targeting.targets($feat-structure) {
  96. width: 100%;
  97. }
  98. }
  99. // postcss-bem-linter: end
  100. }
  101. // Used by filled variants of GM components to conditionally flatten the top
  102. // corners of the menu.
  103. @mixin flatten-top-when-opened-below($query: feature-targeting.all()) {
  104. .mdc-menu-surface--is-open-below {
  105. $feat-structure: feature-targeting.create-target($query, structure);
  106. @include feature-targeting.targets($feat-structure) {
  107. border-top-left-radius: 0px;
  108. border-top-right-radius: 0px;
  109. }
  110. }
  111. }