@@ -13,6 +13,7 @@ import { Handle, NodeProps, NodeResizer, Position, useConnection } from "@xyflow
1313
1414import ContentSticker from "./content-sticker" ;
1515import TopicSticker from "./topic-sticker" ;
16+ import UserSticker from "./user-sticker" ;
1617
1718interface CustomNodeProps extends NodeProps {
1819 topicId : string ;
@@ -21,13 +22,14 @@ interface CustomNodeProps extends NodeProps {
2122}
2223
2324interface NodeData {
24- nodeContent : "topic" | "content" ;
25+ nodeContent : "topic" | "content" | "sticker" ;
2526 item : TopicDTO | CategoryContentDTO ;
2627}
2728
2829const stickerStyle = {
2930 topic : "from-primary bg-gradient-to-br to-blue-600 text-white" ,
3031 content : "bg-card hover:border-primary border-border border" ,
32+ sticker : "bg-yellow-50 border-yellow-300 border hover:border-yellow-400" ,
3133} ;
3234
3335export default function CustomNode ( props : CustomNodeProps ) {
@@ -45,7 +47,6 @@ export default function CustomNode(props: CustomNodeProps) {
4547
4648 const isTarget = connection . inProgress && connection . fromNode . id !== props . id ;
4749 const isSource = connection . inProgress && connection . fromNode . id === props . id ;
48- const isTopic = nodeData . nodeContent === "topic" ;
4950
5051 const stickerClass = stickerStyle [ nodeData . nodeContent ] ;
5152
@@ -59,13 +60,21 @@ export default function CustomNode(props: CustomNodeProps) {
5960 posY : debouncedProps . positionAbsoluteY ,
6061 } ;
6162 const updatePosition = async ( ) => {
62- if ( isTopic ) {
63- await updateTopicPosition ( body ) ;
64- } else {
65- await updateContentPosition ( {
66- ...body ,
67- contentId : nodeData . item . id ,
68- } ) ;
63+ switch ( nodeData . nodeContent ) {
64+ case "topic" :
65+ await updateTopicPosition ( body ) ;
66+ break ;
67+ case "content" :
68+ await updateContentPosition ( {
69+ ...body ,
70+ contentId : nodeData . item . id ,
71+ } ) ;
72+ break ;
73+ case "sticker" :
74+ // TODO: 스티커 위치 변경 시 호출
75+ break ;
76+ default :
77+ return ;
6978 }
7079 } ;
7180 updatePosition ( ) ;
@@ -79,13 +88,21 @@ export default function CustomNode(props: CustomNodeProps) {
7988 height : debouncedProps . height ?? 220 ,
8089 } ;
8190 const updateSize = async ( ) => {
82- if ( isTopic ) {
83- await updateTopicSize ( body ) ;
84- } else {
85- await updateContentSize ( {
86- ...body ,
87- contentId : nodeData . item . id ,
88- } ) ;
91+ switch ( nodeData . nodeContent ) {
92+ case "topic" :
93+ await updateTopicSize ( body ) ;
94+ break ;
95+ case "content" :
96+ await updateContentSize ( {
97+ ...body ,
98+ contentId : nodeData . item . id ,
99+ } ) ;
100+ break ;
101+ case "sticker" :
102+ // TODO: 스티커 크기 변경 시 호출
103+ break ;
104+ default :
105+ return ;
89106 }
90107 } ;
91108 updateSize ( ) ;
@@ -178,14 +195,16 @@ export default function CustomNode(props: CustomNodeProps) {
178195 </ >
179196 ) }
180197
181- { isTopic ? (
198+ { nodeData . nodeContent === "topic" ? (
182199 < TopicSticker item = { nodeData . item as TopicDTO } />
183- ) : (
200+ ) : nodeData . nodeContent === "content" ? (
184201 < ContentSticker
185202 item = { nodeData . item as CategoryContentDTO }
186203 isSelected = { props . isSelected }
187204 onSelect = { props . onSelect }
188205 />
206+ ) : (
207+ < UserSticker item = { nodeData . item as TopicDTO } />
189208 ) }
190209 </ div >
191210 ) ;
0 commit comments