- move font size and color to theme

- move Gauge specific props back to component
This commit is contained in:
Shemy Gan committed 2024-11-06 12:48:01 -05:00
1 parent fb458b279d
commit 94e4d1b1cb
3 files changed
+28 -11

No files matched your search

+7 -6
View File
@@ -7,8 +7,6 @@ const MAXIMUM_VALUE = 100 ;
const DATA = [{ value: MAXIMUM_VALUE }];
const PROGRESS_THRESHOLD = 50;
const DEFAULT_CONTAINER_HEIGHT = 160;
const DEFAULT_HEADER = { fontSize: "11px" };
const DEFAULT_SUBHEADER = { fontSize: "9px" };
const TEXT_POSITIONS = {
value: { x: "50%", y: "45%" },
label: { x: "50%", y: "55%" },
@@ -36,6 +34,11 @@ const RADIALBAR_OVERLAY_PROPS = {
left: "0",
};
const COMMON_HEADER_PROPS = {
textAnchor: "middle",
dominantBaseline: "middle",
};
const Gauge = ({
progressValue,
displayText,
@@ -44,8 +47,6 @@ const Gauge = ({
gaugeSubheader,
}) => {
const theme = useTheme();
const header = gaugeHeader ?? DEFAULT_HEADER;
const subheader = gaugeSubheader ?? DEFAULT_SUBHEADER;
const myProgressValue = Math.max(MINIMUM_VALUE, Math.min(progressValue, MAXIMUM_VALUE));
return (
@@ -73,7 +74,7 @@ const Gauge = ({
{...TEXT_POSITIONS.value}
role="text"
aria-label={`${myProgressValue}%`}
style={{ ...theme.palette.gaugeHeaderCommon, ...header }}
style={{...COMMON_HEADER_PROPS, ...theme.chart.header, ...gaugeHeader }}
>
{`${myProgressValue}%`}
</text>
@@ -81,7 +82,7 @@ const Gauge = ({
{...TEXT_POSITIONS.label}
role="text"
aria-label={`${displayText}`}
style={{ ...theme.palette.gaugeHeaderCommon, ...subheader }}
style={{...COMMON_HEADER_PROPS, ...theme.chart.subheader, ...gaugeSubheader }}
>
{`${displayText}`}
</text>
+10 -1
View File
@@ -1,6 +1,5 @@
import { createTheme } from "@mui/material";
import { gaugeHeaderCommon } from "./lightTheme"
export { gaugeHeaderCommon }
const text = {
primary: "#fafafa",
@@ -31,6 +30,16 @@ const darkTheme = createTheme({
body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
},
chart: {
header :{
...gaugeHeaderCommon,
fontSize: 11,
},
subheader :{
...gaugeHeaderCommon,
fontSize: 9
}
},
palette: {
mode: "dark",
primary: { main: "#1570ef" },
+11 -4
View File
@@ -15,9 +15,7 @@ const background = {
export const gaugeHeaderCommon = {
fontWeight: 400,
fill: text.tertiary,
textAnchor: "middle",
dominantBaseline: "middle",
fill: text.tertiary
}
const border = { light: "#eaecf0", dark: "#d0d5dd" };
@@ -36,11 +34,20 @@ const lightTheme = createTheme({
body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
},
chart: {
header :{
...gaugeHeaderCommon,
fontSize: 11,
},
subheader :{
...gaugeHeaderCommon,
fontSize: 9
}
},
palette: {
primary: { main: "#1570EF" },
secondary: { main: "#F4F4F4", dark: "#e3e3e3", contrastText: "#475467" },
text: text,
gaugeHeaderCommon: gaugeHeaderCommon,
background: background,
border: border,
info: {