_mixins.scss 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /// Makes an element's :before pseudoelement a FontAwesome icon.
  2. /// @param {string} $content Optional content value to use.
  3. /// @param {string} $category Optional category to use.
  4. /// @param {string} $where Optional pseudoelement to target (before or after).
  5. @mixin icon($content: false, $category: regular, $where: before) {
  6. text-decoration: none;
  7. &:#{$where} {
  8. @if $content {
  9. content: $content;
  10. }
  11. -moz-osx-font-smoothing: grayscale;
  12. -webkit-font-smoothing: antialiased;
  13. display: inline-block;
  14. font-style: normal;
  15. font-variant: normal;
  16. text-rendering: auto;
  17. line-height: 1;
  18. text-transform: none !important;
  19. @if ($category == brands) {
  20. font-family: 'Font Awesome 5 Brands';
  21. }
  22. @elseif ($category == solid) {
  23. font-family: 'Font Awesome 5 Free';
  24. font-weight: 900;
  25. }
  26. @else {
  27. font-family: 'Font Awesome 5 Free';
  28. font-weight: 400;
  29. }
  30. }
  31. }
  32. /// Applies padding to an element, taking the current element-margin value into account.
  33. /// @param {mixed} $tb Top/bottom padding.
  34. /// @param {mixed} $lr Left/right padding.
  35. /// @param {list} $pad Optional extra padding (in the following order top, right, bottom, left)
  36. /// @param {bool} $important If true, adds !important.
  37. @mixin padding($tb, $lr, $pad: (0,0,0,0), $important: null) {
  38. @if $important {
  39. $important: '!important';
  40. }
  41. $x: 0.1em;
  42. @if unit(_size(element-margin)) == 'rem' {
  43. $x: 0.1rem;
  44. }
  45. padding: ($tb + nth($pad,1)) ($lr + nth($pad,2)) max($x, $tb - _size(element-margin) + nth($pad,3)) ($lr + nth($pad,4)) #{$important};
  46. }
  47. /// Encodes a SVG data URL so IE doesn't choke (via codepen.io/jakob-e/pen/YXXBrp).
  48. /// @param {string} $svg SVG data URL.
  49. /// @return {string} Encoded SVG data URL.
  50. @function svg-url($svg) {
  51. $svg: str-replace($svg, '"', '\'');
  52. $svg: str-replace($svg, '%', '%25');
  53. $svg: str-replace($svg, '<', '%3C');
  54. $svg: str-replace($svg, '>', '%3E');
  55. $svg: str-replace($svg, '&', '%26');
  56. $svg: str-replace($svg, '#', '%23');
  57. $svg: str-replace($svg, '{', '%7B');
  58. $svg: str-replace($svg, '}', '%7D');
  59. $svg: str-replace($svg, ';', '%3B');
  60. @return url("data:image/svg+xml;charset=utf8,#{$svg}");
  61. }