-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInfoBox.tsx
More file actions
49 lines (42 loc) · 1.31 KB
/
InfoBox.tsx
File metadata and controls
49 lines (42 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from "react";
import {Card, CardContent, CardHeader} from "@mui/material";
import {mainTheme} from "../style/globalStyle";
import {InfoBoxProps} from "../utilities/interfaces/InfoBoxProps";
/**
* A card component to display data. It has a header and a body.
* @param {InfoBoxProps} component
*/
const InfoBox: React.FunctionComponent<InfoBoxProps> = (component: InfoBoxProps) => {
return (
<Card sx={boxProps(component)} elevation={3}>
{component.headerComponent === undefined ? null :
<CardHeader subheader={component.headerComponent} sx={headerStyle}/>}
<CardContent sx={boxProps(component.headerComponent)}>
{component.component}
</CardContent>
</Card>
)
}
/**************
* Styles
**************/
const boxProps = (headerComponent: React.ReactNode) => {
return {
height: "100%",
width: "100%",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "start",
backgroundColor: mainTheme.palette.primary.main,
borderRadius: "0.5rem",
paddingTop: headerComponent === undefined ? "2rem" : 0,
}
}
const headerStyle = {
height: "2rem",
width: "100%",
paddingBottom: 0,
paddingTop: 0
}
export default InfoBox