-
-
Save straker/6cd9923fe1282452f094755fe4be8200 to your computer and use it in GitHub Desktop.
LivingCSS Example Template and Gulpfile
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
var gulp = require('gulp'); | |
var livingcss = require('gulp-livingcss'); | |
var path = require('path'); | |
function findLoneSubsections(sections) { | |
for (var i = 0, section; section = sections[i]; i++) { | |
if (section.subSections && section.subSections.length === 1) { | |
section.loneSubsection = true; | |
} | |
} | |
} | |
gulp.task('generate', function() { | |
return gulp.src([ | |
'node_modules/fs-styles/assets/css/helpers/*.styl', | |
'node_modules/fs-styles/assets/css/elements/*.styl', | |
'node_modules/fs-styles/assets/css/modules/*.styl' | |
]) | |
.pipe(livingcss('.', { | |
template: 'handlebars/template.hbs', | |
preprocess: function(context, template, Handlebars) { | |
findLoneSubsections(context.sections); | |
return livingcss.utils.readFileGlobs('handlebars/partials/*.hbs', function(data, file) { | |
Handlebars.registerPartial(path.basename(file, path.extname(file)), data); | |
}); | |
}, | |
sortOrder: [ | |
{index: ['colors', 'break points', 'typography', 'lists', 'forms', 'buttons', 'icons', 'tooltips', 'badges', 'alerts', 'cards', 'subnav', 'modals']} | |
], | |
tags: { | |
colordef: function() { | |
this.block.name = this.tag.description; | |
this.block.description = this.comment.description; | |
this.block.id = livingcss.utils.getId(this.block.name); | |
}, | |
color: function() { | |
this.block[this.tag.type] = this.tag.description; | |
}, | |
colorof: function() { | |
var section = this.sections[this.tag.description]; | |
if (section) { | |
section.colors = section.colors || []; | |
section.colors.push(this.block); | |
} | |
}, | |
icondef: function() { | |
this.block.name = this.tag.description; | |
this.block.description = this.comment.description; | |
this.block.id = livingcss.utils.getId(this.block.name); | |
}, | |
iconof: function() { | |
var section = this.sections[this.tag.description]; | |
if (section) { | |
section.icons = section.icons || []; | |
section.icons.push(this.block); | |
} | |
} | |
} | |
})) | |
.pipe(gulp.dest('.')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! This is super useful. Any chance you could include the
colorSquare.hbs
oriconSquare.hbs
template as an example of how to render custom tags?