Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added kitchen sink to sample app #1224

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ after_success: "./scripts/travis/after_success.sh"
script:
- npm run bootstrap
- npm run bootstrap:test-cra
- npm run bootstrap:react-native-vanilla
- npm run bootstrap:docs
- npm run lint
- npm run test -- --coverage
Expand Down
Empty file modified app/react-native/src/bin/storybook-build.js
100644 → 100755
Empty file.
Empty file modified app/react-native/src/bin/storybook-start.js
100644 → 100755
Empty file.
Empty file modified app/react-native/src/bin/storybook.js
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion app/react-native/src/manager/components/PreviewHelp.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const PreviewHelp = () =>
For <span style={styles.code}>react-native init</span> apps:
</p>
<div style={styles.codeBlock}>
<pre style={styles.instructionsCode}>npm run &lt;platform&gt;</pre>
<pre style={styles.instructionsCode}>react-native run-&lt;platform&gt;</pre>
</div>
</div>;

Expand Down
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: 'Test-CRA',
url: 'https://github.com/storybooks/storybook/tree/master/examples/test-cra',
goFullScreen: false,
showLeftPanel: true,
showDownPanel: true,
showSearchBox: false,
downPanelInRight: true,
sortStoriesByKind: false,
})

setAddon(infoAddon);

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

configure(loadStories, module);
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
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,30 @@ 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 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
27 changes: 27 additions & 0 deletions examples/react-native-getstorybook/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "react-native-getstorybook",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"storybook": "storybook start -p 7007"
},
"dependencies": {
"react": "16.0.0-alpha.6",
"react-native": "0.44.1"
},
"devDependencies": {
"@storybook/addon-actions": "*",
"@storybook/addon-links": "*",
"@storybook/addon-options": "*",
"@storybook/addon-storyshots": "*",
"@storybook/addons": "*",
"@storybook/channels": "*",
"@storybook/react-native": "*",
"babel-jest": "20.0.3",
"babel-preset-react-native": "1.9.2",
"jest": "20.0.4",
"react-dom": "^15.5.4"
}
}
30 changes: 0 additions & 30 deletions examples/react-native-vanilla/package.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/scripts/automated-cra-storybook.js
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
3 changes: 3 additions & 0 deletions examples/test-cra/.storybook/addons.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
import '@storybook/addon-notes/register';
import '@storybook/addon-options/register';
import '@storybook/addon-knobs/register';
17 changes: 16 additions & 1 deletion examples/test-cra/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import { configure } from '@storybook/react';
import { configure, setAddon } from '@storybook/react';
import { setOptions } from '@storybook/addon-options';
import infoAddon from '@storybook/addon-info';

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

setAddon(infoAddon);

function loadStories() {
require('../src/stories');
Expand Down
5 changes: 5 additions & 0 deletions examples/test-cra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
},
"devDependencies": {
"@storybook/addon-actions": "file:../../addons/actions",
"@storybook/addon-centered": "file:../../addons/centered",
"@storybook/addon-info": "file:../../addons/info",
"@storybook/addon-knobs": "file:../../addons/knobs",
"@storybook/addon-links": "file:../../addons/links",
"@storybook/addon-notes": "file:../../addons/notes",
"@storybook/addon-options": "file:../../addons/options",
"@storybook/addon-storyshots": "file:../../addons/storyshots",
"@storybook/addons": "file:../../lib/addons",
"@storybook/channel-postmessage": "file:../../lib/channel-postmessage",
Expand Down
23 changes: 22 additions & 1 deletion examples/test-cra/src/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';
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 @@ -13,7 +16,25 @@ import ComponentWithRef from './ComponentWithRef';
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);
return <Button>{label} {num}</Button>;
})
.addWithInfo('with some info', 'Use the info addon with its painful API.', () =>
<Button>click the "?" in top right for info</Button>
);

storiesOf('Centered Button', module)
.addDecorator(centered)
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>);

storiesOf('ComponentWithRef', module).add('basic', () => <ComponentWithRef />);
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ module.exports = {
'<rootDir>/addons',
'<rootDir>/app',
'<rootDir>/lib',
'<rootDir>/examples/cra-storybook',
'<rootDir>/examples/cra-kitchen-sink',
'<rootDir>/examples/test-cra',
],
testPathIgnorePatterns: ['/node_modules/'],
projects: ['./', './examples/react-native-vanilla'],
projects: ['./', './examples/react-native-getstorybook'],
collectCoverage: false,
collectCoverageFrom: [
'app/**/*.{js,jsx}',
Expand Down
7 changes: 3 additions & 4 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
"commands": {
"bootstrap": {
"ignore": [
"test-cra",
"react-native-vanilla"
"test-cra"
]
},
"publish": {
"ignore": [
"cra-storybook",
"cra-kitchen-sink",
"test-cra",
"react-native-vanilla"
"react-native-getstorybook"
]
}
},
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"bootstrap": "lerna bootstrap",
"bootstrap:docs": "cd docs && npm i",
"bootstrap:test-cra": "lerna exec --scope test-cra -- npm i",
"bootstrap:react-native-vanilla": "lerna exec --scope react-native-vanilla -- npm i",
"changelog": "pr-log --sloppy",
"precommit": "lint-staged",
"coverage": "codecov",
Expand All @@ -23,7 +22,7 @@
"lint:js": "eslint . --cache --cache-location=.cache/eslint --ext .js,.jsx,.json",
"lint:md": "remark .",
"publish": "lerna publish",
"test": "jest --projects ./ ./examples/react-native-vanilla"
"test": "jest --projects ./ ./examples/react-native-getstorybook"
},
"devDependencies": {
"babel-cli": "^6.24.1",
Expand Down