-
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.
* feat : 올바른 페이지로 가도록 naviagate * chore : 편지 상세 보기 수정 * chore : router 수정 * chroe : api 에러처리 수정 * chore : 페이지 수정 * chore : 스토리지 페이지 스타일 변경 * style : style 수정
- Loading branch information
Showing
9 changed files
with
210 additions
and
172 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
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,42 @@ | ||
import { Margin } from '@/components/Common/Margin/Margin'; | ||
import React, { useState } from 'react'; | ||
import { IoIosArrowDown, IoIosArrowUp } from 'react-icons/io'; | ||
type KeywordListProps = { | ||
keywords: string[]; | ||
}; | ||
|
||
export const KeywordList = ({ keywords }: KeywordListProps) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const onClick = () => { | ||
setIsOpen((prev) => !prev); | ||
}; | ||
return ( | ||
<> | ||
{keywords.length > 0 && ( | ||
<p | ||
className={`flex flex-wrap ${isOpen ? '' : 'max-w-[550px] overflow-hidden'}`} | ||
> | ||
{keywords | ||
.slice(0, isOpen ? keywords.length : 4) | ||
.map((keyword, index) => ( | ||
<span key={index} className="keyword-tag key"> | ||
{keyword} | ||
</span> | ||
))} | ||
{!isOpen && keywords.length > 4 && ( | ||
<button className="flex items-center" onClick={onClick}> | ||
<span className="text-4xl">...</span> | ||
<IoIosArrowDown className="text-3xl " /> | ||
</button> | ||
)} | ||
{isOpen && keywords.length > 4 && ( | ||
<button className="flex items-center" onClick={onClick}> | ||
<IoIosArrowUp className="text-3xl " /> | ||
</button> | ||
)} | ||
</p> | ||
)} | ||
</> | ||
); | ||
}; |
83 changes: 29 additions & 54 deletions
83
src/components/LetterDetailPage/LetterDatail/KeywordLetterDetail.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 |
---|---|---|
@@ -1,72 +1,47 @@ | ||
import { useState } from 'react'; | ||
import { IoIosArrowDown, IoIosArrowUp } from 'react-icons/io'; | ||
import { formatDate } from '@/util/formatDate'; | ||
import { TextArea } from '@/components/Common/TextArea/TextArea'; | ||
import { Margin } from '@/components/Common/Margin/Margin'; | ||
import { KeywordList } from '../Keyword/KeywordList'; | ||
import { DeleteButton } from '../Delete/DeleteButton'; | ||
import clsx from 'clsx'; | ||
|
||
type KeywordLetterDetailProps = { | ||
letterData: { | ||
letterId: number; | ||
title: string; | ||
content: string; | ||
keywords: string[]; | ||
createdAt: string; | ||
font: string; | ||
}; | ||
}; | ||
|
||
export const KeywordLetterDetail = ({ | ||
letterData | ||
}: KeywordLetterDetailProps) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const onClick = () => { | ||
setIsOpen((prev) => !prev); | ||
}; | ||
const { title, content, keywords, createdAt } = letterData; | ||
const { letterId, title, content, keywords, createdAt, font } = letterData; | ||
return ( | ||
<> | ||
<p className="absolute left-24 top-[15rem]">{title}</p> | ||
<p className="absolute left-24 top-[19rem]">{content}</p> | ||
<div className="absolute bottom-16 w-[580px] h-[100px]"> | ||
{keywords.length > 0 && ( | ||
<> | ||
<p className="font-bold m-4">편지의 키워드</p> | ||
<div className="m-4"> | ||
<p | ||
className={`flex flex-wrap ${isOpen ? '' : 'max-w-[550px] overflow-hidden'}`} | ||
> | ||
{keywords | ||
.slice(0, isOpen ? keywords.length : 4) | ||
.map((keyword, index) => ( | ||
<span | ||
key={index} | ||
className="mr-2 mb-2 keyword-tag" | ||
> | ||
{keyword} | ||
</span> | ||
))} | ||
{!isOpen && keywords.length > 4 && ( | ||
<button | ||
className="flex items-center" | ||
onClick={onClick} | ||
> | ||
<span className="text-4xl">...</span> | ||
<IoIosArrowDown className="text-3xl mr-2" /> | ||
</button> | ||
)} | ||
{isOpen && keywords.length > 4 && ( | ||
<button | ||
className="flex items-center" | ||
onClick={onClick} | ||
> | ||
<IoIosArrowUp className="text-3xl mr-2" /> | ||
</button> | ||
)} | ||
</p> | ||
</div> | ||
</> | ||
)} | ||
</div> | ||
<div className="absolute bottom-8 translate-x-60 flex-col"> | ||
<p className="ml-2">{formatDate(createdAt)}</p> | ||
<div className={clsx(font ? font : 'font-sans')}> | ||
<Margin top={20} /> | ||
<div className="relative z-20 flex flex-col justify-center w-9/12 m-auto py-9"> | ||
<div className="absolute top-0 right-0"> | ||
<DeleteButton id={String(letterId)} /> | ||
</div> | ||
<h1>{title}</h1> | ||
<img src={'/to_line.f4c129e6.svg'} className="w-full" /> | ||
|
||
<div className="relative"> | ||
<TextArea value={content} font={font} isReadonly={true} /> | ||
</div> | ||
|
||
<Margin top={30} /> | ||
<div className="flex justify-between w-full "> | ||
<p className="font-bold ">편지의 키워드</p> | ||
<p className="">{formatDate(createdAt)}</p> | ||
</div> | ||
<KeywordList keywords={keywords} /> | ||
<Margin bottom={30} /> | ||
</div> | ||
</> | ||
</div> | ||
); | ||
}; |
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.