Skip to content
This repository has been archived by the owner on Jun 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7 from HugoGiraudel/master
Browse files Browse the repository at this point in the history
Moving to SassDoc compliant comments
  • Loading branch information
kaelig committed Aug 8, 2014
2 parents fd0a1de + 5e66a12 commit be29632
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions _rem.scss
@@ -1,28 +1,51 @@
/**
* Default rem baseline.
*
* @type Number
*/
$guss-rem-baseline: 10px !default;

// Transform a value into rem
// Assuming baseline is set to 10px on :root or html
/**
* Transform a value into rem.
*
* @param {Number} $value
* @param {Number} $baseline ($guss-rem-baseline)
*
* @requires {variable} guss-rem-baseline
*
* @return {List | Number}
*/
@function rem($value, $baseline: $guss-rem-baseline) {
@if $value == 0 { @return 0; } // 0rem -> 0
@if $value == 0 {
@return 0; // 0rem -> 0
}

@if type-of($value) == list {
$result: ();

@each $e in $value {
$result: append($result, rem($e, $baseline));
}

@return $result;
} @else {
@return if(type-of($value) == number and unit($value) == px, $value / $baseline * 1rem, $value);
}
}


// Output rem units with px fallback
// Expects $properties to be a Sass map
// Usage: http://sassmeister.com/gist/7451284
/**
* Output `rem` units with `px` fallback.
*
* @link http://sassmeister.com/gist/7451284 Usage
*
* @param {Map} $properties
*
* @requires {function} rem
*/
@mixin rem($properties) {
@each $property, $value in $properties {
@if (type-of($value) == number and $value != 0) {
// Turn any value into pixels
// Turn unitless values into pixels
$value: if(unitless($value), $value * 1px, $value);
}

Expand Down

0 comments on commit be29632

Please sign in to comment.