_mixins.scss 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /// Makes an element's :before pseudoelement a FontAwesome icon.
  2. /// @param {string} $content Optional content value to use.
  3. /// @param {string} $where Optional pseudoelement to target (before or after).
  4. @mixin icon($content: false, $where: before) {
  5. text-decoration: none;
  6. &:#{$where} {
  7. @if $content {
  8. content: $content;
  9. }
  10. -moz-osx-font-smoothing: grayscale;
  11. -webkit-font-smoothing: antialiased;
  12. font-family: FontAwesome;
  13. font-style: normal;
  14. font-weight: normal;
  15. text-transform: none !important;
  16. }
  17. }
  18. /// Applies padding to an element, taking the current element-margin value into account.
  19. /// @param {mixed} $tb Top/bottom padding.
  20. /// @param {mixed} $lr Left/right padding.
  21. /// @param {list} $pad Optional extra padding (in the following order top, right, bottom, left)
  22. /// @param {bool} $important If true, adds !important.
  23. @mixin padding($tb, $lr, $pad: (0,0,0,0), $important: null) {
  24. @if $important {
  25. $important: '!important';
  26. }
  27. padding: ($tb + nth($pad,1)) ($lr + nth($pad,2)) max(0.1em, $tb - _size(element-margin) + nth($pad,3)) ($lr + nth($pad,4)) #{$important};
  28. }
  29. /// Encodes a SVG data URL so IE doesn't choke (via codepen.io/jakob-e/pen/YXXBrp).
  30. /// @param {string} $svg SVG data URL.
  31. /// @return {string} Encoded SVG data URL.
  32. @function svg-url($svg) {
  33. $svg: str-replace($svg, '"', '\'');
  34. $svg: str-replace($svg, '<', '%3C');
  35. $svg: str-replace($svg, '>', '%3E');
  36. $svg: str-replace($svg, '&', '%26');
  37. $svg: str-replace($svg, '#', '%23');
  38. $svg: str-replace($svg, '{', '%7B');
  39. $svg: str-replace($svg, '}', '%7D');
  40. $svg: str-replace($svg, ';', '%3B');
  41. @return url("data:image/svg+xml;charset=utf8,#{$svg}");
  42. }