Sha256: 2bbea3d0edf5e28e1d91905f4f00524e04c1c03c6b469d9cf9827b29dfe92c6a
Contents?: true
Size: 1.76 KB
Versions: 28
Compression:
Stored size: 1.76 KB
Contents
// Remove the unit and return the integer @function strip-unit($value) { @return ($value / ($value * 0 + 1)); } // Convert a unit value to a pixel while using $base-size as the reference @function to-pixel($from) { $from-unit: unit($from); @if $from-unit == 'px' { @return $from; } @else if $from-unit == '%' or $from-unit == 'em' or $from-unit == 'rem' { @return (strip-unit($from) * $base-size); } @else { @warn 'Unknown pixel conversion unit type.'; } @return $from; } // Convert a unit value to a percentage while using $base-size as the reference @function to-percent($from) { $from-unit: unit($from); @if $from-unit == '%' { @return $from; } @else if $from-unit == 'px' or $from-unit == 'em' or $from-unit == 'rem' { @return percentage((to-pixel($from) / $base-size) / 100); } @else { @warn 'Unknown percentage conversion unit type.'; } @return $from; } // Convert a unit value to a rem unit while using $base-size as the reference @function to-rem($from) { $from-unit: unit($from); @if $from-unit == 'rem' { @return $from; } @else if $from-unit == 'px' or $from-unit == '%' or $from-unit == 'em' { @return (to-pixel($from) / $base-size) * 1rem; } @else { @warn 'Unknown rem conversion unit type.'; } @return $from; } // Convert a unit value to an em unit while using $base-size as the reference @function to-em($from) { $from-unit: unit($from); @if $from-unit == 'em' { @return $from; } @else if $from-unit == 'px' or $from-unit == '%' or $from-unit == 'rem' { @return (to-pixel($from) / $base-size) * 1em; } @else { @warn 'Unknown em conversion unit type.'; } @return $from; }
Version data entries
28 entries across 28 versions & 1 rubygems