-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: timing issue onload for storybook-5
- Loading branch information
1 parent
b1781ec
commit 5fc1631
Showing
23 changed files
with
1,505 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env", "@babel/preset-react"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
stories: [ | ||
'../src/stories/**/*.stories.(js|mdx)', | ||
], | ||
addons: [ | ||
{ | ||
name: '@component-controls/storybook-custom-docs', | ||
options: { | ||
pages: [ | ||
require.resolve('./page-story.js'), | ||
] | ||
}, | ||
} | ||
], | ||
}; |
14 changes: 14 additions & 0 deletions
14
examples/custom-pages-storybook-5/.storybook/page-story.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { useStoryId } from '@component-controls/storybook-custom-docs'; | ||
|
||
const CustomPage = () => { | ||
const storyId = useStoryId(); | ||
return <div><h1>Simple docs page</h1><p>{storyId}</p></div> | ||
} | ||
const page = { | ||
key: 'custom', | ||
title: 'Simple Page', | ||
render: ({ active }) => active ? <CustomPage /> : null, | ||
} | ||
|
||
export default page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "custom-storybook-pages", | ||
"private": true, | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"start": "webpack-dev-server --open --mode development", | ||
"build": "webpack --mode production", | ||
"storybook": "start-storybook -p 9017 -c .storybook", | ||
"build-storybook": "build-storybook -c .storybook -o ./docs" | ||
}, | ||
"dependencies": { | ||
"@component-controls/storybook-custom-docs": "^0.9.0", | ||
"@storybook/react": "^5.3.18", | ||
"prop-types": "^15.7.2", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.9.0", | ||
"@babel/preset-env": "^7.9.5", | ||
"@babel/preset-react": "^7.9.4", | ||
"babel-loader": "^8.1.0", | ||
"html-loader": "^1.1.0", | ||
"html-webpack-plugin": "^4.2.0", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.11", | ||
"webpack-dev-server": "^3.10.3" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
examples/custom-pages-storybook-5/src/components/Person.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export const Person = ({ name, age }) => ( | ||
<div>{`My name is ${name} and I am ${age} years old`}</div> | ||
); | ||
|
||
Person.propTypes = { | ||
name: PropTypes.string, | ||
age: PropTypes.number, | ||
}; | ||
Person.defaultProps = { | ||
name: 'Martin', | ||
age: 22, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Create custom docs pages in storybookjs</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { Person } from './components/Person'; | ||
|
||
ReactDOM.render( | ||
<Person />, | ||
document.getElementById("root") | ||
); |
9 changes: 9 additions & 0 deletions
9
examples/custom-pages-storybook-5/src/stories/person.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import { Person } from '../components/Person'; | ||
|
||
export default { | ||
title: 'Stories/Person', | ||
component: Person | ||
} | ||
|
||
export const main = props => <Person {...props} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const HtmlWebPackPlugin = require('html-webpack-plugin'); | ||
|
||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(js|jsx)$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
}, | ||
}, | ||
{ | ||
test: /\.html$/, | ||
use: [ | ||
{ | ||
loader: 'html-loader', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new HtmlWebPackPlugin({ | ||
template: './src/index.html', | ||
filename: './index.html', | ||
}), | ||
], | ||
}; |
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.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.