Skip to content

Commit

Permalink
Merge pull request #87 from TripInfoWeb/dev_skeleton
Browse files Browse the repository at this point in the history
Feature: 메인 & 정보 페이지 Skeleton 구현
  • Loading branch information
HyunJinNo authored Jun 30, 2024
2 parents c6329a0 + 465d26c commit 887e1d6
Show file tree
Hide file tree
Showing 24 changed files with 443 additions and 474 deletions.
9 changes: 7 additions & 2 deletions src/app/informations/(detail)/[category]/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import InformationViewer from "@/components/informations/InformationViewer";
import PagePath from "@/components/informations/PagePath";
import RecommendationList from "@/components/informations/RecommendationList";
import InformationViewerSkeleton from "@/components/skeleton/informations/InformationViewerSkeleton";
import RecommendationListSkeleton from "@/components/skeleton/informations/RecommendationListSkeleton";
import { CATEGORY_TEXT } from "@/constants/informations/category";
import InformationViewerContainer from "@/containers/informations/InformationViewerContainer";
import { Suspense } from "react";

type MyProps = {
Expand Down Expand Up @@ -36,7 +38,10 @@ export default function page({ params: { category, id } }: MyProps) {

return (
<div className="flex flex-col items-center">
<InformationViewerContainer category={category} id={postId} />
<PagePath category={`${CATEGORY_TEXT[category]} 상세`} />
<Suspense fallback={<InformationViewerSkeleton />}>
<InformationViewer />
</Suspense>
<Suspense fallback={<RecommendationListSkeleton />}>
<RecommendationList />
</Suspense>
Expand Down
23 changes: 8 additions & 15 deletions src/app/informations/list/[category]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CategoryLinks from "@/components/informations/CategoryLinks";
import InformationList from "@/components/informations/InformationList";
import InformationListSkeleton from "@/components/skeleton/informations/InformationListSkeleton";
import { CATEGORY_TEXT } from "@/constants/informations/category";
import InformationListContainer from "@/containers/informations/InformationListContainer";
import CategoryListContainer from "@/containers/informations/CategoryListContainer";
import { Suspense } from "react";

type MyProps = {
Expand All @@ -19,19 +19,12 @@ export async function generateMetadata({ params: { category } }: MyProps) {
export default function page({ params, searchParams }: MyProps) {
return (
<div className="flex flex-col items-center">
<CategoryLinks category={params.category} />
<Suspense
fallback={
<InformationListSkeleton
category={params.category}
subCategory={searchParams["subCategory"]!}
/>
}
>
<InformationListContainer
category={params.category}
subCategory={searchParams["subCategory"]!}
/>
<CategoryListContainer
category={params.category}
subCategory={searchParams["subCategory"]!}
/>
<Suspense fallback={<InformationListSkeleton />}>
<InformationList />
</Suspense>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/app/informations/list/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import TopList from "@/components/common/TopList";
import TopListSkeleton from "@/components/skeleton/common/TopListSkeleton";
import BannerContainer from "@/containers/common/BannerContainer";
import TopListContainer from "@/containers/informations/TopListContainer";
import { Suspense } from "react";

export default function RootLayout({
Expand All @@ -12,7 +12,7 @@ export default function RootLayout({
<div className="flex flex-col items-center">
<BannerContainer />
<Suspense fallback={<TopListSkeleton title="여행" />}>
<TopListContainer category="여행" />
<TopList title="여행" />
</Suspense>
{children}
</div>
Expand Down
32 changes: 20 additions & 12 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
import BestInformationList from "@/components/home/BestInformationList";
import NewMeetingList from "@/components/home/NewMeetingList";
import TabList from "@/components/home/TabList";
import BestInformationListSkeleton from "@/components/skeleton/home/BestInformationListSkeleton";
import NewMeetingListSkeleton from "@/components/skeleton/home/NewMeetingListSkeleton";
import BestInformationListContainer from "@/containers/home/BestInformationListContainer";
import HomeCarouselContainer from "@/containers/home/HomeCarouselContainer";
import NewMeetingListContainer from "@/containers/home/NewMeetingListContainer";
import ListTemplateContainer from "@/containers/home/ListTemplateContainer";
import { Suspense } from "react";

// todo
export default function Home() {
return (
<div className="flex flex-col items-center">
<div className="mb-20 flex flex-col items-center gap-20">
<HomeCarouselContainer />
<TabList />

{/* TODO: async 사용 시 마우스 스크롤 문제 */}
<Suspense fallback={<BestInformationListSkeleton />}>
<BestInformationListContainer />
</Suspense>
<Suspense fallback={<NewMeetingListSkeleton />}>
<NewMeetingListContainer />
</Suspense>
<ListTemplateContainer
titles={["고민을 덜어줄,", "BEST", "여행 정보"]}
description={"솔리투어에서 인기 여행 정보를 확인해보세요!"}
>
<Suspense fallback={<BestInformationListSkeleton />}>
<BestInformationList />
</Suspense>
</ListTemplateContainer>
<ListTemplateContainer
titles={["새로움을 발견할,", "NEW", "모임"]}
description={"솔리투어에서 새로운 사람들과 최신 모임을 찾아보세요!"}
>
<Suspense fallback={<NewMeetingListSkeleton />}>
<NewMeetingList />
</Suspense>
</ListTemplateContainer>
</div>
);
}
74 changes: 12 additions & 62 deletions src/components/home/BestInformationList.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { useDragScrollType } from "@/hooks/useDragScroll";
import InformationItem from "../common/InformationItem";
import Link from "next/link";

type MyProps = {
scrollHook: useDragScrollType;
};

const BestInformationList = ({ scrollHook }: MyProps) => {
//await new Promise((resolve) => setTimeout(resolve, 1000));
const BestInformationList = async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));

// TODO
const data: {
Expand Down Expand Up @@ -48,60 +42,16 @@ const BestInformationList = ({ scrollHook }: MyProps) => {
];

return (
<div className="mt-20 flex w-[60rem] flex-col max-[1024px]:w-[39.75rem] max-[744px]:w-[calc(100%_-_48px)]">
<div className="flex flex-row items-center justify-between max-[744px]:justify-center">
<div className="flex flex-col gap-2 max-[744px]:w-full">
<div className="flex flex-row items-center justify-between gap-1">
<h2 className="flex flex-row items-center gap-2 text-2xl font-bold text-black max-[744px]:flex-col max-[744px]:items-start max-[744px]:gap-0">
<p>{"고민을 덜어줄,"}</p>
<p>
<span className="text-main">BEST</span> 여행 정보
</p>
</h2>
<Link
className="hidden h-[2.3125rem] w-[5.8125rem] items-center justify-center rounded-full border-[0.0625rem] border-gray3 text-gray1 hover:border-main hover:bg-main hover:text-white max-[744px]:flex"
href="/informations/list/restaurant?subCategory=all"
>
전체보기
</Link>
</div>
<p className="text-sm font-medium text-gray1">
솔리투어에서 인기 여행 정보를 확인해보세요!
</p>
</div>
<Link
className="flex h-[2.3125rem] w-[5.8125rem] items-center justify-center rounded-full border-[0.0625rem] border-gray3 text-gray1 hover:border-main hover:bg-main hover:text-white max-[744px]:hidden"
href="/informations/list/restaurant?subCategory=all"
>
전체보기
</Link>
</div>
<div
className="overflow-x-auto"
ref={scrollHook.listRef}
onMouseDown={(e) => {
e.preventDefault();
scrollHook.onDragStart(e);
}}
onMouseMove={scrollHook.onDragMove}
onMouseUp={scrollHook.onDragEnd}
onMouseLeave={scrollHook.onDragEnd}
onTouchStart={scrollHook.onTouchStart}
onTouchMove={scrollHook.onTouchMove}
onTouchEnd={scrollHook.onTouchEnd}
>
<div className="mt-6 flex w-fit flex-wrap items-center justify-center gap-4 p-1 max-[744px]:flex-row max-[744px]:flex-nowrap">
{data.map((post, index) => (
<InformationItem
key={index}
id={index + 1}
category={post.category}
title={post.title}
image={post.image}
/>
))}
</div>
</div>
<div className="mt-6 flex w-fit flex-wrap items-center justify-center gap-4 p-1 max-[744px]:flex-row max-[744px]:flex-nowrap">
{data.map((post, index) => (
<InformationItem
key={index}
id={index + 1}
category={post.category}
title={post.title}
image={post.image}
/>
))}
</div>
);
};
Expand Down
64 changes: 64 additions & 0 deletions src/components/home/ListTemplate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { useDragScrollType } from "@/hooks/useDragScroll";
import Link from "next/link";

type MyProps = {
titles: string[];
description: string;
scrollHook: useDragScrollType;
children: React.ReactNode;
};

const ListTemplate = ({
titles,
description,
scrollHook,
children,
}: MyProps) => {
return (
<div className="flex w-[60rem] flex-col max-[1024px]:w-[39.75rem] max-[744px]:w-[calc(100%_-_48px)]">
<div className="flex flex-row items-center justify-between max-[744px]:justify-center">
<div className="flex flex-col gap-2 max-[744px]:w-full">
<div className="flex flex-row items-center justify-between gap-1">
<h2 className="flex flex-row items-center gap-2 text-2xl font-bold text-black max-[744px]:flex-col max-[744px]:items-start max-[744px]:gap-0">
<p>{titles[0]}</p>
<p>
<span className="text-main">{titles[1]}</span> {titles[2]}
</p>
</h2>
<Link
className="hidden h-[2.3125rem] w-[5.8125rem] items-center justify-center rounded-full border-[0.0625rem] border-gray3 text-gray1 hover:border-main hover:bg-main hover:text-white max-[744px]:flex"
href="/informations/list/restaurant?subCategory=all"
>
전체보기
</Link>
</div>
<p className="text-sm font-medium text-gray1">{description}</p>
</div>
<Link
className="flex h-[2.3125rem] w-[5.8125rem] items-center justify-center rounded-full border-[0.0625rem] border-gray3 text-gray1 hover:border-main hover:bg-main hover:text-white max-[744px]:hidden"
href="/informations/list/restaurant?subCategory=all"
>
전체보기
</Link>
</div>
<div
className="overflow-x-auto"
ref={scrollHook.listRef}
onMouseDown={(e) => {
e.preventDefault();
scrollHook.onDragStart(e);
}}
onMouseMove={scrollHook.onDragMove}
onMouseUp={scrollHook.onDragEnd}
onMouseLeave={scrollHook.onDragEnd}
onTouchStart={scrollHook.onTouchStart}
onTouchMove={scrollHook.onTouchMove}
onTouchEnd={scrollHook.onTouchEnd}
>
{children}
</div>
</div>
);
};

export default ListTemplate;
90 changes: 21 additions & 69 deletions src/components/home/NewMeetingList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { useDragScrollType } from "@/hooks/useDragScroll";
import MeetingItem from "../common/MeetingItem";
import Link from "next/link";

type MyProps = {
scrollHook: useDragScrollType;
};
const NewMeetingList = async () => {
await new Promise((resolve) => setTimeout(resolve, 1000));

const NewMeetingList = ({ scrollHook }: MyProps) => {
// TODO
const data: {
category: string;
Expand Down Expand Up @@ -109,69 +105,25 @@ const NewMeetingList = ({ scrollHook }: MyProps) => {
];

return (
<div className="my-20 w-[60rem] max-[1024px]:w-[39.75rem] max-[744px]:w-[calc(100%_-_48px)]">
<div className="flex flex-row items-center justify-between max-[744px]:justify-center">
<div className="flex flex-col gap-2 max-[744px]:w-full">
<div className="flex flex-row items-center justify-between gap-1">
<h2 className="flex flex-row items-center gap-2 text-2xl font-bold text-black max-[744px]:flex-col max-[744px]:items-start max-[744px]:gap-0">
<p>{"새로움을 발견할,"}</p>
<p>
<span className="text-main">NEW</span> 모임
</p>
</h2>
<Link
className="hidden h-[2.3125rem] w-[5.8125rem] items-center justify-center rounded-full border-[0.0625rem] border-gray3 text-gray1 hover:border-main hover:bg-main hover:text-white max-[744px]:flex"
href="/meetings"
>
전체보기
</Link>
</div>
<p className="text-sm font-medium text-gray1">
솔리투어에서 새로운 사람들과 최신 모임을 찾아보세요!
</p>
</div>
<Link
className="flex h-[2.3125rem] w-[5.8125rem] items-center justify-center rounded-full border-[0.0625rem] border-gray3 text-gray1 hover:border-main hover:bg-main hover:text-white max-[744px]:hidden"
href="/meetings"
>
전체보기
</Link>
</div>
<div
className="overflow-x-auto"
ref={scrollHook.listRef}
onMouseDown={(e) => {
e.preventDefault();
scrollHook.onDragStart(e);
}}
onMouseMove={scrollHook.onDragMove}
onMouseUp={scrollHook.onDragEnd}
onMouseLeave={scrollHook.onDragEnd}
onTouchStart={scrollHook.onTouchStart}
onTouchMove={scrollHook.onTouchMove}
onTouchEnd={scrollHook.onTouchEnd}
>
<div className="mt-6 flex w-fit flex-wrap items-center justify-center gap-4 p-1 max-[744px]:flex-row max-[744px]:flex-nowrap">
{data.map((post, index) => (
<MeetingItem
key={index}
id={index + 1}
category={post.category}
bookmark={post.bookmark}
title={post.title}
username={post.username}
date={post.date}
location={post.location}
time={post.time}
current={post.current}
total={post.total}
qualification={post.qualification}
likes={post.likes}
views={post.views}
/>
))}
</div>
</div>
<div className="mt-6 flex w-fit flex-wrap items-center justify-center gap-4 p-1 max-[744px]:flex-row max-[744px]:flex-nowrap">
{data.map((post, index) => (
<MeetingItem
key={index}
id={index + 1}
category={post.category}
bookmark={post.bookmark}
title={post.title}
username={post.username}
date={post.date}
location={post.location}
time={post.time}
current={post.current}
total={post.total}
qualification={post.qualification}
likes={post.likes}
views={post.views}
/>
))}
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/home/TabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Link from "next/link";

const TabList = () => {
return (
<div className="mt-20 flex w-[60rem] flex-row items-center justify-between max-[1024px]:w-[39.75rem] max-[744px]:w-[calc(100%_-_48px)] max-[744px]:flex-col max-[744px]:gap-4">
<div className="flex w-[60rem] flex-row items-center justify-between max-[1024px]:w-[39.75rem] max-[744px]:w-[calc(100%_-_48px)] max-[744px]:flex-col max-[744px]:gap-4">
<Link
className="flex h-72 w-[29.375rem] flex-col justify-between rounded-2xl bg-gradient-to-br from-[#CBF6FF] to-[#EBE0FA] p-12 duration-300 hover:scale-105 max-[1024px]:h-48 max-[1024px]:w-[19.25rem] max-[1024px]:p-6 max-[744px]:w-full"
href="/informations/list/restaurant?subCategory=all"
Expand Down
Loading

0 comments on commit 887e1d6

Please sign in to comment.