Skip to content

Instantly share code, notes, and snippets.

@anatomic
Created January 6, 2016 12:42
Show Gist options
  • Save anatomic/61ae591b2915b1ee9dc1 to your computer and use it in GitHub Desktop.
Save anatomic/61ae591b2915b1ee9dc1 to your computer and use it in GitHub Desktop.
Simple Sass Modules
/**
* Simple Sass Modules
*
* Prevent output from Sass modules when @imported more than once. Allows for
* modules to declare their own dependencies without a global stylesheet having to know what
* to include and without fear CSS will be exported multiple times.
*
*/
/**
* Stores a list of all the currently exported modules to help with dependency management
* @type list
* @access private
*/
$modules: ()!default;
/**
* Core mixin for managing dependencies through the framework and your project
*
* @author Ian Thomas
* @param {String} $name - The name of your component
* @example scss
* @include exports('my-component') {
* .class { ... }
* }
*/
@mixin exports($name){
@if index($modules, $name) == false {
$modules: append($modules, $name);
@content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment