Skip to content

Commit

Permalink
Merge pull request #1288 from storybooks/1220-cra-kitchensink-reboot
Browse files Browse the repository at this point in the history
Redo CRA kitchen sink work from scratch
  • Loading branch information
shilman authored Jun 15, 2017
2 parents f64f5b7 + aaa6e5b commit 23c3902
Show file tree
Hide file tree
Showing 23 changed files with 63 additions and 18 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
import '@storybook/addon-events/register';
import '@storybook/addon-notes/register';
import '@storybook/addon-options/register';
import '@storybook/addon-knobs/register';
22 changes: 22 additions & 0 deletions examples/cra-kitchen-sink/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { configure, setAddon } from '@storybook/react';
import { setOptions } from '@storybook/addon-options';
import infoAddon from '@storybook/addon-info';

setOptions({
name: 'CRA Kitchen Sink',
url: 'https://github.com/storybooks/storybook/tree/master/examples/cra-kitchen-sink',
goFullScreen: false,
showLeftPanel: true,
showDownPanel: true,
showSearchBox: false,
downPanelInRight: true,
sortStoriesByKind: false,
})

setAddon(infoAddon);

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

configure(loadStories, module);
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "cra-storybook",
"name": "cra-kitchen-sink",
"version": "1.0.0",
"scripts": {
"build": "react-scripts build",
Expand All @@ -20,8 +20,13 @@
},
"devDependencies": {
"@storybook/addon-actions": "^3.0.0",
"@storybook/addon-links": "^3.0.0",
"@storybook/addon-centered": "^3.0.0",
"@storybook/addon-events": "^3.0.0",
"@storybook/addon-knobs": "^3.0.0",
"@storybook/addon-info": "^3.0.0",
"@storybook/addon-links": "^3.0.0",
"@storybook/addon-notes": "^3.0.0",
"@storybook/addon-options": "^3.0.0",
"@storybook/addons": "^3.0.0",
"@storybook/react": "^3.0.0",
"react-scripts": "1.0.1"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';

import EventEmiter from 'eventemitter3';

import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';
import WithEvents from '@storybook/addon-events';
import { WithNotes } from '@storybook/addon-notes';
import { withKnobs, text, number } from '@storybook/addon-knobs';
import centered from '@storybook/addon-centered';

import Button from './Button';
import Welcome from './Welcome';
Expand All @@ -25,12 +27,32 @@ const emit = emiter.emit.bind(emiter);
storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);

storiesOf('Button', module)
.addDecorator(withKnobs)
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)
.add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>);
.add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>)
.add('with notes', () =>
<WithNotes notes={'A very simple button'}>
<Button>Check my notes in the notes panel</Button>
</WithNotes>
)
.add('with knobs', () => {
const label = text('Label', 'Edit me in knobs panel');
const num = number('Number', 1);
const content = `I am ${label} and I'm ${num} years old.`;

return <Button>{content}</Button>;
})
.addWithInfo(
'with some info',
'Use the [info addon](https://github.com/storybooks/storybook/tree/master/addons/info) with its painful API.',
() => <Button>click the "?" in top right for info</Button>
);

storiesOf('App', module).add('full app', () => <App />);

storiesOf('App', module)
.add('with text', () => <App />)
.add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>);
storiesOf('Centered Button', module)
.addDecorator(centered)
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>);

storiesOf('WithEvents', module)
.addDecorator(getStory =>
Expand Down
7 changes: 0 additions & 7 deletions examples/cra-storybook/.storybook/config.js

This file was deleted.

2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A set of examples of how to use storybook, also used for regression testing",
"main": "index.js",
"scripts": {
"test:automated-cra-storybook": "node scripts/automated-cra-storybook.js"
"test:automated-cra-getstorybook": "node scripts/automated-cra-getstorybook.js"
},
"license": "ISC",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const { exec } = require('child-process-promise');
const rimraf = require('rimraf');

const targetFolder = 'automated-cra-storybook';
const targetFolder = 'automated-cra-getstorybook';

const cleanDir = () => new Promise(resolve => rimraf(`./${targetFolder}`, resolve));

Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
'<rootDir>/addons',
'<rootDir>/app',
'<rootDir>/lib',
'<rootDir>/examples/cra-storybook',
'<rootDir>/examples/cra-kitchen-sink',
'<rootDir>/examples/test-cra',
],
testPathIgnorePatterns: ['/node_modules/'],
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"publish": {
"ignore": [
"cra-storybook",
"cra-kitchen-sink",
"test-cra",
"react-native-vanilla"
]
Expand Down

0 comments on commit 23c3902

Please sign in to comment.