-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathAddLinkInput.tsx
60 lines (53 loc) · 1.89 KB
/
AddLinkInput.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React, { ChangeEvent, forwardRef, useState } from "react";
import styles from "./addLinkInput.module.css";
import useModal from "@/hooks/useModal";
import linkIcon from "@/public/icons/link.svg";
import { FolderName } from "@/types/types";
import Image from "next/image";
interface AddLinkInputProps {
folders: FolderName[];
}
const AddLinkInput = forwardRef<HTMLDivElement, AddLinkInputProps>(
({ folders }: AddLinkInputProps, ref) => {
const [url, setUrl] = useState("");
const { open, close, Dialog, isModalOpen } = useModal();
const handleInputValue = (e: ChangeEvent<HTMLInputElement>) => {
setUrl(e.target.value);
};
return (
<div className={styles.wrapper} ref={ref}>
<form className={styles.addLinkInputContainer}>
<Image
src={linkIcon}
alt="link-icon"
className={styles.addLinkIcon}
width={24}
height={24}
/>
<input
name="add-link"
placeholder="링크를 추가해 보세요"
className={styles.addLinkInput}
onChange={handleInputValue}
/>
<button type="button" className={styles.addLinkButton} onClick={open}>
추가하기
</button>
<Dialog onClick={close} isModalOpen={isModalOpen}>
<Dialog.Title>폴더에 추가</Dialog.Title>
<Dialog.Link>{url}</Dialog.Link>
{folders?.map((folder) => (
<Dialog.FolderList key={folder.id}>
<span className="dialog-folder-name">{folder.name}</span>
<span className="dialog-folder-count">개 링크</span>
</Dialog.FolderList>
))}
<Dialog.Button isAddButton>추가하기</Dialog.Button>
</Dialog>
</form>
</div>
);
}
);
AddLinkInput.displayName = "AddLinkInput";
export default AddLinkInput;