Skip to content

Commit 802e28d

Browse files
authored
Merge pull request #109 from Ureca-Mini-Project-Team4/feature/comment
FEAT: #108 Comment 수정 및 import react 제거
2 parents 3f86359 + f086842 commit 802e28d

File tree

3 files changed

+55
-7
lines changed

3 files changed

+55
-7
lines changed

react-app/src/components/Comment/Comment.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Profile from '../Profile/Profile';
2+
import { Dropdown } from './Dropdown';
23

34
interface CommentProps {
45
nickname: string | null;
@@ -8,13 +9,18 @@ interface CommentProps {
89
const Comment = ({ nickname, comment }: CommentProps) => {
910
return (
1011
<div className="w-[300px] pt-[5px] pb-[5px] h-auto sm:w-[450px] flex flex-initial rounded-xl sm:rounded-2xl border-solid border-[1px] border-gray-100 items-center">
11-
<div className="flex gap-[10px] pl-3 pr-3 items-center">
12-
<div className="h-full flex items-start">
13-
<Profile nickname={nickname} />
12+
<div className="flex justify-between w-full">
13+
<div className="flex gap-[10px] pl-3 pr-3 items-center">
14+
<div className="h-full flex items-start">
15+
<Profile nickname={nickname} />
16+
</div>
17+
<div className="font-pm flex flex-col gap-[5px]">
18+
<div className="text-[8px] sm:text-[12px] text-gray-600 mt-[5px]">{nickname}</div>
19+
<div className="text-[10px] sm:text-[15px] mb-[5px]">{comment}</div>
20+
</div>
1421
</div>
15-
<div className="font-pm flex flex-col gap-[5px]">
16-
<div className="text-[8px] sm:text-[12px] text-gray-600 mt-[5px]">{nickname}</div>
17-
<div className="text-[10px] sm:text-[15px] mb-[5px]">{comment}</div>
22+
<div className="pr-3 flex items-center">
23+
<Dropdown data={['수정', '삭제']} />
1824
</div>
1925
</div>
2026
</div>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { useEffect, useRef, useState } from 'react';
2+
3+
interface DropdownProps {
4+
data: string[];
5+
}
6+
7+
export const Dropdown = ({ data }: DropdownProps) => {
8+
const [showOptions, setShowOptions] = useState(false);
9+
const selectRef = useRef<HTMLDivElement>(null);
10+
11+
useEffect(() => {
12+
const handleClickOutside = (event: MouseEvent) => {
13+
if (selectRef.current && !selectRef.current.contains(event.target as Node)) {
14+
setShowOptions(false);
15+
}
16+
};
17+
18+
document.addEventListener('mousedown', handleClickOutside);
19+
return () => {
20+
document.removeEventListener('mousedown', handleClickOutside);
21+
};
22+
}, []);
23+
24+
return (
25+
<div ref={selectRef}>
26+
<div className="items-center cursor-pointer" onClick={() => setShowOptions((prev) => !prev)}>
27+
<p className="text-gray-500 text-lg"></p>
28+
</div>
29+
{showOptions && (
30+
<ul className="absolute z-1 flex flex-col bg-white border border-gray-300 rounded-md">
31+
{data.map((item, index) => (
32+
<li
33+
key={index}
34+
className="w-fit font-pm text-xs sm:text-sm pt-1.5 pb-1.5 pl-2 pr-2 text-center text-gray-600 hover:bg-blue-600 hover:text-white cursor-pointer rounded-md transition"
35+
>
36+
{item}
37+
</li>
38+
))}
39+
</ul>
40+
)}
41+
</div>
42+
);
43+
};

react-app/src/components/Winner/Winner.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { WinnerProps } from './Winner.types';
32

43
const Winner = ({ name, question }: WinnerProps) => {

0 commit comments

Comments
 (0)