Skip to content

Commit

Permalink
feat: skeleton 컴포넌트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seongminn committed Nov 28, 2023
1 parent 389a25d commit faa13e0
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/match/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function Match({ params }: { params: { id: string } }) {
<section>
<AsyncBoundary
errorFallback={props => <MatchBanner.ErrorFallback {...props} />}
loadingFallback={<div>배너 로딩중...</div>}
loadingFallback={<MatchBanner.Skeleton />}
>
<MatchByIdFetcher matchId={params.id}>
{data => <MatchBanner {...data} />}
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function Home() {
<section className="flex flex-col items-center">
<AsyncBoundary
errorFallback={() => <div>에러</div>}
loadingFallback={<div>로딩 중</div>}
loadingFallback={<SportsList.Skeleton />}
>
<SportsListFetcher leagueId={params.get(QUERY_PARAMS.league) || '1'}>
{data => (
Expand Down Expand Up @@ -71,7 +71,7 @@ export default function Home() {

<AsyncBoundary
errorFallback={props => <MatchList.ErrorFallback {...props} />}
loadingFallback={<div>로딩 중</div>}
loadingFallback={<MatchList.Skeleton />}
>
<MatchListFetcher {...paramsObj}>
{({ matchList, ...props }) => (
Expand Down
11 changes: 11 additions & 0 deletions src/components/league/SportsList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,14 @@ export default function SportsList({
</ul>
);
}

SportsList.Skeleton = function Skeleton() {
return (
<ul className="mb-5 flex h-[40px] w-full max-w-md items-center justify-start gap-5 overflow-hidden">
<li className="text-gary-5 h-[40px] w-[70px] animate-pulse cursor-pointer rounded-xl bg-gray-2"></li>
<li className="text-gary-5 h-[40px] w-[70px] animate-pulse cursor-pointer rounded-xl bg-gray-2"></li>
<li className="text-gary-5 h-[40px] w-[70px] animate-pulse cursor-pointer rounded-xl bg-gray-2"></li>
<li className="text-gary-5 h-[40px] w-[70px] animate-pulse cursor-pointer rounded-xl bg-gray-2"></li>
</ul>
);
};
22 changes: 22 additions & 0 deletions src/components/match/Banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,25 @@ MatchBanner.ErrorFallback = function ErrorFallback({
</div>
);
};

MatchBanner.Skeleton = function Skeleton() {
return (
<MatchCard
className="flex flex-col"
gameTeams={[]}
startTime={''}
gameQuarter={''}
gameName={''}
sportsName={''}
>
<div className="flex h-full min-h-[200px] items-center justify-around rounded-xl bg-gray-1 shadow-lg">
<MatchCard.Background
viewBox="-3 120 100 50"
width={150}
height={200}
className="h-[200px]"
/>
</div>
</MatchCard>
);
};
43 changes: 43 additions & 0 deletions src/components/match/MatchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,46 @@ MatchList.ErrorFallback = function ErrorFallback({
</div>
);
};

MatchList.Skeleton = function Skeleton() {
return (
<>
<div className="mb-14 h-[200px] w-full">
<div className="mb-2 h-[30px] rounded-xl bg-gray-1 px-1 pb-1" />
<div className="flex h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"></div>
</div>
<div className="mb-14 h-[200px] w-full">
<div className="mb-2 h-[30px] rounded-xl bg-gray-1 px-1 pb-1" />
<div className="flex h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"></div>
</div>
<div className="mb-14 h-[200px] w-full">
<div className="mb-2 h-[30px] rounded-xl bg-gray-1 px-1 pb-1" />
<div className="flex h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"></div>
</div>
<div className="mb-14 h-[200px] w-full">
<div className="mb-2 h-[30px] rounded-xl bg-gray-1 px-1 pb-1" />
<div className="flex h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"></div>
</div>
<div className="mb-14 h-[200px] w-full">
<div className="mb-2 h-[30px] rounded-xl bg-gray-1 px-1 pb-1" />
<div className="flex h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"></div>
</div>
<div className="mb-14 h-[200px] w-full">
<div className="mb-2 h-[30px] rounded-xl bg-gray-1 px-1 pb-1" />
<div className="flex h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"></div>
</div>
<div className="mb-14 h-[200px] w-full">
<div className="mb-2 h-[30px] rounded-xl bg-gray-1 px-1 pb-1" />
<div className="flex h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"></div>
</div>
<div className="mb-14 h-[200px] w-full">
<div className="mb-2 h-[30px] rounded-xl bg-gray-1 px-1 pb-1" />
<div className="flex h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"></div>
</div>
<div className="mb-14 h-[200px] w-full">
<div className="mb-2 h-[30px] rounded-xl bg-gray-1 px-1 pb-1" />
<div className="flex h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"></div>
</div>
</>
);
};

0 comments on commit faa13e0

Please sign in to comment.