From: Geoff Kimball Date: Fri, 11 Mar 2016 22:03:14 +0000 (-0800) Subject: Comment all the customizer-related things X-Git-Tag: v6.2.1~30^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb06f6ae641b0a0a807abd6f0ceff08feab39d3f;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Comment all the customizer-related things --- diff --git a/customizer/config.yml b/customizer/config.yml index 11bd709cb..4b7dda152 100644 --- a/customizer/config.yml +++ b/customizer/config.yml @@ -1,3 +1,9 @@ +# This is the customizer's master module list. +# Each item in the list is a module with any of these keys: +# - sass: Name of the CSS export. 'grid' becomes '@include foundation-grid;' +# - js: Name of the JavaScript file. 'accordion' becomes 'foundation.accordion.js' +# - js_utils: Names of plugin dependencies. 'box' becomes 'foundation.util.box.js' + grid: sass: grid diff --git a/customizer/lib/js.js b/customizer/lib/js.js index 66f9a9eaf..d8546194b 100644 --- a/customizer/lib/js.js +++ b/customizer/lib/js.js @@ -1,5 +1,11 @@ var unique = require('array-uniq'); +/** + * Creates an array of file paths that can be passed to `gulp.src()`. + * @param {Object} config - Customizer configuration file. + * @param {String[]} modules - Modules to include in the file list. + * @returns {String[]} Array of file paths. + */ module.exports = function(config, modules) { var files = ['core']; var utils = []; @@ -19,9 +25,13 @@ module.exports = function(config, modules) { } } + // Prune duplicate entries from the list of utility files utils = unique(utils); + + // Combine foundation.core.js, utilities, and plugins into one array files = files.concat(utils, libraries); + // Format the modules as paths return files.map(function(file) { return 'js/foundation.' + file + '.js'; }); diff --git a/customizer/lib/sass.js b/customizer/lib/sass.js index 086618f98..69d6faf0a 100644 --- a/customizer/lib/sass.js +++ b/customizer/lib/sass.js @@ -19,6 +19,13 @@ var SASS_TEMPLATE = multiline(function() {/* @include motion-ui-animations; */}); +/** + * Generates an entry point Sass file with a custom list of CSS exports and Sass variables. + * @param {Object} config - Customizer configuration object. + * @param {String[]} modules - Modules to include CSS for. + * @param {Object} variables - Sass variable overrides to include. The key is the name of the variable, and the value is the value. + * @returns {String} Formatted Sass file. + */ module.exports = function(config, modules, variables) { var CONFIG = config; var variableList = []; diff --git a/gulp/customizer.js b/gulp/customizer.js index 29e4f468a..364557c58 100644 --- a/gulp/customizer.js +++ b/gulp/customizer.js @@ -19,8 +19,12 @@ var ARGS = require('yargs').argv; var CUSTOMIZER_CONFIG; var MODULE_LIST; +// Load the configuration file for the customizer. It's a list of modules to load and Sass variables to override gulp.task('customizer:loadConfig', function() { + // Config file with list of all Foundation modules and dependencies var config = fs.readFileSync('customizer/config.yml'); + + // Module file, created from customizer form data var moduleListPath = path.relative(__dirname, path.join(process.cwd(), ARGS.modules)); var moduleList = require(moduleListPath); @@ -29,6 +33,7 @@ gulp.task('customizer:loadConfig', function() { VARIABLE_LIST = moduleList.variables; }); +// Creates a Sass file from the module/variable list and creates foundation.css and foundation.min.css gulp.task('customizer:sass', ['customizer:loadConfig'], function() { var sassFile = customizer.sass(CUSTOMIZER_CONFIG, MODULE_LIST, VARIABLE_LIST); @@ -54,6 +59,7 @@ gulp.task('customizer:sass', ['customizer:loadConfig'], function() { .pipe(gulp.dest('.customizer/css')); }); +// Creates a Foundation JavaScript file from the module list, and also copies dependencies (jQuery, what-input) gulp.task('customizer:javascript', ['customizer:loadConfig'], function() { var jsPaths = customizer.js(CUSTOMIZER_CONFIG, MODULE_LIST); @@ -70,11 +76,18 @@ gulp.task('customizer:javascript', ['customizer:loadConfig'], function() { .pipe(gulp.dest('.customizer/js/vendor')); }); +// Copies the boilerplate index.html to the custom download folder gulp.task('customizer:html', ['customizer:loadConfig'], function() { return gulp.src('customizer/index.html') .pipe(gulp.dest('.customizer')); }); +// Creates a custom build by: +// - Generating a CSS file +// - Generating a JS file +// - Copying the index.html file +// - Creating a blank app.css file +// - Creating an app.js file with Foundation initialization code gulp.task('customizer', ['customizer:sass', 'customizer:javascript', 'customizer:html'], function(done) { touch('.customizer/css/app.css'); touch('.customizer/js/app.js');