benguhin / patternlab-node

The Node version of Pattern Lab

Home Page:http://patternlab.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

About the Node Version of Pattern Lab

The Node version of Pattern Lab is, at its core, a static site generator. It combines platform-agnostic assets, like the Mustache-based patterns and the JavaScript-based viewer, with a Node-based "builder" that transforms and dynamically builds the Pattern Lab site. By making it a static site generator, the Node version of Pattern Lab strongly separates patterns, data, and presentation from build logic. The Node version is a work in progress, the PHP version should be seen as a reference for other developers to improve upon as they build their own Pattern Lab Builders in their language of choice.

Getting Started

To run patternlab-node, just do the following from the command line at the root of patternlab-node:

  1. npm install
  2. npm install -g grunt-cli
  3. grunt

This creates all patterns, the styleguide, and the pattern lab site.

Command Line Interface

The following are grunt task arguments you may execute:

patternlab

With no arguments, patternlab runs the full builder, compiling patterns, and constructing the front-end site.

patternlab:only_patterns

Compile the patterns only, outputting to ./public/patterns

patternlab:v

Retrieve the version of patternlab-node you have installed

patternlab:help

Get more information about patternlab-node, pattern lab in general, and where to report issues.

Config Options

Watching Changes

To have patternlab-node watch for changes to either a mustache template, data, or stylesheets, run grunt watch. The Gruntfile governs what is watched. It should be easy to add scss or whatever preprocessor you fancy.

Nav Bar Controls

If you don't have a need for some of the nav-bar tools in the patternlab frontend, you can turn them off in config.json.

The current selection is as follows. It reflects support versus patternlab-php.

"ishControlsVisible": {
	"s": true,
	"m": true,
	"l": true,
	"full": true,
	"ranndom": true,
	"disco": true,
	"hay": true,
	"mqs": false,
	"find": false,
	"views-all": true,
	"views-annotations": true,
	"views-code": true,
	"views-new": true,
	"tools-all": true,
	"tools-follow": false,
	"tools-reload": false,
	"tools-shortcuts": false,
	"tools-docs": true
}
Verbose Mode

patternlab.json is a file created for debugging purposes. Set debug to true in .config.json to see all the secrets.

Pattern States

You can set the state of a pattern by including it in config.json too. The out of the box styles are in progress (orange), in review (yellow), and complete (green). Pattern states should be lowercase and use hyphens where spaces are present.

"patternStates": {
	"colors" : "inprogress",
	"fonts" : "inreview",
	"three-up" : "complete"
}
Server

Running grunt serve will compile the patternlab front end and host it on http://localhost:9001 by default. Page will reload on any saved source code change.

===

The Node version of Pattern Lab is maintained by @bmuenzenmeyer and contributors. Pull requests welcome, but please take a moment to read the guidelines.

Forward, To the Specification!

Dave Olsen has published the specification for Pattern Lab ports. Development will be oriented toward compliance with this as the spec and the port mature together.

Is Pattern Lab a Platform or a Build Tool?

A lot of good conversation has revolved around whether Pattern Lab is a platform or a tool in the toolbox, part of a larger solution. It's my goal to #1) adhere to the specification and #2) meet the needs of both use cases.

If you want to only build the patterns, alter your Gruntfile.js patternlab task to the following:

grunt.registerTask('default', ['clean', 'concat', 'patternlab:only_patterns', /*'sass',*/ 'copy']);

This will output compiled patterns to ./public/patterns/

Where is the Gulp Version?

The core patternlab engine is free of any dependencies to grunt, allowing users to integrate with gulp if desired. Future efforts here will orient towards this gulp implementation by oscar-g.

===

Working with Patterns

(The following documentation is built for the PHP version of Pattern Lab, but most applies to the node version too. If you find omissions or mistakes please open an issue.)

Patterns are the core element of Pattern Lab. Understanding how they work is the key to getting the most out of the system. Patterns use Mustache so please read Mustache's docs as well.

Creating & Working With Dynamic Data for a Pattern

The Node version of Pattern Lab utilizes Mustache as the template language for patterns. In addition to allowing for the inclusion of one pattern within another it also gives pattern developers the ability to include variables. This means that attributes like image sources can be centralized in one file for easy modification across one or more patterns. The Node version of Pattern Lab uses a JSON file, source/_data/data.json, to centralize many of these attributes.

Using Pattern Lab's Advanced Features

By default, the Pattern Lab assets can be manually generated and the Pattern Lab site manually refreshed but who wants to waste time doing that? Here are some ways that Pattern Lab can make your development workflow a little smoother:

About

The Node version of Pattern Lab

http://patternlab.io

License:MIT License


Languages

Language:JavaScript 55.0%Language:PHP 29.7%Language:CSS 15.3%