-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/custom menu context #313
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @syrok94 thank you for your efforts on this implementation. I have a few points of feedback:
-
Visual Implementation: The current visual design does not match the desired look. There are some unexpected behaviors, and the component is not responsive. Additionally, the colors do not align with our specifications.
-
Code Reusability: It would be great if you could reuse the existing code for this feature. The necessary section already exists, so please refactor and integrate it into the component.
Thank you for addressing these issues. If you have any questions, feel free to reach out.
useEffect(() => { | ||
setContextMenu({ ...contextMenu, visible: false }); | ||
}, [status]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here drops a warning at build time
const handleMove = async (solve: Solve, currentTab: SolveTab) => { | ||
if (!selectedCube) return; | ||
const updatedCube = await moveSolve({ | ||
solve, | ||
selectedCube, | ||
type: currentTab, | ||
}); | ||
mergeUpdateSelectedCube(updatedCube, cubes); | ||
setStatus(false); | ||
}; | ||
|
||
const handleDelete = async (solve: Solve) => { | ||
if (!selectedCube) return; | ||
const updatedCube = await updateSolve({ | ||
selectedCube: selectedCube, | ||
solveId: solve.id, | ||
type: "DELETE", | ||
}); | ||
mergeUpdateSelectedCube(updatedCube, cubes); | ||
setStatus(false); | ||
}; | ||
|
||
const handleCopyToClipboard = async (text: string) => { | ||
if ("clipboard" in navigator) { | ||
await navigator.clipboard.writeText(text); | ||
} | ||
setStatus(false); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic already exist in source, no need duplicate.
{contextMenu.visible && | ||
contextMenu.solve === displaySolves[index] && ( | ||
<AnimatePresence> | ||
<motion.div | ||
initial={{ y: 0, scale: 0.9, opacity: 0 }} | ||
animate={{ y: 0, scale: 1, opacity: 1 }} | ||
exit={{ x: 0, scale: 0.9, opacity: 0 }} | ||
ref={submenuRef} | ||
className="absolute flex flex-col w-32 gap-3 py-2 bg-white rounded-md" | ||
style={{ | ||
top: `${contextMenu.y - window.scrollY}px`, | ||
left: `${contextMenu.x - window.scrollX}px`, | ||
zIndex: 50, | ||
}} | ||
> | ||
<div | ||
className="flex items-start justify-start gap-1 py-1 transition duration-200 ps-2 hover:text-neutral-500 hover:cursor-pointer" | ||
onClick={() => | ||
currentTab === "Session" | ||
? handleMove(contextMenu.solve!, "Session") | ||
: handleMove(contextMenu.solve!, "All") | ||
} | ||
> | ||
<div className="w-4 mr-3 h-4"> | ||
<ArchiveBoxArrowDownIcon className="w-6 h-6" /> | ||
</div> | ||
<div> | ||
{currentTab === "Session" ? t("archive") : t("unarchive")} | ||
</div> | ||
</div> | ||
<div | ||
className="flex items-start justify-start gap-1 py-1 transition duration-200 ps-2 hover:text-neutral-500 hover:cursor-pointer" | ||
onClick={() => | ||
handleCopyToClipboard( | ||
`[${formatTime(contextMenu.solve!.time)}s] - ${ | ||
contextMenu.solve!.scramble | ||
}` | ||
) | ||
} | ||
> | ||
<div className="w-4 mr-3 h-4"> | ||
<DocumentDuplicateIcon className="w-6 h-6" /> | ||
</div> | ||
<div>{t("copy")}</div> | ||
</div> | ||
<div | ||
className="flex items-start justify-start gap-1 py-1 transition duration-200 ps-2 hover:text-neutral-500 hover:cursor-pointer" | ||
onClick={() => handleDelete(contextMenu.solve!)} | ||
> | ||
<div className="w-4 mr-3 h-4"> | ||
<TrashIcon className="w-6 h-6" /> | ||
</div> | ||
<div>{t("remove")}</div> | ||
</div> | ||
</motion.div> | ||
</AnimatePresence> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This small mini section, already exist as solve options, no need duplicate
className="flex items-start justify-start gap-1 py-1 transition duration-200 ps-2 hover:text-neutral-500 hover:cursor-pointer" | ||
onClick={() => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why was needed
Merged: #316 |
What does this PR do?
Fix #312 and added Feat #270 which results in adding a context menu.
Related Issue(s)
None
Changes
Screenshots or GIFs (if applicable)
Additional Comments
If some changes have to be made, please let me know.
By submitting this PR, I confirm that: