Skip to content

Commit

Permalink
Feat: 공유 모달 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
juan0444 committed May 5, 2024
1 parent 09fb67c commit 4bcf2ab
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 5 deletions.
Binary file added public/images/modalFacebookIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/modalKakaoIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/modalLinkIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 13 additions & 4 deletions src/components/LinkItems/LinkItems.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import styles from "./LinkItems.module.scss";
import classNames from "classnames/bind";
import { DeleteModal, AddModal } from "../";
import { DeleteModal, AddModal, ShareModal } from "../";
import { SEARCH_ICON, PEN_ICON, WASTEBASKET_ICON } from "./constant";

const cx = classNames.bind(styles);
Expand All @@ -26,11 +26,13 @@ const choiceItems = [

export const LinkItems = ({ folderName }) => {
const [deletemodal, setDeleteModal] = useState(false);
const [addemodal, setAddModal] = useState(false);
const [addModal, setAddModal] = useState(false);
const [shareModal, setShareModal] = useState(false);

const handleClick = (text) => {
text === "삭제" && setDeleteModal(true);
text === "이름 변경" && setAddModal(true);
text === "공유" && setShareModal(true);
};

return (
Expand Down Expand Up @@ -63,13 +65,20 @@ export const LinkItems = ({ folderName }) => {
</DeleteModal>
)}

{addemodal && (
<AddModal modal={addemodal} setModal={setAddModal}>
{addModal && (
<AddModal modal={addModal} setModal={setAddModal}>
<h2>폴더 이름 변경</h2>
<input type="text" placeholder={folderName} />
<button type="button">변경하기</button>
</AddModal>
)}

{shareModal && (
<ShareModal modal={shareModal} setModal={setShareModal}>
<h2>폴더 공유</h2>
<p>{folderName}</p>
</ShareModal>
)}
</div>
);
};
50 changes: 50 additions & 0 deletions src/components/ShareModal/ShareModal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { useEffect, useRef } from "react";
import styles from "./ShareModal.module.scss";
import classNames from "classnames/bind";
import { KAKAO_ICON, FACEBOOK_ICON, LINK_ICON } from "./constant";

const cx = classNames.bind(styles);

export const ShareModal = ({ modal, setModal, children }) => {
const modalRef = useRef(null);

// 모달 영역 밖 클릭 시 닫기
useEffect(() => {
const handleModal = (event) => {
if (modal && !modalRef.current.contains(event.target)) {
setModal(false);
}
};

document.addEventListener("mousedown", handleModal);

return () => {
document.removeEventListener("mousedown", handleModal);
};
}, [modal, setModal, modalRef]);

return (
<div className={cx("container")}>
<div className={cx("content")} ref={modalRef}>
<div className={cx("title")}>{children}</div>

<div className={cx("icon-block")}>
<div className={cx("text")}>
<img src={KAKAO_ICON} alt="카카오톡" />
<p>카카오톡</p>
</div>

<div className={cx("text")}>
<img src={FACEBOOK_ICON} alt="페이스북" />
<p>페이스북</p>
</div>

<div className={cx("text")}>
<img src={LINK_ICON} alt="링크 복사" />
<p>링크 복사</p>
</div>
</div>
</div>
</div>
);
};
81 changes: 81 additions & 0 deletions src/components/ShareModal/ShareModal.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@import "/src/styles/global.scss";

.container {
z-index: 4;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: $modal-gray;
}

.content {
position: absolute;
top: 50%;
left: 50%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
transform: translate(-50%, -50%);
gap: 1.5rem;

padding: 2.2rem 2.5rem;

width: 25rem;
height: 18rem;

border-radius: 0.9375rem;
border: 1px solid $color-gray-light;
background: $color-white;

h2 {
@include font(1.5rem, $color-gray100, 700);
}

button {
display: flex;
width: 100%;
padding: 1rem 1.25rem;
justify-content: center;
align-items: center;
gap: 0.625rem;

border-radius: 0.5rem;
background: $color-red;

@include font(1.2rem, $color-gray-light, 600);
}
}

.title {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
gap: 0.8rem;

@include font(1.2rem, $color-gray60, 400);

p {
width: 20rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-break: break-all;
}
}

.icon-block {
display: flex;
gap: 2.4rem;
}

.text {
display: flex;
flex-direction: column;
gap: 0.5rem;
@include font(1.2rem, $color-gray100, 400);
}
3 changes: 3 additions & 0 deletions src/components/ShareModal/constant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const KAKAO_ICON = "/images/modalKakaoIcon.png";
export const FACEBOOK_ICON = "/images/modalFacebookIcon.png";
export const LINK_ICON = "/images/modalLinkIcon.png";
1 change: 1 addition & 0 deletions src/components/ShareModal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./ShareModal";
3 changes: 2 additions & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export * from "./AddFolderModal";
export * from "./AddModal";
export * from "./DeleteModal";
export * from "./ShareModal";
export * from "./Cards";
export * from "./LinkAddSearchBar";
export * from "./DeleteModal";
export * from "./FolderCards";
export * from "./FolderToolBar";
export * from "./Footer";
Expand Down

0 comments on commit 4bcf2ab

Please sign in to comment.