- Updated to use configurable gaugeHeader, gaugeSubheader and containerHeight etc

This commit is contained in:
Shemy Gan committed 2024-11-01 11:06:25 -04:00
1 parent f4f863e60f
commit a2d31124ff
3 files changed
+21 -23

No files matched your search

+17 -5
View File
@@ -7,12 +7,21 @@ const commonRadialBarProps = {
minAngle: 15,
clockWise: true,
dataKey: "value",
cornerRadius: 0
cornerRadius: 0,
};
const Gauge = ({ progressValue, displayText, theme }) => {
const Gauge = ({
progressValue,
displayText,
theme,
containerHeight,
gaugeHeader,
gaugeSubheader,
}) => {
const header = gaugeHeader ?? { fontSize: "11px" };
const subheader = gaugeSubheader ?? { fontSize: "9px" };
return (
<ResponsiveContainer>
<ResponsiveContainer height={containerHeight ?? 160}>
<RadialBarChart
cx="50%"
cy="50%"
@@ -45,14 +54,14 @@ const Gauge = ({ progressValue, displayText, theme }) => {
<text
x="50%"
y="45%"
style={theme.palette.gaugePercentageText}
style={{ ...theme.palette.gaugeHeaderCommon, ...header }}
>
{`${progressValue}%`}
</text>
<text
x="50%"
y="55%"
style={theme.palette.gaugeDisplayText}
style={{ ...theme.palette.gaugeHeaderCommon, ...subheader }}
>
{`${displayText}`}
</text>
@@ -65,5 +74,8 @@ Gauge.propTypes = {
progressValue: PropTypes.number.isRequired,
displayText: PropTypes.string.isRequired,
theme: PropTypes.object.isRequired,
containerHeight: PropTypes.number,
gaugeHeader: PropTypes.object,
gaugeSubheader: PropTypes.object,
};
export default Gauge;
+2 -9
View File
@@ -1,5 +1,6 @@
import { createTheme } from "@mui/material";
import { gaugeText } from "./lightTheme"
import { gaugeHeaderCommon } from "./lightTheme"
export { gaugeHeaderCommon }
const text = {
primary: "#fafafa",
@@ -35,14 +36,6 @@ const darkTheme = createTheme({
primary: { main: "#1570ef" },
secondary: { main: "#2D2D33" },
text: text,
gaugePercentageText: {
...gaugeText,
fontSize: "11px"
},
gaugeDisplayText: {
...gaugeText,
fontSize: "9px"
},
background: background,
border: border,
info: {
+2 -9
View File
@@ -13,7 +13,7 @@ const background = {
accent: "#f9fafb",
};
export const gaugeText = {
export const gaugeHeaderCommon = {
fontWeight: 400,
fill: text.tertiary,
textAnchor: "middle",
@@ -40,14 +40,7 @@ const lightTheme = createTheme({
primary: { main: "#1570EF" },
secondary: { main: "#F4F4F4", dark: "#e3e3e3", contrastText: "#475467" },
text: text,
gaugePercentageText: {
...gaugeText,
fontSize: "11px"
},
gaugeDisplayText: {
...gaugeText,
fontSize: "9px"
},
gaugeHeaderCommon: gaugeHeaderCommon,
background: background,
border: border,
info: {