Created
June 22, 2014 14:56
-
-
Save Phize/1a10ec1c1556dfd3d6b5 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.3.8) | |
// Compass (v1.0.0.alpha.19) | |
// ---- | |
// Polymorphic components with Sass. | |
// by https://twitter.com/phize | |
// | |
// Dependency Injection: http://sassmeister.com/gist/5122325c0c29889b91c3 | |
// More simple DI: http://sassmeister.com/gist/3686b8eb3462fef52013 | |
// This is Facade, API mixin | |
@mixin button($properties: ()) { | |
$type: map-get($properties, type); | |
@if ($type == 'a') { | |
@include link-button($properties); | |
} | |
@if ($type == 'input') { | |
@include input-button($properties); | |
} | |
} | |
// Button component for a element. | |
// This is a low-level mixin. | |
@mixin link-button($properties: ()) { | |
content: "This is a link-button"; | |
} | |
// Button component for input element | |
// This is a low-level mixin. | |
@mixin input-button($properties: ()) { | |
content: "This is a input-button"; | |
} | |
// Placeholder definitions | |
// These placehodlers are default components | |
// that capsulate mixin and properties. | |
// They are also used for dependency injection. | |
// If you need Component variants, define new placeholders. | |
a%button { | |
$properties: ( | |
// component's variant specific properties. | |
); | |
@include link-button($properties); | |
} | |
input%button { | |
$properties: ( | |
// component's variant specific properties. | |
); | |
@include input-button($properties); | |
} | |
// Map placeholder to concreate class selector(s). | |
// Don't include other mixins, just only map each component to class | |
// (or modfiy a little for the context-specific ruleset.) | |
a.button { | |
@extend %button; | |
} | |
input.submit-button { | |
@extend %button; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a.button { | |
content: "This is a link-button"; | |
} | |
input.submit-button { | |
content: "This is a input-button"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment