2
0

_icons.scss 2.6 KB

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