Skip to content

Instantly share code, notes, and snippets.

@jdsteinbach
Forked from camerond/_inheritance.sass
Last active June 17, 2016 08:44
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdsteinbach/338e00af78e3ef7e0b5d to your computer and use it in GitHub Desktop.
Save jdsteinbach/338e00af78e3ef7e0b5d to your computer and use it in GitHub Desktop.
$global_store: ()
= override($args:(), $is_child:true)
@if $is_child
$global_store: () !global
$global_store: map-merge($global_store, $args) !global
= default($key_or_map, $value:null)
@if $value
+store-default($key_or_map, $value)
@else
@each $key, $value in $key_or_map
+store-default($key, $value)
= store-default($key, $value)
@if map-has-key($global_store, $key)
@else
$global_store: map-merge($global_store, ($key: $value)) !global
@function fetch($key)
@return map-get($global_store, $key)
$global_store: ();
@mixin override($args, $is_child:true) {
@if $is_child {
$global_store: () !global;
}
$global_store: map-merge($global_store, $args) !global;
}
@mixin default($key_or_map, $value:null) {
@if $value {
@include store-default($key_or_map, $value);
}
@else {
@each $key, $value in $key_or_map {
@include store-default($key, $value);
}
}
}
@mixin store-default($key, $value) {
@if map-has-key($global_store, $key) {
}
@else {
$global_store: map-merge($global_store, ($key: $value)) !global;
}
}
@function fetch($key) {
@return map-get($global_store, $key);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment