Added skeleton layout
This commit is contained in:
1 parent
e914a39d0b
commit
8b351871c6
1 file changed
+62
-3
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { Box, Modal, Stack, Typography } from "@mui/material";
|
import { Box, Modal, Skeleton, Stack, Typography } from "@mui/material";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { useNavigate, useParams } from "react-router";
|
import { useNavigate, useParams } from "react-router";
|
||||||
import {
|
import {
|
||||||
@@ -21,6 +21,53 @@ import RedCheck from "../../../assets/icons/checkbox-red.svg?react";
|
|||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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} maxWidth="1000px">
|
||||||
|
<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={100} height={34} />
|
||||||
|
<Skeleton variant="rounded" width={100} height={34} />
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
<Skeleton variant="rounded" width="100%" height={500} />
|
||||||
|
<Stack direction="row" justifyContent="flex-end">
|
||||||
|
<Skeleton variant="rounded" width="15%" height={34} />
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const PageSpeedConfigure = () => {
|
const PageSpeedConfigure = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -55,7 +102,7 @@ const PageSpeedConfigure = () => {
|
|||||||
|
|
||||||
const handleChange = (event, id) => {
|
const handleChange = (event, id) => {
|
||||||
let { value } = event.target;
|
let { value } = event.target;
|
||||||
if ((id = "interval")) {
|
if (id === "interval") {
|
||||||
value = value * MS_PER_MINUTE;
|
value = value * MS_PER_MINUTE;
|
||||||
}
|
}
|
||||||
setMonitor((prev) => ({ ...prev, [id]: value }));
|
setMonitor((prev) => ({ ...prev, [id]: value }));
|
||||||
@@ -97,8 +144,14 @@ const PageSpeedConfigure = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let loading = Object.keys(monitor).length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="configure-pagespeed">
|
<Box className="configure-pagespeed">
|
||||||
|
{loading ? (
|
||||||
|
<SkeletonLayout />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<Button
|
<Button
|
||||||
level="tertiary"
|
level="tertiary"
|
||||||
label="Back"
|
label="Back"
|
||||||
@@ -129,7 +182,11 @@ const PageSpeedConfigure = () => {
|
|||||||
<Stack direction="row" gap={theme.gap.small}>
|
<Stack direction="row" gap={theme.gap.small}>
|
||||||
{monitor?.status ? <GreenCheck /> : <RedCheck />}
|
{monitor?.status ? <GreenCheck /> : <RedCheck />}
|
||||||
<Box>
|
<Box>
|
||||||
<Typography component="h1" mb={theme.gap.xs} sx={{ lineHeight: 1 }}>
|
<Typography
|
||||||
|
component="h1"
|
||||||
|
mb={theme.gap.xs}
|
||||||
|
sx={{ lineHeight: 1 }}
|
||||||
|
>
|
||||||
{monitor?.url}
|
{monitor?.url}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
@@ -253,6 +310,8 @@ const PageSpeedConfigure = () => {
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</form>
|
</form>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Modal
|
<Modal
|
||||||
aria-labelledby="modal-delete-pagespeed-monitor"
|
aria-labelledby="modal-delete-pagespeed-monitor"
|
||||||
aria-describedby="delete-pagespeed-monitor-confirmation"
|
aria-describedby="delete-pagespeed-monitor-confirmation"
|
||||||
|
|||||||
Reference in new issue
Block a user