@function number($number) @if type-of($number) == number @return true @else @return null @function number_list($values) @if list($values) @each $value in $values @if number($value) @return true @else @return null @else @return null @function optional_number_list($values) @if type-of($values) == number @return true @else if number_list($values) @return true @else @return null @function odd($number) @if ceil($number/2) != $number/2 @return true @else @return null @function even($number) @if ceil($number/2) == $number/2 @return true @else @return null @function strip_unit($number) // strip the units // That works. strip_unit(13.48cm) will return 13.48 @if number($number) @return $number / ($number * 0 + 1) @function unitless_number($value) @if number($value) and unitless($value) @return true @else @return null @function px($value) @if number($value) and unit($value) == "px" @return true @else @return null @function em($value) @if number($value) and unit($value) == "em" @return true @else @return null @function percent($value) @if number($value) and unit($value) == "%" @return true @else @return null @function px_to_em($px, $base-px) @if strip_unit($px) == 0 @return 0 @else if px($px) @return (strip_unit($px) / strip_unit($base-px)) * 1em @else if em($px) @return $px @function em_to_px($em, $base-px: $baseline-px) @if $em == 0 @return 0 @else if em($em) @return (strip_unit($em) * strip_unit($base-px)) * 1px @else if px($em) @return $em