Skip to content

Commit d268a8e

Browse files
committed
feat: 커서를 렌더링하는 컴포넌트 구현
1 parent f716647 commit d268a8e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Panel } from "@xyflow/react";
2+
import { useReactFlow } from "@xyflow/react";
3+
import { type AwarenessState } from "@/hooks/useCursor";
4+
import Cursor from "./cursor";
5+
6+
interface CollaborativeCursorsProps {
7+
cursors: Map<number, AwarenessState>;
8+
}
9+
10+
export function CollaborativeCursors({ cursors }: CollaborativeCursorsProps) {
11+
const { flowToScreenPosition } = useReactFlow();
12+
13+
return (
14+
<Panel position="top-left" className="pointer-events-none">
15+
{Array.from(cursors.values()).map((cursor) => {
16+
if (!cursor.cursor) return null;
17+
18+
const position = flowToScreenPosition({
19+
x: cursor.cursor.x,
20+
y: cursor.cursor.y,
21+
});
22+
23+
return (
24+
<Cursor key={cursor.clientId} coors={position} color={cursor.color} />
25+
);
26+
})}
27+
</Panel>
28+
);
29+
}

0 commit comments

Comments
 (0)