Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit 459f814

Browse files
authored
Merge pull request #58 from rmevans9/storybook-ify
Storybook-ify this thing!
2 parents 966cd22 + 213c2eb commit 459f814

File tree

8 files changed

+63
-6
lines changed

8 files changed

+63
-6
lines changed

.storybook/addons.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@storybook/addon-actions/register'
2+
import '@storybook/addon-links/register'

.storybook/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { configure } from '@storybook/react'
2+
3+
const req = require.context('../src', true, /story\.tsx?$/)
4+
5+
function loadStories() {
6+
req.keys().forEach((filename) => req(filename))
7+
}
8+
9+
configure(loadStories, module)

.storybook/webpack.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require('path')
2+
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js')
3+
4+
module.exports = (config, env) => {
5+
const myConfig = genDefaultConfig(config, env)
6+
7+
myConfig.module.rules.push({
8+
test: /\.tsx?$/,
9+
loader: 'ts-loader',
10+
exclude: /node_modules/,
11+
include: path.resolve(__dirname, '..', 'src')
12+
})
13+
14+
myConfig.resolve.extensions.unshift('.tsx')
15+
myConfig.resolve.extensions.unshift('.ts')
16+
17+
return myConfig
18+
}

package.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"name": "Steve Kellock"
55
},
66
"ava": {
7-
"require": ["./out-test/main/test/setup.js"]
7+
"require": [
8+
"./out-test/main/test/setup.js"
9+
]
810
},
911
"build": {
1012
"appId": "com.example.electron-starter",
@@ -19,7 +21,9 @@
1921
"!globals.d.ts"
2022
],
2123
"linux": {
22-
"target": ["tar.gz"]
24+
"target": [
25+
"tar.gz"
26+
]
2327
},
2428
"mac": {
2529
"category": "public.app-category.developer-tools"
@@ -31,7 +35,10 @@
3135
"repo": "electron-starter"
3236
},
3337
"win": {
34-
"target": ["zip", "nsis"]
38+
"target": [
39+
"zip",
40+
"nsis"
41+
]
3542
}
3643
},
3744
"dependencies": {
@@ -52,13 +59,15 @@
5259
},
5360
"description": "An electron starter project.",
5461
"devDependencies": {
62+
"@storybook/react": "^3.2.4",
5563
"@types/electron-store": "1.2.0",
5664
"@types/mockery": "1.4.29",
5765
"@types/mousetrap": "1.5.34",
5866
"@types/react": "15.0.38",
5967
"@types/react-dom": "15.5.2",
6068
"@types/react-test-renderer": "15.5.2",
6169
"@types/sinon": "2.3.3",
70+
"@types/storybook__react": "^3.0.3",
6271
"ava": "0.21.0",
6372
"babel-preset-react": "6.24.1",
6473
"electron": "1.7.5",
@@ -72,6 +81,7 @@
7281
"prettier": "1.5.3",
7382
"react-test-renderer": "15.6.1",
7483
"sinon": "3.2.0",
84+
"ts-loader": "^2.3.2",
7585
"ts-node": "3.3.0",
7686
"tslint": "5.6.0",
7787
"tslint-eslint-rules": "4.1.1",
@@ -112,7 +122,9 @@
112122
"test:compile": "tsc -p tsconfig.test.json",
113123
"test:unit": "ava out-test/**/*.test.js",
114124
"watch:compile": "npm run test:compile -- -w",
115-
"watch:tests": "npm run test:unit -- --watch"
125+
"watch:tests": "npm run test:unit -- --watch",
126+
"storybook": "start-storybook -p 6006",
127+
"build-storybook": "build-storybook"
116128
},
117129
"version": "0.12.0"
118130
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import * as React from 'react'
2+
import { storiesOf } from '@storybook/react'
3+
4+
import { FunDog } from './index'
5+
6+
storiesOf('Fun Dog', module).add('default', () => <FunDog />)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as React from 'react'
2+
import { storiesOf } from '@storybook/react'
3+
4+
import { Text } from './index'
5+
6+
storiesOf('Text', module).add('default', () => <Text>Hello World!</Text>).add('with children', () =>
7+
<Text>
8+
<strong>I am STRONG</strong>
9+
</Text>,
10+
)

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"moduleResolution": "node",
66
"jsx": "react",
77
"experimentalDecorators": true,
8-
"allowSyntheticDefaultImports": false,
8+
"allowSyntheticDefaultImports": true,
99
"strict": true,
1010
"noUnusedLocals": true
1111
}

tsconfig.test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"moduleResolution": "node",
66
"jsx": "react",
77
"experimentalDecorators": true,
8-
"allowSyntheticDefaultImports": false,
8+
"allowSyntheticDefaultImports": true,
99
"strict": true,
1010
"noUnusedLocals": true,
1111

0 commit comments

Comments
 (0)