Skip to content

Commit e6c7394

Browse files
committed
Initial commit
0 parents  commit e6c7394

File tree

13 files changed

+7872
-0
lines changed

13 files changed

+7872
-0
lines changed

.babelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["@babel/preset-typescript", "@babel/preset-react"],
3+
"plugins": ["styled-components"]
4+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
build

.storybook/addons.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import '@storybook/addon-actions/register';
2+
import '@storybook/addon-links/register';
3+
import 'storybook-addon-jsx/register';

.storybook/config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { configure } from '@storybook/react';
2+
import { setAddon, addDecorator } from '@storybook/react';
3+
import JSXAddon from 'storybook-addon-jsx';
4+
import { withInfo } from '@storybook/addon-info';
5+
6+
setAddon(JSXAddon);
7+
addDecorator(withInfo);
8+
9+
// automatically import all files ending in *.stories.js
10+
const req = require.context('../src', true, /.stories.js$/);
11+
function loadStories() {
12+
req.keys().forEach(req);
13+
}
14+
15+
configure(loadStories, module);

.storybook/webpack.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const path = require("path");
2+
3+
module.exports = (baseConfig, env, config) => {
4+
config.module.rules.push({
5+
test: /\.tsx?$/,
6+
include: path.resolve(__dirname, "../src"),
7+
use: [
8+
require.resolve("babel-loader"),
9+
require.resolve("react-docgen-typescript-loader"),
10+
],
11+
});
12+
13+
config.resolve.extensions.push(".ts", ".tsx");
14+
15+
return config;
16+
};

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
transform: {
3+
".(ts|tsx)": "ts-jest",
4+
},
5+
testPathIgnorePatterns: ["/node_modules/", "/lib/"],
6+
testRegex: "(/test/.*|\\.(test|spec))\\.(ts|tsx|js)$",
7+
moduleFileExtensions: ["ts", "tsx", "js", "json"],
8+
};

package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "design-system",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"devDependencies": {
7+
"@babel/core": "^7.2.0",
8+
"@babel/preset-react": "^7.0.0",
9+
"@babel/preset-typescript": "^7.1.0",
10+
"@babel/runtime": "^7.2.0",
11+
"@storybook/addon-actions": "^4.0.12",
12+
"@storybook/addon-info": "^4.0.12",
13+
"@storybook/addon-links": "^4.0.12",
14+
"@storybook/addons": "^4.0.12",
15+
"@storybook/react": "^4.0.12",
16+
"@types/jest": "^23.3.10",
17+
"@types/react-test-renderer": "^16.0.3",
18+
"@types/storybook__react": "^4.0.0",
19+
"@types/styled-components": "^4.1.2",
20+
"babel-jest": "^23.6.0",
21+
"babel-loader": "^8.0.4",
22+
"babel-plugin-styled-components": "^1.9.2",
23+
"jest": "^23.6.0",
24+
"react-docgen-typescript-loader": "^3.0.0",
25+
"react-test-renderer": "^16.6.3",
26+
"storybook-addon-jsx": "^6.0.0",
27+
"ts-jest": "^23.10.5",
28+
"typescript": "^3.2.2"
29+
},
30+
"dependencies": {
31+
"react": "^16.6.3",
32+
"react-dom": "^16.6.3",
33+
"styled-components": "^4.1.2"
34+
},
35+
"scripts": {
36+
"storybook": "start-storybook -p 6006",
37+
"build-storybook": "build-storybook",
38+
"check-types": "tsc",
39+
"test": "jest"
40+
}
41+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Button test suite Snapshot test 1`] = `
4+
<button
5+
className="sc-bdVaJa igACHl"
6+
disabled={false}
7+
>
8+
Facebook
9+
</button>
10+
`;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as React from "react";
2+
import * as renderer from "react-test-renderer";
3+
4+
import { Button } from "../index";
5+
6+
describe("Button test suite", () => {
7+
test("Snapshot test", () => {
8+
const tree = renderer.create(<Button>Facebook</Button>).toJSON();
9+
10+
expect(tree).toMatchSnapshot();
11+
});
12+
});

src/button/button.stories.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as React from "react";
2+
import { storiesOf } from "@storybook/react";
3+
4+
import { Button } from "./index";
5+
6+
const stories = storiesOf("Button", module);
7+
8+
stories
9+
.add("with text", () => <Button>Hello TypeScript</Button>, {
10+
info: { inline: true }
11+
})
12+
.add(
13+
"with text disabled",
14+
() => <Button isDisabled={true}>Hello TypeScript</Button>,
15+
{
16+
info: { inline: true }
17+
}
18+
);

0 commit comments

Comments
 (0)