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

touchup(drop down menu): applied icons and background colors for UX #633

Merged
merged 8 commits into from
Jan 16, 2025
20 changes: 15 additions & 5 deletions src/web/common/components/ContextMenu/AddNodeMenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useTheme } from "@mui/material/styles";
import { NestedMenuItem } from "mui-nested-menu";

import { breakdownNodeTypes, researchNodeTypes } from "@/common/node";
Expand All @@ -22,6 +23,8 @@ export const AddNodeMenuItem = ({ parentMenuOpen }: Props) => {
// always showing breakdown + research nodes seems reasonable. justification nodes never need to be added on their own.
const shownNodeTypes = breakdownNodeTypes.concat(researchNodeTypes);

const theme = useTheme();

// shouldn't be able to view this menu item if we're in the table view
if (!userCanEditTopicData || format == "table") return <></>;

Expand All @@ -33,11 +36,18 @@ export const AddNodeMenuItem = ({ parentMenuOpen }: Props) => {
// match default mui menu padding and size
className="px-[16px] [&_p]:px-0 [&_p]:text-sm"
>
{shownNodeTypes.map((type) => (
<ContextMenuItem key={type} onClick={() => addNodeWithoutParent(type, "diagram")}>
{nodeDecorations[type].title}
</ContextMenuItem>
))}
{shownNodeTypes.map((type) => {
const { NodeIcon, title } = nodeDecorations[type];
return (
<ContextMenuItem key={type} onClick={() => addNodeWithoutParent(type, "diagram")}>
<NodeIcon
sx={{ backgroundColor: theme.palette[type].main }}
className="mr-2 rounded p-0.5"
/>
{title}
</ContextMenuItem>
);
})}
</NestedMenuItem>
</>
);
Expand Down
Loading