Skip to content

Commit 80df5d4

Browse files
chawaxpiotrwitek
authored andcommitted
Storybook (piotrwitek#178)
* Storybook configuration * Stories examples * Add storybook-static to .gitignore * Custom Webpack configuration * Add Storyshots * Correct version
1 parent 44773b1 commit 80df5d4

18 files changed

+245
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ jspm_packages
3838

3939
temp/
4040
playground/dist
41+
playground/storybook-static

playground/.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';

playground/.storybook/config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { configure } from '@storybook/react';
2+
import requireContext from 'require-context.macro';
3+
4+
// We load every file in src directory ending with .stories.tsx
5+
6+
const req = requireContext('../src', true, /.stories.tsx$/);
7+
function loadStories() {
8+
req.keys().forEach(filename => req(filename));
9+
}
10+
configure(loadStories, module);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = ({ config, mode }) => {
2+
config.module.rules.push({
3+
test: /\.(ts|tsx)$/,
4+
loader: require.resolve('babel-loader'),
5+
options: {
6+
presets: [['react-app', { flow: false, typescript: true }]],
7+
},
8+
});
9+
config.resolve.extensions.push('.ts', '.tsx');
10+
return config;
11+
};

playground/package.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"ci-check": "npm run lint && npm run tsc && npm run test",
1717
"lint": "tslint -p ./",
1818
"tsc": "tsc -p ./ --noEmit",
19-
"tsc:watch": "tsc -p ./ --noEmit -w"
19+
"tsc:watch": "tsc -p ./ --noEmit -w",
20+
"storybook": "start-storybook -p 9009 -s public",
21+
"build-storybook": "build-storybook -s public"
2022
},
2123
"dependencies": {
2224
"@types/jest": "24.0.11",
@@ -53,5 +55,16 @@
5355
"not dead",
5456
"not ie <= 11",
5557
"not op_mini all"
56-
]
58+
],
59+
"devDependencies": {
60+
"@storybook/addon-actions": "5.1.9",
61+
"@storybook/addon-links": "5.1.9",
62+
"@storybook/addon-storyshots": "5.1.9",
63+
"@storybook/addons": "5.1.9",
64+
"@storybook/react": "5.1.9",
65+
"@types/storybook__addon-storyshots": "4.0.1",
66+
"@types/storybook__react": "4.0.2",
67+
"react-test-renderer": "16.8.6",
68+
"require-context.macro": "1.0.4"
69+
}
5770
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Storyshots ClassCounterWithDefaultProps with defaut initial count 1`] = `
4+
<div>
5+
<span>
6+
ClassCounterWithDefaultProps
7+
:
8+
0
9+
</span>
10+
<button
11+
onClick={[Function]}
12+
type="button"
13+
>
14+
Increment
15+
</button>
16+
</div>
17+
`;
18+
19+
exports[`Storyshots ClassCounterWithDefaultProps with initial count set 1`] = `
20+
<div>
21+
<span>
22+
ClassCounterWithDefaultProps
23+
:
24+
5
25+
</span>
26+
<button
27+
onClick={[Function]}
28+
type="button"
29+
>
30+
Increment
31+
</button>
32+
</div>
33+
`;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Storyshots ClassCounter default 1`] = `
4+
<div>
5+
<span>
6+
ClassCounter
7+
:
8+
0
9+
</span>
10+
<button
11+
onClick={[Function]}
12+
type="button"
13+
>
14+
Increment
15+
</button>
16+
</div>
17+
`;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Storyshots FCCounter default 1`] = `
4+
<div>
5+
<span>
6+
FCCounter
7+
:
8+
0
9+
</span>
10+
<button
11+
onClick={[Function]}
12+
type="button"
13+
>
14+
Increment
15+
</button>
16+
</div>
17+
`;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Storyshots FCSpreadAttributes default 1`] = `
4+
<div
5+
className="classy"
6+
style={
7+
Object {
8+
"backgroundColor": "lightcyan",
9+
}
10+
}
11+
>
12+
I'll spread every property you give me!
13+
</div>
14+
`;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Storyshots GenericList default 1`] = `
4+
<div>
5+
<div>
6+
Rosamonte Especial
7+
</div>
8+
<div>
9+
Aguantadora Despalada
10+
</div>
11+
<div>
12+
Taragui Vitality
13+
</div>
14+
</div>
15+
`;

0 commit comments

Comments
 (0)