font.scss 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @class Global_CSS
  3. */
  4. /**
  5. * Adds a font specification to an element.
  6. * Uses a single "font" property if possible, otherwise uses separate font-family, font-size,
  7. * font-weight and line-height properties.
  8. *
  9. * @param {number/string} $font-weight
  10. * The font-weight
  11. *
  12. * @param {number/string} $font-size
  13. * The font-size
  14. *
  15. * @param {number/string} $line-height
  16. * The line-height
  17. *
  18. * @param {string} $font-family
  19. * The font-family
  20. *
  21. * @private
  22. */
  23. @mixin font(
  24. $font-weight: null,
  25. $font-size: null,
  26. $line-height: null,
  27. $font-family: null
  28. ) {
  29. @if $font-weight == null or $font-family == null or $font-size == null or $line-height == null {
  30. // if any of the parameters are null we cannot use a single "font" declaration
  31. // Single font declaration does not work without font-family and font-size, and
  32. // omitting line-height results in an effective line-height of "normal" which may
  33. // end up unintentionally overriding an explicit line-height set elsewhere.
  34. font-weight: $font-weight;
  35. font-size: $font-size;
  36. line-height: $line-height;
  37. font-family: $font-family;
  38. } @else if $line-height == null {
  39. font: $font-weight $font-size $font-family;
  40. } @else {
  41. font: $font-weight #{$font-size}/#{$line-height} $font-family;
  42. }
  43. }