Skip to content

Commit 9956d85

Browse files
authored
Merge pull request #4 from Stackup-Rwanda/ch-setup-story-book-171380692
#171380692 Setup storybook
2 parents e0ea199 + cedf26a commit 9956d85

File tree

7 files changed

+62
-6
lines changed

7 files changed

+62
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ build
1717
#caches
1818
package-lock.json
1919
yarn.lock
20+
yarn-error.log
2021

2122
#test coverage
2223
coverage

.storybook/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
stories: ['../stories/**/*.stories.js'],
3+
addons: ['@storybook/addon-actions', '@storybook/addon-links'],
4+
};

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Build Status](https://travis-ci.org/Stackup-Rwanda/stackup2-barefoot-frontend.svg?branch=develop)](https://travis-ci.org/Stackup-Rwanda/stackup2-barefoot-frontend)
44

55
## To run it locally
6-
### A.Pre-requisites :
6+
### A. Pre-requisites:
77
* To be able to test this project locally, you need to have the following tools on your local machine:
88
> * You need to have [NodeJS version between `6` higher](https://nodejs.org/en/) and [npm version `6` or higher](https://www.npmjs.com/) or [yarn v1.15.0 or higher](https://yarnpkg.com/getting-started/install)
99
> * Your local machine needs to be able to run terminal, Powershell, or bash commands
@@ -28,3 +28,5 @@
2828
1. [node-sass](https://www.npmjs.com/package/node-sass)
2929
2. [sass](https://www.npmjs.com/package/sass)
3030
3. [sass-loader](https://www.npmjs.com/package/sass-loader)
31+
4. [Storybook](https://storybook.js.org/docs/guides/guide-react/)
32+
5. [Enzyme](https://enzymejs.github.io/enzyme/)

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"name": "stackup2-barefoot-frontend",
33
"version": "1.0.0",
4-
"description": "This is the frontend of the barefoot-nomad app",
4+
"description": "This is the frontend of the Barefoot Nomad application",
55
"main": "src/entry/index.js",
66
"scripts": {
77
"build": "webpack -p --env production",
88
"dev": "webpack-dev-server --env development --watch --open",
99
"start": "npm run build && node ./src/entry/server.js",
10-
"test": "jest"
10+
"test": "jest",
11+
"storybook": "start-storybook -p 6006",
12+
"build-storybook": "build-storybook"
1113
},
1214
"repository": {
1315
"type": "git",
@@ -27,9 +29,11 @@
2729
"homepage": "https://github.com/Stackup-Rwanda/stackup2-barefoot-frontend#readme",
2830
"dependencies": {
2931
"@babel/core": "^7.9.6",
30-
"@babel/preset-env": "^7.9.6",
3132
"@babel/preset-react": "^7.9.4",
32-
"babel-eslint": "^10.1.0",
33+
"@storybook/addon-actions": "^5.3.18",
34+
"@storybook/addon-links": "^5.3.18",
35+
"@storybook/addons": "^5.3.18",
36+
"@storybook/react": "^5.3.18",
3337
"babel-jest": "^26.0.1",
3438
"babel-loader": "^8.1.0",
3539
"babel-plugin-transform-class-properties": "^6.24.1",
@@ -43,7 +47,6 @@
4347
"html-webpack-plugin": "^4.3.0",
4448
"identity-obj-proxy": "^3.0.0",
4549
"jest": "^26.0.1",
46-
"jest-enzyme": "^7.1.2",
4750
"jest-html-reporters": "^1.2.1",
4851
"jest-transform-stub": "^2.0.0",
4952
"mini-css-extract-plugin": "^0.9.0",

stories/0-Welcome.stories.js

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 { linkTo } from '@storybook/addon-links';
3+
import { Welcome } from '@storybook/react/demo';
4+
5+
export default {
6+
title: 'Welcome',
7+
component: Welcome,
8+
};
9+
10+
export const ToStorybook = () => <Welcome showApp={linkTo('Button')} />;
11+
12+
ToStorybook.story = {
13+
name: 'to Storybook',
14+
};

stories/1-Button.stories.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
3+
import { action } from '@storybook/addon-actions';
4+
import { Button } from '@storybook/react/demo';
5+
6+
export default {
7+
title: 'Button',
8+
component: Button,
9+
};
10+
11+
export const Text = () => <Button onClick={action('clicked')}>Hello Button</Button>;
12+
13+
export const Emoji = () => (
14+
<Button onClick={action('clicked')}>
15+
<span role="img" aria-label="so cool">
16+
😀 😎 👍 💯
17+
</span>
18+
</Button>
19+
);
20+
21+
Emoji.story = {
22+
name: 'with emoji',
23+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import HelloComponent from '../src/components/HelloComponent';
3+
4+
export default {
5+
title: 'Hello Component',
6+
components: [HelloComponent],
7+
};
8+
9+
export const HelloStory = () => (<HelloComponent />);

0 commit comments

Comments
 (0)