({
page,
onNavigate,
onSearch,
savedList,
activeDownloads,
onReorderSaved,
onRemoveSaved,
canGoBack,
onBack,
onShowShortcuts,
})
| 15 | } from "./Icons"; |
| 16 | |
| 17 | export default function Sidebar({ |
| 18 | page, |
| 19 | onNavigate, |
| 20 | onSearch, |
| 21 | savedList, |
| 22 | activeDownloads, |
| 23 | onReorderSaved, |
| 24 | onRemoveSaved, |
| 25 | canGoBack, |
| 26 | onBack, |
| 27 | onShowShortcuts, |
| 28 | }) { |
| 29 | const [dragOver, setDragOver] = useState(null); |
| 30 | const dragItem = useRef(null); |
| 31 | const dragNode = useRef(null); |
| 32 | const seasonalEvent = useSeasonalEvent(); |
| 33 | |
| 34 | const [tooltip, setTooltip] = useState(null); // { title, y } |
| 35 | const [contextMenu, setContextMenu] = useState(null); // { item, x, y } |
| 36 | |
| 37 | useEffect(() => { |
| 38 | const close = () => setContextMenu(null); |
| 39 | window.addEventListener("click", close); |
| 40 | window.addEventListener("contextmenu", close); |
| 41 | return () => { |
| 42 | window.removeEventListener("click", close); |
| 43 | window.removeEventListener("contextmenu", close); |
| 44 | }; |
| 45 | }, []); |
| 46 | |
| 47 | const handleContextMenu = (e, item) => { |
| 48 | e.preventDefault(); |
| 49 | e.stopPropagation(); |
| 50 | setTooltip(null); |
| 51 | setContextMenu({ item, x: e.clientX, y: e.clientY }); |
| 52 | }; |
| 53 | |
| 54 | const handleDragStart = (e, index) => { |
| 55 | dragItem.current = index; |
| 56 | dragNode.current = e.currentTarget; |
| 57 | setTimeout(() => { |
| 58 | if (dragNode.current) dragNode.current.style.opacity = "0.4"; |
| 59 | }, 0); |
| 60 | e.dataTransfer.effectAllowed = "move"; |
| 61 | }; |
| 62 | |
| 63 | const handleDragEnd = () => { |
| 64 | if (dragNode.current) dragNode.current.style.opacity = "1"; |
| 65 | dragItem.current = null; |
| 66 | dragNode.current = null; |
| 67 | setDragOver(null); |
| 68 | }; |
| 69 | |
| 70 | const handleDragEnter = (e, index) => { |
| 71 | if (dragItem.current === index) return; |
| 72 | setDragOver(index); |
| 73 | }; |
| 74 |
nothing calls this directly
no test coverage detected