DocumentCSS is an awesome way to document style patterns as you make them. This starter kit was built to make it super easy to get started.
Speaking of getting started...
package.json
file to reference your style guide repo.npm install
npm install -g gulp
documentjs
build command: npm install -g documentjs
.Run gulp dev
to compile the style guide and run a live reloading local server at http://localhost:4200/
. You can change the port number in gulpfile.js
.
Couple notes...
less
in documentjs.json
and gulpfile.js
.The strategy here is that your core styles patterns are in their own repo with a style guide that others can reference. Then these styles are imported into your apps (the compiled styles from the dist
folder), you'll have additional app view specific styles that don't necessarily cut it as a pattern in the app's own repo. If you develop a repeatable pattern in an app, transfer it to the style guide! You'll be able to document it quickly and easily.
After you npm install
and run gulp dev
for the first time, you'll have a folder structure like this.
styles.less
file is your LESS import file that gulp will compile (if you change this files name, update the reference in gulpfile.js
).
If you checkout the buttons.less
example file in the less
folder, you can get an idea how it works.
@stylesheet NAME TITLE
is declared. This creates a page. NAME
is the unique name that will show up in the URL, TITLE
is what will appear in the style guide as the page header.@parent NAME ORDER
tells the static site generator where to place this page in the navigation. In this starter kit, you'll pretty much always have this as @parent styleguide
plus whatever index number you want to give it, controlling what order it appears in.@description
can be written using markdown and appears at the top of the page under the main title.You can also use @group
and other cool stuff to organize your documentation. Learn more at documentcss.com.
@styles NAME TITLE
to document it. The NAME
is the unique identifier that shows up in the URL, and the TITLE
appears on the page.@description
allows you to write markdown that will appear below the @styles
title.@demo PATH
allows you specify a demo snippet to use with these styles. Create a demo snippet of HTML
markup in ./less/demos/
and reference it in the styles file (ex. @demo demos/some-demo.html
)../style-guide-theme/
.static
folder contains styles and images that you can override. The styles in there are written with LESS, they're essentially copied from the default documentjs theme with a few modifications.templates
folder contains handlebar templates that you can modify for changing the header/footer/pages/sidebar markup.The styleguide
folder is your generated pattern library. You can upload that to any server or use github pages to host it.