Skip to content

Instantly share code, notes, and snippets.

@lachlanjc
Created April 3, 2016 05:45
Show Gist options
  • Save lachlanjc/b7fa7a307e2646baf0e5b1ee312331c9 to your computer and use it in GitHub Desktop.
Save lachlanjc/b7fa7a307e2646baf0e5b1ee312331c9 to your computer and use it in GitHub Desktop.
//---------------------------
// Size function
// =============
// The size function returns a measurement determined by
// the (required) argument of level.
//
// Example: size(5);
// This will return 16rem.
//---------------------------
$__size-default: 2;
$__size-unit: 1rem;
@function size($level: 1) {
@if $level <= 8 {
$value: $level;
@if $level == 1 {
$value: half($__size-default);
} @else {
$value: power($__size-default, ($level + 1));
}
@return ($value * $__size-unit);
} @else {
@warn "Size ranges from 1–8. You provided #{level}."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment