Skip to content

Commit

Permalink
Added skeleton and fixed button placement
Browse files Browse the repository at this point in the history
  • Loading branch information
lakansantos committed May 1, 2024
1 parent 72c8eb8 commit fb2f167
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions app/modules/map/MapDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import React, {useState} from 'react';
import Image from 'next/image';
import {
Box,
Button,
Card,
CardContent,
CardMedia,
Divider,
Skeleton,
ThemeProvider,
Typography,
createTheme,
Expand Down Expand Up @@ -65,6 +67,9 @@ const MapDetails = ({data}: {data: Country}) => {

const {openTab, toggleOpenTab} = useToggleSideMap();

const [isImageRendered, setIsImageRendered] = useState(false);

console.log(isImageRendered);
return (
<Box
sx={{
Expand All @@ -83,6 +88,7 @@ const MapDetails = ({data}: {data: Country}) => {
variant="contained"
sx={{
top: '50%',
transform: 'translateY(-50%)',
right: -32,
zIndex: -1,
height: 70,
Expand Down Expand Up @@ -140,16 +146,21 @@ const MapDetails = ({data}: {data: Country}) => {
N/A
</Box>
) : (
<CardMedia
component="img"
image={coatOfArms.svg}
title=""
sx={{
height: 100,
width: 100,
objectFit: 'fill',
}}
/>
<React.Fragment>
<Image
height={100}
width={100}
src={coatOfArms.svg}
style={{
opacity: isImageRendered ? '1' : '0',
}}
alt="image"
onLoad={() => setIsImageRendered(true)}
/>
{!isImageRendered && (
<Skeleton variant="rectangular" width={100} height={100} />
)}
</React.Fragment>
)}
</CardContent>
<Divider />
Expand Down

0 comments on commit fb2f167

Please sign in to comment.