Created
April 6, 2014 04:42
-
-
Save tjbenton/10001637 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
<script> | |
</script> | |
<iframe id=codepen src=http://www.codepen.io/pen?innerframe=true></iframe> |
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.3.7) | |
// Compass (v) | |
// ---- | |
// ---- | |
// Sass (v3.3.4) | |
@import "compass"; | |
$icons: ( | |
social: ( | |
facebook: "fb", | |
twitter: "tweet", | |
google-plus: "+plus" | |
), | |
arrow: ( | |
arrow-up: "^", | |
arrow-right: ">", | |
arrow-down: "^^", | |
arrow-left: "<" | |
), | |
special: "special-icon" | |
); | |
@function find-icon($a, $b: null, $icon-list: $icons){ | |
$set: map-get($icon-list, $a); | |
@return if(type-of($set) != map, $set, map-get($set, $b)); | |
} | |
$map-find:( | |
item-1: "value-1", | |
item-2: "value-2", | |
map-1:( | |
item-3: "value-3", | |
item-4: "value-4", | |
map-2:( | |
item-5: "value-5", | |
map-3: ( | |
item-7: "value-7", | |
item-8: "value-8", | |
map-4: ( | |
item-9: "value-9", | |
item-10: "value-10", | |
map-5: ( | |
item-11: "value-11" | |
) | |
) | |
) | |
) | |
) | |
); | |
@function map-find($map, $a){ | |
$value: map-get(call(map-merge-this, $map), $a); | |
@if $value == null{ @warn "#{$a} is not in #{$map}"; } | |
@return $value; | |
} | |
// Map merge this | |
// @notes{ This is used to merge all the maps in a single map together as a single map } | |
@function map-merge-this($map){ | |
$tmp-map: (); | |
@each $item, $value in $map{ | |
$tmp-map: map-merge($tmp-map, if(type-of($value) == map, $value, ($item: $value))); | |
} | |
@each $item, $value in $tmp-map{ | |
$tmp-map: if(type-of($value) == map, call(map-merge-this, $tmp-map), $tmp-map); | |
} | |
@return $tmp-map; | |
} | |
// icon-get | |
// @notes { This is used to get the value for the icons } | |
@function icon-get($icon, $icon-map: $icons){ | |
$icon: call(map-find, $icon-map, $icon); | |
@return $icon; | |
} | |
/* map-find() tests */ | |
.map-find{ | |
test-1: map-find($map-find, item-1); | |
test-2: map-find($map-find, item-2); | |
test-3: map-find($map-find, item-3); | |
test-4: map-find($map-find, item-4); | |
test-8: map-find($map-find, item-8); | |
test-10: map-find($map-find, item-10); | |
test-11: map-find($map-find, item-11); | |
} | |
/* icon-get() tests */ | |
.icon-get{ | |
test-1: icon-get(facebook); | |
// test-2: ; | |
// test-3: ; | |
// test-4: ; | |
} |
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
/* map-find() tests */ | |
.map-find { | |
test-1: "value-1"; | |
test-2: "value-2"; | |
test-3: "value-3"; | |
test-4: "value-4"; | |
test-8: "value-8"; | |
test-10: "value-10"; | |
test-11: "value-11"; | |
} | |
/* icon-get() tests */ | |
.icon-get { | |
test-1: "fb"; | |
} |
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
<script> | |
</script> | |
<iframe id=codepen src=http://www.codepen.io/pen?innerframe=true></iframe> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment