Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions components/modal/AddFolderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ModalContainer from "./modalComponents/ModalContainer";
import ModalInput from "./modalComponents/ModalInput";
import { postFolders } from "@/lib/api/folder";
import useModalStore from "@/store/useModalStore";
import SubmitButton from "../SubMitButton";

const AddFolderModal = ({ folderName }: { folderName: string }) => {
const [value, setValue] = useState("");
Expand All @@ -27,17 +28,22 @@ const AddFolderModal = ({ folderName }: { folderName: string }) => {
closeModal();
};
return (
<ModalContainer
title="폴더 추가"
buttonText="추가하기"
onClick={handleSubmit}
>
<ModalContainer title="폴더 추가">
<ModalInput
placeholder="내용 입력"
name={folderName}
value={value}
onChange={handleChange}
/>
<SubmitButton
type="button"
onClick={handleSubmit}
width="w-full"
height="h-[51px] "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사소한거긴 한데 height="h-[51px] " 에 공백이 있습니당! tailwind css 는 공백이 있을 경우 안먹을 수도 있다네욧

Copy link
Collaborator Author

@hongggyelim hongggyelim Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 감사합니다 수정해써요~!

color="positive"
>
추가하기
</SubmitButton>
</ModalContainer>
);
};
Expand Down
18 changes: 12 additions & 6 deletions components/modal/AddModal.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { FolderItemType } from "@/types/modalTypes";
import FolderList from "./modalComponents/FolderList";
import ModalContainer from "./modalComponents/ModalContainer";
import SubmitButton from "../SubMitButton";

const AddModal = ({ list }: { list: FolderItemType[] }) => {
const AddModal = ({ list, link }: { list: FolderItemType[]; link: string }) => {
return (
<ModalContainer
title="폴더에 추가"
subtitle="링크 주소"
buttonText="추가하기"
>
<ModalContainer title="폴더에 추가" subtitle={link}>
<FolderList list={list} />
<SubmitButton
type="button"
// onClick={handleSubmit}
width="w-full"
height="h-[51px] "
color="positive"
>
추가하기
</SubmitButton>
</ModalContainer>
);
};
Expand Down
18 changes: 12 additions & 6 deletions components/modal/DeleteFolderModal.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import SubmitButton from "../SubMitButton";
import ModalContainer from "./modalComponents/ModalContainer";

const DeleteFolderModal = ({ folderName }: { folderName: string }) => {
return (
<ModalContainer
title="폴더 삭제"
subtitle={folderName}
buttonText="삭제하기"
buttonColor="negative"
></ModalContainer>
<ModalContainer title="폴더 삭제" subtitle={folderName}>
<SubmitButton
type="button"
// onClick={handleSubmit}
width="w-full"
height="h-[51px] "
color="negative"
>
삭제하기
</SubmitButton>
</ModalContainer>
);
};
export default DeleteFolderModal;
19 changes: 13 additions & 6 deletions components/modal/DeleteLinkModal.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import SubmitButton from "../SubMitButton";
import ModalContainer from "./modalComponents/ModalContainer";

const DeleteLinkModal = ({ link }: { link: string }) => {
return (
<ModalContainer
title="링크 삭제"
subtitle={link}
buttonText="삭제하기"
buttonColor="negative"
></ModalContainer>
<ModalContainer title="링크 삭제" subtitle={link}>
{" "}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

불필요한 코드일까요? ㅎㅎ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헛 그렇네요 삭제했습니다 ㅎㅎ

<SubmitButton
type="button"
// onClick={handleSubmit}
width="w-full"
height="h-[51px] "
color="negative"
>
삭제하기
</SubmitButton>
</ModalContainer>
);
};
export default DeleteLinkModal;
16 changes: 11 additions & 5 deletions components/modal/EditModal.tsx
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상태관리를 용이하게 하기위해 버튼 컴포넌트를 ModalContainer에서 분리했습니다

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ModalContainer from "./modalComponents/ModalContainer";
import ModalInput from "./modalComponents/ModalInput";
import useModalStore from "@/store/useModalStore";
import { putFolder } from "@/lib/api/folder";
import SubmitButton from "../SubMitButton";

const EditModal = ({ folderName }: { folderName: string }) => {
const [value, setValue] = useState("");
Expand All @@ -29,17 +30,22 @@ const EditModal = ({ folderName }: { folderName: string }) => {
closeModal();
};
return (
<ModalContainer
title="폴더 이름 변경"
buttonText="변경하기"
onClick={handleSubmit}
>
<ModalContainer title="폴더 이름 변경">
<ModalInput
placeholder="내용 입력"
name={folderName}
value={value}
onChange={handleChange}
/>
<SubmitButton
type="button"
// onClick={handleSubmit}
width="w-full"
height="h-[51px] "
color="positive"
>
변경하기
</SubmitButton>
</ModalContainer>
);
};
Expand Down
46 changes: 46 additions & 0 deletions components/modal/modalComponents/FolderItemRadio.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { bindCls } from "@/lib/utils";
import { FolderItemType } from "@/types/modalTypes";
import { useState } from "react";
import { FaCheck } from "react-icons/fa6";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수명은 줄이지 않고 FaviconCheck 라고 하는게 전 더 직관적인 것 같아요~
다른 애들도 안 줄였으니 통일성도 좋고요!
위에도 마찬가지로 bindClass 이런식으로요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FaCheck 은 react-icon에서 지원하는 svg 컴포넌트 입니다!
cls 는 다음번에 참고하겠습니다


const FolderItemRadio = ({
item,
isSelected,
}: {
item: FolderItemType;
isSelected: boolean;
}) => {
// const bgColor = selected ? "bg-gray100" : "bg-white";

const { name, linkCount, id } = item;

const onClickFolder = () => {
// setSelected(!selected);
};
return (
<li
className={bindCls(
// bgColor,
"w-full p-2 flex h-10 rounded-lg items-center justify-between cursor-pointer"
)}
onClick={onClickFolder}
>
<div className="flex items-center gap-2">
<input
value={name}
type="radio"
className="opacity-0"
id={String(id)}
/>
<label htmlFor={String(id)}>{name}</label>
<div className="text-gray400 text-sm">{linkCount}개 링크</div>
</div>
{/* {selected && ( */}
<div>
<FaCheck className="text-purple100" />
</div>
{/* )} */}
</li>
);
};
export default FolderItemRadio;
9 changes: 7 additions & 2 deletions components/modal/modalComponents/FolderList.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { FolderItemType } from "@/types/modalTypes";
import FolderItem from "./FolderItem";
import FolderItemRadio from "./FolderItemRadio";
import { useState } from "react";

const FolderList = ({ list }: { list: FolderItemType[] | undefined }) => {
const [isSelected, setIsSelected] = useState(false);
const [selectedId, setSelectedId] = useState<number[]>();
return (
<ul className="mb-6 flex flex-col gap-1 w-full">
{list?.map((item) => <FolderItem key={item.id} item={item} />)}
{list?.map((item) => (
<FolderItemRadio key={item.id} item={item} isSelected={isSelected} />
))}
</ul>
);
};
Expand Down
24 changes: 2 additions & 22 deletions components/modal/modalComponents/ModalContainer.tsx
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModalContainer내부에 있던 버튼 컴포넌트를 children으로 받도록 하면서 버튼 관련 prop 제거했습니다

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ import { ModalPropType } from "@/types/modalTypes";
import useModalStore from "@/store/useModalStore";
import { MouseEvent, useRef } from "react";

const ModalContainer = ({
title,
subtitle,
children,
buttonText,
buttonColor,
onClick,
}: ModalPropType) => {
const ModalContainer = ({ title, subtitle, children }: ModalPropType) => {
const { closeModal } = useModalStore();
const modalRef = useRef<HTMLDivElement | null>(null);
const onClickBackDrop = (e: MouseEvent<HTMLDivElement>) => {
Expand Down Expand Up @@ -41,22 +34,9 @@ const ModalContainer = ({
</div>
)}
</div>
{/* children -> inpul, sns공유, folder list 등.. */}
{/* children -> input, sns공유, folder list 등.. */}
<div className="flex justify-center items-center flex-col">
{children && <>{children}</>}

{/* 제출 버튼 */}
{buttonText && (
<SubmitButton
type="button"
onClick={onClick}
width="w-full"
height="h-[51px] "
color={buttonColor}
>
{buttonText}
</SubmitButton>
)}
</div>

{/* 모달 닫기 버튼 */}
Expand Down
1 change: 1 addition & 0 deletions components/modal/modalManager/ModalManager.tsx
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기본 값을 수정했습니다 (단순 참고용)

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const Modal = () => {
{ id: 4, name: "나만의 장소", linkCount: 7, createAt: "" },
]
}
link={props.link || ""}
/>
);
case "DeleteFolderModal":
Expand Down
3 changes: 0 additions & 3 deletions types/modalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ export interface ModalPropType {
title?: string;
subtitle?: string;
children?: ReactNode;
buttonText?: string;
buttonColor?: "positive" | "negative";
onClick?: () => void;
folderName?: string;
list?: FolderItemType[];
link?: string;
Expand Down