Skip to content

Instantly share code, notes, and snippets.

@jakob-e
Created December 4, 2014 11:57
Show Gist options
  • Save jakob-e/87e73f3bcb3882108b33 to your computer and use it in GitHub Desktop.
Save jakob-e/87e73f3bcb3882108b33 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
//
// SCSS unit conversion
//
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
$ratios:(
golden : (1.618, 1),
typographic : ((6,7,8,9,10,11,12,14,16,18,21,24,36,48,60,72), 12)
);
@mixin scale(){}
@function num($val) { @return convert($val,0); }
@function str($val) { @return convert($val,''); }
@function px($val) { @return convert($val,0px); }
@function pt($val) { @return convert($val,0pt); }
@function pc($val) { @return convert($val,0pc); }
@function in($val) { @return convert($val,0in); }
@function mm($val) { @return convert($val,0mm); }
@function cm($val) { @return convert($val,0cm); }
@function deg($val) { @return convert($val,0deg); }
@function rad($val) { @return convert($val,0rad); }
@function grad($val){ @return convert($val,0grad); }
@function turn($val){ @return convert($val,0turn); }
@function convert($val,$zero-unit){
@return if(not $val, $val,
if(type-of($zero-unit) == 'string', inspect($val),
if(unit($zero-unit)=='', $val/($val*0+1), $zero-unit + $val
)));
}
.foo { font-size: px(12pt); }
.foo {
font-size: 16px;
}
//
// SCSS unit conversion
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment