Skip to content

refactor(site): make minor design tweaks and fix issues on more options menus #10493

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

Merged
merged 13 commits into from
Nov 3, 2023
Prev Previous commit
Next Next commit
Refactor template menu
  • Loading branch information
BrunoQuaresma committed Nov 2, 2023
commit 5640a9f9d6fa11e4ad32e5203958b356bba1fc46
12 changes: 10 additions & 2 deletions site/src/components/MoreMenu/MoreMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export const MoreMenu = (props: Omit<MenuProps, "open" | "onClose">) => {
};

export const MoreMenuItem = (
props: MenuItemProps & { closeOnClick?: boolean },
props: MenuItemProps & { closeOnClick?: boolean; danger?: boolean },
) => {
const { closeOnClick = true, ...menuItemProps } = props;
const { closeOnClick = true, danger = false, ...menuItemProps } = props;
const ctx = useContext(MoreMenuContext);

if (!ctx) {
Expand All @@ -54,6 +54,14 @@ export const MoreMenuItem = (
return (
<MenuItem
{...menuItemProps}
css={(theme) => ({
fontSize: 14,
color: danger ? theme.palette.error.light : undefined,
"& .MuiSvgIcon-root": {
width: theme.spacing(2),
height: theme.spacing(2),
},
})}
onClick={(e) => {
menuItemProps.onClick && menuItemProps.onClick(e);
if (closeOnClick) {
Expand Down
5 changes: 3 additions & 2 deletions site/src/pages/TemplatePage/TemplatePageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import DeleteIcon from "@mui/icons-material/DeleteOutlined";
import EditIcon from "@mui/icons-material/EditOutlined";
import CopyIcon from "@mui/icons-material/FileCopyOutlined";
import { MoreMenu, MoreMenuItem } from "components/MoreMenu/MoreMenu";
import Divider from "@mui/material/Divider";

type TemplateMenuProps = {
templateName: string;
Expand Down Expand Up @@ -81,8 +82,8 @@ const TemplateMenu: FC<TemplateMenuProps> = ({
<CopyIcon />
Duplicate&hellip;
</MoreMenuItem>

<MoreMenuItem onClick={dialogState.openDeleteConfirmation}>
<Divider />
<MoreMenuItem onClick={dialogState.openDeleteConfirmation} danger>
<DeleteIcon />
Delete&hellip;
</MoreMenuItem>
Expand Down
7 changes: 7 additions & 0 deletions site/src/theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,13 @@ dark = createTheme(dark, {
padding: "4px 0",
minWidth: 160,
},
root: {
// It should be the same as the menu padding
"& .MuiDivider-root": {
marginTop: 4,
marginBottom: 4,
},
},
},
},
MuiMenuItem: {
Expand Down