Last active
August 31, 2015 23:28
-
-
Save iamskok/c7b0e7e6b03b65923a0c to your computer and use it in GitHub Desktop.
Equal-lists Sass function
This file contains hidden or 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
// ---- | |
// Sass (v3.4.14) | |
// Compass (v1.0.3) | |
// ---- | |
$v1: 1 2 3; | |
$v2: 4 5 6; | |
$v3: 7 8 9; | |
.test { | |
// Is there any shorthand for that? | |
// @Hugo: see the function below | |
content: (length($v1) == length($v2)) == (length($v2) == length($v3)); | |
// Why this is not working ? | |
// @Hugo: because this is translated to *is `true` equal `3`?*, which is `false` | |
content: ((length($v1) == length($v2)) == length($v3)); | |
// Why this is not working ? | |
// @Hugo: same as above | |
content: (length($v1) == length($v2) == length($v3)); | |
} | |
@function equal-lists($lists...) { | |
@if length($lists) < 2 { | |
@return true; | |
} | |
$length: length(nth($lists, 1)); | |
@for $i from 2 through length($lists) { | |
@if length(nth($lists, $i)) != $length { | |
@return false; | |
} | |
} | |
@return true; | |
} | |
.test { | |
content: equal-lists($v1, $v2, $v3); | |
} |
This file contains hidden or 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
.test { | |
content: true; | |
content: false; | |
content: false; | |
} | |
.test { | |
content: true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment