-
Notifications
You must be signed in to change notification settings - Fork 2
๐ค Refactor(#117): type ์ง์ ๋ฐ ๋ถํ์ํ ๋ก์ง ์ ๊ฑฐ #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seoyoung81
wants to merge
7
commits into
develop
Choose a base branch
from
refactor/#117/main-carousel
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f18e4c6
๐ค Refactor(#117): type ์ง์ ๋ฐ ๋ถํ์ํ ๋ก์ง ์ ๊ฑฐ
seoyoung81 0fc360f
feat: usememo ์ฌ์ฉ
seoyoung81 65a7c2e
fix: type ์์ ๋ฐ ๋ก๋ฉ ์ค ํ๋ฉด ๊ณ ๋ ค
seoyoung81 1bad487
๐จ Fix(#117): modified main image
seoyoung81 b0edad6
๐ค Refactor(#117): useMemo ์ฌ์ฉ
seoyoung81 5c74515
๐ค Refactor(#117): seperate recommendItem type
seoyoung81 fe579e3
๐ค Refactor(#117): add useWindowSizehook
seoyoung81 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,16 +1,27 @@ | ||
"use client"; | ||
import RecommendItem from "./RecommendItem"; | ||
import { useEffect, useState } from "react"; | ||
import { TagProps } from "@component/components/common-components/tag"; | ||
import { useMemo } from "react"; | ||
import Slider from "react-slick"; | ||
import "slick-carousel/slick/slick.css"; | ||
import "slick-carousel/slick/slick-theme.css"; | ||
import { useGetProjectRecommend } from "@component/hooks/useProject"; | ||
import { TagProps } from "@component/components/common-components/tag"; | ||
|
||
// ์บ๋ฌ์ ํ์ดํ | ||
import ArrowBackIosNewRoundedIcon from "@mui/icons-material/ArrowBackIosNewRounded"; | ||
import ArrowForwardIosRoundedIcon from "@mui/icons-material/ArrowForwardIosRounded"; | ||
|
||
export interface RecommendData { | ||
|
||
createdAt: string; | ||
createdBy: string; | ||
field: TagProps["type"]; | ||
profileImageUrl: string; | ||
progress: TagProps["status"]; | ||
projectId: number; | ||
summary: string; | ||
title: string; | ||
} | ||
|
||
const PrevArrow = ({ onClick }: any) => { | ||
return ( | ||
<ArrowBackIosNewRoundedIcon | ||
|
@@ -38,29 +49,34 @@ const settings = { | |
slidesToShow: 3, // ํ๋ฉด์ ํ ๋ฒ์ ํ์ํ ์ฌ๋ผ์ด๋ ๊ฐ์ ์ค์ | ||
slidesToScroll: 3, // ๋ค์ ๋ณด์ฌ ์ค ์ฌ๋ผ์ด๋์ ๊ฐ์ ์ค์ | ||
speed: 2000, // ํ๋ฉด์ ๋๊ธธ ๋ ์๋ | ||
autoplay: false, // TODO: ์๋ ๋๊น ๋ ผ์ | ||
autoplay: false, | ||
autoplaySpeed: 5000, // ๊ฐ๊ฒฉ | ||
nextArrow: <NextArrow />, | ||
prevArrow: <PrevArrow />, | ||
}; | ||
|
||
const Carousel = () => { | ||
const { data, error, isLoading } = useGetProjectRecommend(); | ||
const [recommendData, setRecommendData] = useState<any>(); | ||
|
||
useEffect(() => { | ||
if (data) { | ||
setRecommendData(data.data.data) | ||
} | ||
const recommendData: RecommendData[] = useMemo(() => { | ||
return data?.data.data ?? []; | ||
}, [data]); | ||
|
||
if (error) { | ||
console.log(error); | ||
if (isLoading || error) { | ||
return ( | ||
<Slider {...settings} className="mt-[32.5px]"> | ||
{[...Array(3)].map((_, index) => ( | ||
<div> | ||
<div className="w-[344px] h-[340px] rounded-[10px] border border-[1.5px] border-purple-main1 bg-purple-main5 flex justify-center items-center"></div> | ||
</div> | ||
))} | ||
</Slider> | ||
); | ||
} | ||
return ( | ||
<> | ||
<Slider {...settings} className="mt-[32.5px]"> | ||
{recommendData?.map((item: any) => ( | ||
{recommendData?.map((item: RecommendData) => ( | ||
<RecommendItem | ||
key={item.projectId} | ||
projectId={item.projectId} | ||
|
@@ -71,7 +87,6 @@ const Carousel = () => { | |
profileImg={item.profileImageUrl} | ||
nickname={item.createdBy} | ||
createdAt={item.createdAt} | ||
isLoading={isLoading} | ||
/> | ||
))} | ||
</Slider> | ||
|
This file contains hidden or 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 hidden or 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,45 +1,61 @@ | ||
import Image from "next/image"; | ||
import Tag from "@component/components/common-components/tag/Tag"; | ||
import { useRouter } from "next/navigation"; | ||
import { TagProps } from "@component/components/common-components/tag"; | ||
|
||
const RecommendItem = ({ | ||
projectId, | ||
fields, | ||
progress, | ||
title, | ||
content, | ||
profileImg, | ||
nickname, | ||
createdAt, | ||
isLoading | ||
}: any) => { | ||
const router = useRouter(); | ||
return ( | ||
<> | ||
{isLoading ? ( | ||
<div className="w-[344px] h-[340px] rounded-[10px] border border-[1.5px] border-purple-main1 bg-purple-main5 flex justify-center items-center cursor-pointer"> | ||
</div> | ||
) : ( | ||
<div | ||
className="w-[344px] h-[340px] rounded-[10px] border border-[1.5px] border-purple-main1 bg-purple-main5 flex justify-center items-center cursor-pointer" | ||
onClick={() => { | ||
router.push(`/project/${projectId}`) | ||
}} | ||
> | ||
<div className="w-[261px] h-[296.93px] relative"> | ||
<Tag type={fields} status={progress} /> | ||
<div className="text-title mt-[12px] mb-[24px]">{title}</div> | ||
<div className="text-body1 text-gray-60 font-medium">{content}</div> | ||
<div className="absolute bottom-0 flex items-center"> | ||
<Image src={profileImg} alt="์์ ํ๋กํ ์ด๋ฏธ์ง" width={20} height={20} className="w-[20px] h-[20px] rounded-full me-[10px]" /> | ||
<div className="text-body1 text-gray-60 me-[24px] font-medium">{nickname}</div> | ||
<div className="text-body1 text-gray-60 font-medium">{createdAt}</div> | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
); | ||
interface RecommendItemData { | ||
projectId: number; | ||
fields: TagProps["type"]; | ||
progress: TagProps["status"]; | ||
title: string; | ||
content: string; | ||
profileImg: string; | ||
nickname: string; | ||
createdAt: string; | ||
} | ||
|
||
const RecommendItem = ({ | ||
projectId, | ||
fields, | ||
progress, | ||
title, | ||
content, | ||
profileImg, | ||
nickname, | ||
createdAt, | ||
}: RecommendItemData) => { | ||
const router = useRouter(); | ||
return ( | ||
<> | ||
<div | ||
className="w-[344px] h-[340px] rounded-[10px] border border-[1.5px] border-purple-main1 bg-purple-main5 flex justify-center items-center cursor-pointer" | ||
onClick={() => { | ||
router.push(`/project/${projectId}`); | ||
}} | ||
> | ||
<div className="w-[261px] h-[296.93px] relative"> | ||
<Tag type={fields} status={progress} /> | ||
<div className="text-title mt-[12px] mb-[24px]">{title}</div> | ||
<div className="text-body1 text-gray-60 font-medium">{content}</div> | ||
<div className="absolute bottom-0 flex items-center"> | ||
<Image | ||
src={profileImg} | ||
alt="์์ ํ๋กํ ์ด๋ฏธ์ง" | ||
width={20} | ||
height={20} | ||
className="w-[20px] h-[20px] rounded-full me-[10px]" | ||
/> | ||
<div className="text-body1 text-gray-60 me-[24px] font-medium"> | ||
{nickname} | ||
</div> | ||
<div className="text-body1 text-gray-60 font-medium"> | ||
{createdAt} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default RecommendItem; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p3: ์๋์ฐ ๋๋น์ฒดํฌํ๋ ์ ๋ถ๋ถ์ useWindowSize์ ๊ฐ์ด ํ ์ผ๋ก ๋นผ๋ ์ข์ ๊ฒ ๊ฐ๋ค์~
๊ทผ๋ฐ ์ฌ๊ธฐ์๋ง ์ฌ์ฉ๋ ๊ฒ ๊ฐ๋ค๋ฉด ๊ตณ์ด ์ํด๋ ๋ ๊ฒ ๊ฐ์ต๋๋น!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useWindowSize ๊ด๋ จ ํ ์ผ๋ก ๋ถ๋ฆฌํ ์๊ฐ์ ๋ชปํ๋ค์..! ๐