diff --git a/.storybook/addons.js b/.storybook/addons.js new file mode 100644 index 0000000..6622fe4 --- /dev/null +++ b/.storybook/addons.js @@ -0,0 +1 @@ +import '@storybook/addon-knobs/register'; diff --git a/.storybook/config.js b/.storybook/config.js new file mode 100644 index 0000000..cffac93 --- /dev/null +++ b/.storybook/config.js @@ -0,0 +1,11 @@ +import { configure } from '@storybook/html'; + +import '../css/nes.min.css' + +// automatically import all files ending in *.stories.js +const req = require.context('../docs', true, /.stories.js$/); +function loadStories() { + req.keys().forEach(filename => req(filename)); +} + +configure(loadStories, module); diff --git a/README.md b/README.md index 7c902c3..9be85c9 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,11 @@ npm run watch npm run build ``` +#### Run Storybook +``` +npm run storybook +``` + Linting, formatting and building runs automatically in the pre-commit hook. TODO: ビルドはCIでするように変更したい @@ -87,6 +92,7 @@ TODO: ビルドはCIでするように変更したい ├── index.html: Demo page ├── style.css: Demo page style ├── css: Distribution files +├── docs: Storybook stories └── scss: Source ├── base │ ├── reboot.scss: Don't change! (Bootstrap Reboot) diff --git a/docs/balloons.stories.js b/docs/balloons.stories.js new file mode 100644 index 0000000..ceed78f --- /dev/null +++ b/docs/balloons.stories.js @@ -0,0 +1,16 @@ +import { storiesOf } from '@storybook/html'; // eslint-disable-line import/no-extraneous-dependencies +import { // eslint-disable-line import/no-extraneous-dependencies + withKnobs, radios, +} from '@storybook/addon-knobs'; + +const stories = storiesOf('Ballons', module); +stories.addDecorator(withKnobs); + +stories.add('balloon', () => { + const selectedClass = radios('direction', { + default: '', + 'from-left': 'from-left', + 'from-right': 'from-right', + }, ''); + return `

Hello NES.css

`; +}); diff --git a/docs/buttons.stories.js b/docs/buttons.stories.js new file mode 100644 index 0000000..af8ae8f --- /dev/null +++ b/docs/buttons.stories.js @@ -0,0 +1,18 @@ +import { storiesOf } from '@storybook/html'; // eslint-disable-line import/no-extraneous-dependencies +import { // eslint-disable-line import/no-extraneous-dependencies + withKnobs, radios, +} from '@storybook/addon-knobs'; + +const stories = storiesOf('Buttons', module); +stories.addDecorator(withKnobs); + +stories.add('button', () => { + const extraClass = radios('class', { + default: '', + 'is-primary': 'is-primary', + 'is-success': 'is-success', + 'is-warning': 'is-warning', + 'is-error': 'is-error', + }, ''); + return ``; +}); diff --git a/docs/containers.stories.js b/docs/containers.stories.js new file mode 100644 index 0000000..9e347e4 --- /dev/null +++ b/docs/containers.stories.js @@ -0,0 +1,24 @@ +import { storiesOf } from '@storybook/html'; // eslint-disable-line import/no-extraneous-dependencies +import { // eslint-disable-line import/no-extraneous-dependencies + withKnobs, boolean, radios, +} from '@storybook/addon-knobs'; + +const stories = storiesOf('Containers', module); +stories.addDecorator(withKnobs); + +stories.add('container', () => { + const withTitle = boolean('with-title', false) ? 'with-title' : ''; + const isDark = boolean('is-dark', false) ? 'is-dark' : ''; + const isRounded = boolean('is-rounded', false) ? 'is-rounded' : ''; + const alignment = radios('alignment', { + default: '', + 'is-center': 'is-center', + 'is-right': 'is-right', + }, ''); + const selectedClasses = [withTitle, isDark, isRounded, alignment]; + + return `
+

Container

+

Good morning. Thou hast had a good night's sleep, I hope.

+
`; +}); diff --git a/docs/icons.stories.js b/docs/icons.stories.js new file mode 100644 index 0000000..4d0f991 --- /dev/null +++ b/docs/icons.stories.js @@ -0,0 +1,30 @@ +import { storiesOf } from '@storybook/html'; // eslint-disable-line import/no-extraneous-dependencies +import { // eslint-disable-line import/no-extraneous-dependencies + withKnobs, select, radios, +} from '@storybook/addon-knobs'; + +const stories = storiesOf('Icons', module); +stories.addDecorator(withKnobs); + +stories.add('icon', () => { + const selectedClass = select('class', { + 'icon twitter': 'icon twitter', + 'icon facebook': 'icon facebook', + 'icon github': 'icon github', + 'icon youtube': 'icon youtube', + 'icon close': 'icon close', + 'octocat animate': 'octocat animate', + 'icon trophy': 'icon trophy', + 'nes-logo': 'nes-logo', + 'nes-jp-logo': 'nes-jp-logo', + 'snes-logo': 'snes-logo', + 'snes-jp-logo': 'snes-jp-logo', + }, 'icon twitter'); + const selectedSize = radios('size', { + default: '', + 'is-medium': 'is-medium', + 'is-large': 'is-large', + }, ''); + + return ``; +}); diff --git a/docs/inputs.stories.js b/docs/inputs.stories.js new file mode 100644 index 0000000..6fa8016 --- /dev/null +++ b/docs/inputs.stories.js @@ -0,0 +1,31 @@ +import { storiesOf } from '@storybook/html'; // eslint-disable-line import/no-extraneous-dependencies +import { // eslint-disable-line import/no-extraneous-dependencies + withKnobs, radios, +} from '@storybook/addon-knobs'; + +const stories = storiesOf('Inputs', module); +stories.addDecorator(withKnobs); + +stories.add('input.radio', () => ` + `) + .add('input.checkbox', () => ` + `) + .add('input', () => { + const selectedClass = radios('class', { + default: '', + 'is-success': 'is-success', + 'is-warning': 'is-warning', + 'is-error': 'is-error', + }, ''); + + return ``; + }); diff --git a/docs/table.stories.js b/docs/table.stories.js new file mode 100644 index 0000000..fdd571e --- /dev/null +++ b/docs/table.stories.js @@ -0,0 +1,36 @@ +import { storiesOf } from '@storybook/html'; // eslint-disable-line import/no-extraneous-dependencies +import { // eslint-disable-line import/no-extraneous-dependencies + withKnobs, boolean, +} from '@storybook/addon-knobs'; + +const stories = storiesOf('Tables', module); +stories.addDecorator(withKnobs); + +stories.add('table', () => { + const isBordered = boolean('is-bordered', true) ? 'is-bordered' : ''; + const isCentered = boolean('is-centered', false) ? 'is-centered' : ''; + + const selectedClasses = [isBordered, isCentered]; + + return ` + + + + + + + + + + + + + + + + + + + +
TableTable.is-borderedTable.is-centered
Thou hast had a good morningThou hast had a good afternoonThou hast had a good night
Thou hast had a good morningThou hast had a good afternoonThou hast had a good night
`; +}); diff --git a/package.json b/package.json index dac6c84..c47f3db 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,16 @@ "description": "NES.css is NES-style CSS Framework.", "scripts": { "watch": "npm run build:sass -- --watch", - "build": "npm run build:clean && npm run build:stylelint && npm run build:sass && npm run build:autoprefix && npm run build:cleancss", + "build": "npm run build:clean && npm run build:stylelint && npm run build:sass && npm run build:autoprefix && npm run build:cleancss && npm run build-storybook", "stylelint": "stylelint scss/**/*.scss", "build:stylelint": "npm run stylelint -- --fix", "build:clean": "rimraf css", "build:sass": "node-sass --output-style expanded --source-map true scss/nes.scss css/nes.css", "build:autoprefix": "postcss --use autoprefixer --map false --output css/nes.css css/nes.css", "build:cleancss": "cleancss -o css/nes.min.css css/nes.css", - "deploy": "npm run build" + "deploy": "npm run build", + "storybook": "start-storybook -p 6006", + "build:storybook": "build-storybook" }, "repository": { "type": "git", @@ -30,8 +32,14 @@ }, "homepage": "https://github.com/BcRikko/NES.css#readme", "devDependencies": { + "@storybook/addon-knobs": "^4.0.11", + "@storybook/html": "^4.0.11", "autoprefixer": "^9.1.5", + "babel-loader": "^8.0.4", "clean-css-cli": "^4.2.1", + "eslint": "^5.9.0", + "eslint-config-airbnb-base": "^13.1.0", + "eslint-plugin-import": "^2.14.0", "husky": "^1.0.0", "lint-staged": "^7.3.0", "node-sass": "^4.9.3", @@ -58,6 +66,10 @@ "npm run build", "git add ./css", "git add" + ], + "*.js": [ + "eslint .", + "git add" ] }, "prettier": { @@ -79,5 +91,8 @@ "at-rule-no-unknown": null, "scss/at-rule-no-unknown": true } + }, + "eslintConfig": { + "extends": "airbnb-base" } }