-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #310 - 메인페이지 Suspense적용 및 스켈레톤UI 적용
메인페이지 Suspense적용 및 스켈레톤UI 적용
- Loading branch information
Showing
12 changed files
with
292 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/components/PopularLink/PopularLinkList/PopularLinkList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
'use client' | ||
|
||
import useGetPopularLinks from '@/components/PopularLinkList/hooks/useGetPopularLinks' | ||
import { ChipColors } from '@/components/common/Chip/Chip' | ||
import LinkItem from '@/components/common/LinkItem/LinkItem' | ||
import { PopularLinkResBody } from '@/types' | ||
import 'swiper/css' | ||
import 'swiper/css/free-mode' | ||
import 'swiper/css/pagination' | ||
import { FreeMode } from 'swiper/modules' | ||
import { Swiper, SwiperSlide } from 'swiper/react' | ||
|
||
const PopularLinkList = () => { | ||
const { data } = useGetPopularLinks() | ||
return ( | ||
<Swiper | ||
slidesPerView={2.2} | ||
breakpoints={{ | ||
640: { | ||
slidesPerView: 2.2, | ||
}, | ||
743: { | ||
slidesPerView: 3.2, | ||
}, | ||
1099: { | ||
slidesPerView: 4.2, | ||
}, | ||
1455: { | ||
slidesPerView: 5.2, | ||
}, | ||
1811: { | ||
slidesPerView: 6.2, | ||
}, | ||
2152: { | ||
slidesPerView: 7.2, | ||
}, | ||
2324: { | ||
slidesPerView: 8.2, | ||
}, | ||
}} | ||
spaceBetween={16} | ||
freeMode={true} | ||
pagination={{ | ||
clickable: true, | ||
}} | ||
modules={[FreeMode]} | ||
className="mySwiper"> | ||
{data?.responses.map((link: PopularLinkResBody) => ( | ||
<SwiperSlide key={link.linkId}> | ||
<LinkItem | ||
linkId={link.linkId} | ||
title={link.title} | ||
url={link.url} | ||
tagName={link.tagName} | ||
tagColor={link.tagColor as ChipColors} | ||
isInitLiked={link.isLiked} | ||
likeInitCount={link.likeCount} | ||
type="card" | ||
/> | ||
</SwiperSlide> | ||
))} | ||
</Swiper> | ||
) | ||
} | ||
|
||
export default PopularLinkList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { PopularLinkResBody } from '@/types' | ||
import 'swiper/css' | ||
import 'swiper/css/free-mode' | ||
import 'swiper/css/pagination' | ||
import { FreeMode } from 'swiper/modules' | ||
import { Swiper, SwiperSlide } from 'swiper/react' | ||
import { ChipColors } from '../common/Chip/Chip' | ||
import LinkItem from '../common/LinkItem/LinkItem' | ||
import useGetPopularLinks from './hooks/useGetPopularLinks' | ||
|
||
const PopularLinkList = () => { | ||
const { data } = useGetPopularLinks() | ||
return ( | ||
<Swiper | ||
slidesPerView={2.2} | ||
breakpoints={{ | ||
640: { | ||
slidesPerView: 2.2, | ||
}, | ||
743: { | ||
slidesPerView: 3.2, | ||
}, | ||
1099: { | ||
slidesPerView: 4.2, | ||
}, | ||
1455: { | ||
slidesPerView: 5.2, | ||
}, | ||
1811: { | ||
slidesPerView: 6.2, | ||
}, | ||
2152: { | ||
slidesPerView: 7.2, | ||
}, | ||
2324: { | ||
slidesPerView: 8.2, | ||
}, | ||
}} | ||
spaceBetween={16} | ||
freeMode={true} | ||
pagination={{ | ||
clickable: true, | ||
}} | ||
modules={[FreeMode]} | ||
className="mySwiper"> | ||
{data?.responses.map((link: PopularLinkResBody) => ( | ||
<SwiperSlide key={link.linkId}> | ||
<LinkItem | ||
linkId={link.linkId} | ||
title={link.title} | ||
url={link.url} | ||
tagName={link.tagName} | ||
tagColor={link.tagColor as ChipColors} | ||
isInitLiked={link.isLiked} | ||
likeInitCount={link.likeCount} | ||
type="card" | ||
/> | ||
</SwiperSlide> | ||
))} | ||
</Swiper> | ||
) | ||
} | ||
|
||
export default PopularLinkList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const LinkSkeleton = () => { | ||
return ( | ||
<div className="mr-4 min-w-[164px]"> | ||
<div className="flex min-h-[101.5px] flex-col justify-between gap-1 rounded-md border border-slate3 px-3 py-2.5"> | ||
<div className="button-round h-[20px] w-3/4 bg-slate-100 text-sm font-medium text-gray9 dark:bg-slate-800" /> | ||
<div> | ||
<div className="button-round inline-flex h-[24px] w-[40.74px] rounded-xl bg-slate-100 px-2.5 py-1 text-center text-xs font-medium dark:bg-slate-800" /> | ||
</div> | ||
<div className="flex items-center justify-end"> | ||
<div className="button-round h-[26px] w-[41.28px] bg-slate-100 dark:bg-slate-800" /> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
const PopularLinkSkeleton = () => { | ||
return ( | ||
<div className="overflow-hidden"> | ||
<div className="flex"> | ||
<LinkSkeleton /> | ||
<LinkSkeleton /> | ||
<LinkSkeleton /> | ||
<LinkSkeleton /> | ||
<LinkSkeleton /> | ||
<LinkSkeleton /> | ||
<LinkSkeleton /> | ||
<LinkSkeleton /> | ||
<LinkSkeleton /> | ||
<LinkSkeleton /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default PopularLinkSkeleton |
11 changes: 11 additions & 0 deletions
11
src/components/PopularLinkList/hooks/useGetPopularLinks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { fetchGetPopularLinks } from '@/services/link/link' | ||
import { useSuspenseQuery } from '@tanstack/react-query' | ||
|
||
const useGetPopularLinks = () => { | ||
return useSuspenseQuery({ | ||
queryKey: ['popularLinks'], | ||
queryFn: () => fetchGetPopularLinks(), | ||
}) | ||
} | ||
|
||
export default useGetPopularLinks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.