Skip to content

Instantly share code, notes, and snippets.

@fredyang
Created January 20, 2014 04:28
Show Gist options
  • Save fredyang/8514872 to your computer and use it in GitHub Desktop.
Save fredyang/8514872 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.2)
// Compass (v1.0.0.alpha.17)
// ----
@mixin log($comment, $value: null) {
@if $value == null {
/* #{$comment} */
} @else {
/* #{$comment}:#{$value} */
}
}
//------------testing
@function lower-bound($range) {
@if length($range) <= 0 {
@return 0;
}
@return nth($range, 1);
}
@function upper-bound($range) {
@if length($range) < 2 {
@return 999999999999;
}
@return nth($range, 2);
}
$x: (21, 434, 13);
@include log(upper-bound($x));
$rem-base: 16px;
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
@function convert-to-rem($value, $base-value: $rem-base) {
$value: strip-unit($value) / strip-unit($base-value) * 1rem;
@if ($value == 0rem) { $value: 0; } // Turn 0rem into 0
@return $value;
}
@function rem-calc($values, $base-value: $rem-base) {
$max: length($values);
@if $max == 1 { @return convert-to-rem(nth($values, 1), $base-value); }
$remValues: ();
@for $i from 1 through $max {
$remValues: append($remValues, convert-to-rem(nth($values, $i), $base-value));
}
@return $remValues;
}
@include log(strip-unit(16px));
@include log(convert-to-rem(34));
/* 434 */
/* 16 */
/* 2.125rem */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment