Created
June 29, 2015 13:27
-
-
Save bookwyrm/3f1f5991df0791f54b3b to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// libsass (v3.2.5) | |
// ---- | |
@import "true"; | |
// From Thoughtbot's Bourbon | |
/// Converts shorthand to the 4-value syntax. | |
/// | |
/// @param {List} $shorthand | |
/// | |
/// @example scss - Usage | |
/// .element { | |
/// margin: unpack(1em 2em); | |
/// } | |
/// | |
/// @example css - CSS Output | |
/// .element { | |
/// margin: 1em 2em 1em 2em; | |
/// } | |
@function unpack($shorthand) { | |
@if length($shorthand) == 1 { | |
@return nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1); | |
} @else if length($shorthand) == 2 { | |
@return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 1) nth($shorthand, 2); | |
} @else if length($shorthand) == 3 { | |
@return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 3) nth($shorthand, 2); | |
} @else { | |
@return $shorthand; | |
} | |
} | |
@include test-module('Utilities') { | |
@include test('unpack [function]') { | |
$test: unpack(1em); | |
$expect: 1em 1em 1em 1em; | |
@include assert-equal($test, $expect, 'Handles one value'); | |
$test: unpack(1em 2em); | |
$expect: 1em 2em 1em 2em; | |
@include assert-equal($test, $expect, 'Handles two values'); | |
$test: unpack(1em 2em 3em); | |
$expect: 1em 2em 3em 2em; | |
@include assert-equal($test, $expect, 'Handles three values'); | |
$test: unpack(1em 2em 3em 4em); | |
$expect: 1em 2em 3em 4em; | |
@include assert-equal($test, $expect, 'Handles four values'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* # Utilities ---------- */ | |
/* unpack [function] */ | |
[data-module="Utilities"] [data-test="unpack [function]"] .assert-equal { | |
-result: PASS; | |
-description: "Handles one value"; | |
} | |
[data-module="Utilities"] [data-test="unpack [function]"] .assert-equal { | |
-result: PASS; | |
-description: "Handles two values"; | |
} | |
[data-module="Utilities"] [data-test="unpack [function]"] .assert-equal { | |
-result: PASS; | |
-description: "Handles three values"; | |
} | |
[data-module="Utilities"] [data-test="unpack [function]"] .assert-equal { | |
-result: PASS; | |
-description: "Handles four values"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment