2
0

_icons.scss 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. @use 'sass:string';
  2. @use '../tools' as *;
  3. @use '../settings' as *;
  4. // Set SVG icons to use the current text color in the location they appear as
  5. // their default fill color. Can be overridden for a specific icon by either
  6. // the color or fill properties.
  7. .icon {
  8. fill: currentColor;
  9. }
  10. .icon.teal {
  11. color: theme('colors.text-button-outline-default');
  12. }
  13. .icon.white {
  14. color: theme('colors.surface-page');
  15. }
  16. // =============================================================================
  17. // Icon factory methods
  18. // =============================================================================
  19. // Legacy icons still implemented via CSS due to the markup being hard to change.
  20. $icons-after: ('arrow-down', 'arrow-up');
  21. @each $icon in $icons-after {
  22. .icon-#{$icon}-after::after {
  23. content: '';
  24. mask-image: url('#{$images-root}icons/#{$icon}.svg');
  25. width: 1em;
  26. height: 1em;
  27. display: inline-block;
  28. background-color: currentColor;
  29. }
  30. }
  31. // =============================================================================
  32. // Custom config for various icons
  33. // =============================================================================
  34. // Add spinner styles onto the use element,
  35. // so an icon can be turned into a spinner by changing the href only.
  36. // This allows us to switch any icon to a spinner with much less boilerplate.
  37. use[href='#icon-spinner'] {
  38. animation: spin-wag 0.5s infinite linear;
  39. transform-origin: center;
  40. }
  41. .text-replace {
  42. font-size: 0;
  43. line-height: 0;
  44. overflow: hidden;
  45. .icon {
  46. @include svg-icon(1rem, middle);
  47. }
  48. }
  49. @keyframes spin-wag {
  50. 0% {
  51. transform: rotate(0deg);
  52. }
  53. 100% {
  54. transform: rotate(360deg);
  55. }
  56. }
  57. // stylelint-disable-next-line no-duplicate-selectors
  58. .icon {
  59. &.initial {
  60. @include svg-icon(1em, $position: initial);
  61. }
  62. &.default {
  63. @include svg-icon(1.5em);
  64. }
  65. &.middle {
  66. @include svg-icon(1.5em, $position: middle);
  67. }
  68. &--flipped {
  69. transform: scaleX(-1);
  70. }
  71. }
  72. .icon.locale-error {
  73. vertical-align: text-top;
  74. margin-inline-end: 0.5em;
  75. width: 1.5em;
  76. height: 1.5em;
  77. color: theme('colors.critical.200');
  78. }
  79. .icon-wagtail {
  80. width: 100%;
  81. height: auto;
  82. }
  83. .icon-wagtail__wordmark {
  84. fill: theme('colors.text-context');
  85. }
  86. // Icons mirroring for RTL languages to match the rest of the Wagtail UI.
  87. // Automatically mirror child elements of SVG icons marked with
  88. // icon--directional. This will be applied to the children of the <symbol>
  89. // elements in the icons sprite, ensuring all usages of the icons will be in the
  90. // correct direction.
  91. .icon--directional * {
  92. transform: scaleX(var(--w-direction-factor));
  93. transform-origin: center;
  94. }