# Dashboard Pattern Library

## Live demo
Please visit our [Pattern Library Site](http://celtra.github.io/pattern-library) for a live demo.

## Running it locally
You can see everything on the live demo. Setup a local environment only for development purposes.

#### Dependencies
* Ruby 2.1.5+
* RubyGems
* NodeJS

#### Install Jekyll

If you don't have `bundler` installed, install it with

```sh
[sudo] gem install bundler
```

and then

```sh
bundle install
```

On OS X you'll probably have to use `sudo`.

#### Install node packages

```sh
npm install
```

### Running the platform

#### Compile
We're using gulp to compile CoffeScripts and less files and to arrange assets so they can be picked up by Jekyll.

```sh
npm start
```
Once gulp starts it will watch for any changes made to your files and recompile automatically if needed.

#### Start the server
Open a second terminal window and startup Jekyll.

```sh
bundle exec jekyll s
```

Jekyll generates a static web page based on the source files. Use `--no-watch` to not re-generate whenever the source files change.

#### Open the library in browser
By default the server is running on 0.0.0.0 at port 4000.

Start up your browser and head to `http://localhost:4000`. If you're running jekyll on a VM open `http://{ip_of_your_VM}:4000`.

## Publishing to NPM (cegli)

First bump version in `package.json` and then

```sh
npm publish # npm login if not logged in
```

#### Problems with publishing

You need to have correct registry URL Setup

```sh
npm config get registry
# if http://npm.celtra.com/ then:
npm config set registry http://registry.npmjs.org/
```

#### Prepublishing
Sometimes you need to publish a package before it's ready to be released. We're using npm tags to do this.

First bump package version and assign a tag to it.

```sh
npm dist-tag add cegli@0.1.16 beta
```

Check if tag is assigned.

```sh
npm dist-tag ls

latest: 0.1.15
beta: 0.1.16
```

Once a version has a custom tag assigned it's ready to be prepublished. Publishing a package sets the `latest` tag to the published version unless the `--tag` option is used

```sh
npm publish --tag beta
```

Now you can use tag instead of version to install package.

```json
"dependencies": {
	"cegli" : "beta"
}
```

```sh
npm install cegli --tag beta
```

Don't forget to clear the tag once you're done.

```sh
npm dist-tag rm cegli beta
```

## Updating live demo
The *gh-pages* branch is specially configured to run on github pages and will not run on your local environment. Make sure you never directly commit to *gh-pages*. You should instead first update the *master* and then merge to *gh-pages* branch. This way we keep all changes in master and it's harder to break the live demo. Run `gulp build` before committing to *gh-pages* branch.

## Developer notes

* All folders with the `_` prefix are ignored by jekyll and not copied to `_site`.
* Run `gulp clean` if you get an error similar to the one bellow when trying to switch the branch.

```
Untracked working tree file 'build/fonts/avenirnextltpro-light-webfont.ttf' would be overwritten by merge.
```
