Skip to content

Commit cbf37f3

Browse files
committed
feat: 이모지 placeholder UI 구현
Co-authored-by: 김동준 <[email protected]>
1 parent 5049cef commit cbf37f3

File tree

4 files changed

+58
-22
lines changed

4 files changed

+58
-22
lines changed

apps/frontend/src/components/canvas/NoteNode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import useUserStore from "@/store/useUserStore";
88
import Emoji from "../commons/emoji";
99
import { useEffect, useState } from "react";
1010

11-
export type NoteNodeData = { title: string; id: number; emoji?: string };
11+
export type NoteNodeData = { title: string; id: number; emoji: string };
1212
export type NoteNodeType = Node<NoteNodeData, "note">;
1313

1414
export function NoteNode({ data }: NodeProps<NoteNodeType>) {
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import { cn } from "@/lib/utils";
2+
import { FileText } from "lucide-react";
23
import { Tailwindest } from "tailwindest";
34

45
interface EmojiProps {
5-
emoji: string;
6+
emoji: string | null;
67
width?: Tailwindest["width"];
78
height?: Tailwindest["height"];
89
fontSize?: Tailwindest["fontSize"];
910
}
1011

1112
export default function Emoji({ emoji, width, height, fontSize }: EmojiProps) {
13+
if (!emoji)
14+
return (
15+
<FileText
16+
className={cn("", width, height)}
17+
strokeWidth="1.5px"
18+
color="#91918e"
19+
/>
20+
);
21+
1222
return <div className={cn("", width, height, fontSize)}>{emoji}</div>;
1323
}

apps/frontend/src/components/editor/EditorTitle.tsx

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Emoji from "@/components/commons/emoji";
77
import useYDocStore from "@/store/useYDocStore";
88
import { useYText } from "@/hooks/useYText";
99
import { useOptimisticUpdatePage } from "@/hooks/usePages";
10+
import { cn } from "@/lib/utils";
1011

1112
interface EditorTitleProps {
1213
currentPage: number;
@@ -44,11 +45,11 @@ export default function EditorTitle({
4445
});
4546
};
4647

47-
const handleEmojiClick = (emoji: Emoji) => {
48-
setYEmoji(emoji.native);
48+
const handleEmojiClick = ({ native }: Emoji) => {
49+
setYEmoji(native);
4950

5051
optimisticUpdatePageMutation.mutate({
51-
pageData: { title, content: pageContent, emoji: emoji.native },
52+
pageData: { title, content: pageContent, emoji: native },
5253
});
5354

5455
setIsEmojiPickerOpen(false);
@@ -64,21 +65,46 @@ export default function EditorTitle({
6465
setIsEmojiPickerOpen(false);
6566
};
6667

68+
const handleRemoveIconClick = (e: React.MouseEvent) => {
69+
e.stopPropagation();
70+
71+
setYEmoji("");
72+
73+
optimisticUpdatePageMutation.mutate({
74+
pageData: { title, content: pageContent, emoji: "" },
75+
});
76+
77+
setIsEmojiPickerOpen(false);
78+
};
79+
6780
return (
6881
<div className="flex flex-col gap-3">
69-
<div className="relative">
70-
<button onClick={handleTitleEmojiClick}>
71-
<Emoji emoji={emoji} width="w-10" height="h-10" fontSize="text-6xl" />
72-
</button>
73-
<div
74-
className={`top-18 absolute z-50 ${isEmojiPickerOpen ? "block" : "hidden"}`}
75-
>
76-
<Picker
77-
theme="light"
78-
previewPosition="none"
79-
onEmojiSelect={handleEmojiClick}
80-
onClickOutside={handleEmojiOutsideClick}
81-
/>
82+
<div className="group">
83+
<div className={cn("relative duration-200")}>
84+
<button onClick={handleTitleEmojiClick}>
85+
<Emoji
86+
emoji={emoji}
87+
width="w-16"
88+
height="h-16"
89+
fontSize="text-6xl"
90+
/>
91+
</button>
92+
<div
93+
className={`top-18 absolute z-50 ${isEmojiPickerOpen ? "block" : "hidden"}`}
94+
>
95+
<button
96+
onClick={handleRemoveIconClick}
97+
className="absolute -top-8 right-0 z-10 rounded-md bg-neutral-50 p-1 px-2 text-sm hover:bg-neutral-200"
98+
>
99+
Remove
100+
</button>
101+
<Picker
102+
theme="light"
103+
previewPosition="none"
104+
onEmojiSelect={handleEmojiClick}
105+
onClickOutside={handleEmojiOutsideClick}
106+
/>
107+
</div>
82108
</div>
83109
</div>
84110
<input

apps/frontend/src/components/sidebar/NoteList.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ export default function NoteList({ className }: NoteListProps) {
3636
<Button
3737
onClick={() => handleNoteClick(id)}
3838
key={id}
39-
className="group flex flex-row justify-between gap-1 rounded-sm px-3 py-1 hover:bg-neutral-100"
39+
className="group flex flex-row items-center justify-between gap-1 rounded-sm px-3 py-1 hover:bg-neutral-100"
4040
>
41-
{emoji && <Emoji emoji={emoji} />}
42-
<div className="w-full truncate text-start">{title}</div>
41+
<Emoji emoji={emoji} width="w-5" height="h-5" />
42+
<div className="flex-1 truncate text-start">{title}</div>
4343
<span
4444
className="hidden text-neutral-400 transition-colors group-hover:block hover:text-red-500"
4545
onClick={(e) => {
4646
e.stopPropagation();
4747
openModal(id);
4848
}}
4949
>
50-
<Trash2 width={20} height={20} />
50+
<Trash2 width={18} height={18} />
5151
</span>
5252
</Button>
5353
))}

0 commit comments

Comments
 (0)