_mixins.scss 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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/density/functions' as density-functions;
  26. @use '@material/feature-targeting/feature-targeting';
  27. @use '@material/tab-scroller/mixins' as tab-scroller-mixins;
  28. @use '@material/tab/mixins' as tab-mixins;
  29. @use './variables';
  30. @mixin static-styles($query: feature-targeting.all()) {
  31. .mdc-tab-bar {
  32. @include width(100%, $query);
  33. }
  34. }
  35. @mixin core-styles($query: feature-targeting.all()) {
  36. // postcss-bem-linter: define tab-bar
  37. @include static-styles($query: $query);
  38. @include density(variables.$density-scale, $query: $query);
  39. @include stacked-density(variables.$stacked-density-scale, $query: $query);
  40. // postcss-bem-linter: end
  41. }
  42. @mixin width($width, $query: feature-targeting.all()) {
  43. $feat-structure: feature-targeting.create-target($query, structure);
  44. @include feature-targeting.targets($feat-structure) {
  45. width: $width;
  46. }
  47. }
  48. ///
  49. /// Sets density scale to default tab bar variant. Use `mdc-tab-bar-stacked-density()` mixin for stacked tab bar
  50. /// variant.
  51. ///
  52. /// @param {Number} $density-scale Density scale value. Supported density scales `-4`, `-3`, `-2`, `-1` and `0`.
  53. ///
  54. @mixin density($density-scale, $query: feature-targeting.all()) {
  55. $height: density-functions.prop-value(
  56. $density-config: variables.$density-config,
  57. $density-scale: $density-scale,
  58. $property-name: height,
  59. );
  60. .mdc-tab {
  61. @include tab-mixins.height($height, $query: $query);
  62. }
  63. }
  64. ///
  65. /// Sets density scale to stacked tab bar variant.
  66. ///
  67. /// @param {Number} $density-scale Density scale value. Supported density scales `-4`, `-3`, `-2`, `-1` and `0`.
  68. ///
  69. @mixin stacked-density($density-scale, $query: feature-targeting.all()) {
  70. $height: density-functions.prop-value(
  71. $density-config: variables.$stacked-density-config,
  72. $density-scale: $density-scale,
  73. $property-name: height,
  74. );
  75. .mdc-tab--stacked {
  76. @include tab-mixins.height($height, $query: $query);
  77. }
  78. }
  79. ///
  80. /// Sets the CSS transition for the tab scrolling animation. This mixin is a proxy to `mdc-tab-scroller-transition`
  81. /// mixin.
  82. ///
  83. /// @param {Number | String} $duration-ms - Duration (in ms) of the animation.
  84. /// @param {String} $timing-function - Optionally overrides the default animation timing function.
  85. ///
  86. @mixin tab-scroller-transition(
  87. $duration-ms,
  88. $timing-function: animation-variables.$standard-curve-timing-function,
  89. $query: feature-targeting.all()
  90. ) {
  91. .mdc-tab-scroller {
  92. @include tab-scroller-mixins.transition(
  93. $duration-ms,
  94. $timing-function: $timing-function,
  95. $query: $query
  96. );
  97. }
  98. }