Browse Source

chore: remove unused code

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 1 month ago
parent
commit
13794a4bc9

+ 0 - 86
client/src/components/menu/SimpleMenu.tsx

@@ -1,86 +0,0 @@
-import { FC, useMemo } from 'react';
-import React from 'react';
-import Menu from '@mui/material/Menu';
-import MenuItem from '@mui/material/MenuItem';
-import CustomButton from '../customButton/CustomButton';
-import { generateId } from '../../utils/Common';
-import type { SimpleMenuType } from './Types';
-
-const SimpleMenu: FC<SimpleMenuType> = props => {
-  const {
-    label,
-    menuItems,
-    buttonProps,
-    menuItemWidth = '160px',
-    className = '',
-  } = props;
-  const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
-
-  const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
-    setAnchorEl(event.currentTarget);
-  };
-
-  const handleClose = () => {
-    setAnchorEl(null);
-  };
-  // for accessibility
-  const id = useMemo(() => generateId(), []);
-
-  return (
-    <div className={className}>
-      <CustomButton
-        aria-controls={id}
-        aria-haspopup="true"
-        onClick={handleClick}
-        {...buttonProps}
-      >
-        {label}
-      </CustomButton>
-      <Menu
-        id={id}
-        anchorEl={anchorEl}
-        keepMounted
-        open={Boolean(anchorEl)}
-        onClose={handleClose}
-        PaperProps={{
-          sx: {
-            boxShadow: '0px 4px 24px rgba(0, 0, 0, 0.08)',
-          },
-        }}
-        // anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
-        // transformOrigin={{ vertical: 'top', horizontal: 'center' }}
-      >
-        <div>
-          {menuItems.map((v, i) =>
-            typeof v.label === 'string' ? (
-              <MenuItem
-                sx={theme => ({
-                  minWidth: menuItemWidth,
-                  padding: theme.spacing(1),
-                  '&:hover': {
-                    backgroundColor: '#f4f4f4',
-                  },
-                })}
-                onClick={() => {
-                  v.callback && v.callback();
-                  handleClose();
-                }}
-                key={v.label + i}
-              >
-                {v.wrapperClass ? (
-                  <span className={v.wrapperClass}>{v.label}</span>
-                ) : (
-                  v.label
-                )}
-              </MenuItem>
-            ) : (
-              <span key={i}>{v.label}</span>
-            )
-          )}
-        </div>
-      </Menu>
-    </div>
-  );
-};
-
-export default SimpleMenu;

+ 0 - 16
client/src/components/menu/Types.ts

@@ -1,19 +1,3 @@
-import { ButtonProps } from '@mui/material/Button';
-import { ReactElement } from 'react';
-
-export type SimpleMenuType = {
-  label: string;
-  menuItems: {
-    label: string | ReactElement;
-    callback?: () => void;
-    wrapperClass?: string;
-  }[];
-  buttonProps?: ButtonProps;
-  className?: string;
-  // e.g. 160px
-  menuItemWidth?: string;
-};
-
 type CustomIcon = (
   props?: any
 ) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;

+ 2 - 3
client/src/pages/dialogs/insert/Preview.tsx

@@ -25,7 +25,6 @@ const InsertPreview: FC<InsertPreviewProps> = ({
   tableHeads,
   setTableHeads,
 }) => {
-  // Styles replaced with Box and sx below
   const { t: insertTrans } = useTranslation('insert');
 
   const ArrowIcon = icons.dropdown;
@@ -68,7 +67,7 @@ const InsertPreview: FC<InsertPreviewProps> = ({
                   paddingTop: '8px', // Reduce padding
                   paddingBottom: '8px', // Reduce padding
                 },
-                '&:hover': { backgroundColor: 'transparent' }, // Mimic SimpleMenu style
+                '&:hover': { backgroundColor: 'transparent' },
               }}
               renderValue={selected => {
                 if (!selected) {
@@ -86,7 +85,7 @@ const InsertPreview: FC<InsertPreviewProps> = ({
                   value={schema.label}
                   className={
                     head === schema.label ? 'menu-active' : 'menu-item'
-                  } // Keep similar class for potential existing styles
+                  }
                 >
                   {schema.label}
                 </MenuItem>