Skip to content

Instantly share code, notes, and snippets.

@graste
Forked from KittyGiraudel/SassMeister-input.scss
Created January 27, 2014 20:40
Show Gist options
  • Select an option

  • Save graste/8656862 to your computer and use it in GitHub Desktop.

Select an option

Save graste/8656862 to your computer and use it in GitHub Desktop.
// ----
// Sass (v3.3.0.rc.2)
// Compass (v1.0.0.alpha.17)
// ----
// Extend function, JS STYYYYLE !
// ------------------------------------------------------------
// @param (map) $obj: default object
// @param (map) $extObj: conf object
// ------------------------------------------------------------
// @return (map) extended object
@function extend($obj, $extObj) {
@each $key, $value in $extObj {
$obj: map-merge($obj, ($key: $value));
}
@return $obj;
}
// A mixin of yours
@mixin app($conf: ()) {
// What could be the defaults parameter for your mixin
$conf: extend((
speed : 1000,
theme : dark,
name : 'default',
duration : 250ms,
width : 100%,
widget : modular
), if(type-of($conf) != map, (), $conf));
// Do something with the configuration objecy
test: inspect($conf);
}
test {
// Including the mixin with a custom conf object
@include app((
speed: 500,
theme: light,
name: 'test'
));
// Or full default if you don't feel like specifying any parameter
@include app();
}
test {
test: (speed: 500, theme: light, name: "test", duration: 250ms, width: 100%, widget: modular);
test: (speed: 1000, theme: dark, name: "default", duration: 250ms, width: 100%, widget: modular);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment