Last active
December 17, 2015 02:59
-
-
Save lunelson/5540139 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com, the Sass playground.
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
// advanced list operation experiments; part of a larger codebase | |
@function contains($list, $var) | |
@return index($list, $var) != false | |
@function nested-contains($list, $key) | |
@each $tuple in $list | |
@if index($tuple, $key) != false | |
@return true | |
@return false | |
@function nested-index($list, $key) | |
@each $tuple in $list | |
@if index($tuple, $key) != false | |
@return index($list, $tuple) index($tuple, $key) | |
@return false | |
@function remainder($list, $item) | |
$out: () | |
@each $arg in $list | |
@if $arg != $item | |
$out: append($out, $arg) | |
@return $out | |
@function tuple-values($list, $key) | |
@each $tuple in $list | |
@if index($tuple, $key) | |
@return reject($tuple, $key) | |
@return false | |
@function tuple-values-2($list, $key, $key2) | |
@each $tuple in $list | |
@if index($tuple, $key) | |
$list2: reject($tuple, $key) | |
@each $tuple2 in nth($list2,1) | |
@if index($tuple2, $key2) | |
@return reject($tuple2, $key2) | |
@return false | |
$complex-list: 32px, trim bottom top, height 0.75, collapse top | |
.tuple-values-test | |
trim-contains: nested-contains($complex-list, trim) | |
trim-index: nested-index($complex-list, collapse) | |
trim-values: tuple-values($complex-list, trim) | |
height-values: tuple-values($complex-list, height) | |
collapse-value: tuple-values($complex-list, collapse) | |
$fonts: body (family unquote('"Helvetica", Helvetica'), topline 0.8, capline 0.75, midline 0, baseline 0.75, beardline 0.9), heading (family "Georgia", topline 0.8, capline 0.75, midline 0, baseline 0.75, beardline 0.9) | |
$body-data: tuple-values($fonts, body) | |
.font-data-test | |
font-family: tuple-values-2($fonts, body, family) | |
capline: tuple-values-2($fonts, body, capline) |
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
.tuple-values-test { | |
trim-contains: true; | |
trim-index: 4 1; | |
trim-values: bottom top; | |
height-values: 0.75; | |
collapse-value: top; | |
} | |
.font-data-test { | |
font-family: "Helvetica", Helvetica; | |
capline: 0.75; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment