Created
January 5, 2015 17:59
-
-
Save jdelight/1ee285f31ebccdce876f to your computer and use it in GitHub Desktop.
Simple themes with sass 3.3 (works with Fabricator 0.7 but requires changing collate.js to include current index)
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
/** | |
* Block iteration | |
* @description Repeat a block a given amount of times. | |
* @example | |
* {{#iterate 20}} | |
* <li>List Item {{@index}}</li> | |
* {{/iterate}} | |
*/ | |
Handlebars.registerHelper('iterate', function (n, block) { | |
var accum = '', data; | |
for (var i = 0; i < n; ++i) { | |
if (block.data){ | |
data = Handlebars.createFrame(block.data || {}); | |
data.index = i; | |
} | |
data.index = i; | |
accum += block.fn(i, {data: data}); | |
} | |
return accum; | |
}); |
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
{{#iterate 4}} | |
<div class="theme-{{@index}}"> | |
<div class="header"> | |
header | |
</div> | |
<div class="footer"> | |
footer | |
</div> | |
</div> | |
{{/iterate}} |
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
$themes: ( | |
( | |
header: #b06, | |
text: #334, | |
footer: #666777, | |
), | |
( | |
header: #333, | |
text: #fff, | |
footer: #f33, | |
), | |
( | |
header: #999, | |
text: #444, | |
footer: #f83, | |
), | |
( | |
header: #bbb, | |
text: #ddd, | |
footer: #283, | |
) | |
); | |
@mixin themed($prop, $val) { | |
@each $theme in $themes { | |
.theme-#{index($themes, $theme) - 1 } & { | |
#{$prop}: map-get($theme, #{$val}); | |
} | |
} | |
} | |
.header { | |
@include themed('background', 'header'); | |
@include themed('color', 'text'); | |
} | |
.footer{ | |
@include themed('background', 'footer'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment