A hackable, living style guide for Odopod projects.
The Odopod style guide reads JSON files for type styles, UI components, and other variables to generate style guide pages. See the writing CSS with JSON section in OdoSassplate for more details on the JSON.
npm install @odopod/style-guide --save-dev
Require the style guide within your project's main gulpfile.
// gulpfile.js
const styleguide = require('@odopod/style-guide');
styleguide.configure(options);
gulp.task('default', ['style-guide']);
The following gulp tasks are exported after the style guide is configured:
style-guide
style-guide--clean
style-guide--css
style-guide--js
style-guide--nunjucks
style-guide--watch
All availabe options can be found in defaults.js.
default: null
A string path to the .json files which Odopod Sassplate uses.
default: 'Odopod Style Guide'
Project title. Shown in the header on each page.
default: 'Odopod'
Project client. Shown in the header on each page.
default: ['css/docs.css']
Array of href
attributes used for each stylesheet added in the <head>
on every page. You can add your own project css here too, just make sure you add the generated docs.css
too when you change it!
default: []
Array of src
attributes used for each <script>
added in the <head>
on every page.
default: ['js/docs.js']
Array of src
attributes used for each <script>
added at the bottom of <body>
on every page.
default:
{
markup: path.join(process.cwd(), 'dist'),
css: path.join(process.cwd(), 'dist/css'),
js: path.join(process.cwd(), 'dist/js'),
}
Where to place generated files.
default: '#03a9fa'
Color to use for headers.
default: null
Allows you to define a path for your own templates. This path will take precedence in Nunjucks' searchPaths
. So when {% include "partials/foo.nunjucks" %}
is used, it will first look inside this path, then the original Odopod Style Guide template path. If templatePath
is defined, nunjucks files inside ${templatePath}/pages/*.nunjucks
will be used to generate the final markup. Files with the same name as originals will overwrite the original.
default: null
If defined, Odopod Style Guide will search this directory for any .svg
files, then include them on the ui-components
page at the bottom via a <use>
tag.
default: null
If defined, this file will be @import
ed in the main doc.scss file, allowing you to add your own custom styles to the style guide.
docsCssPath: './my-docs-theme.scss',
default: 'index.html'
Back link's href
attribute.
An object with keys as sections. Each key will be output on the index page with its array of links.
A function or object to pass directly to gulp-rename
. For example, to rename the index.html
file, you could do this:
renamePages: (filepath) => {
if (filepath.basename === 'index') {
filepath.basename = 'cool-index';
}
return filepath;
},
Odo Sassplate uses Odopod Style Guide. Here's that configuration.
const styleguide = require('@odopod/style-guide');
// Configure style guide
styleguide.configure({
name: 'Odo Sassplate',
client: 'Odopod',
jsonSource: 'extensions',
stylesheets: [
'styles.css',
'css/docs.css',
],
dist: {
markup: path.join(process.cwd(), 'dist'),
},
});