()
| 490 | projectPath: string; |
| 491 | } |
| 492 | const ProjectDragLayer: React.FC = () => { |
| 493 | const dragState = useDragLayer<{ |
| 494 | isDragging: boolean; |
| 495 | item: unknown; |
| 496 | currentOffset: { x: number; y: number } | null; |
| 497 | }>((monitor) => ({ |
| 498 | isDragging: monitor.isDragging(), |
| 499 | item: monitor.getItem(), |
| 500 | currentOffset: monitor.getClientOffset(), |
| 501 | })); |
| 502 | const isDragging = dragState.isDragging; |
| 503 | const item = dragState.item as ProjectDragItem | null; |
| 504 | const currentOffset = dragState.currentOffset; |
| 505 | |
| 506 | React.useEffect(() => { |
| 507 | if (!isDragging) return; |
| 508 | const originalBody = document.body.style.cursor; |
| 509 | const originalHtml = document.documentElement.style.cursor; |
| 510 | document.body.style.cursor = "grabbing"; |
| 511 | document.documentElement.style.cursor = "grabbing"; |
| 512 | return () => { |
| 513 | document.body.style.cursor = originalBody; |
| 514 | document.documentElement.style.cursor = originalHtml; |
| 515 | }; |
| 516 | }, [isDragging]); |
| 517 | |
| 518 | if (!isDragging || !currentOffset || !item?.projectPath || item.type !== "PROJECT") return null; |
| 519 | |
| 520 | const abbrevPath = PlatformPaths.abbreviate(item.projectPath); |
| 521 | const { basename } = PlatformPaths.splitAbbreviated(abbrevPath); |
| 522 | |
| 523 | return ( |
| 524 | <div className="pointer-events-none fixed inset-0 z-9999 cursor-grabbing"> |
| 525 | <div style={{ transform: `translate(${currentOffset.x + 10}px, ${currentOffset.y + 10}px)` }}> |
| 526 | <div className={cn(PROJECT_ITEM_BASE_CLASS, "w-fit max-w-64 rounded-sm shadow-lg")}> |
| 527 | <span className="text-secondary mr-2 flex h-5 w-5 shrink-0 items-center justify-center"> |
| 528 | <ChevronRight className="h-4 w-4" /> |
| 529 | </span> |
| 530 | <div className="flex min-w-0 flex-1 items-center pr-2"> |
| 531 | <span className="text-foreground truncate text-sm font-medium">{basename}</span> |
| 532 | </div> |
| 533 | </div> |
| 534 | </div> |
| 535 | </div> |
| 536 | ); |
| 537 | }; |
| 538 | |
| 539 | /** |
| 540 | * Handles F2 (edit title) and Shift+F2 (generate new title) keybinds. |
nothing calls this directly
no test coverage detected