Skip to content

Instantly share code, notes, and snippets.

@camerond
Last active January 31, 2016 17:53
Show Gist options
  • Save camerond/026835a92e4c00da69e3 to your computer and use it in GitHub Desktop.
Save camerond/026835a92e4c00da69e3 to your computer and use it in GitHub Desktop.
Classical mixin inheritance in Sass
$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)
@jdsteinbach
Copy link

Created a .scss version of this partial - that may be helpful to some:

https://gist.github.com/jdsteinbach/338e00af78e3ef7e0b5d

@lifeiscontent
Copy link

@camerond your inheritance is a leaky abstraction: http://codepen.io/lifeiscontent/pen/emQeQM

look at the CSS output.

@camerond
Copy link
Author

@lifeiscontent Hmm. Belated thanks. Figures that it was too good to be true. Had fun experimenting, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment