Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit bb9efbf

Browse files
author
Morley Zhi
committedApr 22, 2019
Set up storybook with one simple styled component
1 parent 1a28072 commit bb9efbf

File tree

7 files changed

+7912
-0
lines changed

7 files changed

+7912
-0
lines changed
 

‎.storybook/addons.js

+2
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

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { configure } from '@storybook/react';
2+
3+
// automatically import all files ending in *.stories.js
4+
const req = require.context('../stories', true, /\.stories\.js$/);
5+
function loadStories() {
6+
req.keys().forEach(filename => req(filename));
7+
}
8+
9+
configure(loadStories, module);

‎.storybook/webpack.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = async ({ config }) => {
2+
config.resolve.modules = [...(config.resolve.modules || []), "./src"];
3+
4+
return config;
5+
};

‎package.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "js-stellar-elements",
3+
"version": "0.0.0",
4+
"description": "Styled elements for use on Stellar projects",
5+
"main": "index.js",
6+
"repository": "git@github.com:stellar/js-stellar-elements.git",
7+
"author": "Morley Zhi <morley@stellar.org>",
8+
"license": "Apache-2.0",
9+
"dependencies": {
10+
"styled-components": "^4.2.0"
11+
},
12+
"devDependencies": {
13+
"@storybook/react": "^5.0.10",
14+
"@storybook/addon-actions": "^5.0.10",
15+
"@storybook/addon-links": "^5.0.10",
16+
"@storybook/addons": "^5.0.10",
17+
"@babel/core": "^7.4.3",
18+
"babel-loader": "^8.0.5"
19+
},
20+
"scripts": {
21+
"storybook": "NODE_PATH=src && start-storybook -p 6006",
22+
"build-storybook": "build-storybook"
23+
}
24+
}

‎src/Button.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import styled from "styled-components";
2+
3+
const Button = styled.button`
4+
background: blue;
5+
color: white;
6+
`;
7+
8+
export default Button;

‎stories/index.stories.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from "react";
2+
3+
import { storiesOf } from "@storybook/react";
4+
import { action } from "@storybook/addon-actions";
5+
import { linkTo } from "@storybook/addon-links";
6+
7+
import Button from "Button";
8+
9+
storiesOf("Button", module)
10+
.add("with text", () => (
11+
<Button onClick={action("clicked")}>Hello Button</Button>
12+
))
13+
.add("with some emoji", () => (
14+
<Button onClick={action("clicked")}>
15+
<span role="img" aria-label="so cool">
16+
😀 😎 👍 💯
17+
</span>
18+
</Button>
19+
));

0 commit comments

Comments
 (0)
This repository has been archived.