Skip to content

Commit b213d4c

Browse files
committed
Add storybook
1 parent cb15be4 commit b213d4c

File tree

10 files changed

+7845
-70
lines changed

10 files changed

+7845
-70
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
node_modules/
88
npm-debug.log
99
yarn-error.log
10+
11+
dist

docs/.storybook/addons.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@storybook/addon-options/register';

docs/.storybook/config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { setOptions } from '@storybook/addon-options';
2+
import { configure, addDecorator } from '@storybook/react';
3+
import centered from './decorator-centered';
4+
5+
addDecorator(centered);
6+
7+
setOptions({
8+
name: 'Linear Gradient',
9+
url: 'https://react-native-web-community.github.io/react-native-web-linear-gradient',
10+
goFullScreen: false,
11+
showLeftPanel: true,
12+
showDownPanel: false,
13+
downPanelInRight: false
14+
});
15+
16+
function loadStories() {
17+
require('../stories');
18+
}
19+
20+
configure(loadStories, module);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import { StyleSheet, View } from 'react-native';
3+
4+
const styles = StyleSheet.create({
5+
root: {
6+
minHeight: '100vh',
7+
maxWidth: 680,
8+
marginHorizontal: 'auto'
9+
}
10+
});
11+
12+
export default function(renderStory) {
13+
return <View style={styles.root}>{renderStory()}</View>;
14+
}

docs/.storybook/webpack.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
4+
module.exports = (storybookBaseConfig, configType) => {
5+
const DEV = configType === 'DEVELOPMENT';
6+
7+
storybookBaseConfig.module.rules.push({
8+
test: /\.js$/,
9+
exclude: /node_modules/,
10+
use: {
11+
loader: 'babel-loader',
12+
options: { cacheDirectory: true }
13+
}
14+
});
15+
16+
storybookBaseConfig.plugins.push(
17+
new webpack.DefinePlugin({
18+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
19+
'process.env.__REACT_NATIVE_DEBUG_ENABLED__': DEV
20+
})
21+
);
22+
23+
storybookBaseConfig.resolve.alias = {
24+
'react-native': 'react-native-web',
25+
'react-native-linear-gradient': path.join(__dirname, '../../src/')
26+
};
27+
28+
return storybookBaseConfig;
29+
};

docs/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"scripts": {
3+
"build": "yarn && build-storybook -o ./dist -c ./.storybook",
4+
"start": "start-storybook -p 9001 -c ./.storybook",
5+
"release": "yarn build && git checkout gh-pages && rm -rf ../storybook && mv dist ../storybook && git add -A && git commit -m \"Storybook deploy\" && git push origin gh-pages && git checkout -"
6+
},
7+
"dependencies": {
8+
"@storybook/addon-options": "^3.2.10",
9+
"@storybook/react": "^3.1.9"
10+
}
11+
}

docs/stories/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react';
2+
3+
import { storiesOf } from '@storybook/react';
4+
import LinearGradient from 'react-native-linear-gradient';
5+
import { View } from 'react-native';
6+
7+
storiesOf('LinearGradient', module).add('simple', () => <LinearGradient colors={['red', 'blue']} />);

0 commit comments

Comments
 (0)