Skip to content

Commit

Permalink
feat(detail): skeleton 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Me1e committed Aug 1, 2023
1 parent 40f93c7 commit 7ce52bd
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion packages/nextjs/pages/report/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Image from "next/image";
import { useRouter } from "next/router";
import { css, keyframes } from "@emotion/react";
import styled from "@emotion/styled";
import { CircularProgress, Skeleton } from "@mui/material";
import { Swiper, SwiperSlide } from "swiper/react";
import Writer from "~~/components/Writer";
import { useScaffoldContractRead } from "~~/hooks/scaffold-eth";
Expand All @@ -11,6 +12,7 @@ const DetailPage = () => {
const {
query: { id },
} = useRouter();
const [isLoading, setIsLoading] = useState(true);

const [detailData, setDetailData] = useState({
alertLevel: -1,
Expand Down Expand Up @@ -84,7 +86,18 @@ const DetailPage = () => {
if (id === undefined) return null;
return (
<DetailWrapper>
<DetailImage src={detailData.image} />
{isLoading && (
<SkeletonElement>
<CircularProgress />
</SkeletonElement>
)}
<DetailImage
src={detailData.image}
onLoad={() => {
setIsLoading(false);
}}
style={{ display: isLoading ? "none" : "block" }}
/>
<DetailBox>
<DetailInfo>
<DetailDate>{formatTimestamp(detailData.timestamp)}</DetailDate>
Expand Down Expand Up @@ -310,3 +323,13 @@ const Badge = styled.div<{ delay: number }>`
animation: ${floatAnimation} 2s infinite ease-in-out;
animation-delay: ${props => props.delay}s;
`;

const SkeletonElement = styled.div`
border-radius: 30px;
width: 100%;
height: 327px;
background-color: #ccc; /* 스켈레톤의 배경색 */
display: flex;
align-items: center;
justify-content: center;
`;

0 comments on commit 7ce52bd

Please sign in to comment.