Skip to content

Commit

Permalink
React Components base for pages (#813)
Browse files Browse the repository at this point in the history
  • Loading branch information
skamril authored Apr 8, 2022
1 parent 87948b3 commit e60556b
Show file tree
Hide file tree
Showing 12 changed files with 427 additions and 14,318 deletions.
1 change: 1 addition & 0 deletions webapp_v2/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/.pnp
.pnp.js
package-lock.json

# testing
/coverage
Expand Down
14,003 changes: 0 additions & 14,003 deletions webapp_v2/package-lock.json

This file was deleted.

72 changes: 36 additions & 36 deletions webapp_v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,62 @@
"version": "2.3.2",
"private": true,
"dependencies": {
"@emotion/react": "11.7.1",
"@emotion/styled": "11.6.0",
"@mui/icons-material": "5.2.5",
"@mui/lab": "5.0.0-alpha.69",
"@mui/material": "5.2.8",
"@testing-library/jest-dom": "5.16.1",
"@testing-library/react": "12.1.2",
"@testing-library/user-event": "13.5.0",
"@types/d3": "^5.16.4",
"@types/jest": "27.4.0",
"@emotion/react": "11.9.0",
"@emotion/styled": "11.8.1",
"@mui/icons-material": "5.6.0",
"@mui/lab": "5.0.0-alpha.76",
"@mui/material": "5.6.0",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "13.0.0",
"@testing-library/user-event": "14.0.4",
"@types/d3": "5.16.4",
"@types/jest": "27.4.1",
"@types/node": "16.11.20",
"@types/react": "17.0.38",
"@types/react-d3-graph": "^2.6.3",
"@types/react-d3-graph": "2.6.3",
"@types/react-dom": "17.0.11",
"assert": "2.0.0",
"axios": "0.24.0",
"axios": "0.26.1",
"buffer": "6.0.3",
"crypto-browserify": "3.12.0",
"d3": "^5.16.0",
"debug": "4.3.3",
"d3": "5.16.0",
"debug": "4.3.4",
"downshift": "6.1.7",
"fs": "0.0.1-security",
"https-browserify": "1.0.0",
"i18next": "21.6.6",
"i18next-browser-languagedetector": "6.1.2",
"i18next": "21.6.14",
"i18next-browser-languagedetector": "6.1.4",
"i18next-xhr-backend": "3.2.2",
"js-cookie": "3.0.1",
"jwt-decode": "3.1.2",
"lodash": "4.17.21",
"moment": "2.29.1",
"moment": "2.29.2",
"notistack": "2.0.3",
"os": "0.1.2",
"os-browserify": "0.3.0",
"react": "17.0.2",
"react-color": "^2.19.3",
"react-d3-graph": "^2.6.0",
"react-color": "2.19.3",
"react-d3-graph": "2.6.0",
"react-dom": "17.0.2",
"react-hook-form": "7.24.1",
"react-i18next": "11.15.3",
"react-redux": "7.2.6",
"react-router": "6.2.1",
"react-router-dom": "6.2.1",
"react-hook-form": "7.29.0",
"react-i18next": "11.16.2",
"react-redux": "7.2.8",
"react-router": "6.3.0",
"react-router-dom": "6.3.0",
"react-scripts": "5.0.0",
"react-split": "2.0.14",
"react-tsparticles": "1.39.0",
"react-tsparticles": "1.43.1",
"react-virtualized-auto-sizer": "1.0.6",
"react-window": "1.8.6",
"redux": "4.1.2",
"redux-devtools-extension": "2.13.9",
"redux-logger": "3.0.6",
"redux-thunk": "2.4.1",
"stream-http": "3.2.0",
"swagger-ui-react": "4.6.1",
"swagger-ui-react": "4.10.3",
"url": "0.11.0",
"uuid": "8.3.2",
"web-vitals": "2.1.3"
"web-vitals": "2.1.4"
},
"scripts": {
"start": "react-app-rewired start",
Expand All @@ -85,28 +85,28 @@
"devDependencies": {
"@types/debug": "4.1.7",
"@types/js-cookie": "3.0.1",
"@types/lodash": "4.14.178",
"@types/react-color": "^3.0.6",
"@types/lodash": "4.14.181",
"@types/react-color": "3.0.6",
"@types/react-virtualized-auto-sizer": "1.0.1",
"@types/react-window": "1.8.5",
"@types/redux-logger": "3.0.9",
"@types/swagger-ui-react": "4.1.1",
"@types/uuid": "8.3.4",
"@typescript-eslint/eslint-plugin": "5.10.0",
"@typescript-eslint/parser": "5.10.0",
"eslint": "8.7.0",
"@typescript-eslint/eslint-plugin": "5.18.0",
"@typescript-eslint/parser": "5.18.0",
"eslint": "8.12.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsx-a11y": "6.5.1",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-react": "7.28.0",
"eslint-plugin-react-hooks": "4.3.0",
"eslint-plugin-react": "7.29.4",
"eslint-plugin-react-hooks": "4.4.0",
"husky": "7.0.4",
"prettier": "2.6.2",
"process": "0.11.10",
"react-app-rewired": "2.2.1",
"stream-browserify": "3.0.0",
"typescript": "4.5.4"
"typescript": "4.6.3"
}
}
55 changes: 55 additions & 0 deletions webapp_v2/src/components/common/page/BasicPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Box, Divider, styled } from "@mui/material";
import { PropsWithChildren, ReactNode } from "react";

/**
* Styles
*/

const Header = styled("div")(({ theme }) => ({
width: "100%",
display: "flex",
flexFlow: "column nowrap",
justifyContent: "flex-start",
alignItems: "center",
padding: theme.spacing(2, 3),
boxSizing: "border-box",
}));

/**
* Types
*/

type PropTypes = {
header?: ReactNode;
};

/**
* Component
*/

function BasicPage(props: PropsWithChildren<PropTypes>) {
const { header, children } = props;

return (
<Box
width="100%"
height="100%"
display="flex"
flexDirection="column"
justifyContent="flex-start"
alignItems="center"
boxSizing="border-box"
overflow="hidden"
>
{header && <Header>{header}</Header>}
<Divider sx={{ width: "98%" }} />
{children}
</Box>
);
}

BasicPage.defaultProps = {
header: null,
};

export default BasicPage;
79 changes: 79 additions & 0 deletions webapp_v2/src/components/common/page/RootPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Box, Typography } from "@mui/material";
import { ElementType, PropsWithChildren, ReactNode } from "react";
import BasicPage from "./BasicPage";

/**
* Types
*/

type PropTypes = {
title: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
titleIcon?: ElementType<any>; // TODO: replace any
headerRight?: ReactNode;
headerBottom?: ReactNode;
};

/**
* Component
*/

function RootPage(props: PropsWithChildren<PropTypes>) {
const {
title,
titleIcon: TitleIcon,
headerRight,
headerBottom,
children,
} = props;

return (
<BasicPage
header={
<>
<Box width="100%" alignItems="center" display="flex">
<Box alignItems="center" display="flex">
{TitleIcon && (
<TitleIcon
sx={{
color: "text.secondary",
width: "42px",
height: "42px",
}}
/>
)}
<Typography color="white" sx={{ ml: 2, fontSize: "34px" }}>
{title}
</Typography>
</Box>
{headerRight && (
<Box
alignItems="center"
justifyContent="flex-end"
flexGrow={1}
display="flex"
>
{headerRight}
</Box>
)}
</Box>
{headerBottom && (
<Box display="flex" width="100%" alignItems="center">
{headerBottom}
</Box>
)}
</>
}
>
{children}
</BasicPage>
);
}

RootPage.defaultProps = {
titleIcon: null,
headerRight: null,
headerBottom: null,
};

export default RootPage;
Loading

0 comments on commit e60556b

Please sign in to comment.