Skip to content

Commit 0d2fbf2

Browse files
author
Le Tuan Kiet
committed
[RTT-06] Integrate storybook for MUI
1 parent 139b3ca commit 0d2fbf2

File tree

20 files changed

+6218
-152
lines changed

20 files changed

+6218
-152
lines changed

.storybook/main.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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-interactions",
10+
"@storybook/preset-create-react-app"
11+
],
12+
"framework": "@storybook/react",
13+
"core": {
14+
"builder": "@storybook/builder-webpack5"
15+
}
16+
}

.storybook/preview.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const parameters = {
2+
actions: { argTypesRegex: "^on[A-Z].*" },
3+
controls: {
4+
matchers: {
5+
color: /(background|color)$/i,
6+
date: /Date$/,
7+
},
8+
},
9+
}

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"**/CVS": true,
77
"**/.DS_Store": true,
88
"**/Thumbs.db": true,
9-
"**/node_modules": true
9+
"**/node_modules": false
1010
}
1111
}

package.json

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
"@testing-library/user-event": "^13.2.1",
1414
"@types/jest": "^27.0.1",
1515
"@types/node": "^16.7.13",
16-
"@types/react-dom": "^18.0.0",
1716
"@types/react": "^18.0.0",
17+
"@types/react-dom": "^18.0.0",
1818
"@types/uuid": "^8.3.4",
1919
"axios": "^0.27.2",
2020
"lodash": "^4.17.21",
21+
"react": "^18.2.0",
2122
"react-dom": "^18.2.0",
2223
"react-scripts": "5.0.1",
23-
"react": "^18.2.0",
2424
"typescript": "^4.4.2",
2525
"url-join": "^5.0.0",
2626
"uuid": "^9.0.0",
@@ -30,12 +30,24 @@
3030
"start": "react-scripts start",
3131
"build": "react-scripts build",
3232
"test": "react-scripts test",
33-
"eject": "react-scripts eject"
33+
"eject": "react-scripts eject",
34+
"storybook": "start-storybook -p 6006 -s public",
35+
"build-storybook": "build-storybook -s public"
3436
},
3537
"eslintConfig": {
3638
"extends": [
3739
"react-app",
3840
"react-app/jest"
41+
],
42+
"overrides": [
43+
{
44+
"files": [
45+
"**/*.stories.*"
46+
],
47+
"rules": {
48+
"import/no-anonymous-default-export": "off"
49+
}
50+
}
3951
]
4052
},
4153
"browserslist": {
@@ -51,6 +63,19 @@
5163
]
5264
},
5365
"devDependencies": {
54-
"@types/lodash": "^4.14.186"
66+
"@storybook/addon-actions": "^6.5.12",
67+
"@storybook/addon-essentials": "^6.5.12",
68+
"@storybook/addon-interactions": "^6.5.12",
69+
"@storybook/addon-links": "^6.5.12",
70+
"@storybook/builder-webpack5": "^6.5.12",
71+
"@storybook/manager-webpack5": "^6.5.12",
72+
"@storybook/node-logger": "^6.5.12",
73+
"@storybook/preset-create-react-app": "^4.1.2",
74+
"@storybook/react": "^6.5.12",
75+
"@storybook/testing-library": "^0.0.13",
76+
"@types/lodash": "^4.14.186",
77+
"babel-plugin-named-exports-order": "^0.0.2",
78+
"prop-types": "^15.8.1",
79+
"webpack": "^5.74.0"
5580
}
5681
}

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { debounce, Typography } from '@mui/material';
1+
import { debounce } from '@mui/material';
22
import { useEffect, useReducer, useState } from 'react';
33
import { getInfoCity } from './api/weather';
44
import './App.css';
@@ -45,7 +45,6 @@ function App() {
4545

4646
return (
4747
<div className="App">
48-
<Typography variant="h3">Hello word</Typography>
4948
<div className={`wrapper ${isSuccess && 'active'}`}>
5049
<header>
5150
<i className="bx bx-left-arrow-alt" onClick={() => setIsSuccess(false)}></i>Weather App
@@ -58,6 +57,7 @@ function App() {
5857
<button disabled={state.isLoading} onClick={() => getInfoDevice()}>
5958
Get Device Location
6059
</button>
60+
6161
</div>
6262
</section>
6363

src/assets/style/abstracts/variables.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ export default {
3030
},
3131

3232
text: {
33-
primary: 'white',
33+
primary: 'black',
3434
},
3535
} as const;

src/assets/style/base/global.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Theme } from '@mui/material';
2+
import { lightBlue } from '@mui/material/colors';
23

34
/**
45
* @style CssBaseLine,
@@ -13,7 +14,7 @@ export default {
1314
}
1415
1516
body{
16-
background-color: ${themeParam.palette.secondary.contrastText}
17+
background-color: ${lightBlue[200]}
1718
}
1819
1920
.content-default-layout{

src/components/button.component.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
Button as MuiButton,
3+
ButtonProps as MuiButtonProps
4+
} from "@mui/material";
5+
6+
interface ButtonProps extends MuiButtonProps {
7+
label:string
8+
}
9+
10+
export const Button = ({label,...rest}:ButtonProps) => (
11+
<MuiButton {...rest}>{label}</MuiButton>
12+
)
13+
14+
Button.defaultProps = {
15+
variant: "contained",
16+
size: "medium",
17+
color: "primary",
18+
};

src/stories/assets/code-brackets.svg

Lines changed: 1 addition & 0 deletions
Loading

src/stories/assets/colors.svg

Lines changed: 1 addition & 0 deletions
Loading

src/stories/assets/comments.svg

Lines changed: 1 addition & 0 deletions
Loading

src/stories/assets/direction.svg

Lines changed: 1 addition & 0 deletions
Loading

src/stories/assets/flow.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)