icon.scss 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * @class Global_CSS
  3. */
  4. @import 'icon.js';
  5. /**
  6. * Generates style rules for an icon element
  7. *
  8. * @param {list/string} $icon
  9. * A unicode character to use as the icon, or a list specifying the character to use
  10. * followed by font-family and degrees of rotation (90, 180, or 270).
  11. * All parameters in the list are optional except for glyph. For example, each of the
  12. * following is valid:
  13. *
  14. * Use the letter "A" as the icon and use the default font-family
  15. *
  16. * @include font-icon('\0041');
  17. *
  18. * Use the letter "A" as the icon and use FontAwesome as the font-family
  19. *
  20. * @include font-icon('\0041' FontAwesome);
  21. *
  22. * Use the letter "A" as the icon and rotate the icon 90 degrees clockwise.
  23. *
  24. * @include font-icon('\0041' 90);
  25. *
  26. * Use the letter "A" as the icon, use FontAwesome as the font-family, and rotate the icon
  27. * 90 degrees clockwise.
  28. *
  29. * @include font-icon('\0041' FontAwesome 90);
  30. *
  31. * @param {color} $color
  32. * The color to apply to the element which is containing the icon. See $pseudo-color below
  33. *
  34. * @param {number} $size
  35. * The size of the icon element
  36. *
  37. * @param {number} $size-big
  38. * The size of the icon element in the {@link Global_CSS#$enable-big big} sizing scheme
  39. *
  40. * @param {number} $font-size
  41. * The font-size of the icon. Applied to the :before pseudo element so that it does not affect
  42. * `$size` when `$size` is specified in `em` units.
  43. *
  44. * @param {number} $font-size-big
  45. * The font-size of the icon in the {@link Global_CSS#$enable-big big} sizing scheme.
  46. * Applied to the :before pseudo element so that it does not affect `$size-big` when
  47. * `$size-big` is specified in `em` units.
  48. *
  49. * @param {booleab} $style-pseudo
  50. * Specify as `true` to apply the `$color` and `$size` parameters to the pseudo element
  51. * which carries the icon rather than to its encapsulating element.
  52. *
  53. * @private
  54. */
  55. @mixin icon(
  56. $icon: null,
  57. $color: null,
  58. $size: null,
  59. $size-big: null,
  60. $font-size: null,
  61. $font-size-big: null,
  62. $style-pseudo: false
  63. ) {
  64. $args: parseIconArgs($icon);
  65. $char: nth($args, 1);
  66. $font-family: nth($args, 2);
  67. $rotation: nth($args, 3);
  68. @if $font-size == null {
  69. $font-size: $size;
  70. }
  71. @if $font-size-big == null {
  72. $font-size-big: $size-big;
  73. }
  74. @if not $style-pseudo {
  75. color: $color;
  76. width: $size;
  77. height: $size;
  78. @if $enable-big {
  79. .#{$prefix}big & {
  80. width: $size-big;
  81. height: $size-big;
  82. }
  83. }
  84. }
  85. &:before {
  86. @if $style-pseudo {
  87. color: $color;
  88. width: $size;
  89. height: $size;
  90. @if $enable-big {
  91. .#{$prefix}big & {
  92. width: $size-big;
  93. height: $size-big;
  94. }
  95. }
  96. }
  97. content: $char;
  98. font-family: $font-family;
  99. font-size: $font-size;
  100. @if $rotation != null {
  101. $rotation-origin: 50% 50%;
  102. $angle: rotate(#{$rotation}deg);
  103. display: inline-block;
  104. -webkit-transform: $angle;
  105. -webkit-transform-origin: $rotation-origin;
  106. transform: $angle;
  107. transform-origin: $rotation-origin;
  108. }
  109. @if $enable-big {
  110. .#{$prefix}big & {
  111. font-size: $font-size-big;
  112. }
  113. }
  114. }
  115. }