Skip to content

Commit 453521e

Browse files
committed
Added Storybook environment
1 parent ee9ed2f commit 453521e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4940
-152
lines changed

.DS_Store

2 KB
Binary file not shown.

.storybook/.DS_Store

8 KB
Binary file not shown.

.storybook/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Storybook
2+
3+
## 0.0.1
4+
* Init release.

.storybook/addons/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import withCustomStyles from './withCustomStyles'
2+
3+
export { withCustomStyles }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Adds an ability to set custom styles for the body node.
2+
const withCustomStyles = (customStyles: string) => (story: Function) => {
3+
document.body.setAttribute('style', customStyles)
4+
5+
return story()
6+
}
7+
8+
export default withCustomStyles

.storybook/constants/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const BACKGROUNDS = {
2+
backgrounds: [
3+
{ name: 'ccc', value: '#ccc', default: true },
4+
{ name: 'white', value: '#fff' },
5+
{ name: 'black', value: '#111' }
6+
]
7+
}

.storybook/generated-stories-entry.js

Whitespace-only changes.

.storybook/main.js

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
const webpack = require('webpack')
2+
const path = require('path')
3+
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
4+
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin')
5+
6+
const globals = require('../globals')
7+
8+
module.exports = {
9+
stories: ['../**/*.story.*'],
10+
addons: [
11+
'@storybook/addon-actions',
12+
'@storybook/addon-backgrounds',
13+
'@storybook/addon-knobs',
14+
'@storybook/addon-links',
15+
'@storybook/addon-viewport'
16+
],
17+
webpackFinal: async (config) => {
18+
// TODO: investigate how we can implement pure webpack.config.js in Storybook!!!
19+
const customConfig = {
20+
...config,
21+
plugins: [
22+
...config.plugins,
23+
new webpack.DefinePlugin(globals),
24+
new MiniCssExtractPlugin({
25+
filename: '[name].css',
26+
chunkFilename: '[id].css'
27+
}),
28+
new HardSourceWebpackPlugin()
29+
],
30+
module: {
31+
...config.module,
32+
rules: [
33+
{
34+
test: /\.(js|jsx|ts|tsx)?$/,
35+
loader: 'ts-loader',
36+
exclude: [/node_modules/]
37+
},
38+
// JSON
39+
{
40+
type: 'javascript/auto',
41+
test: /\.json$/,
42+
loader: 'json-loader'
43+
},
44+
// SCSS
45+
{
46+
test: /(\.cssmodule|\.cssmodule\.scss)$/,
47+
use: [
48+
{
49+
loader: MiniCssExtractPlugin.loader
50+
},
51+
{
52+
loader: 'css-modules-typescript-loader'
53+
},
54+
{
55+
loader: 'css-loader',
56+
modules: {
57+
localIdentName: '[local]___[hash:base64:5]'
58+
}
59+
},
60+
{
61+
loader: 'postcss-loader'
62+
},
63+
{
64+
loader: 'sass-loader'
65+
}
66+
]
67+
},
68+
// FONTS
69+
{
70+
test: /\.woff(\?.*)?$/,
71+
loader: 'url-loader?prefix=fonts/&name=[path][name].[ext]&limit=10000&mimetype=application/font-woff'
72+
},
73+
{
74+
test: /\.woff2(\?.*)?$/,
75+
loader: 'url-loader?prefix=fonts/&name=[path][name].[ext]&limit=10000&mimetype=application/font-woff2'
76+
},
77+
{
78+
test: /\.otf(\?.*)?$/,
79+
loader: 'file-loader?prefix=fonts/&name=[path][name].[ext]&limit=10000&mimetype=font/opentype'
80+
},
81+
{
82+
test: /\.ttf(\?.*)?$/,
83+
loader: 'url-loader?prefix=fonts/&name=[path][name].[ext]&limit=10000&mimetype=application/octet-stream'
84+
},
85+
{
86+
test: /\.eot(\?.*)?$/,
87+
loader: 'file-loader?prefix=fonts/&name=[path][name].[ext]'
88+
},
89+
// IMAGES
90+
{
91+
test: /\.svg(\?.*)?$/,
92+
loader: 'url-loader?limit=8192'
93+
},
94+
{
95+
test: /\.(png|jpg|webp)$/,
96+
loader: 'url-loader?limit=8192'
97+
}
98+
]
99+
},
100+
externals: {
101+
...config.externals,
102+
react: 'React',
103+
'react-dom': 'ReactDOM'
104+
},
105+
resolve: {
106+
...config.resolve,
107+
modules: [...config.resolve.modules, 'node_modules'],
108+
extensions: [...config.resolve.extensions, '.ts', '.tsx', '.js', '.jsx', '.json']
109+
}
110+
}
111+
112+
return customConfig
113+
},
114+
typescript: {
115+
reactDocgen: 'none' // TODO: remove this once the error on 70% will be fixed (about undefined .properties)
116+
}
117+
}

.storybook/middleware.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const express = require('express')
2+
const path = require('path')
3+
const proxy = require('../bin/proxy')
4+
5+
module.exports = (router) => {
6+
// custom storybook server middleware for static folder serving
7+
router.use('/public', express.static(path.join(__dirname, '.', 'public')))
8+
// custom storybook proxy for handling static files from real DEV server
9+
router.use('/', proxy)
10+
}

.storybook/preview-head.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script type="text/javascript" src="/js/script/lib/react.16.17.1.development.js"></script>
2+
<script type="text/javascript" src="/js/script/lib/react-dom.16.17.1.development.js"></script>
3+
<script type="text/javascript" src="/js/script/lib/prop-types.min.js"></script>
4+
5+
<style>
6+
@import url('https://fonts.googleapis.com/css?family=Fjalla+One');
7+
8+
* {
9+
font-family: 'Fjalla One', sans-serif;
10+
}
11+
</style>

0 commit comments

Comments
 (0)