ingvoo / patterns

Collection of reusable UI patterns
https://patterns.ljomi.ch/
MIT License
5 stars 0 forks source link
fractal nunjucks scss

Patterns

A starterkit to create web styleguides with Fractal and Webpack.

Installation

Prerequisites: Node.js >= 10, <= 12

Inside the directory of your choice, install a copy of the starterkit with:

curl -L https://github.com/ingvoo/patterns/archive/master.tar.gz | tar zx --strip 1

Then install the npm dependencies with:

npm install

Getting started

To start the development server, run:

npm start

You can now access your styleguide at localhost:3000.

You’re all set, start to:

Build

You can build a static version of the styleguide to deploy it wherever you like by running:

npm run build

The generated files go to the dist directory.

Release

The starterkit comes with a preconfigured release management tool. It will automatically update the CHANGELOG.md file at the root of the project based on the commit messages as long as they follow the Angular commit guidelines. It will also bump the version number in the package.json, run the build command above, commit, tag and push the changes. This process is interactive and you’ll be able to skip steps manually if you like.

To release a new version run:

npm run release [patch|minor|major|version_number]

By default the version bump is automatically determined based on the commits messages.

Read more in the release-it documentation.

Misc

Browsers support

The browsers support is defined in .browserslistrc. It’s used both by Autoprefixer for the CSS and by @babel/preset-env for the JavaScript.

Check browserslist’s documentation to change the browser support.

Icons

Icons placed inside assets/icons are combined into a sprite called icons.svg when referenced. To load them, either reference them in your JavaScript:

import 'icons/foo.svg';

Or in your stylesheet:

background-image: url('../icons/foo.svg');

Webpack will automatically rewrite the links to the sprite with the correct identifier. See svg-sprite-loader documentation for more information.

You can then easily use an icon in a template with the icon snippet:

{% render '@icon', { id: 'foo', class: 'bar' } %}

Warning: This method of including remote SVG file is not supported by Internet Explorer 11 and below. You may want to polyfill it with svgxuse.

Credits

This project was originally cloned from https://github.com/liip/styleguide-starterkit. Very special thanks to to Liip and to Benoît Burgener.