• Stars
    star
    526
  • Rank 84,247 (Top 2 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PostCSS plugin to generate a style guide automatically

postcss-style-guide Build Status

PostCSS plugin to generate a style guide automatically.

CSS comments will be parsed through Markdown and displayed in a generated HTML document.

Install

$ npm install postcss-style-guide

Example

Node.js:

var fs = require('fs');
var postcss = require('postcss');
var styleguide = require('postcss-style-guide');
var input = fs.readFileSync('input.css', 'utf8');

var output = postcss([
  styleguide
]).process(input)
.then(function (reuslt) {
  var output = fs.readFileSync('styleGuide/index.html', 'utf8');
  console.log('output:', output);
});

in Gulp:

var gulp = require('gulp')

gulp.task('build:css', function () {
    var concat = require('gulp-concat')
    var postcss = require('gulp-postcss')
    var autoprefixer = require('autoprefixer')
    var customProperties = require('postcss-custom-properties')
    var Import = require('postcss-import')
    var styleGuide = require('postcss-style-guide')
    var nano = require('cssnano')

    return gulp.src('./app.css')
        .pipe(postcss([
            Import,
            customProperties({ preserve: true }),
            autoprefixer,
            styleGuide({
                project: 'Project name',
                dest: 'styleguide/index.html',
                showCode: false,
                themePath: '../'
            }),
            nano
        ]))
        .pipe(concat('app.min.css'))
        .pipe(gulp.dest('dist/css'))
})

We can generate color palette from CSS Custom Properties with @start color and @end color annotations.

app.css:

@import "color";
@import "button";

color.css:

@import "button";
/* @start color */
:root {
    --red: #e23B00;
    --blue: #3f526b;
    --black: #000;
    --background: #faf8f5;
}
/* @end color */

postcss-style-guide generate style guide from CSS comments that have special annotation(@styleguide).

@title: set component name

button.css:

/*
@styleguide

@title Button

Use the button classes on and `<a>`, `<button>`, `<input>` elements.

<button class="button button--large button--red">Red Button</button>

    <button class="button button--large button--red">Red Button</button>

<button class="button button--large button--blue">Red Button</button>

    <button class="button button--large button--blue">Red Button</button>
*/
.button {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
}

.button--large {
    width: 140px;
    height: 40px;
    font-size: 14px;
}

.button--red {
    color: #fff;
    background-color: var(--red);
}

.button--blue {
    color: #fff;
    background-color: var(--blue);
}

You will get styleguide/index.html for the style guide.

Default style guide design

Options

  • options.src: The path to the source CSS file.
  • options.dest: The path to style guide file. (default: styleguide/index.html)
  • options.project: Project name. (default: Style Guide)
  • options.showCode: The flag to show CSS code (default: true)
  • options.theme: Theme name. (default: psg-theme-default)
  • options.themePath: The path to theme file. (default: node_modules/psg-theme-default)

Themes

You can select a theme of style guide with options.theme. And you can also create original themes. When you create themes, please read theme guideline

All of postcss-style-guide themes that can be used are here.

Themes list

How to develop postcss-style-guide theme

License

The MIT License (MIT)

Copyright (c) 2015 Masaaki Morishita

More Repositories

1

stylefmt

stylefmt is a tool that automatically formats stylesheets.
JavaScript
2,099
star
2

picostyle

Ultra small CSS in JS library in 0.4 KB
JavaScript
360
star
3

atcss

Annotations based CSS processor
JavaScript
63
star
4

scssfmt

Standard SCSS code formatter
JavaScript
57
star
5

YACP

Yet Another CSS Preprocessor
JavaScript
52
star
6

gulp-stylefmt

gulp plugin for stylefmt
JavaScript
44
star
7

gulp-csscss

gulp plugin for running csscss
JavaScript
29
star
8

postcss-ref

PostCSS plugin to refer properties from another rule (@ref rule)
JavaScript
25
star
9

is-color

Check if a string is CSS color value
JavaScript
17
star
10

picostyle-react

Picostyle for React
JavaScript
11
star
11

grunt-stylefmt

Grunt plugin for stylefmt
JavaScript
11
star
12

csscs

CSS Code Style checker
JavaScript
9
star
13

postcss-namespace

PostCSS plugin for the scope of name binding
JavaScript
9
star
14

gridbugs

A community-curated list of CSS Grid issues and cross-browser workarounds for them.
7
star
15

postcss-font-smoothing

PostCSS plugin to fallback font-smoothing property
JavaScript
6
star
16

fly-cssfmt

Fly plugin for CSSfmt
JavaScript
6
star
17

fly-stylus

Fly plugin for Stylus
JavaScript
6
star
18

rails-grape-sample

Sample REST API implemented by Rails with Grape.
Ruby
5
star
19

psg-theme-default

Default theme of postcss-style-guide
HTML
5
star
20

postcss-annotation-include

PostCSS plugin for annotations based including properties in other rule sets
JavaScript
5
star
21

sketch.css

Sketch is a CSS framework, it makes Web designing more fun.
CSS
5
star
22

css-annotation

Annotation parser for CSS
JavaScript
5
star
23

psg

Command line interface of postcss-style-guide
JavaScript
4
star
24

psg-theme-forest

'Forest': Theme of postcss-style-guide
CSS
4
star
25

postcss-important

PostCSS plugin for annotations based `!important`
JavaScript
4
star
26

normalize.styl

Stylus port of normalize.css v3.0.3
CSS
3
star
27

postcss-validator

PostCSS plugin to check if an input string is valid CSS
JavaScript
3
star
28

generator-npmodule

Yeoman generator of node packaged module
JavaScript
3
star
29

css-annotation-block

A css-annotation module to return the specific nodes
JavaScript
3
star
30

cheatah

More fast and casual CSS styleguide or cheatsheat generator
JavaScript
3
star
31

masaakim-hidden

About me
2
star
32

css-utilify

Add `@base` annotations to the rules
JavaScript
2
star
33

custom-properties-sass

Transpile Custom Properties to Sass variables
JavaScript
2
star
34

cli-tree

Object tree viewer for the CLI
JavaScript
2
star
35

postcss-annotation-extend

PostCSS plugin for annotations based inheritance from other rule sets
JavaScript
2
star
36

css-border-property

Parser and stringifier of `border` property
JavaScript
2
star
37

fly-csso

Fly plugin for csso
JavaScript
2
star
38

css-tuning

Postprocessing pack for CSS performance tuning
JavaScript
2
star
39

css-specificity

CSS selector specificity calculator
JavaScript
1
star
40

postcss-atcss-inherit

A module for ACSS to inherit other rules
JavaScript
1
star
41

inCollege

inCollege is dating site for university students. They can connect each other.
JavaScript
1
star
42

grunt-yacp

grunt plugin for YACP.
JavaScript
1
star
43

tapestry

Test Anything Protocol tools and its wrapper testing framework in Ruby
Ruby
1
star
44

is-css-length

Check if a string is CSS value of the length
JavaScript
1
star
45

morishitter.com

JavaScript
1
star
46

tecsst

CSS testing framework without taking screenshots
JavaScript
1
star
47

rework-rule-binding

Rework plugin to prohibit cascading the ruleset.
JavaScript
1
star
48

morishitter2

PHP
1
star
49

css-type-definition

List of values that the CSS property can be taken
JavaScript
1
star
50

fly-csscomb

CSSComb plugin for Fly.
JavaScript
1
star
51

YouJukeMix

https://morishitter.github.io/YouJukeMix
JavaScript
1
star
52

css-value-type

get types of CSS properties
JavaScript
1
star
53

search-Twitter-id

The script for searching Twitter ID which has two or three characters.
PHP
1
star
54

heavyarms-syntax

A theme for Atom
CSS
1
star