-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
React Components base for pages (#813)
- Loading branch information
Showing
12 changed files
with
427 additions
and
14,318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
/node_modules | ||
/.pnp | ||
.pnp.js | ||
package-lock.json | ||
|
||
# testing | ||
/coverage | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.