Skip to content

Instantly share code, notes, and snippets.

@tjbenton
Created April 6, 2014 04:42
Show Gist options
  • Save tjbenton/10001637 to your computer and use it in GitHub Desktop.
Save tjbenton/10001637 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<script>
</script>
<iframe id=codepen src=http://www.codepen.io/pen?innerframe=true></iframe>
// ----
// 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: ;
}
/* 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";
}
<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