-
Notifications
You must be signed in to change notification settings - Fork 46
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
[권주현] Week11 #363
The head ref may contain hidden characters: "part2-\uAD8C\uC8FC\uD604-week11"
[권주현] Week11 #363
Changes from all commits
109cbb7
6b6affe
4d0ad60
9699195
b0fece2
d412c83
c19a637
8d4d9cf
bec021d
a9d870b
8895927
6ea9077
b46ea0f
9e28bd0
73821a0
cc0a6da
e2c0b25
49b8898
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.background { | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0, 0, 0, 0.4); | ||
z-index: 1000; | ||
top: 0; | ||
left: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
position: fixed; | ||
} | ||
|
||
.container { | ||
padding: 28px; | ||
background-color: var(--white); | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: 8px; | ||
border-radius: 15px; | ||
position: relative; | ||
} | ||
|
||
.exitButton { | ||
width: 24px; | ||
height: 24px; | ||
position: absolute; | ||
right: 16px; | ||
top: 16px; | ||
border: none; | ||
border-radius: 9999px; | ||
background-color: var(--gray-400); | ||
color: var(--gray-600); | ||
cursor: pointer; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
.formContainer { | ||
width: 280px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
margin-top: 10px; | ||
} | ||
|
||
.formInput { | ||
width: 100%; | ||
padding: 15px 18px; | ||
border: 1px solid var(--primary); | ||
border-radius: 10px; | ||
color: var(--black); | ||
font-size: 16px; | ||
font-weight: 400; | ||
} | ||
|
||
.formButton { | ||
width: 100%; | ||
padding: 16px 20px; | ||
border-radius: 10px; | ||
border: none; | ||
background: var(--primary-gradient); | ||
font-size: 16px; | ||
font-weight: 600; | ||
color: var(--white); | ||
} | ||
|
||
.redBackground { | ||
background: none; | ||
background-color: var(--red); | ||
} | ||
|
||
.shareBox { | ||
width: 280px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 32px; | ||
margin-top: 10px; | ||
} | ||
|
||
.shareButtonWrapper { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: 10px; | ||
font-size: 13px; | ||
font-weight: 400; | ||
color: var(--black); | ||
} | ||
|
||
.shareButton { | ||
background: none; | ||
border: none; | ||
border-radius: 100%; | ||
} | ||
|
||
.title { | ||
font-size: 20px; | ||
font-weight: 700; | ||
color: var(--black); | ||
} | ||
|
||
.subTitle { | ||
font-size: 14px; | ||
font-weight: 400; | ||
color: var(--gray-600); | ||
} | ||
|
||
.inputList { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
} | ||
|
||
.inputList button { | ||
width: 100%; | ||
text-align: left; | ||
font-size: 16px; | ||
font-weight: 400; | ||
background-color: transparent; | ||
border: none; | ||
border-radius: 8px; | ||
padding: 6px 15px; | ||
} | ||
|
||
.inputList button:active { | ||
background-color: var(--gray-400); | ||
color: var(--primary); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import styles from "./Modal.module.css"; | ||
|
||
function Modal({ children, onClick }) { | ||
return ( | ||
<div className={styles.background}> | ||
<div className={styles.container}> | ||
{children} | ||
<button className={styles.exitButton} onClick={onClick}> | ||
X | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Modal; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import styles from "../../../../../../globalComponents/Modal/ModalChildren.module.css"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 폴더구조가 맥락별로 깔끔하게 바뀌었지만, 그 깊이가 어마어마해졌습니다 ㅋㅋㅋㅋㅋ 자주 있는 일인데요, TypeScript의 alias로 해결할 수 있습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사실 저도 PR올리면서 이게 맞나 싶었는데 다음 과제가 프로젝트를 ts로 변경하는거여서 아래의 내용도 다 포함해서 리팩토링하고 다음 PR엔 깔끔하게 보이도록 하겠습니다.🥲 |
||
|
||
function LinkAddToFolderForm() { | ||
return ( | ||
<> | ||
<h1 className={styles.title}>폴더에 추가</h1> | ||
<h2 className={styles.subTitle}>링크 주소</h2> | ||
<form className={styles.formContainer}> | ||
<ul className={styles.inputList}> | ||
<li> | ||
<button>코딩 팁</button> | ||
</li> | ||
<li> | ||
<button>채용 사이트</button> | ||
</li> | ||
<li> | ||
<button>유용한 글</button> | ||
</li> | ||
<li> | ||
<button>나만의 장소</button> | ||
</li> | ||
</ul> | ||
<button className={styles.formButton}>추가하기</button> | ||
</form> | ||
</> | ||
); | ||
} | ||
|
||
export default LinkAddToFolderForm; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import styles from "../../../../../../globalComponents/Modal/ModalChildren.module.css"; | ||
|
||
function LinkDeleteForm() { | ||
return ( | ||
<> | ||
<h1 className={styles.title}>링크 삭제</h1> | ||
<h2 className={styles.subTitle}>url</h2> | ||
<form className={styles.formContainer}> | ||
<button className={`${styles.formButton} ${styles.redBackground}`}> | ||
삭제하기 | ||
</button> | ||
</form> | ||
</> | ||
); | ||
} | ||
|
||
export default LinkDeleteForm; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { useState } from "react"; | ||
import { | ||
displayCreatedTime, | ||
formatDateString, | ||
} from "../../../../utils/dateUtils"; | ||
import defaultImage from "../../../../assets/card-default.png"; | ||
import kebab from "../../../../assets/kebab.svg"; | ||
import styles from "../../../LinkCard.module.css"; | ||
import { FaRegStar } from "react-icons/fa"; | ||
import Modal from "../../../../globalComponents/Modal"; | ||
import LinkAddToFolderForm from "./components/LinkAddToFolderForm"; | ||
import LinkDeleteForm from "./components/LinkDeleteForm"; | ||
|
||
function FolderLinkCard({ link }) { | ||
const [onModal, setOnModal] = useState(false); | ||
const [modalContent, setModalContent] = useState(null); | ||
|
||
const handleClickModal = (actionType) => { | ||
const actionTypes = { | ||
deleteLink: <LinkDeleteForm />, | ||
addLink: <LinkAddToFolderForm />, | ||
}; | ||
|
||
setModalContent(actionTypes[actionType]); | ||
setOnModal(true); | ||
}; | ||
Comment on lines
+15
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modal을 띄워주는 state와 Modal의 내용을 정해주는 state가 따로있네요. 하나만 있어도 될 것 같은데 줄여볼 수 있지 않을까요? |
||
|
||
const { url, description, title, created_at, image_source } = link; | ||
|
||
const createdTime = displayCreatedTime(created_at); | ||
const createdAtFormat = formatDateString(created_at); | ||
|
||
const src = image_source || defaultImage; | ||
|
||
const handleToggleDropDown = (e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
|
||
const button = e.currentTarget; | ||
const linkInfo = button.closest(`.${styles.linkInfo}`); | ||
const dropdown = linkInfo.querySelector(`.${styles.dropdown}`); | ||
dropdown.classList.toggle(styles.hidden); | ||
}; | ||
|
||
return ( | ||
<div className={styles.linkContainer}> | ||
<a href={url} target="_blank" rel="noreferrer"> | ||
<div className={styles.imageWrapper}> | ||
<img className={styles.linkImage} src={src} alt={title} /> | ||
<FaRegStar className={styles.starIcon} /> | ||
</div> | ||
</a> | ||
<div className={styles.linkInfo}> | ||
<div className={styles.linkInfoContent}> | ||
<div>{createdTime}</div> | ||
<button onClick={handleToggleDropDown} className={styles.kebabButton}> | ||
<img src={kebab} alt="menu" /> | ||
</button> | ||
</div> | ||
<div className={styles.linkInfoContent}>{description}</div> | ||
<div className={styles.linkInfoContent}>{createdAtFormat}</div> | ||
<div className={`${styles.dropdown} ${styles.hidden}`}> | ||
<button onClick={() => handleClickModal("deleteLink")}> | ||
삭제하기 | ||
</button> | ||
<button onClick={() => handleClickModal("addLink")}> | ||
폴더에 추가 | ||
</button> | ||
</div> | ||
</div> | ||
{onModal && ( | ||
<Modal onClick={() => setOnModal(false)}>{modalContent}</Modal> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default FolderLinkCard; |
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.
DeleteModal, xxModal 등 여러 Modal이 있는데, 이 Modal 컴포넌트는 전혀 사용되지 않고 있네요.
Modal 컴포넌트 자체가 좀 더 확장성이 있어서 다른 구체화된 Modal 들의 수고를 덜어 줄 수 있지 않을까요?
확장을 위한 prop을 몇개 더 추가해줄 수도 있고, children에 구체화된 컴포넌트를 넣을 수도 있을 것 같네요.