- move font size and color to theme
- move Gauge specific props back to component
This commit is contained in:
1 parent
fb458b279d
commit
94e4d1b1cb
3 files changed
+28
-11
No files matched your search
@@ -7,8 +7,6 @@ const MAXIMUM_VALUE = 100 ;
|
|||||||
const DATA = [{ value: MAXIMUM_VALUE }];
|
const DATA = [{ value: MAXIMUM_VALUE }];
|
||||||
const PROGRESS_THRESHOLD = 50;
|
const PROGRESS_THRESHOLD = 50;
|
||||||
const DEFAULT_CONTAINER_HEIGHT = 160;
|
const DEFAULT_CONTAINER_HEIGHT = 160;
|
||||||
const DEFAULT_HEADER = { fontSize: "11px" };
|
|
||||||
const DEFAULT_SUBHEADER = { fontSize: "9px" };
|
|
||||||
const TEXT_POSITIONS = {
|
const TEXT_POSITIONS = {
|
||||||
value: { x: "50%", y: "45%" },
|
value: { x: "50%", y: "45%" },
|
||||||
label: { x: "50%", y: "55%" },
|
label: { x: "50%", y: "55%" },
|
||||||
@@ -36,6 +34,11 @@ const RADIALBAR_OVERLAY_PROPS = {
|
|||||||
left: "0",
|
left: "0",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const COMMON_HEADER_PROPS = {
|
||||||
|
textAnchor: "middle",
|
||||||
|
dominantBaseline: "middle",
|
||||||
|
};
|
||||||
|
|
||||||
const Gauge = ({
|
const Gauge = ({
|
||||||
progressValue,
|
progressValue,
|
||||||
displayText,
|
displayText,
|
||||||
@@ -44,8 +47,6 @@ const Gauge = ({
|
|||||||
gaugeSubheader,
|
gaugeSubheader,
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const header = gaugeHeader ?? DEFAULT_HEADER;
|
|
||||||
const subheader = gaugeSubheader ?? DEFAULT_SUBHEADER;
|
|
||||||
const myProgressValue = Math.max(MINIMUM_VALUE, Math.min(progressValue, MAXIMUM_VALUE));
|
const myProgressValue = Math.max(MINIMUM_VALUE, Math.min(progressValue, MAXIMUM_VALUE));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -73,7 +74,7 @@ const Gauge = ({
|
|||||||
{...TEXT_POSITIONS.value}
|
{...TEXT_POSITIONS.value}
|
||||||
role="text"
|
role="text"
|
||||||
aria-label={`${myProgressValue}%`}
|
aria-label={`${myProgressValue}%`}
|
||||||
style={{ ...theme.palette.gaugeHeaderCommon, ...header }}
|
style={{...COMMON_HEADER_PROPS, ...theme.chart.header, ...gaugeHeader }}
|
||||||
>
|
>
|
||||||
{`${myProgressValue}%`}
|
{`${myProgressValue}%`}
|
||||||
</text>
|
</text>
|
||||||
@@ -81,7 +82,7 @@ const Gauge = ({
|
|||||||
{...TEXT_POSITIONS.label}
|
{...TEXT_POSITIONS.label}
|
||||||
role="text"
|
role="text"
|
||||||
aria-label={`${displayText}`}
|
aria-label={`${displayText}`}
|
||||||
style={{ ...theme.palette.gaugeHeaderCommon, ...subheader }}
|
style={{...COMMON_HEADER_PROPS, ...theme.chart.subheader, ...gaugeSubheader }}
|
||||||
>
|
>
|
||||||
{`${displayText}`}
|
{`${displayText}`}
|
||||||
</text>
|
</text>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { createTheme } from "@mui/material";
|
import { createTheme } from "@mui/material";
|
||||||
import { gaugeHeaderCommon } from "./lightTheme"
|
import { gaugeHeaderCommon } from "./lightTheme"
|
||||||
export { gaugeHeaderCommon }
|
|
||||||
|
|
||||||
const text = {
|
const text = {
|
||||||
primary: "#fafafa",
|
primary: "#fafafa",
|
||||||
@@ -31,6 +30,16 @@ const darkTheme = createTheme({
|
|||||||
body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
|
body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
|
||||||
body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
|
body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
|
||||||
},
|
},
|
||||||
|
chart: {
|
||||||
|
header :{
|
||||||
|
...gaugeHeaderCommon,
|
||||||
|
fontSize: 11,
|
||||||
|
},
|
||||||
|
subheader :{
|
||||||
|
...gaugeHeaderCommon,
|
||||||
|
fontSize: 9
|
||||||
|
}
|
||||||
|
},
|
||||||
palette: {
|
palette: {
|
||||||
mode: "dark",
|
mode: "dark",
|
||||||
primary: { main: "#1570ef" },
|
primary: { main: "#1570ef" },
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ const background = {
|
|||||||
|
|
||||||
export const gaugeHeaderCommon = {
|
export const gaugeHeaderCommon = {
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
fill: text.tertiary,
|
fill: text.tertiary
|
||||||
textAnchor: "middle",
|
|
||||||
dominantBaseline: "middle",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const border = { light: "#eaecf0", dark: "#d0d5dd" };
|
const border = { light: "#eaecf0", dark: "#d0d5dd" };
|
||||||
@@ -36,11 +34,20 @@ const lightTheme = createTheme({
|
|||||||
body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
|
body1: { fontSize: 13, color: text.tertiary, fontWeight: 400 },
|
||||||
body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
|
body2: { fontSize: 12, color: text.tertiary, fontWeight: 400 },
|
||||||
},
|
},
|
||||||
|
chart: {
|
||||||
|
header :{
|
||||||
|
...gaugeHeaderCommon,
|
||||||
|
fontSize: 11,
|
||||||
|
},
|
||||||
|
subheader :{
|
||||||
|
...gaugeHeaderCommon,
|
||||||
|
fontSize: 9
|
||||||
|
}
|
||||||
|
},
|
||||||
palette: {
|
palette: {
|
||||||
primary: { main: "#1570EF" },
|
primary: { main: "#1570EF" },
|
||||||
secondary: { main: "#F4F4F4", dark: "#e3e3e3", contrastText: "#475467" },
|
secondary: { main: "#F4F4F4", dark: "#e3e3e3", contrastText: "#475467" },
|
||||||
text: text,
|
text: text,
|
||||||
gaugeHeaderCommon: gaugeHeaderCommon,
|
|
||||||
background: background,
|
background: background,
|
||||||
border: border,
|
border: border,
|
||||||
info: {
|
info: {
|
||||||
|
|||||||
Reference in new issue
Block a user