_mixins.scss 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. //
  2. // Copyright 2018 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/animation/variables' as animation-variables;
  25. @use '@material/tab/mixins' as tab-mixins;
  26. @use '@material/feature-targeting/feature-targeting';
  27. @use './variables';
  28. ///
  29. /// Sets the CSS transition for the tab scrolling animation.
  30. ///
  31. /// @param {Number | String} $duration-ms - Duration (in ms) of the animation.
  32. /// @param {String} $timing-function - Optionally overrides the default animation timing function.
  33. ///
  34. @mixin transition(
  35. $duration-ms,
  36. $timing-function: animation-variables.$standard-curve-timing-function,
  37. $query: feature-targeting.all()
  38. ) {
  39. $feat-animation: feature-targeting.create-target($query, animation);
  40. &.mdc-tab-scroller--animating .mdc-tab-scroller__scroll-content {
  41. @include feature-targeting.targets($feat-animation) {
  42. transition: $duration-ms transform $timing-function;
  43. }
  44. }
  45. }
  46. @mixin static-styles($query: feature-targeting.all()) {
  47. @include core-styles($query: $query);
  48. }
  49. @mixin core-styles($query: feature-targeting.all()) {
  50. $feat-structure: feature-targeting.create-target($query, structure);
  51. $feat-animation: feature-targeting.create-target($query, animation);
  52. // postcss-bem-linter: define tab-scroller
  53. .mdc-tab-scroller {
  54. @include transition(
  55. $duration-ms: variables.$transition-duration,
  56. $query: $query
  57. );
  58. @include feature-targeting.targets($feat-structure) {
  59. overflow-y: hidden;
  60. }
  61. }
  62. // Selector for test element used to feature-detect horizontal scrollbar height
  63. .mdc-tab-scroller__test {
  64. @include feature-targeting.targets($feat-structure) {
  65. position: absolute;
  66. top: -9999px;
  67. width: 100px;
  68. height: 100px;
  69. overflow-x: scroll;
  70. }
  71. }
  72. .mdc-tab-scroller__scroll-area {
  73. @include feature-targeting.targets($feat-structure) {
  74. -webkit-overflow-scrolling: touch;
  75. display: flex;
  76. overflow-x: hidden;
  77. }
  78. }
  79. .mdc-tab-scroller__scroll-area,
  80. .mdc-tab-scroller__test {
  81. @include feature-targeting.targets($feat-structure) {
  82. &::-webkit-scrollbar {
  83. display: none;
  84. }
  85. }
  86. }
  87. // This modifier class will be added in JS after computing the OS scrollbar size in order to hide the scrollbar.
  88. .mdc-tab-scroller__scroll-area--scroll {
  89. @include feature-targeting.targets($feat-structure) {
  90. overflow-x: scroll;
  91. }
  92. }
  93. .mdc-tab-scroller__scroll-content {
  94. @include scroll-content_($query);
  95. }
  96. .mdc-tab-scroller--align-start .mdc-tab-scroller__scroll-content {
  97. @include feature-targeting.targets($feat-structure) {
  98. justify-content: flex-start;
  99. }
  100. }
  101. .mdc-tab-scroller--align-end .mdc-tab-scroller__scroll-content {
  102. @include feature-targeting.targets($feat-structure) {
  103. justify-content: flex-end;
  104. }
  105. }
  106. .mdc-tab-scroller--align-center .mdc-tab-scroller__scroll-content {
  107. @include feature-targeting.targets($feat-structure) {
  108. justify-content: center;
  109. }
  110. }
  111. .mdc-tab-scroller--animating {
  112. .mdc-tab-scroller__scroll-area {
  113. @include feature-targeting.targets($feat-animation) {
  114. -webkit-overflow-scrolling: auto;
  115. }
  116. }
  117. }
  118. // postcss-bem-linter: end
  119. }
  120. //
  121. // Private
  122. //
  123. @mixin scroll-content_($query: feature-targeting.all()) {
  124. $feat-structure: feature-targeting.create-target($query, structure);
  125. $feat-animation: feature-targeting.create-target($query, animation);
  126. @include tab-mixins.parent-positioning($query);
  127. @include feature-targeting.targets($feat-structure) {
  128. display: flex;
  129. flex: 1 0 auto;
  130. transform: none;
  131. }
  132. @include feature-targeting.targets($feat-animation) {
  133. will-change: transform;
  134. }
  135. }