Skip to content

Commit

Permalink
Add $offset parameter to rhythm() function.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnAlbin committed Apr 16, 2012
1 parent c00ae82 commit c5041fb
Showing 1 changed file with 5 additions and 4 deletions.
Expand Up @@ -111,12 +111,13 @@ $base-half-leader: $base-leader / 2;
// Calculate rhythm units.
@function rhythm(
$lines: 1,
$font-size: $base-font-size
$font-size: $base-font-size,
$offset: 0
) {
@if not $relative-font-sizing and $font-size != $base-font-size {
@warn "$relative-font-sizing is false but a relative font size was passed to the rhythm function";
}
$rhythm: $font-unit * $lines * $base-line-height / $font-size;
$rhythm: $font-unit * ($lines * $base-line-height - $offset) / $font-size;
// Round the pixels down to nearest integer.
@if unit($rhythm) == px {
$rhythm: floor($rhythm);
Expand Down Expand Up @@ -183,7 +184,7 @@ $base-half-leader: $base-leader / 2;
style: $border-style;
width: $font-unit * $width / $font-size;
};
padding-#{$side}: $font-unit / $font-size * ($lines * $base-line-height - $width);
padding-#{$side}: rhythm($lines, $font-size, $offset: $width);
}

// Apply borders and whitespace equally to all sides.
Expand All @@ -195,7 +196,7 @@ $base-half-leader: $base-leader / 2;
style: $border-style;
width: $font-unit * $width / $font-size;
};
padding: $font-unit / $font-size * ($lines * $base-line-height - $width);
padding: rhythm($lines, $font-size, $offset: $width);
}

// Apply a leading border.
Expand Down

0 comments on commit c5041fb

Please sign in to comment.