Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
feat(component): render Skeleton for component 'Summary' when loading…
Browse files Browse the repository at this point in the history
… data

  ## what
  - Render skeleton when loading data

  ## how
  - Use Material-ui `Grid` to arrange elements
  - Use `Box` to define a element container with a defined height
  - Use `Skeleton` to render loading component

  ## why
  - its for better readability

  ## where
  - ./src/components/Summary/index.tsx

  ## usage
  • Loading branch information
Clumsy-Coder committed Aug 20, 2023
1 parent 4958437 commit e9a7572
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/components/Summary/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Box from '@mui/material/Box';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import { green, blue, red, orange } from '@mui/material/colors';
import Grid from '@mui/material/Grid';
import Skeleton from '@mui/material/Skeleton';
import Typography from '@mui/material/Typography';

import { ISummary } from '@utils/url/upstream.types';
Expand Down Expand Up @@ -36,8 +38,35 @@ const Summary: React.FC<Props> = (props: Props) => {
unique_clients: uniqueClients,
} = data;

if (isLoading) {
return (
<Grid container spacing={2}>
<Grid item xs={12} md={3} sm={6}>
<Box sx={{ height: 117 }}>
<Skeleton variant='rounded' height='inherit' />
</Box>
</Grid>
<Grid item xs={12} md={3} sm={6}>
<Box sx={{ height: 117 }}>
<Skeleton variant='rounded' height='inherit' />
</Box>
</Grid>
<Grid item xs={12} md={3} sm={6}>
<Box sx={{ height: 117 }}>
<Skeleton variant='rounded' height='inherit' />
</Box>
</Grid>
<Grid item xs={12} md={3} sm={6}>
<Box sx={{ height: 117 }}>
<Skeleton variant='rounded' height='inherit' />
</Box>
</Grid>
</Grid>
);
}

return (
<Grid container spacing={1}>
<Grid container spacing={2}>
<Grid item xs={12} sm={6} md={3}>
<Card sx={{ backgroundColor: green[900] }}>
<CardContent>
Expand Down

0 comments on commit e9a7572

Please sign in to comment.