| 1 |
//************************************************************************// |
| 2 |
// Helper function for str-to-num fn. |
| 3 |
// Source: http://sassmeister.com/gist/9647408 |
| 4 |
//************************************************************************// |
| 5 |
@function _convert-units($number, $unit) { |
| 6 |
@if $output-bourbon-deprecation-warnings == true { |
| 7 |
@warn "[Bourbon] [Deprecation] `_convert-units` is deprecated and will " + |
| 8 |
"be removed in 5.0.0."; |
| 9 |
} |
| 10 |
|
| 11 |
$strings: "px", "cm", "mm", "%", "ch", "pica", "in", "em", "rem", "pt", "pc", "ex", "vw", "vh", "vmin", "vmax", "deg", "rad", "grad", "turn"; |
| 12 |
$units: 1px, 1cm, 1mm, 1%, 1ch, 1pica, 1in, 1em, 1rem, 1pt, 1pc, 1ex, 1vw, 1vh, 1vmin, 1vmax, 1deg, 1rad, 1grad, 1turn; |
| 13 |
$index: index($strings, $unit); |
| 14 |
|
| 15 |
@if not $index { |
| 16 |
@warn "Unknown unit `#{$unit}`."; |
| 17 |
@return false; |
| 18 |
} |
| 19 |
|
| 20 |
@if type-of($number) != "number" { |
| 21 |
@warn "`#{$number} is not a number`"; |
| 22 |
@return false; |
| 23 |
} |
| 24 |
|
| 25 |
@return $number * nth($units, $index); |
| 26 |
} |