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

Fix webpack overriding && Add an example with local file dependencies #965

Merged
merged 7 commits into from
Apr 27, 2017
Merged
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
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": ["env", "stage-0", "react"],
"plugins": [
["transform-runtime", {
"polyfill": false,
"regenerator": true
}]
]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ npm-shrinkwrap.json
dist
.tern-port
*.DS_Store
.jest
.cache
junit.xml
coverage/
*.lerna_backup
Expand Down
2 changes: 1 addition & 1 deletion .jestrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cacheDirectory": ".jest",
"cacheDirectory": ".cache/jest",
"clearMocks": true,
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: node_js
cache:
directories:
- node_modules
- .jest
- .cache
notifications:
email: false
node_js:
Expand Down
1,623 changes: 0 additions & 1,623 deletions examples/cra-storybook/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/cra-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cra-storybook",
"version": "0.1.0",
"version": "1.0.0",
"private": true,
"devDependencies": {
"@kadira/storybook": "*",
Expand Down
18 changes: 18 additions & 0 deletions examples/test-cra/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env
npm-debug.log*
yarn-debug.log*
yarn-error.log*

7 changes: 7 additions & 0 deletions examples/test-cra/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { configure } from '@kadira/storybook';

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

configure(loadStories, module);
Empty file added examples/test-cra/README.md
Empty file.
26 changes: 26 additions & 0 deletions examples/test-cra/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "test-cra",
"version": "1.0.0",
"private": true,
"devDependencies": {
"@kadira/storybook": "file:../../packages/react-storybook",
"@kadira/storybook-addons": "file:../../packages/addons",
"@kadira/storybook-channel": "file:../../packages/channel",
"@kadira/storybook-ui": "file:../../packages/storybook-ui",
"@kadira/storybook-addon-actions": "file:../../packages/addon-actions",
"@kadira/storybook-channel-postmsg": "file:../../packages/channel-postmessage",
"react-scripts": "0.9.5"
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be on ^15.5.4 as the latest version published?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah for some reason npm-check-updates is no longer helping me with this 😞

},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -s public"
}
}
Binary file added examples/test-cra/public/favicon.ico
Binary file not shown.
31 changes: 31 additions & 0 deletions examples/test-cra/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tag above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start`.
To create a production bundle, use `npm run build`.
-->
</body>
</html>
24 changes: 24 additions & 0 deletions examples/test-cra/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.App {
text-align: center;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}

.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
}

.App-intro {
font-size: large;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
21 changes: 21 additions & 0 deletions examples/test-cra/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class App extends Component {
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
}
}

export default App;
8 changes: 8 additions & 0 deletions examples/test-cra/src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});
5 changes: 5 additions & 0 deletions examples/test-cra/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
6 changes: 6 additions & 0 deletions examples/test-cra/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';

ReactDOM.render(<App />, document.getElementById('root'));
7 changes: 7 additions & 0 deletions examples/test-cra/src/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions examples/test-cra/src/stories/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';

const buttonStyles = {
border: '1px solid #eee',
borderRadius: 3,
backgroundColor: '#FFFFFF',
cursor: 'pointer',
fontSize: 15,
padding: '3px 10px',
margin: 10,
};

const Button = ({ children, onClick }) => (
<button style={buttonStyles} onClick={onClick}>
{children}
</button>
);

Button.propTypes = {
children: React.PropTypes.string.isRequired,
onClick: React.PropTypes.func,
};

export default Button;
111 changes: 111 additions & 0 deletions examples/test-cra/src/stories/Welcome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React from 'react';

const styles = {
main: {
margin: 15,
maxWidth: 600,
lineHeight: 1.4,
fontFamily: '"Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif',
},

logo: {
width: 200,
},

link: {
color: '#1474f3',
textDecoration: 'none',
borderBottom: '1px solid #1474f3',
paddingBottom: 2,
},

code: {
fontSize: 15,
fontWeight: 600,
padding: '2px 5px',
border: '1px solid #eae9e9',
borderRadius: 4,
backgroundColor: '#f3f2f2',
color: '#3a3a3a',
},

codeBlock: {
backgroundColor: '#f3f2f2',
padding: '1px 10px',
margin: '10px 0',
},
};

const codeBlock = `
// Add this code to "src/stories/index.js"

import '../index.css';
import App from '../App';

storiesOf('App', module)
.add('default view', () => (
&lt;App /&gt;
))
`;

export default class Welcome extends React.Component {
showApp(e) {
e.preventDefault();
if (this.props.showApp) this.props.showApp();
}

render() {
return (
<div style={styles.main}>
<h1>Welcome to STORYBOOK</h1>
<p>
This is a UI component dev environment for your app.
</p>
<p>
We've added some basic stories inside the
{' '}
<code style={styles.code}>src/stories</code>
{' '}
directory.
<br />
A story is a single state of one or more UI components. You can have as many stories as you want.
<br />
(Basically a story is like a visual test case.)
</p>
<p>
See these sample
{' '}
<a style={styles.link} href="#" onClick={this.showApp.bind(this)}>stories</a>
{' '}
for a component called
{' '}
<code style={styles.code}>Button</code>
.
</p>
<p>
Just like that, you can add your own components as stories.
<br />
Here's how to add your <code style={styles.code}>App</code> component as a story.
<div
style={styles.codeBlock}
dangerouslySetInnerHTML={{ __html: `<pre>${codeBlock}</pre>` }}
/>
</p>
<p>
Usually we create stories with smaller UI components in the app.<br />
Have a look at the
{' '}
<a
style={styles.link}
href="https://getstorybook.io/docs/basics/writing-stories"
target="_blank"
>
Writing Stories
</a>
{' '}
section in our documentation.
</p>
</div>
);
}
}
10 changes: 10 additions & 0 deletions examples/test-cra/src/stories/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { storiesOf, action, linkTo } from '@kadira/storybook';
import Button from './Button';
import Welcome from './Welcome';

storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);

storiesOf('Button', module)
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)
.add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>);
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "2.0.0-beta.38",
"lerna": "2.0.0-rc.3",
"version": "3.0.0",
"packages": [
"packages/*",
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"name": "storybook",
"devDependencies": {
"babel-cli": "^6.14.0",
"babel-core": "^6.24.1",
"babel-eslint": "^7.2.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.13.0",
"babel-preset-env": "^1.4.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-0": "^6.5.0",
"codecov": "^2.1.0",
"enzyme": "^2.8.2",
"enzyme-to-json": "^1.5.1",
Expand All @@ -16,7 +23,8 @@
"prettier": "^1.1.0",
"react": "^15.5.4",
"react-addons-test-utils": "^15.5.1",
"react-dom": "^15.5.4"
"react-dom": "^15.5.4",
"shelljs": "^0.7.7"
},
"scripts": {
"postinstall": "lerna bootstrap --hoist",
Expand Down
3 changes: 0 additions & 3 deletions packages/addon-actions/.babelrc

This file was deleted.

Loading