-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds new mixin partial and includes updated strip-unit, em(), rem() a…
…nd new line height mixins for use with Bourbon 5 (#254)
- Loading branch information
1 parent
03f518f
commit 8534ddb
Showing
2 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//-------------------------------------------------------------- | ||
// Size Conversion SCSS Mixins | ||
//-------------------------------------------------------------- | ||
|
||
//----------------------------------------- | ||
// Strip Units Forked from Bourbon 4 https://github.com/thoughtbot/bourbon/blob/v4-stable/app/assets/stylesheets/functions/_strip-units.scss | ||
//----------------------------------------- | ||
@function strip-unit($number) { | ||
@if type-of($number) == "number" and not unitless($number) { | ||
@return $number / ($number * 0 + 1); | ||
} | ||
|
||
@return $number; | ||
} | ||
|
||
//----------------------------------------- | ||
// PX to EM Forked from Bourbon 4 https://github.com/thoughtbot/bourbon/blob/v4-stable/app/assets/stylesheets/functions/_px-to-em.scss | ||
// Usage em(12) — defaults context to 16 | ||
// Usage em(12, 16) = same as above. | ||
//----------------------------------------- | ||
@function em($pixelvalue, $context: $base-context) { | ||
|
||
@if not unitless($pixelvalue) { | ||
$pixelvalue: strip-units($pixelvalue); | ||
} | ||
|
||
@if not unitless($context) { | ||
$base: strip-units($context); | ||
} | ||
|
||
@return ($pixelvalue / $base-context) * 1em; | ||
} | ||
|
||
|
||
//----------------------------------------- | ||
// PX to REM Forked from Bourbon 4 https://github.com/thoughtbot/bourbon/blob/v4-stable/app/assets/stylesheets/functions/_px-to-rem.scss | ||
// Usage em(12) — defaults context to 16 | ||
// Usage em(12, 16) = same as above. | ||
//----------------------------------------- | ||
@function rem($pixelvalue, $context: $base-context) { | ||
|
||
@if not unitless($pixelvalue) { | ||
$pixelvalue: strip-units($pixelvalue); | ||
} | ||
|
||
@if not unitless($context) { | ||
$base: strip-units($context); | ||
} | ||
|
||
@return ($pixelvalue / $base-context) * 1rem; | ||
} | ||
|
||
//----------------------------------------- | ||
// Unitless Line Height | ||
// Usage lh(12) = lh(12,12) = 1 | ||
// Usage lh(24, 12) = 2 | ||
//----------------------------------------- | ||
@function lh($font-size, $line-height: $font-size) { | ||
|
||
@if not unitless($font-size) { | ||
$font-size: strip-units($font-size); | ||
} | ||
|
||
@if not unitless($line-height) { | ||
$line-height: strip-units($line-height); | ||
} | ||
|
||
@return $font-size / $line-height; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters