Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

syrok94
Copy link
Contributor

@syrok94 syrok94 commented Jun 19, 2024

What does this PR do?
Fix #312 and added Feat #270 which results in adding a context menu.

Related Issue(s)
None

Changes

  • change the CSS of the context menu.
  • added a context menu

Screenshots or GIFs (if applicable)
nexus1

nexus2

Additional Comments
If some changes have to be made, please let me know.

By submitting this PR, I confirm that:

  • I have reviewed my code and believe it is ready for merging.
  • I understand that this PR may be subject to review and changes.
  • I agree to abide by the code of conduct and contributing guidelines of this project.

Copy link
Owner

@bryanlundberg bryanlundberg left a 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:

  1. 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.

  2. 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.

f904cdcb19147b01d3720517dd5a2f25

Thank you for addressing these issues. If you have any questions, feel free to reach out.

Comment on lines +53 to +55
useEffect(() => {
setContextMenu({ ...contextMenu, visible: false });
}, [status]);
Copy link
Owner

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

Comment on lines +67 to +94
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);
};
Copy link
Owner

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.

Comment on lines +154 to +210
{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>
)}
Copy link
Owner

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

Comment on lines +243 to 244
className="flex items-start justify-start gap-1 py-1 transition duration-200 ps-2 hover:text-neutral-500 hover:cursor-pointer"
onClick={() =>
Copy link
Owner

@bryanlundberg bryanlundberg Jun 19, 2024

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

@bryanlundberg
Copy link
Owner

bryanlundberg commented Jun 22, 2024

Merged: #316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrectly defined submenu solved details icons
2 participants