add a flex basis prop instead of one-off fix
This commit is contained in:
1 parent
96b2266a9d
commit
5343241036
3 files changed
+7
-8
No files matched your search
@@ -12,6 +12,7 @@ type BaseChartProps = React.PropsWithChildren<{
|
|||||||
title: string;
|
title: string;
|
||||||
width?: number | string;
|
width?: number | string;
|
||||||
maxWidth?: number | string;
|
maxWidth?: number | string;
|
||||||
|
flexBasis?: number | string;
|
||||||
padding?: number | string | ResponsiveStyleValue<number | string>;
|
padding?: number | string | ResponsiveStyleValue<number | string>;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}>;
|
}>;
|
||||||
@@ -21,6 +22,7 @@ export const BaseChart = ({
|
|||||||
title,
|
title,
|
||||||
width = "100%",
|
width = "100%",
|
||||||
maxWidth = "100%",
|
maxWidth = "100%",
|
||||||
|
flexBasis = "0%",
|
||||||
padding,
|
padding,
|
||||||
onClick,
|
onClick,
|
||||||
}: BaseChartProps) => {
|
}: BaseChartProps) => {
|
||||||
@@ -32,6 +34,7 @@ export const BaseChart = ({
|
|||||||
padding: padding ?? theme.spacing(LAYOUT.MD),
|
padding: padding ?? theme.spacing(LAYOUT.MD),
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
flexBasis,
|
||||||
width: width,
|
width: width,
|
||||||
maxWidth: maxWidth,
|
maxWidth: maxWidth,
|
||||||
...(onClick && {
|
...(onClick && {
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ export const DetailGauge = ({
|
|||||||
lowerLabel,
|
lowerLabel,
|
||||||
lowerValue,
|
lowerValue,
|
||||||
maxWidth = 225,
|
maxWidth = 225,
|
||||||
|
flexBasis = "0%",
|
||||||
}: {
|
}: {
|
||||||
title: string;
|
title: string;
|
||||||
progress: number;
|
progress: number;
|
||||||
@@ -131,6 +132,7 @@ export const DetailGauge = ({
|
|||||||
lowerLabel?: string;
|
lowerLabel?: string;
|
||||||
lowerValue?: string | number;
|
lowerValue?: string | number;
|
||||||
maxWidth?: number;
|
maxWidth?: number;
|
||||||
|
flexBasis?: number | string;
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
return (
|
return (
|
||||||
@@ -138,6 +140,7 @@ export const DetailGauge = ({
|
|||||||
icon={null}
|
icon={null}
|
||||||
title={title}
|
title={title}
|
||||||
maxWidth={maxWidth}
|
maxWidth={maxWidth}
|
||||||
|
flexBasis={flexBasis}
|
||||||
>
|
>
|
||||||
<Stack
|
<Stack
|
||||||
alignItems={"center"}
|
alignItems={"center"}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { useTheme } from "@mui/material";
|
|||||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
||||||
import type { CheckSnapshot } from "@/Types/Check";
|
import type { CheckSnapshot } from "@/Types/Check";
|
||||||
|
|
||||||
// Width each gauge card aims for, and the basis the wrapping row breaks on.
|
|
||||||
const GAUGE_MAX_WIDTH = 260;
|
const GAUGE_MAX_WIDTH = 260;
|
||||||
|
|
||||||
export const InfraDetailsGauges = ({
|
export const InfraDetailsGauges = ({
|
||||||
@@ -31,13 +30,6 @@ export const InfraDetailsGauges = ({
|
|||||||
alignItems={"stretch"}
|
alignItems={"stretch"}
|
||||||
flexWrap={"wrap"}
|
flexWrap={"wrap"}
|
||||||
useFlexGap
|
useFlexGap
|
||||||
sx={{
|
|
||||||
// The gauge cards are flex: 1 1 0, so a wrapping row would never
|
|
||||||
// overflow and they would squash to min-content instead of breaking
|
|
||||||
// the line. Give each one its own width as the basis so the row wraps
|
|
||||||
// at the intended card size.
|
|
||||||
"& > *": { flexBasis: GAUGE_MAX_WIDTH },
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<DetailGauge
|
<DetailGauge
|
||||||
title={t("pages.infrastructure.gauges.memory.title")}
|
title={t("pages.infrastructure.gauges.memory.title")}
|
||||||
@@ -47,6 +39,7 @@ export const InfraDetailsGauges = ({
|
|||||||
upperValue={prettyBytes(snapshot?.memory?.used_bytes || 0)}
|
upperValue={prettyBytes(snapshot?.memory?.used_bytes || 0)}
|
||||||
lowerLabel={t("pages.infrastructure.gauges.memory.lowerLabel")}
|
lowerLabel={t("pages.infrastructure.gauges.memory.lowerLabel")}
|
||||||
lowerValue={prettyBytes(snapshot?.memory?.total_bytes || 0)}
|
lowerValue={prettyBytes(snapshot?.memory?.total_bytes || 0)}
|
||||||
|
flexBasis={isSmall ? "auto" : GAUGE_MAX_WIDTH}
|
||||||
/>
|
/>
|
||||||
<DetailGauge
|
<DetailGauge
|
||||||
title={t("pages.infrastructure.gauges.cpu.title")}
|
title={t("pages.infrastructure.gauges.cpu.title")}
|
||||||
|
|||||||
Reference in new issue
Block a user