Refactored skeletons

This commit is contained in:
Daniel Cojocea committed 2024-08-07 19:49:08 -04:00
1 parent 70f88058a0
commit 2485198b6a
6 files changed
+471 -448

No files matched your search

+27 -14
View File
@@ -12,6 +12,32 @@ import Select from "../../Components/Inputs/Select";
import "./index.css"; import "./index.css";
/**
* Renders a skeleton layout.
*
* @returns {JSX.Element}
*/
const SkeletonLayout = () => {
const theme = useTheme();
return (
<>
<Stack direction="row" alignItems="center" gap={theme.gap.medium}>
<Skeleton variant="rounded" width={150} height={34} />
<Skeleton variant="rounded" width="15%" height={34} />
<Skeleton
variant="rounded"
width="20%"
height={34}
sx={{ ml: "auto" }}
/>
</Stack>
<Skeleton variant="rounded" width="100%" height={300} />
<Skeleton variant="rounded" width="100%" height={100} />
</>
);
};
const Incidents = () => { const Incidents = () => {
const theme = useTheme(); const theme = useTheme();
const navigate = useNavigate(); const navigate = useNavigate();
@@ -106,20 +132,7 @@ const Incidents = () => {
<> <>
<Stack className="incidents" gap={theme.gap.large}> <Stack className="incidents" gap={theme.gap.large}>
{loading ? ( {loading ? (
<> <SkeletonLayout />
<Stack direction="row" alignItems="center" gap={theme.gap.medium}>
<Skeleton variant="rounded" width={150} height={34} />
<Skeleton variant="rounded" width="15%" height={34} />
<Skeleton
variant="rounded"
width="20%"
height={34}
sx={{ ml: "auto" }}
/>
</Stack>
<Skeleton variant="rounded" width="100%" height={300} />
<Skeleton variant="rounded" width="100%" height={100} />
</>
) : hasAnyIncidents ? ( ) : hasAnyIncidents ? (
<> <>
<Stack direction="row" alignItems="center" gap={theme.gap.medium}> <Stack direction="row" alignItems="center" gap={theme.gap.medium}>
+98 -93
View File
@@ -36,6 +36,54 @@ const parseUrl = (url) => {
} }
}; };
/**
* Renders a skeleton layout.
*
* @returns {JSX.Element}
*/
const SkeletonLayout = () => {
const theme = useTheme();
return (
<>
<Skeleton variant="rounded" width="15%" height={34} />
<Stack gap={theme.gap.xl} mt={theme.gap.medium}>
<Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}>
<Skeleton
variant="circular"
style={{ minWidth: 24, minHeight: 24 }}
/>
<Box width="80%">
<Skeleton
variant="rounded"
width="50%"
height={24}
sx={{ mb: theme.gap.small }}
/>
<Skeleton variant="rounded" width="50%" height={18} />
</Box>
<Stack
direction="row"
gap={theme.gap.medium}
sx={{
ml: "auto",
alignSelf: "flex-end",
}}
>
<Skeleton variant="rounded" width={150} height={34} />
</Stack>
</Stack>
<Skeleton variant="rounded" width="100%" height={200} />
<Skeleton variant="rounded" width="100%" height={200} />
<Skeleton variant="rounded" width="100%" height={200} />
<Stack direction="row" justifyContent="flex-end">
<Skeleton variant="rounded" width="15%" height={34} />
</Stack>
</Stack>
</>
);
};
/** /**
* Configure page displays monitor configurations and allows for editing actions. * Configure page displays monitor configurations and allows for editing actions.
* @component * @component
@@ -169,56 +217,35 @@ const Configure = () => {
return ( return (
<Box className="configure-monitor"> <Box className="configure-monitor">
{loading ? ( {loading ? (
<Skeleton variant="rounded" width="15%" height={34} /> <SkeletonLayout />
) : ( ) : (
<Button <>
level="tertiary" <Button
label="Back" level="tertiary"
animate="slideLeft" label="Back"
img={<WestRoundedIcon />} animate="slideLeft"
onClick={() => navigate(-1)} img={<WestRoundedIcon />}
sx={{ onClick={() => navigate(-1)}
backgroundColor: "#f4f4f4", sx={{
px: theme.gap.ml, backgroundColor: "#f4f4f4",
"& svg.MuiSvgIcon-root": { px: theme.gap.ml,
mr: theme.gap.small, "& svg.MuiSvgIcon-root": {
fill: theme.palette.otherColors.slateGray, mr: theme.gap.small,
}, fill: theme.palette.otherColors.slateGray,
}} },
/> }}
)} />
<form <form
className="configure-monitor-form" className="configure-monitor-form"
noValidate noValidate
spellCheck="false" spellCheck="false"
style={{ style={{
marginTop: theme.gap.medium, marginTop: theme.gap.medium,
}} }}
> >
<Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}> <Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}>
{loading ? ( {monitor?.status ? <GreenCheck /> : <RedCheck />}
<Skeleton <Box>
variant="circular"
style={{ minWidth: 24, minHeight: 24 }}
/>
) : monitor?.status ? (
<GreenCheck />
) : (
<RedCheck />
)}
<Box width="80%">
{loading ? (
<>
<Skeleton
variant="rounded"
width="50%"
height={24}
sx={{ mb: theme.gap.small }}
/>
<Skeleton variant="rounded" width="50%" height={18} />
</>
) : (
<>
{parsedUrl?.host ? ( {parsedUrl?.host ? (
<Typography <Typography
component="h1" component="h1"
@@ -244,23 +271,15 @@ const Configure = () => {
Checking every {duration}.{" "} Checking every {duration}.{" "}
{lastChecked ? `Last time checked ${lastChecked} ago.` : ""} {lastChecked ? `Last time checked ${lastChecked} ago.` : ""}
</Typography> </Typography>
</> </Box>
)} <Stack
</Box> direction="row"
<Stack gap={theme.gap.medium}
direction="row" sx={{
gap={theme.gap.medium} ml: "auto",
sx={{ alignSelf: "flex-end",
ml: "auto", }}
alignSelf: "flex-end", >
}}
>
{loading ? (
<>
<Skeleton variant="rounded" width={150} height={34} />
</>
) : (
<>
<Button <Button
level="tertiary" level="tertiary"
label="Pause" label="Pause"
@@ -284,18 +303,8 @@ const Configure = () => {
}} }}
onClick={() => setIsOpen(true)} onClick={() => setIsOpen(true)}
/> />
</> </Stack>
)} </Stack>
</Stack>
</Stack>
{loading ? (
<>
<Skeleton variant="rounded" width="100%" height={200} />
<Skeleton variant="rounded" width="100%" height={200} />
<Skeleton variant="rounded" width="100%" height={200} />
</>
) : (
<>
<Stack <Stack
className="config-box" className="config-box"
direction="row" direction="row"
@@ -414,21 +423,17 @@ const Configure = () => {
/> />
</Stack> </Stack>
</Stack> </Stack>
</> <Stack direction="row" justifyContent="flex-end">
)} <Button
<Stack direction="row" justifyContent="flex-end"> level="primary"
{loading ? ( label="Save"
<Skeleton variant="rounded" width="15%" height={34} /> sx={{ px: theme.gap.large }}
) : ( onClick={handleSubmit}
<Button />
level="primary" </Stack>
label="Save" </form>
sx={{ px: theme.gap.large }} </>
onClick={handleSubmit} )}
/>
)}
</Stack>
</form>
<Modal <Modal
aria-labelledby="modal-delete-monitor" aria-labelledby="modal-delete-monitor"
aria-describedby="delete-monitor-confirmation" aria-describedby="delete-monitor-confirmation"
+141 -139
View File
@@ -35,6 +35,76 @@ StatBox.propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
}; };
/**
* Renders a skeleton layout.
*
* @returns {JSX.Element}
*/
const SkeletonLayout = () => {
const theme = useTheme();
return (
<>
<Skeleton variant="rounded" width="20%" height={34} />
<Stack gap={theme.gap.xl} mt={theme.gap.medium}>
<Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}>
<Skeleton
variant="circular"
style={{ minWidth: 24, minHeight: 24 }}
/>
<Box width="80%">
<Skeleton variant="rounded" width="50%" height={24} />
<Skeleton
variant="rounded"
width="50%"
height={18}
sx={{ mt: theme.gap.small }}
/>
</Box>
<Skeleton
variant="rounded"
width="20%"
height={34}
sx={{ alignSelf: "flex-end" }}
/>
</Stack>
<Stack
direction="row"
justifyContent="space-between"
gap={theme.gap.large}
>
<Skeleton variant="rounded" width="100%" height={80} />
<Skeleton variant="rounded" width="100%" height={80} />
<Skeleton variant="rounded" width="100%" height={80} />
</Stack>
<Box>
<Stack
direction="row"
justifyContent="space-between"
mb={theme.gap.ml}
>
<Skeleton
variant="rounded"
width="20%"
height={24}
sx={{ alignSelf: "flex-end" }}
/>
<Skeleton variant="rounded" width="20%" height={34} />
</Stack>
<Box sx={{ height: "200px" }}>
<Skeleton variant="rounded" width="100%" height="100%" />
</Box>
</Box>
<Stack gap={theme.gap.ml}>
<Skeleton variant="rounded" width="20%" height={24} />
<Skeleton variant="rounded" width="100%" height={200} />
<Skeleton variant="rounded" width="100%" height={50} />
</Stack>
</Stack>
</>
);
};
/** /**
* Details page component displaying monitor details and related information. * Details page component displaying monitor details and related information.
* @component * @component
@@ -168,49 +238,28 @@ const DetailsPage = () => {
return ( return (
<Box className="monitor-details"> <Box className="monitor-details">
{loading ? ( {loading ? (
<Skeleton variant="rounded" width="20%" height={34} /> <SkeletonLayout />
) : ( ) : (
<Button <>
level="tertiary" <Button
label="Back to Monitors" level="tertiary"
animate="slideLeft" label="Back to Monitors"
img={<WestRoundedIcon />} animate="slideLeft"
onClick={() => navigate("/monitors")} img={<WestRoundedIcon />}
sx={{ onClick={() => navigate("/monitors")}
backgroundColor: "#f4f4f4", sx={{
px: theme.gap.ml, backgroundColor: "#f4f4f4",
"& svg.MuiSvgIcon-root": { px: theme.gap.ml,
mr: theme.gap.small, "& svg.MuiSvgIcon-root": {
fill: theme.palette.otherColors.slateGray, mr: theme.gap.small,
}, fill: theme.palette.otherColors.slateGray,
}} },
/> }}
)} />
<Stack gap={theme.gap.xl} mt={theme.gap.medium}> <Stack gap={theme.gap.xl} mt={theme.gap.medium}>
<Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}> <Stack direction="row" gap={theme.gap.small} mt={theme.gap.small}>
{loading ? ( {monitor?.status ? <GreenCheck /> : <RedCheck />}
<Skeleton <Box>
variant="circular"
style={{ minWidth: 24, minHeight: 24 }}
/>
) : monitor?.status ? (
<GreenCheck />
) : (
<RedCheck />
)}
<Box width="80%">
{loading ? (
<>
<Skeleton variant="rounded" width="50%" height={24} />
<Skeleton
variant="rounded"
width="50%"
height={18}
sx={{ mt: theme.gap.small }}
/>
</>
) : (
<>
<Typography component="h1" sx={{ lineHeight: 1 }}> <Typography component="h1" sx={{ lineHeight: 1 }}>
{monitor.url?.replace(/^https?:\/\//, "") || "..."} {monitor.url?.replace(/^https?:\/\//, "") || "..."}
</Typography> </Typography>
@@ -229,55 +278,36 @@ const DetailsPage = () => {
Last time checked{" "} Last time checked{" "}
{formatDurationRounded(getLastChecked(monitor?.checks))} ago. {formatDurationRounded(getLastChecked(monitor?.checks))} ago.
</Typography> </Typography>
</> </Box>
)} <Button
</Box> level="tertiary"
{loading ? ( label="Configure"
<Skeleton animate="rotate90"
variant="rounded" img={
width="20%" <SettingsIcon
height={34} style={{
sx={{ alignSelf: "flex-end" }} minWidth: theme.gap.mlplus,
/> minHeight: theme.gap.mlplus,
) : ( }}
<Button />
level="tertiary" }
label="Configure" onClick={() => navigate(`/monitors/configure/${monitorId}`)}
animate="rotate90" sx={{
img={ ml: "auto",
<SettingsIcon alignSelf: "flex-end",
style={{ backgroundColor: "#f4f4f4",
minWidth: theme.gap.mlplus, px: theme.gap.medium,
minHeight: theme.gap.mlplus, "& svg": {
}} mr: "6px",
/> },
} }}
onClick={() => navigate(`/monitors/configure/${monitorId}`)} />
sx={{ </Stack>
ml: "auto", <Stack
alignSelf: "flex-end", direction="row"
backgroundColor: "#f4f4f4", justifyContent="space-between"
px: theme.gap.medium, gap={theme.gap.large}
"& svg": { >
mr: "6px",
},
}}
/>
)}
</Stack>
<Stack
direction="row"
justifyContent="space-between"
gap={theme.gap.large}
>
{loading ? (
<>
<Skeleton variant="rounded" width="100%" height={80} />
<Skeleton variant="rounded" width="100%" height={80} />
<Skeleton variant="rounded" width="100%" height={80} />
</>
) : (
<>
<StatBox <StatBox
title="Currently up for" title="Currently up for"
value={formatDuration(calculateUptimeDuration(monitor.checks))} value={formatDuration(calculateUptimeDuration(monitor.checks))}
@@ -290,27 +320,13 @@ const DetailsPage = () => {
title="Incidents" title="Incidents"
value={countIncidents(monitor.checks)} value={countIncidents(monitor.checks)}
/> />
</> </Stack>
)} <Box>
</Stack> <Stack
<Box> direction="row"
<Stack justifyContent="space-between"
direction="row" mb={theme.gap.ml}
justifyContent="space-between" >
mb={theme.gap.ml}
>
{loading ? (
<>
<Skeleton
variant="rounded"
width="20%"
height={24}
sx={{ alignSelf: "flex-end" }}
/>
<Skeleton variant="rounded" width="20%" height={34} />
</>
) : (
<>
<Typography component="h2" mb={theme.gap.small}> <Typography component="h2" mb={theme.gap.small}>
Response Times Response Times
</Typography> </Typography>
@@ -344,35 +360,21 @@ const DetailsPage = () => {
}} }}
/> />
</ButtonGroup> </ButtonGroup>
</> </Stack>
)} <Box sx={{ height: "200px" }}>
</Stack> <MonitorDetailsAreaChart
<Box sx={{ height: "200px" }}> checks={monitor.checks}
{loading ? ( filter={filter}
<Skeleton variant="rounded" width="100%" height="100%" /> />
) : ( </Box>
<MonitorDetailsAreaChart </Box>
checks={monitor.checks} <Stack gap={theme.gap.ml}>
filter={filter}
/>
)}
</Box>
</Box>
<Stack gap={theme.gap.ml}>
{loading ? (
<>
<Skeleton variant="rounded" width="20%" height={24} />
<Skeleton variant="rounded" width="100%" height={200} />
<Skeleton variant="rounded" width="100%" height={50} />
</>
) : (
<>
<Typography component="h2">History</Typography> <Typography component="h2">History</Typography>
<BasicTable data={data} paginated={true} reversed={true} /> <BasicTable data={data} paginated={true} reversed={true} />
</> </Stack>
)} </Stack>
</Stack> </>
</Stack> )}
</Box> </Box>
); );
}; };
+69 -59
View File
@@ -72,6 +72,38 @@ const Host = ({ params }) => {
); );
}; };
/**
* Renders a skeleton layout.
*
* @returns {JSX.Element}
*/
const SkeletonLayout = () => {
const theme = useTheme();
return (
<>
<Stack direction="row" justifyContent="space-between" alignItems="center">
<Skeleton variant="rounded" width="50%" height={36} />
<Skeleton variant="rounded" width="15%" height={36} />
</Stack>
<Stack
gap={theme.gap.large}
direction="row"
justifyContent="space-between"
>
<Skeleton variant="rounded" width="100%" height={100} />
<Skeleton variant="rounded" width="100%" height={100} />
<Skeleton variant="rounded" width="100%" height={100} />
</Stack>
<Stack gap={theme.gap.large} p={theme.gap.xl} backgroundColor="#f9fafb">
<Skeleton variant="rounded" width="50%" height={25} />
<Skeleton variant="rounded" width="100%" height={300} />
<Skeleton variant="rounded" width="100%" height={100} />
</Stack>
</>
);
};
const Monitors = () => { const Monitors = () => {
const theme = useTheme(); const theme = useTheme();
const navigate = useNavigate(); const navigate = useNavigate();
@@ -205,18 +237,19 @@ const Monitors = () => {
}; };
}); });
let loading = monitorState.isLoading && monitorState.monitors.length === 0; let loading = monitorState.isLoading && monitorState.monitors.length === 0;
return ( return (
<Stack className="monitors" gap={theme.gap.large}> <Stack className="monitors" gap={theme.gap.large}>
<Stack direction="row" justifyContent="space-between" alignItems="center"> {loading ? (
{loading ? ( <SkeletonLayout />
<> ) : (
<Skeleton variant="rounded" width="50%" height={36} /> <>
<Skeleton variant="rounded" width="15%" height={36} /> <Stack
</> direction="row"
) : ( justifyContent="space-between"
<> alignItems="center"
>
<Typography component="h1"> <Typography component="h1">
Hello, {authState.user.firstName} Hello, {authState.user.firstName}
</Typography> </Typography>
@@ -227,60 +260,37 @@ const Monitors = () => {
navigate("/monitors/create"); navigate("/monitors/create");
}} }}
/> />
</> </Stack>
)} <Stack
</Stack> gap={theme.gap.large}
<Stack direction="row"
gap={theme.gap.large} justifyContent="space-between"
direction="row" >
justifyContent="space-between"
>
{loading ? (
<>
<Skeleton variant="rounded" width="100%" height={100} />
<Skeleton variant="rounded" width="100%" height={100} />
<Skeleton variant="rounded" width="100%" height={100} />
</>
) : (
<>
<ServerStatus title="Up" value={up} state="up" /> <ServerStatus title="Up" value={up} state="up" />
<ServerStatus title="Down" value={down} state="down" /> <ServerStatus title="Down" value={down} state="down" />
<ServerStatus title="Paused" value={0} state="pause" /> <ServerStatus title="Paused" value={0} state="pause" />
</>
)}
</Stack>
<Stack
gap={theme.gap.large}
p={theme.gap.xl}
border={1}
borderColor={
loading ? "#f9fafb" : theme.palette.otherColors.graishWhite
}
backgroundColor={loading ? "#f9fafb" : "white"}
sx={{
borderRadius: `${theme.shape.borderRadius}px`,
}}
>
{loading ? (
<Skeleton variant="rounded" width="50%" height={25} />
) : (
<Stack direction="row" alignItems="center">
<Typography component="h2">Current monitors</Typography>
<Box className="current-monitors-counter">
{monitorState.monitors.length}
</Box>
{/* TODO - add search bar */}
</Stack> </Stack>
)} <Stack
{loading ? ( gap={theme.gap.large}
<> p={theme.gap.xl}
<Skeleton variant="rounded" width="100%" height={400} /> border={1}
<Skeleton variant="rounded" width="100%" height={100} /> borderColor={theme.palette.otherColors.graishWhite}
</> backgroundColor={theme.palette.otherColors.white}
) : ( sx={{
<BasicTable data={data} paginated={true} /> borderRadius: `${theme.shape.borderRadius}px`,
)} }}
</Stack> >
<Stack direction="row" alignItems="center">
<Typography component="h2">Current monitors</Typography>
<Box className="current-monitors-counter">
{monitorState.monitors.length}
</Box>
{/* TODO - add search bar */}
</Stack>
<BasicTable data={data} paginated={true} />
</Stack>
</>
)}
<Menu <Menu
className="actions-menu" className="actions-menu"
anchorEl={anchorEl} anchorEl={anchorEl}
+74 -94
View File
@@ -126,6 +126,53 @@ const PieValueLabel = ({ value, startAngle, endAngle, color, highlighted }) => {
); );
}; };
/**
* Renders a skeleton layout.
*
* @returns {JSX.Element}
*/
const SkeletonLayout = () => {
const theme = useTheme();
return (
<>
<Skeleton variant="rounded" width="15%" height={34} />
<Stack direction="row" gap={theme.gap.small}>
<Skeleton variant="circular" style={{ minWidth: 24, minHeight: 24 }} />
<Box width="80%">
<Skeleton variant="rounded" width="50%" height={24} />
<Skeleton
variant="rounded"
width="50%"
height={18}
sx={{ mt: theme.gap.small }}
/>
</Box>
<Skeleton
variant="rounded"
width="15%"
height={34}
sx={{ alignSelf: "flex-end" }}
/>
</Stack>
<Stack
direction="row"
justifyContent="space-between"
gap={theme.gap.xl}
flexWrap="wrap"
>
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} />
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} />
<Skeleton variant="rounded" width="30%" height={90} sx={{ flex: 1 }} />
</Stack>
<Skeleton variant="rounded" width="25%" height={24} />
<Skeleton variant="rounded" width="100%" height={300} />
<Skeleton variant="rounded" width="25%" height={24} />
<Skeleton variant="rounded" width="100%" height={300} />
</>
);
};
const PageSpeedDetails = () => { const PageSpeedDetails = () => {
const theme = useTheme(); const theme = useTheme();
const navigate = useNavigate(); const navigate = useNavigate();
@@ -254,50 +301,26 @@ const PageSpeedDetails = () => {
return ( return (
<Stack className="page-speed-details" gap={theme.gap.large}> <Stack className="page-speed-details" gap={theme.gap.large}>
{loading ? ( {loading ? (
<Skeleton variant="rounded" width="15%" height={34} /> <SkeletonLayout />
) : ( ) : (
<Button <>
level="tertiary" <Button
label="Back" level="tertiary"
animate="slideLeft" label="Back"
img={<WestRoundedIcon />} animate="slideLeft"
onClick={() => navigate("/pagespeed")} img={<WestRoundedIcon />}
sx={{ onClick={() => navigate("/pagespeed")}
width: "fit-content", sx={{
backgroundColor: theme.palette.otherColors.fillGray, width: "fit-content",
px: theme.gap.ml, backgroundColor: theme.palette.otherColors.fillGray,
"& svg.MuiSvgIcon-root": { px: theme.gap.ml,
mr: theme.gap.small, "& svg.MuiSvgIcon-root": {
fill: theme.palette.otherColors.slateGray, mr: theme.gap.small,
}, fill: theme.palette.otherColors.slateGray,
}} },
/> }}
)} />
<Stack direction="row" gap={theme.gap.small}> <Stack direction="row" gap={theme.gap.small}>
{loading ? (
<>
<Skeleton
variant="circular"
style={{ minWidth: 24, minHeight: 24 }}
/>
<Box width="80%">
<Skeleton variant="rounded" width="50%" height={24} />
<Skeleton
variant="rounded"
width="50%"
height={18}
sx={{ mt: theme.gap.small }}
/>
</Box>
<Skeleton
variant="rounded"
width="15%"
height={34}
sx={{ alignSelf: "flex-end" }}
/>
</>
) : (
<>
<GreenCheck /> <GreenCheck />
<Box> <Box>
<Typography <Typography
@@ -334,38 +357,13 @@ const PageSpeedDetails = () => {
}, },
}} }}
/> />
</> </Stack>
)} <Stack
</Stack> direction="row"
<Stack justifyContent="space-between"
direction="row" gap={theme.gap.xl}
justifyContent="space-between" flexWrap="wrap"
gap={theme.gap.xl} >
flexWrap="wrap"
>
{loading ? (
<>
<Skeleton
variant="rounded"
width="30%"
height={90}
sx={{ flex: 1 }}
/>
<Skeleton
variant="rounded"
width="30%"
height={90}
sx={{ flex: 1 }}
/>
<Skeleton
variant="rounded"
width="30%"
height={90}
sx={{ flex: 1 }}
/>
</>
) : (
<>
<StatBox <StatBox
icon={<LastCheckedIcon />} icon={<LastCheckedIcon />}
title="Last checked" title="Last checked"
@@ -408,31 +406,13 @@ const PageSpeedDetails = () => {
title="Checks every" title="Checks every"
value={formatDurationRounded(monitor?.interval)} value={formatDurationRounded(monitor?.interval)}
></StatBox> ></StatBox>
</> </Stack>
)}
</Stack>
{loading ? (
<>
<Skeleton variant="rounded" width="25%" height={24} />
<Skeleton variant="rounded" width="100%" height={300} />
</>
) : (
<>
<Typography component="h2">Score history</Typography> <Typography component="h2">Score history</Typography>
<Box height="300px"> <Box height="300px">
<PageSpeedLineChart <PageSpeedLineChart
pageSpeedChecks={monitor?.checks?.slice(0, 25)} pageSpeedChecks={monitor?.checks?.slice(0, 25)}
/> />
</Box> </Box>
</>
)}
{loading ? (
<>
<Skeleton variant="rounded" width="25%" height={24} />
<Skeleton variant="rounded" width="100%" height={300} />
</>
) : (
<>
<Typography component="h2">Performance report</Typography> <Typography component="h2">Performance report</Typography>
<Stack direction="row" alignItems="center" overflow="hidden"> <Stack direction="row" alignItems="center" overflow="hidden">
<Stack <Stack
+62 -49
View File
@@ -57,6 +57,67 @@ const Card = ({ data }) => {
); );
}; };
/**
* Renders a skeleton layout.
*
* @returns {JSX.Element}
*/
const SkeletonLayout = () => {
const theme = useTheme();
return (
<Stack gap={theme.gap.xs}>
<Stack
direction="row"
justifyContent="space-between"
mb={theme.gap.large}
>
<Box width="80%">
<Skeleton variant="rounded" width="25%" height={24} />
<Skeleton
variant="rounded"
width="50%"
height={19.5}
sx={{ mt: theme.gap.xs }}
/>
</Box>
<Skeleton
variant="rounded"
width="20%"
height={34}
sx={{ alignSelf: "flex-end" }}
/>
</Stack>
<Stack direction="row" flexWrap="wrap" gap={theme.gap.large}>
<Skeleton
variant="rounded"
width="100%"
height={120}
sx={{ flex: "35%" }}
/>
<Skeleton
variant="rounded"
width="100%"
height={120}
sx={{ flex: "35%" }}
/>
<Skeleton
variant="rounded"
width="100%"
height={120}
sx={{ flex: "35%" }}
/>
<Skeleton
variant="rounded"
width="100%"
height={120}
sx={{ flex: "35%" }}
/>
</Stack>
</Stack>
);
};
const PageSpeed = () => { const PageSpeed = () => {
const theme = useTheme(); const theme = useTheme();
const dispatch = useDispatch(); const dispatch = useDispatch();
@@ -77,55 +138,7 @@ const PageSpeed = () => {
return ( return (
<Box className="page-speed"> <Box className="page-speed">
{isActuallyLoading ? ( {isActuallyLoading ? (
<Stack gap={theme.gap.xs}> <SkeletonLayout />
<Stack
direction="row"
justifyContent="space-between"
mb={theme.gap.large}
>
<Box width="80%">
<Skeleton variant="rounded" width="25%" height={24} />
<Skeleton
variant="rounded"
width="50%"
height={19.5}
sx={{ mt: theme.gap.xs }}
/>
</Box>
<Skeleton
variant="rounded"
width="20%"
height={34}
sx={{ alignSelf: "flex-end" }}
/>
</Stack>
<Stack direction="row" flexWrap="wrap" gap={theme.gap.large}>
<Skeleton
variant="rounded"
width="100%"
height={120}
sx={{ flex: "35%" }}
/>
<Skeleton
variant="rounded"
width="100%"
height={120}
sx={{ flex: "35%" }}
/>
<Skeleton
variant="rounded"
width="100%"
height={120}
sx={{ flex: "35%" }}
/>
<Skeleton
variant="rounded"
width="100%"
height={120}
sx={{ flex: "35%" }}
/>
</Stack>
</Stack>
) : monitors?.length !== 0 ? ( ) : monitors?.length !== 0 ? (
<Stack gap={theme.gap.xs}> <Stack gap={theme.gap.xs}>
<Stack <Stack