-
Notifications
You must be signed in to change notification settings - Fork 2
design : 랜덤 편지 페이지 & 편지 상세 페이지 퍼블리싱 #17
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
Changes from 11 commits
1fa63c6
ca28130
98dda5c
eeb8946
2562d7c
6efd0b4
b64bdc3
6e91f8c
e4ca4c7
bb12b73
478e301
d7a75f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,91 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useEffect, useRef, useState } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { twMerge } from 'tailwind-merge'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { CloudIcon, ColorSirenIcon, SnowIcon, ThermostatIcon, WarmIcon } from '@/assets/icons'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| import ReportModal from './ReportModal'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default function LetterDetail({ title, text }: { title: string; text: string }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const FONT = ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const THEME = 'celebrate'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const DEGREES = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| { icon: WarmIcon, title: '따뜻해요' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| { icon: CloudIcon, title: '그럭저럭' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| { icon: SnowIcon, title: '앗! 차가워' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [degreeModalOpen, setDegreeModalOpen] = useState<boolean>(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [reportModalOpen, setReportModalOpen] = useState<boolean>(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| const degreeButtonRef = useRef<HTMLButtonElement>(null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleOutsideClick = (event: MouseEvent) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const target = event.target as Node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!target || degreeButtonRef.current?.contains(target)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| setDegreeModalOpen(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.body.addEventListener('click', handleOutsideClick); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| return () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.body.removeEventListener('click', handleOutsideClick); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, []); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| {reportModalOpen && <ReportModal onClose={() => setReportModalOpen(false)} />} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className={twMerge(`flex grow flex-col gap-3 px-5 pb-7.5`, THEME)}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="absolute top-5 right-5 flex gap-3"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref={degreeButtonRef} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| className="flex items-center justify-center gap-1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| setDegreeModalOpen((cur) => !cur); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <img src={ThermostatIcon} alt="편지 온도 아이콘" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="caption-b text-primary-1">편지 온도</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| setReportModalOpen(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <img src={ColorSirenIcon} alt="신고 아이콘" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| <img src={ColorSirenIcon} alt="신고 아이콘" /> | |
| <SirenOutlinedIcon className="text-primary-1" /> |
이렇게 했을 때의 장점은!! svg 에셋이 줄어든다는 것이지용~~
컬러마다 svg 추출없이 하나의 svg만 뽑아서 색상 변경만 하면 되니까요!
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.
앗차차! 아이콘 크기가 다양할 수 있어서 width랑 height는 반드시 포함시키도록 해놔서..
제가 제안드린 방식대로 하신다면 className에 width랑 height 반드시 넣어주셔야 합니다...ㅎㅎㅎ
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.
오오오 이게 svgr이군요 ㄷㄷㄷㄷ 잘 적용해서 사용해보겠습니당 감사합니다!!!👍👍👍👍👍
Outdated
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.
이것도 아마 <degree.icon /> 이런식으로 사용 가능할거에요!!
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.
svgr 굉장히 좋군요✨✨
Outdated
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.
이것도 취향차이겠지만! 이렇게 하면 return 키워드 사용없이도 가능합니당
| {DEGREES.map((degree, idx) => { | |
| return ( | |
| <button | |
| key={idx} | |
| className="flex items-center justify-start gap-1" | |
| onClick={() => { | |
| console.log(idx); | |
| }} | |
| > | |
| <img src={degree.icon} alt={`${degree.title} 아이콘`} /> {degree.title} | |
| </button> | |
| ); | |
| })} | |
| {DEGREES.map((degree, idx) => ( | |
| <button | |
| key={idx} | |
| className="flex items-center justify-start gap-1" | |
| onClick={() => { | |
| console.log(idx); | |
| }} | |
| > | |
| <img src={degree.icon} alt={`${degree.title} 아이콘`} /> {degree.title} | |
| </button> | |
| ) | |
| )} |
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.
오홍 return 넣는거 귀찮아서 이 방법도 한번 고려해봐야겠습니다!!!
Outdated
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.
focus:outline-none도 전역 스타일로 빼둬서 없애도 될 것 같습니다!
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.
엇 전역으로 만들어주셨군용 바로 제거하겠습니다!!!👍👍👍
Outdated
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.
FONT가 이미 문자열로 들어오는 것 같은데 템플릿 리터럴을 적용하지 않아도 되지 않나 싶습니다!
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.
엇 나중에 상세페이지 데이터를 받을때 저기에 폰트속성이 들어갈 거 같아서 미리 템플릿리터럴로 자리만 만들어 놨습니다!! 주석도 없이 그냥 만들어놨었군요 제가😅
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.
이 친구만 네이밍 방식이 다릅니다!
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.
엇 이걸 캐치해주시다니 ㄷㄷㄷㄷ 수정해놓겠습니다!!