_mixins.general.scss 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. // =============================================================================
  2. // Mixins
  3. // =============================================================================
  4. // Please note that the mixins partial shouldn't include any classes. This is so
  5. // it can be included in any file without accidentally producing output
  6. @use '../settings' as *;
  7. // Turns on font-smoothing when used. Use sparingly.
  8. @mixin font-smoothing {
  9. -webkit-font-smoothing: antialiased;
  10. -moz-osx-font-smoothing: grayscale;
  11. }
  12. @mixin clearfix() {
  13. &:before,
  14. &:after {
  15. content: ' ';
  16. display: table;
  17. }
  18. &:after {
  19. clear: both;
  20. }
  21. }
  22. @mixin unlist() {
  23. margin-top: 0;
  24. margin-bottom: 0;
  25. padding-inline-start: 0;
  26. list-style-type: none;
  27. font-style: normal;
  28. li {
  29. list-style-type: none;
  30. font-style: normal;
  31. }
  32. }
  33. // remove list styles, but only for the immediate element -
  34. // allow nested lists inside it to keep the default style
  35. @mixin unlistimmediate() {
  36. margin-top: 0;
  37. margin-bottom: 0;
  38. padding-inline-start: 0;
  39. list-style-type: none;
  40. font-style: normal;
  41. > li {
  42. list-style-type: none;
  43. font-style: normal;
  44. }
  45. }
  46. @mixin transition($transition...) {
  47. body.ready & {
  48. transition: $transition;
  49. }
  50. }
  51. @mixin svg-icon($size: 1em, $position: text-top) {
  52. width: $size;
  53. height: $size;
  54. vertical-align: $position;
  55. }
  56. // Applies given rules on hover, for devices that support hover.
  57. @mixin hover {
  58. @media (hover: hover) {
  59. a:hover {
  60. @content;
  61. }
  62. }
  63. }
  64. // Where included, show the focus outline within focusable items instead of around them.
  65. // This is useful when focusable items are tightly packed and there is no space in-between.
  66. @mixin show-focus-outline-inside {
  67. outline-offset: -1 * $focus-outline-width;
  68. }
  69. /**
  70. * Apply styles for the dark theme only.
  71. */
  72. @mixin dark-theme() {
  73. .w-theme-dark & {
  74. @content;
  75. }
  76. @media (prefers-color-scheme: dark) {
  77. .w-theme-system & {
  78. @content;
  79. }
  80. }
  81. }
  82. /**
  83. * Apply styles for enhanced contrast theming.
  84. */
  85. @mixin more-contrast() {
  86. .w-contrast-more & {
  87. @content;
  88. }
  89. @media (prefers-contrast: more) {
  90. .w-contrast-system & {
  91. @content;
  92. }
  93. }
  94. }
  95. /**
  96. * Apply styles for the light theme only.
  97. */
  98. @mixin light-theme() {
  99. .w-theme-light & {
  100. @content;
  101. }
  102. @media (prefers-color-scheme: light) {
  103. .w-theme-system & {
  104. @content;
  105. }
  106. }
  107. }
  108. /**
  109. * Apply styles for the dark theme with increased contrast.
  110. */
  111. @mixin dark-theme-more-contrast() {
  112. .w-theme-dark.w-contrast-more & {
  113. @content;
  114. }
  115. @media (prefers-color-scheme: dark) {
  116. .w-theme-system.w-contrast-more & {
  117. @content;
  118. }
  119. }
  120. @media (prefers-contrast: more) {
  121. .w-theme-dark.w-contrast-system & {
  122. @content;
  123. }
  124. }
  125. @media (prefers-color-scheme: dark) and (prefers-contrast: more) {
  126. .w-theme-system.w-contrast-system & {
  127. @content;
  128. }
  129. }
  130. }
  131. /**
  132. * Increased contrast theme styles for interactive components
  133. */
  134. @mixin more-contrast-interactive() {
  135. @include more-contrast() {
  136. border: 1px solid theme('colors.border-interactive-more-contrast');
  137. &:hover {
  138. border-color: theme('colors.border-interactive-more-contrast-hover');
  139. }
  140. &[disabled],
  141. &[disabled]:hover {
  142. border-style: dashed;
  143. }
  144. }
  145. }