2
0

_mixins.general.scss 3.2 KB

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