-
Notifications
You must be signed in to change notification settings - Fork 1
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 #24 from NewMillenniumWorkout/dev/HomePage
[DEV] HomePage 구성 완료, 로고 이미지 적용, 스크롤 관련 버그들 수정
- Loading branch information
Showing
16 changed files
with
203 additions
and
94 deletions.
There are no files selected for viewing
Binary file not shown.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
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,95 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { FinalDiary } from "../../api/diary"; | ||
import { format } from "date-fns"; | ||
import { ko } from "date-fns/locale"; | ||
import sampleImg from "/Users/minsik/Documents/Projects/A-Neuk-FE/src/assets/images/odocat.png"; | ||
import { getEmotionColor } from "../../utils/GetEmotionColor"; | ||
|
||
interface HomeCardProps { | ||
curDiary: FinalDiary | null; | ||
isFlipped: boolean; | ||
isFlipping: boolean; | ||
setIsFlipped: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
const HomeCard: React.FC<HomeCardProps> = ({ | ||
curDiary, | ||
isFlipped, | ||
isFlipping, | ||
setIsFlipped, | ||
}) => { | ||
const handleCardClick = () => { | ||
setIsFlipped(!isFlipped); | ||
}; | ||
|
||
useEffect(() => { | ||
setIsFlipped(false); | ||
}, [curDiary]); | ||
|
||
const categories = curDiary?.data.emotionList.map( | ||
(emotion) => emotion.category | ||
); | ||
const uniqueCategories = categories | ||
? categories.filter( | ||
(value, index, self) => self.indexOf(value) === index | ||
) | ||
: []; | ||
|
||
if (curDiary === null) { | ||
return ( | ||
<div className="flex flex-1 justify-center items-center"> | ||
<div className="font-pretendard-regular text-xl text-black-aneuk"> | ||
이날은 일기가 없어요~ | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div | ||
className={`group flex flex-col w-[90%] aspect-[2/2.8] mt-[5%] [perspective:1000px] animate-flip cursor-pointer`} | ||
onClick={handleCardClick} | ||
> | ||
<div | ||
className={`relative h-full w-full rounded-[32px] shadow-custom-strong transition-all duration-500 [transform-style:preserve-3d] | ||
${isFlipped ? "[transform:rotateY(-180deg)]" : ""}`} | ||
> | ||
<div | ||
className={`absolute inset-0 flex flex-col w-full h-full p-2 bg-white rounded-[32px] [backface-visibility:hidden]`} | ||
> | ||
<img | ||
src={curDiary.data.imageUrl} | ||
alt="Diary Image" | ||
className="flex flex-col justify-center items-center w-[100%] h-[80%] rounded-[24px] object-cover" | ||
/> | ||
<div className="flex flex-row flex-1 justify-start items-start p-2 space-x-2"> | ||
{uniqueCategories.map((category, index) => ( | ||
<div | ||
key={index} | ||
className={`aspect-square w-6 rounded-full ${getEmotionColor( | ||
category | ||
)}`} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
<div | ||
className={`absolute inset-0 flex flex-col justify-start items-start w-full h-full p-7 bg-white rounded-[32px] [transform:rotateY(-180deg)] [backface-visibility:hidden]`} | ||
> | ||
<div className="font-gowun-bold text-lg text-black-aneuk mb-2"> | ||
{format( | ||
new Date(curDiary.data.date), | ||
"yyyy.MM.dd EEEE", | ||
{ locale: ko } | ||
)} | ||
</div> | ||
<div className="font-gowun-regular text-black-aneuk text-base text-start overflow-y-auto"> | ||
{curDiary.data.content} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HomeCard; |
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
Oops, something went wrong.