Skip to content

Commit 8e6a0fa

Browse files
committed
feat(components): Project set-up
- Set-up project dependencies Use Atomic Design architecture for components - Add basic elements (atoms) - Add sample widgets (molecules)
1 parent cbc3f5c commit 8e6a0fa

35 files changed

+4991
-146
lines changed

.storybook/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
"stories": [
3+
"../src/**/*.stories.mdx",
4+
"../src/**/*.stories.@(js|jsx|ts|tsx)"
5+
],
6+
"addons": [
7+
"@storybook/addon-links",
8+
"@storybook/addon-essentials",
9+
"@storybook/addon-controls",
10+
"@storybook/preset-create-react-app"
11+
]
12+
}

.storybook/preview.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
export const parameters = {
3+
actions: { argTypesRegex: "^on[A-Z].*" },
4+
}

package.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
"@types/node": "^12.0.0",
1111
"@types/react": "^17.0.0",
1212
"@types/react-dom": "^17.0.0",
13+
"antd": "^4.12.3",
1314
"react": "^17.0.1",
1415
"react-dom": "^17.0.1",
16+
"react-router": "^5.2.0",
1517
"react-scripts": "4.0.2",
1618
"typescript": "^4.1.2",
1719
"web-vitals": "^1.0.1"
@@ -20,7 +22,9 @@
2022
"start": "react-scripts start",
2123
"build": "react-scripts build",
2224
"test": "react-scripts test",
23-
"eject": "react-scripts eject"
25+
"eject": "react-scripts eject",
26+
"storybook": "start-storybook -p 6006 -s public",
27+
"build-storybook": "build-storybook -s public"
2428
},
2529
"eslintConfig": {
2630
"extends": [
@@ -39,5 +43,14 @@
3943
"last 1 firefox version",
4044
"last 1 safari version"
4145
]
46+
},
47+
"devDependencies": {
48+
"@storybook/addon-actions": "^6.1.18",
49+
"@storybook/addon-controls": "^6.1.18",
50+
"@storybook/addon-essentials": "^6.1.18",
51+
"@storybook/addon-links": "^6.1.18",
52+
"@storybook/node-logger": "^6.1.18",
53+
"@storybook/preset-create-react-app": "^3.1.6",
54+
"@storybook/react": "^6.1.18"
4255
}
4356
}

src/App.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
1-
import React from 'react';
21
import logo from './logo.svg';
32
import './App.css';
43

54
function App() {
65
return (
76
<div className="App">
87
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>src/App.tsx</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
8+
User Analytics
219
</header>
2210
</div>
2311
);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { action } from '@storybook/addon-actions';
2+
import { Story } from '@storybook/react/types-6-0';
3+
4+
import Button, { ButtonProps } from './index';
5+
6+
export default {
7+
title: 'Components/Elements/Button',
8+
component: Button,
9+
argTypes: {
10+
type: {
11+
control: {
12+
type: 'select',
13+
options: [
14+
"default",
15+
"primary",
16+
"ghost",
17+
"dashed",
18+
],
19+
},
20+
},
21+
},
22+
};
23+
24+
const Template: Story<ButtonProps> = (args) => <Button {...args} />;
25+
26+
export const Primary = Template.bind({});
27+
28+
Primary.args = {
29+
type: "primary" as ButtonProps["type"],
30+
label: "I am a button",
31+
};
32+
33+
export const Ghost = Template.bind({});
34+
35+
Ghost.args = {
36+
type: "ghost",
37+
label: "I am a ghost button"
38+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { useState, useEffect } from 'react';
2+
import {
3+
Button as AntButton,
4+
ButtonProps as AntButtonProps,
5+
} from 'antd';
6+
7+
import 'antd/lib/button/style/css';
8+
9+
export interface ButtonProps extends AntButtonProps {
10+
label: string;
11+
}
12+
13+
function Button(props: ButtonProps) {
14+
const {label, ...rest} = props;
15+
16+
return (
17+
<AntButton
18+
{...rest}
19+
>
20+
{props.label}
21+
</AntButton>
22+
)
23+
}
24+
25+
export default Button;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { action } from '@storybook/addon-actions';
2+
import { Story } from '@storybook/react/types-6-0';
3+
4+
import Header, { HeaderProps } from './index';
5+
6+
export default {
7+
title: 'Components/Elements/Header',
8+
component: Header,
9+
};
10+
11+
const Template: Story<HeaderProps> = (args) => <Header {...args} />;
12+
13+
export const Primary = Template.bind({});
14+
15+
Primary.args = {
16+
title: "I am a Header",
17+
subTitle: "I am a subtitle",
18+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { useState, useEffect } from 'react';
2+
import { PageHeader, PageHeaderProps } from 'antd';
3+
4+
import 'antd/lib/page-header/style/css';
5+
6+
export interface HeaderProps extends PageHeaderProps {
7+
8+
}
9+
10+
function Header(props: HeaderProps) {
11+
12+
return (
13+
<PageHeader
14+
{...props}
15+
/>
16+
);
17+
}
18+
19+
export default Header;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { action } from '@storybook/addon-actions';
2+
import { Story } from '@storybook/react/types-6-0';
3+
4+
import Input, { InputProps } from './index';
5+
6+
export default {
7+
title: 'Components/Elements/Input',
8+
component: Input,
9+
argTypes: {
10+
size: {
11+
control: {
12+
type: 'select',
13+
options: [
14+
"small",
15+
"default",
16+
"large",
17+
],
18+
},
19+
},
20+
},
21+
};
22+
23+
const Template: Story<InputProps> = (args) => <Input {...args} />;
24+
25+
export const Default = Template.bind({});
26+
27+
Default.args = {
28+
value: "",
29+
placeholder: "I am a placeholder",
30+
size: "default" as InputProps["size"],
31+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { useState, useEffect } from 'react';
2+
import { Input as AntInput, InputProps as AntInputProps } from 'antd';
3+
4+
import 'antd/lib/input/style/css';
5+
6+
export interface InputProps extends AntInputProps {
7+
8+
}
9+
10+
function Input(props: InputProps) {
11+
12+
return (
13+
<AntInput
14+
{...props}
15+
/>
16+
);
17+
}
18+
19+
export default Input;

0 commit comments

Comments
 (0)