-
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.
Merge pull request #327 from Team-TenTen/develop
[Release] v0.1.14
- Loading branch information
Showing
41 changed files
with
493 additions
and
849 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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 |
---|---|---|
@@ -1,110 +1,22 @@ | ||
'use client' | ||
|
||
import { CategoryList, Dropdown, LinkItem, Spinner } from '@/components' | ||
import FloatingButton from '@/components/FloatingButton/FloatingButton' | ||
import { ChipColors } from '@/components/common/Chip/Chip' | ||
import DeferredComponent from '@/components/common/DeferedComponent/DeferedComponent' | ||
import MainSpaceList from '@/components/common/MainSpaceList/MainSpaceList' | ||
import { useCategoryParam, useSortParam } from '@/hooks' | ||
import useGetPopularLinks from '@/hooks/useGetPopularLinks' | ||
import { fetchGetSpaces } from '@/services/space/spaces' | ||
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 HydratePopularLinkList from '@/components/PopularLinkList/HydratePopularLinkList' | ||
import FloatingBtnController from '@/components/common/MainSpaceList/FloatingBtnController' | ||
import MainSpaceHeader from '@/components/common/MainSpaceList/MainSpaceHeader' | ||
import SpaceListController from '@/components/common/MainSpaceList/SpaceListController' | ||
|
||
export default function Home() { | ||
const { links, isPopularLinksLoading } = useGetPopularLinks() | ||
const { sort, sortIndex, handleSortChange } = useSortParam('space') | ||
const { category, categoryIndex, handleCategoryChange } = | ||
useCategoryParam('all') | ||
|
||
return isPopularLinksLoading ? ( | ||
<DeferredComponent> | ||
<Spinner /> | ||
</DeferredComponent> | ||
) : ( | ||
return ( | ||
<> | ||
<section className="px-4 pb-8"> | ||
<h2 className="py-4 font-bold text-gray9">인기있는 링크</h2> | ||
{links && ( | ||
<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"> | ||
{links.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> | ||
)} | ||
<div className="min-h-[101.5px]"> | ||
<HydratePopularLinkList /> | ||
</div> | ||
</section> | ||
<section> | ||
<div className="sticky top-[53px] z-40 bg-bgColor"> | ||
<div className="flex items-center justify-between px-4 pt-2"> | ||
<h2 className="font-bold text-gray9">스페이스 모음</h2> | ||
<Dropdown | ||
type="space" | ||
placement="right" | ||
defaultIndex={sortIndex} | ||
onChange={handleSortChange} | ||
/> | ||
</div> | ||
<CategoryList | ||
type="all" | ||
defaultIndex={categoryIndex} | ||
onChange={handleCategoryChange} | ||
/> | ||
</div> | ||
<MainSpaceList | ||
queryKey="main" | ||
sort={sort ?? ''} | ||
category={category ?? ''} | ||
fetchFn={fetchGetSpaces} | ||
/> | ||
<MainSpaceHeader /> | ||
<SpaceListController /> | ||
</section> | ||
<FloatingButton /> | ||
<FloatingBtnController /> | ||
</> | ||
) | ||
} |
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,21 @@ | ||
import React from 'react' | ||
import { getQueryClient } from '@/lib/queryClient' | ||
import { fetchGetPopularLinks } from '@/services/link/link' | ||
import { HydrationBoundary, dehydrate } from '@tanstack/react-query' | ||
import PopularLinkList from './PopularLinkList' | ||
|
||
const HydratePopularLinkList = async () => { | ||
const queryClient = getQueryClient() | ||
await queryClient.prefetchQuery({ | ||
queryKey: ['PopularLinks'], | ||
queryFn: fetchGetPopularLinks, | ||
}) | ||
|
||
return ( | ||
<HydrationBoundary state={dehydrate(queryClient)}> | ||
<PopularLinkList /> | ||
</HydrationBoundary> | ||
) | ||
} | ||
|
||
export default React.memo(HydratePopularLinkList) |
Oops, something went wrong.