Skip to content

Commit

Permalink
Add react-storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Sep 28, 2017
1 parent f8358ff commit a69125c
Show file tree
Hide file tree
Showing 6 changed files with 1,713 additions and 63 deletions.
2 changes: 2 additions & 0 deletions .storybook/addons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '@storybook/addon-actions/register';
import '@storybook/addon-knobs/register';
7 changes: 7 additions & 0 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { configure } from '@storybook/react';

function loadStories() {
require('../stories');
}

configure(loadStories, module);
39 changes: 39 additions & 0 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const path = require('path')
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js');

module.exports = (baseConfig, env) => {
const config = genDefaultConfig(baseConfig, env);

config.module.rules = [
{
test: /\.js$/,
loader: 'babel-loader',
include: [
path.resolve(__dirname, '../stories'),
path.resolve(__dirname, '../src'),
path.resolve(__dirname, '../node_modules/measure-scrollbar'),
path.resolve(__dirname, '../data'),
],
},
{
test: /\.svg$/,
loaders: ['babel-loader?presets[]=react', 'svg-jsx-loader?es6=true'],
include: [
path.resolve(__dirname, '../src/svgs'),
],
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ],
include: [
path.resolve(__dirname, '../css'),
],
},
];

config.devtool.sourcemaps = {
enabled: false,
};

return config;
};
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"react": "^0.14.0 || ^15.0.0-0 || ^16.0.0"
},
"devDependencies": {
"@storybook/addon-actions": "^3.2.11",
"@storybook/addon-knobs": "^3.2.10",
"@storybook/addon-links": "^3.2.10",
"@storybook/react": "^3.2.11",
"babel-cli": "^6.26.0",
"babel-core": "6.7.2",
"babel-loader": "^7.1.2",
Expand Down Expand Up @@ -69,7 +73,9 @@
"react:14": "npm run react:clean && npm i react@^0.14 react-dom@^0.14 react-addons-test-utils@^0.14 --save-dev",
"react:15": "npm run react:clean && npm i react@^15 react-dom@^15 react-addons-test-utils@^15 --save-dev",
"test": "NODE_ENV=test karma start && size-limit",
"prepublish": "npm run clean && npm run build"
"prepublish": "npm run clean && npm run build",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"size-limit": [
{
Expand Down
36 changes: 36 additions & 0 deletions stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';

import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { withKnobs, text, boolean, number } from '@storybook/addon-knobs';

import { Picker, Emoji } from '../src';
import '../css/emoji-mart.css';

storiesOf('Picker', module)
.addDecorator(withKnobs)
.add('default', () => (
<Picker
onClick={action('clicked')}
set={text('Emoji pack', 'twitter')}
emojiSize={number('Emoji size', 24)}
perLine={number('Per line', 9)}
native={boolean('Unicode', false)}
title={text('Idle text', 'Your Title Here')}
emoji={text('Idle emoji', 'department_store')}
skin={number('Skin tone', 1)}
color={text('Highlight color', '#ae65c5')}
/>
));

storiesOf('Emoji', module)
.addDecorator(withKnobs)
.add('default', () => (
<Emoji
set={text('Emoji pack', 'twitter')}
emoji={text('Emoji', '+1')}
size={number('Emoji size', 64)}
skin={number('Skin tone', 1)}
native={boolean('Unicode', false)}
/>
));
Loading

0 comments on commit a69125c

Please sign in to comment.