Skip to content

Instantly share code, notes, and snippets.

@joshdcomp
Created March 27, 2015 19:27
Show Gist options
  • Save joshdcomp/adda6df7500988d4907b to your computer and use it in GitHub Desktop.
Save joshdcomp/adda6df7500988d4907b to your computer and use it in GitHub Desktop.
Complex data structures
$_helvetica: (
'font-family': #{"Helvetica", sans-serif},
'font-weight': (
'default': 300,
'light': 100,
'normal': 300,
'semi-bold': 500,
'bold': 700
),
'line-height': 1.3,
'letter-spacing': '1px',
'color': $fontColor,
);
@function _get($map, $key, $subKey: false){
//check to see if the passed map exists
@if(!global-variable-exists($map)){
@warn "#{$map} doesn't exist.";
@return false;
}
//check to see if the property key passed resolves to a value
@if(map-has-key($map, $key)){
@if($subKey and map-has-key($map, $subKey)){
$key: map-get($map, $key);
@return map-get($key, $subKey);
}
@else{
@return map-get($map, $key);
}
}
@else{
@warn "#{$key} doesn't exist in #{$map}. Current font property options for #{$map} are: #{map-keys($map)}.";
@return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment