Merge pull request #848 from JohnAlbin/rhythm-offset

Add $offset parameter to rhythm() function.
This commit is contained in:
Eric Meyer 2012-04-16 11:15:40 -07:00
commit 0e2a5d7579

View File

@ -111,12 +111,13 @@ $base-half-leader: $base-leader / 2;
// Calculate rhythm units. // Calculate rhythm units.
@function rhythm( @function rhythm(
$lines: 1, $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 { @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"; @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. // Round the pixels down to nearest integer.
@if unit($rhythm) == px { @if unit($rhythm) == px {
$rhythm: floor($rhythm); $rhythm: floor($rhythm);
@ -183,7 +184,7 @@ $base-half-leader: $base-leader / 2;
style: $border-style; style: $border-style;
width: $font-unit * $width / $font-size; 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. // Apply borders and whitespace equally to all sides.
@ -195,7 +196,7 @@ $base-half-leader: $base-leader / 2;
style: $border-style; style: $border-style;
width: $font-unit * $width / $font-size; 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. // Apply a leading border.