danielhq
11/5/2014 - 9:54 AM

Vertical Rhythm

Vertical Rhythm

/*
* This is a port of Compass rhythm function
* To do: add other parameters
* $font-base and $line-height variables should be set according to your vertical rhythm
*/

@function rhythm($lines: 1, $font-size: $font-base, $offset: 0) {
  $rhythm: $lines * $line-height;
  @if unit($rhythm) == px {
    $rhythm: floor($rhythm);
  }
  @return #{$rhythm}em;
}

/*
* Returns the font-size in em calculated on the $font-base or the value speciefied in the second parameter
* TODO: add $lines parameter 
*/
@mixin adjust-font-size-to($to-size, $from-size: $font-base) {
  @if $from-size == $font-base {
  	font-size: #{$to-size / $font-base}em;
  } @else {
  	font-size: #{$to-size / $from-size}em;
  }
}