Skip to content

TagSpaces is an offline, open source, document manager with tagging support

chore: migration to tsmenu list

Ilian Sapundshiev6245e71bcda6
diff --git a/src/renderer/components/EntryContainerMenu.tsx b/src/renderer/components/EntryContainerMenu.tsx
index 2d9739a04..8138d2613 100644
--- a/src/renderer/components/EntryContainerMenu.tsx
+++ b/src/renderer/components/EntryContainerMenu.tsx
@@ -9,7 +9,6 @@ import {
ListItemText,
Menu,
MenuItem,
- MenuList,
Divider,
} from '@mui/material';
import { useSelector } from 'react-redux';
@@ -41,10 +40,10 @@ import { useNotificationContext } from '-/hooks/useNotificationContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import {
createNewInstance,
- downloadFile,
openDirectoryMessage,
openFileMessage,
} from '-/services/utils-io';
+import TsMenuList from '-/components/TsMenuList';
interface Props {
anchorEl: null | HTMLElement;
@@ -449,7 +448,7 @@ function EntryContainerMenu(props: Props) {
horizontal: 'left',
}}
>
- <MenuList sx={{ minWidth: 300 }}>{menuItems}</MenuList>
+ <TsMenuList sx={{ minWidth: 300 }}>{menuItems}</TsMenuList>
</Menu>
{isDeleteEntryModalOpened && (
<ConfirmDialog
diff --git a/src/renderer/components/MobileNavigation.tsx b/src/renderer/components/MobileNavigation.tsx
index 91c267f3b..72e1c6060 100644
--- a/src/renderer/components/MobileNavigation.tsx
+++ b/src/renderer/components/MobileNavigation.tsx
@@ -61,7 +61,7 @@ import Grow from '@mui/material/Grow';
import Paper from '@mui/material/Paper';
import Popper from '@mui/material/Popper';
import MenuItem from '@mui/material/MenuItem';
-import MenuList from '@mui/material/MenuList';
+import TsMenuList from '-/components/TsMenuList';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import { AppDispatch } from '-/reducers/app';
@@ -271,7 +271,7 @@ function MobileNavigation(props: Props) {
>
<Paper>
<ClickAwayListener onClickAway={handleClose}>
- <MenuList id="split-button-menu" autoFocusItem>
+ <TsMenuList id="split-button-menu" autoFocusItem>
<MenuItem
key="createNewTextFileTID"
ata-tid="createNewTextFileTID"
@@ -454,7 +454,7 @@ function MobileNavigation(props: Props) {
</MenuItem>
</>
)}
- </MenuList>
+ </TsMenuList>
</ClickAwayListener>
</Paper>
</Grow>
diff --git a/src/renderer/components/SplitButton.tsx b/src/renderer/components/SplitButton.tsx
index 747532919..4e4faf652 100644
--- a/src/renderer/components/SplitButton.tsx
+++ b/src/renderer/components/SplitButton.tsx
@@ -8,7 +8,7 @@ import Grow from '@mui/material/Grow';
import Paper from '@mui/material/Paper';
import Popper from '@mui/material/Popper';
import MenuItem from '@mui/material/MenuItem';
-import MenuList from '@mui/material/MenuList';
+import TsMenuList from '-/components/TsMenuList';
interface Props {
options: Array<any>;
@@ -92,7 +92,7 @@ export default function SplitButton(props: Props) {
>
<Paper>
{/* <ClickAwayListener onClickAway={handleClose}> */}
- <MenuList id="split-button-menu">
+ <TsMenuList id="split-button-menu">
{options.map((option, index) => (
<MenuItem
key={option.key}
@@ -103,7 +103,7 @@ export default function SplitButton(props: Props) {
{option.value}
</MenuItem>
))}
- </MenuList>
+ </TsMenuList>
{/* </ClickAwayListener> */}
</Paper>
</Grow>
diff --git a/src/renderer/components/TsMenuList.tsx b/src/renderer/components/TsMenuList.tsx
new file mode 100644
index 000000000..5e2e4dbb4
--- /dev/null
+++ b/src/renderer/components/TsMenuList.tsx
@@ -0,0 +1,44 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2024-present TagSpaces GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+import React from 'react';
+import { useSelector } from 'react-redux';
+import MenuList, { MenuListProps } from '@mui/material/MenuList';
+import { isDesktopMode } from '-/reducers/settings';
+import AppConfig from '-/AppConfig';
+
+export type TSButtonProps = MenuListProps & {};
+
+function TsMenuList(props: TSButtonProps) {
+ const { children, style } = props;
+ const desktopMode = useSelector(isDesktopMode);
+
+ return (
+ <MenuList
+ dense={desktopMode ? true : false}
+ {...props}
+ style={{
+ ...style,
+ }}
+ >
+ {children}
+ </MenuList>
+ );
+}
+
+export default TsMenuList;
diff --git a/src/renderer/components/TsTextField.tsx b/src/renderer/components/TsTextField.tsx
index a5e5fb311..342adb2c7 100644
--- a/src/renderer/components/TsTextField.tsx
+++ b/src/renderer/components/TsTextField.tsx
@@ -22,7 +22,7 @@ import TextField, { TextFieldProps } from '@mui/material/TextField';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';
import FormHelperText from '@mui/material/FormHelperText';
-import MenuList from '@mui/material/MenuList';
+import TsMenuList from '-/components/TsMenuList';
import ListItemText from '@mui/material/ListItemText';
import MenuKeyBinding from '-/components/menus/MenuKeyBinding';
import { useTranslation } from 'react-i18next';
@@ -127,7 +127,7 @@ function TsTextField(props: TSTextFieldProps) {
: undefined
}
>
- <MenuList dense style={{ minWidth: 150 }}>
+ <TsMenuList style={{ minWidth: 150 }}>
<MenuItem onClick={handleCopy}>
<ListItemText primary={t('core:copy')} />
<MenuKeyBinding keyBinding="command+c" />
@@ -138,7 +138,7 @@ function TsTextField(props: TSTextFieldProps) {
<MenuKeyBinding keyBinding="command+v" />
</MenuItem>
)}
- </MenuList>
+ </TsMenuList>
</Menu>
</div>
);
diff --git a/src/renderer/components/menus/BookmarksMenu.tsx b/src/renderer/components/menus/BookmarksMenu.tsx
index b875143b2..930b60681 100644
--- a/src/renderer/components/menus/BookmarksMenu.tsx
+++ b/src/renderer/components/menus/BookmarksMenu.tsx
@@ -19,9 +19,10 @@
import React from 'react';
import ListItemText from '@mui/material/ListItemText';
import ListItemIcon from '@mui/material/ListItemIcon';
-import { Menu, MenuList, MenuItem } from '@mui/material';
+import { Menu, MenuItem } from '@mui/material';
import { DeleteIcon, ReloadIcon } from '-/components/CommonIcons';
-import { Pro } from '../../pro';
+import TsMenuList from '-/components/TsMenuList';
+import { Pro } from '-/pro';
import { useTranslation } from 'react-i18next';
interface Props {
@@ -71,7 +72,7 @@ function BookmarksMenu(props: Props) {
return (
<Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>
- <MenuList>{menuItems}</MenuList>
+ <TsMenuList>{menuItems}</TsMenuList>
</Menu>
);
}
diff --git a/src/renderer/components/menus/DirectoryMenu.tsx b/src/renderer/components/menus/DirectoryMenu.tsx
index 4b20748dd..0fdb512e5 100644
--- a/src/renderer/components/menus/DirectoryMenu.tsx
+++ b/src/renderer/components/menus/DirectoryMenu.tsx
@@ -35,6 +35,7 @@ import {
readMacOSTags,
} from '-/services/utils-io';
import { PerspectiveIDs } from '-/perspectives';
+import TsMenuList from '-/components/TsMenuList';
import { getDirectoryMenuItems } from '-/perspectives/common/DirectoryMenuItems';
import { useTranslation } from 'react-i18next';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
@@ -437,19 +438,17 @@ Do you want to continue?`)
);
return (
- <>
- <Menu
- anchorEl={anchorEl}
- open={open}
- onClose={onClose}
- anchorReference={mouseY && mouseX ? 'anchorPosition' : undefined}
- anchorPosition={
- mouseY && mouseX ? { top: mouseY, left: mouseX } : undefined
- }
- >
- <MenuList>{menuItems}</MenuList>
- </Menu>
- </>
+ <Menu
+ anchorEl={anchorEl}
+ open={open}
+ onClose={onClose}
+ anchorReference={mouseY && mouseX ? 'anchorPosition' : undefined}
+ anchorPosition={
+ mouseY && mouseX ? { top: mouseY, left: mouseX } : undefined
+ }
+ >
+ <TsMenuList>{menuItems}</TsMenuList>
+ </Menu>
);
}
diff --git a/src/renderer/components/menus/FileMenu.tsx b/src/renderer/components/menus/FileMenu.tsx
index 7ae1face9..0d74b650a 100644
--- a/src/renderer/components/menus/FileMenu.tsx
+++ b/src/renderer/components/menus/FileMenu.tsx
@@ -20,7 +20,7 @@ import React, { useEffect, useReducer, useRef } from 'react';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import ShareIcon from '@mui/icons-material/Share';
-import { Menu, MenuList, MenuItem } from '@mui/material';
+import { Menu, MenuItem } from '@mui/material';
import Divider from '@mui/material/Divider';
import OpenFile from '@mui/icons-material/SubdirectoryArrowRight';
import OpenFileNatively from '@mui/icons-material/Launch';
@@ -67,6 +67,7 @@ import MenuKeyBinding from '-/components/menus/MenuKeyBinding';
import { TS } from '-/tagspaces.namespace';
import { generateClipboardLink } from '-/utils/dom';
import { useDeleteMultipleEntriesDialogContext } from '-/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext';
+import TsMenuList from '-/components/TsMenuList';
interface Props {
anchorEl: Element;
@@ -625,7 +626,7 @@ function FileMenu(props: Props) {
open={open}
onClose={onClose}
>
- <MenuList>{menuItems}</MenuList>
+ <TsMenuList>{menuItems}</TsMenuList>
</Menu>
);
}
diff --git a/src/renderer/containers/App.tsx b/src/renderer/containers/App.tsx
index c2443377a..3d7441516 100644
--- a/src/renderer/containers/App.tsx
+++ b/src/renderer/containers/App.tsx
@@ -66,6 +66,7 @@ const newlightTheme = createTheme({
},
divider: '#ddd',
},
+ // shape: { borderRadius: 10 },
});
// https://mui.com/material-ui/customization/dark-mode/