_dom.scss 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Copyright 2020 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/feature-targeting/feature-targeting';
  21. @use '@material/rtl/rtl';
  22. ///
  23. /// Emits necessary layout styles to set a transparent border around an element
  24. /// without interfering with the rest of its component layout. The border is
  25. /// only visible in high-contrast mode. The target element should be a child of
  26. /// a relatively positioned top-level element (i.e. a ::before pseudo-element).
  27. ///
  28. /// @param {number} $border-width - The width of the transparent border.
  29. /// @param {string} $border-style - The style of the transparent border.
  30. ///
  31. @mixin transparent-border(
  32. $border-width: 1px,
  33. $border-style: solid,
  34. $query: feature-targeting.all()
  35. ) {
  36. $feat-structure: feature-targeting.create-target($query, structure);
  37. @include feature-targeting.targets($feat-structure) {
  38. position: absolute;
  39. box-sizing: border-box;
  40. width: 100%;
  41. height: 100%;
  42. top: 0;
  43. @include rtl.ignore-next-line();
  44. left: 0;
  45. border: $border-width $border-style transparent;
  46. border-radius: inherit;
  47. content: '';
  48. pointer-events: none;
  49. }
  50. // Used to satisfy Firefox v94 which does not render transparent borders in HCM (b/206440838).
  51. @include forced-colors-mode($exclude-ie11: true) {
  52. @include feature-targeting.targets($feat-structure) {
  53. border-color: CanvasText;
  54. }
  55. }
  56. }
  57. ///
  58. /// Visually hides text content for accessibility. This text should only be
  59. /// visible to screen reader users.
  60. /// See https://a11yproject.com/posts/how-to-hide-content/
  61. ///
  62. @mixin visually-hidden($query: feature-targeting.all()) {
  63. $feat-structure: feature-targeting.create-target($query, structure);
  64. @include feature-targeting.targets($feat-structure) {
  65. clip: rect(1px, 1px, 1px, 1px);
  66. height: 1px;
  67. overflow: hidden;
  68. position: absolute;
  69. white-space: nowrap; /* added line */
  70. width: 1px;
  71. }
  72. }
  73. /// Selects for IE11 support.
  74. ///
  75. /// @content styles to emit for IE11 support
  76. @mixin ie11-support {
  77. @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  78. @content;
  79. }
  80. }
  81. /// Selects for `forced-colors` high contrast mode.
  82. ///
  83. /// While in `forced-colors` mode, only system colors should be used.
  84. ///
  85. /// @link https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#system_colors
  86. /// @link https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors
  87. /// @content styles to emit in `forced-colors` mode
  88. @mixin forced-colors-mode($exclude-ie11: false) {
  89. @if $exclude-ie11 {
  90. @media screen and (forced-colors: active) {
  91. @content;
  92. }
  93. } @else {
  94. @media screen and (forced-colors: active), (-ms-high-contrast: active) {
  95. @content;
  96. }
  97. }
  98. }