@@ -193,39 +193,40 @@ interface CursorProps {
193193 connection: ClientConnection
194194}
195195
196- export const Cursor = forwardRef <HTMLDivElement , CursorProps >(
197- function Cursor({ connection }, ref ) {
198- const hash = new ColorHash ({ lightness: 0.3 })
199- const color = hash .hex (connection .username )
200-
201- return (
202- <div
203- ref = { ref }
204- className = { clsx (
205- " fixed flex translate-x-[--x] translate-y-[--y] gap-1 rounded text-xs" ,
206- // If we don't have any initial coordinates for the user, hide this
207- // cursor. This happens when a new client first connects.
208- connection .coords .x ? " visible" : " invisible" ,
209- )}
210- style = {
211- {
212- " --x" : ` ${connection .coords .x }vw ` ,
213- " --y" : ` ${connection .coords .y }vh ` ,
214- } as React .CSSProperties
215- }
196+ export const Cursor = forwardRef <HTMLDivElement , CursorProps >(function Cursor(
197+ { connection },
198+ ref ,
199+ ) {
200+ const hash = new ColorHash ({ lightness: 0.3 })
201+ const color = hash .hex (connection .username )
202+
203+ return (
204+ <div
205+ ref = { ref }
206+ className = { clsx (
207+ " fixed flex translate-x-[--x] translate-y-[--y] gap-1 rounded text-xs" ,
208+ // If we don't have any initial coordinates for the user, hide this
209+ // cursor. This happens when a new client first connects.
210+ connection .coords .x ? " visible" : " invisible" ,
211+ )}
212+ style = {
213+ {
214+ " --x" : ` ${connection .coords .x }vw ` ,
215+ " --y" : ` ${connection .coords .y }vh ` ,
216+ } as React .CSSProperties
217+ }
218+ >
219+ <Arrow color = { color } />
220+
221+ <span
222+ className = " relative -left-1.5 top-4 rounded-sm px-1.5 py-0.5 text-white"
223+ style = { { backgroundColor: color }}
216224 >
217- <Arrow color = { color } />
218-
219- <span
220- className = " relative -left-1.5 top-4 rounded-sm px-1.5 py-0.5 text-white"
221- style = { { backgroundColor: color }}
222- >
223- { connection .username }
224- </span >
225- </div >
226- )
227- },
228- )
225+ { connection .username }
226+ </span >
227+ </div >
228+ )
229+ })
229230```
230231
231232Now that we can display a single cursor, it's time to display them all!
0 commit comments