Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Add react storybook - Closes #496 #497

Merged
merged 9 commits into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { configure } from '@storybook/react';
import '../src/components/app/app.css';

function loadStories() {
require('../src/components/account/stories');
require('../src/components/dialog/stories');
require('../src/components/formattedNumber/stories');
}

configure(loadStories, module);
5 changes: 5 additions & 0 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = require('../webpack.config.js');

module.exports = config({
test: true,
});
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ Run the protractor tests (replace `~/git/lisk/` with your path to lisk core):
npm run e2e-test
```

## Launch React Storybook

To launch storybook sandbox with components run
```
npm run storybook
```
and go to

http://localhost:6006/



## Authors

- Ricardo Ferro <[email protected]>
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"dist:mac": "build --mac",
"dist:linux": "build --linux --ia32 --x64 --armv7l",
"copy-files": "mkdir dist && cp -r ./src/index.html ./src/assets ./dist",
"clean": "del dist -f"
"clean": "del dist -f",
"storybook": "start-storybook -p 6006 -s ./src/",
"build-storybook": "build-storybook"
},
"author": "Lisk Foundation <[email protected]>, lightcurve GmbH <[email protected]>",
"license": "GPL-3.0",
Expand Down Expand Up @@ -99,7 +101,8 @@
"url-loader": "=0.5.7",
"webpack": "=2.2.1",
"webpack-bundle-analyzer": "=2.4.0",
"webpack-dev-server": "=2.4.2"
"webpack-dev-server": "=2.4.2",
"@storybook/react": "=3.1.8"
},
"build": {
"appId": "io.lisk.nano",
Expand Down
44 changes: 44 additions & 0 deletions src/components/account/stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';

import { storiesOf } from '@storybook/react';
import Account from './accountComponent';
import Address from './address';

storiesOf('Account', module)
.add('delegate', () => (
<Account
peers={{
status: {
online: true,
},
data: {
options: {
name: 'testy',
},
currentPeer: 'testpeer',
port: 8000,
},
}}
account={{
isDelegate: true,
username: 'testy',
address: '9396639332432599292L',
}}
balance="3.1415926535"
/>
));

storiesOf('Address', module)
.add('delegate', () => (
<Address
isDelegate={true}
username="testy"
address="9396639332432599292L"
/>
))
.add('non-delegate', () => (
<Address
isDelegate={false}
address="9396639332432599292L"
/>
));
18 changes: 18 additions & 0 deletions src/components/dialog/stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';

import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import Dialog from './dialogElement';

const dialogContent = () => (<div>Hello</div>);

storiesOf('Dialog', module)
.add('default', () => (
<Dialog
dialog={{
title: 'Title',
childComponent: dialogContent,
}}
onCancelClick={ action('onCancelClick') }
/>
));
10 changes: 10 additions & 0 deletions src/components/formattedNumber/stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

import { storiesOf } from '@storybook/react';

import FormattedNumber from './';

storiesOf('FormattedNumber', module)
.add('with val', () => (
<FormattedNumber val="-3.1415926535" />
));