TagSpaces is an offline, open source, document manager with tagging support
chore: redesign tsicon buttons, introducing tstoolbar button
Ilian Sapundshieved39d0227d20
diff --git a/src/renderer/components/TsIconButton.tsx b/src/renderer/components/TsIconButton.tsxindex 270eed5cf..3279d6db0 100644--- a/src/renderer/components/TsIconButton.tsx+++ b/src/renderer/components/TsIconButton.tsx@@ -16,12 +16,11 @@**/-import React from 'react';-import { useSelector } from 'react-redux';-import IconButton, { IconButtonProps } from '@mui/material/IconButton';-import { isDesktopMode } from '-/reducers/settings';-import TooltipTS from '-/components/Tooltip';import AppConfig from '-/AppConfig';+import TooltipTS from '-/components/Tooltip';+import { isDesktopMode } from '-/reducers/settings';+import IconButton, { IconButtonProps } from '@mui/material/IconButton';+import { useSelector } from 'react-redux';export type TSIconButtonProps = IconButtonProps & {tooltip?: string;@@ -34,6 +33,7 @@ function TsIconButton(props: TSIconButtonProps) {const iconButton = (<IconButtonsize={desktopMode ? 'medium' : 'large'}+ style={{ borderRadius: AppConfig.defaultCSSRadius }}disabled={disabled}{...restProps}>diff --git a/src/renderer/components/TsToolbarButton.tsx b/src/renderer/components/TsToolbarButton.tsxnew file mode 100644index 000000000..4030b1574--- /dev/null+++ b/src/renderer/components/TsToolbarButton.tsx@@ -0,0 +1,82 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2025-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 AppConfig from '-/AppConfig';+import TooltipTS from '-/components/Tooltip';+import { isDesktopMode } from '-/reducers/settings';+import { Typography } from '@mui/material';+import IconButton, { IconButtonProps } from '@mui/material/IconButton';+import { useTheme } from '@mui/material/styles';+import { useSelector } from 'react-redux';++export type TSIconButtonProps = IconButtonProps & {+ title?: string;+ tooltip?: string;+ keyBinding?: string;+ showTitle?: boolean;+};++function TsToolbarButton(props: TSIconButtonProps) {+ const {+ children,+ keyBinding,+ tooltip,+ title,+ disabled,+ // showTitle = false,+ ...restProps+ } = props;+ const showTitle = true;+ const desktopMode = useSelector(isDesktopMode);+ const theme = useTheme();+ const iconButton = (+ <IconButton+ size={desktopMode ? 'medium' : 'large'}+ disabled={disabled}+ style={{ borderRadius: AppConfig.defaultCSSRadius, display: 'block' }}+ sx={{+ '& .MuiSvgIcon-root ': {+ width: showTitle ? '0.8em' : '1em',+ heigh: showTitle ? '0.8em' : '1em',+ },+ // border: '1px solid transparent',+ // '&:hover': {+ // border: '1px solid ' + alpha(theme.palette.divider, 0.9),+ // borderRadius: AppConfig.defaultCSSRadius,+ // },+ }}+ {...restProps}+ >+ {children}+ {showTitle && (+ <Typography style={{ display: 'block', fontSize: 11, marginTop: -5 }}>+ {title}+ </Typography>+ )}+ </IconButton>+ );+ return tooltip && !disabled ? (+ <TooltipTS keyBinding={keyBinding} title={tooltip}>+ {iconButton}+ </TooltipTS>+ ) : (+ iconButton+ );+}++export default TsToolbarButton;diff --git a/src/renderer/components/ZoomComponent.tsx b/src/renderer/components/ZoomComponent.tsxindex 0556c5ba8..2610fd028 100644--- a/src/renderer/components/ZoomComponent.tsx+++ b/src/renderer/components/ZoomComponent.tsx@@ -16,27 +16,29 @@**/-import * as React from 'react';-import { useTheme } from '@mui/material/styles';-import Box from '@mui/material/Box';-import ZoomOutIcon from '@mui/icons-material/RemoveCircleOutline';+import TsToolbarButton from '-/components/TsToolbarButton';+import { usePerspectiveSettingsContext } from '-/hooks/usePerspectiveSettingsContext';import ZoomInIcon from '@mui/icons-material/ControlPoint';+import ZoomOutIcon from '@mui/icons-material/RemoveCircleOutline';+import Box from '@mui/material/Box';import Typography from '@mui/material/Typography';-import TsIconButton from '-/components/TsIconButton';-import { usePerspectiveSettingsContext } from '-/hooks/usePerspectiveSettingsContext';+import { useTheme } from '@mui/material/styles';import { useReducer } from 'react';+import { useTranslation } from 'react-i18next';interface Props {preview: boolean;+ showTitle?: boolean;}export default function ZoomComponent(props: Props) {- const { preview } = props;+ const { preview, showTitle } = props;const { entrySize, setSettings, saveSettings } =usePerspectiveSettingsContext();const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);const theme = useTheme();const entrySizePercent = mapEntrySizeToPercent();+ const { t } = useTranslation();function mapEntrySizeToPercent() {if (entrySize === 'huge') {@@ -90,18 +92,18 @@ export default function ZoomComponent(props: Props) {return (<Box sx={{ display: 'flex' }}>- <TsIconButton onClick={zoomOut}>+ <TsToolbarButton tooltip={t('core:zoomOut')} title="" onClick={zoomOut}><ZoomOutIcon />- </TsIconButton>+ </TsToolbarButton><Typographyvariant="overline"style={{ color: theme.palette.text.primary, marginTop: 4 }}>{entrySizePercent}</Typography>- <TsIconButton onClick={zoomIn}>+ <TsToolbarButton tooltip={t('core:zoomIn')} title="" onClick={zoomIn}><ZoomInIcon />- </TsIconButton>+ </TsToolbarButton></Box>);}diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.jsonindex f9cfeb35d..10a99a537 100644--- a/src/renderer/locales/en/core.json+++ b/src/renderer/locales/en/core.json@@ -951,5 +951,6 @@"doubleClickToEdit": "Double-click to edit","tsLinksHelp": "TagSpaces links begin with ts://? and are used for internal sharing of files and folders","pasteImageFromClipboard": "Paste an image from clipboard by pressing",+ "parentFolder": "Parent","-": "-"}diff --git a/src/renderer/perspectives/grid/components/MainToolbar.tsx b/src/renderer/perspectives/grid/components/MainToolbar.tsxindex 62358ec1d..ed5f0ff33 100644--- a/src/renderer/perspectives/grid/components/MainToolbar.tsx+++ b/src/renderer/perspectives/grid/components/MainToolbar.tsx@@ -35,7 +35,7 @@ import {UnSelectedIcon,} from '-/components/CommonIcons';import { ProTooltip } from '-/components/HelperComponents';-import TsIconButton from '-/components/TsIconButton';+import TsToolbarButton from '-/components/TsToolbarButton';import ZoomComponent from '-/components/ZoomComponent';import { useAiGenerationDialogContext } from '-/components/dialogs/hooks/useAiGenerationDialogContext';import { useDeleteMultipleEntriesDialogContext } from '-/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext';@@ -145,8 +145,9 @@ function MainToolbar(props: Props) {variant="dense"data-tid={prefixDataTID + 'perspectiveToolbar'}>- <TsIconButton+ <TsToolbarButtontooltip={t('core:navigateToParentDirectory')}+ title={t('core:parentFolder')}keyBinding={keyBindings['openParentDirectory']}aria-label={t('core:navigateToParentDirectory')}data-tid={prefixDataTID + 'PerspectiveOnBackButton'}@@ -155,110 +156,119 @@ function MainToolbar(props: Props) {}}><ParentFolderIcon />- </TsIconButton>- <TsIconButton+ </TsToolbarButton>+ <TsToolbarButtontooltip={t('core:toggleSelectAllFiles')}+ title={t('core:selectAll')}keyBinding={keyBindings['selectAll']}data-tid={prefixDataTID + 'PerspectiveSelectAllFiles'}onClick={toggleSelectAllFiles}>{selectedEntries.length > 1 ? <SelectedIcon /> : <UnSelectedIcon />}- </TsIconButton>- <TsIconButton+ </TsToolbarButton>+ <TsToolbarButtontooltip={t('core:directoryPropertiesTitle')}+ title={t('core:details')}aria-label={t('core:directoryPropertiesTitle')}data-tid="openFolderProperties"onClick={showProperties}><EntryPropertiesIcon />- </TsIconButton>+ </TsToolbarButton><Divider flexItem orientation="vertical" sx={{ mx: 0.5, my: 1.5 }} /><Box sx={{ display: selectedEntries.length < 1 ? 'none' : 'flex' }}>{!readOnlyMode && (- <TsIconButton+ <TsToolbarButtontooltip={t('core:tagSelectedEntries')}+ title={t('core:fileTags')}keyBinding={keyBindings['addRemoveTags']}aria-label={t('core:tagSelectedEntries')}data-tid={prefixDataTID + 'PerspectiveAddRemoveTags'}onClick={openAddRemoveTagsDialog}><TagIcon />- </TsIconButton>+ </TsToolbarButton>)}{!readOnlyMode && (- <TsIconButton+ <TsToolbarButtontooltip={t('core:aiGenSelectedEntries')}+ title={t('core:aiSettingsTab')}aria-label={t('core:aiGenSelectedEntries')}data-tid={prefixDataTID + 'PerspectiveAiGenTID'}onClick={() => openAiGenerationDialog()}><AIIcon />- </TsIconButton>+ </TsToolbarButton>)}{!readOnlyMode && (- <TsIconButton+ <TsToolbarButtontooltip={t('core:copyMoveSelectedEntries')}+ title={t('core:copyEntriesButton')}keyBinding={keyBindings['copyMoveSelectedEntries']}aria-label={t('core:copyMoveSelectedEntries')}data-tid={prefixDataTID + 'PerspectiveCopySelectedFiles'}onClick={openMoveCopyFilesDialog}><CopyMoveIcon />- </TsIconButton>+ </TsToolbarButton>)}{!readOnlyMode && (- <TsIconButton+ <TsToolbarButtontooltip={t('core:deleteSelectedEntries')}+ title={t('core:delete')}keyBinding={keyBindings['deleteDocument']}aria-label={t('core:deleteSelectedEntries')}data-tid={prefixDataTID + 'PerspectiveDeleteMultipleFiles'}onClick={() => openDeleteMultipleEntriesDialog()}><DeleteIcon />- </TsIconButton>+ </TsToolbarButton>)}{openShareFilesDialog && currentLocation?.haveObjectStoreSupport() && (<ProTooltip tooltip={t('core:shareFiles')}>- <TsIconButton+ <TsToolbarButtonaria-label={t('core:shareFiles')}data-tid={prefixDataTID + 'PerspectiveShareFiles'}onClick={openShareFilesDialog}disabled={selectedEntries.length < 1}><ShareIcon />- </TsIconButton>+ </TsToolbarButton></ProTooltip>)}<Divider flexItem orientation="vertical" sx={{ mx: 0.5, my: 1 }} /></Box>- <TsIconButton+ <TsToolbarButtontooltip={t('core:sort')}aria-label={t('core:sort')}+ title={t('core:sort')}data-tid={prefixDataTID + 'PerspectiveSortMenu'}onClick={(e) => {handleSortingMenu(e);}}><SortingIcon />- </TsIconButton>+ </TsToolbarButton>{showDownloadButton && (- <TsIconButton+ <TsToolbarButtontooltip={t('core:downloadFiles')}+ title={t('core:downloadsFolder')}data-tid={prefixDataTID + 'PerspectiveDownloadMultipleMenuTID'}onClick={multipleDownload}><DownloadIcon />- </TsIconButton>+ </TsToolbarButton>)}{Pro &&- !AppConfig.isCordovaAndroid && ( // SaveAs do not worlk on Android- <TsIconButton+ !AppConfig.isCordovaAndroid && ( // SaveAs do not work on Android+ <TsToolbarButtontooltip={t('core:exportCsv')}+ title={t('core:startExportButton')}data-tid={prefixDataTID + 'PerspectiveExportCsvMenuTID'}onClick={handleExportCsvMenu}><ExportIcon />- </TsIconButton>+ </TsToolbarButton>)}<Divider flexItem orientation="vertical" sx={{ mx: 0.5, my: 1.5 }} /><Box sx={{ display: { xs: 'none', sm: 'flex' } }}>@@ -266,23 +276,25 @@ function MainToolbar(props: Props) {<Divider flexItem orientation="vertical" sx={{ mx: 0.5, my: 1 }} /></Box>{AppConfig.isElectron && !currentLocation?.haveObjectStoreSupport() && (- <TsIconButton+ <TsToolbarButtontooltip={t('core:dragMode')}data-tid={prefixDataTID + 'PerspectiveDragNative'}onClick={() => {setNativeDragModeEnabled(!nativeDragModeEnabled);}}+ title={t('Drag outside')}>{nativeDragModeEnabled ? <DragOnIcon /> : <DragOffIcon />}- </TsIconButton>+ </TsToolbarButton>)}<Box sx={{ flexGrow: 1 }} /><Box sx={{ display: 'flex' }}>- <TsIconButton+ <TsToolbarButtontooltip={t('core:perspectiveSettingsTitle') +(folderSettingsAvailable ? ' - folder specific' : '')}+ title={t('core:setting')}data-tid={prefixDataTID + 'PerspectiveOptionsMenu'}onClick={openSettings}>@@ -291,7 +303,7 @@ function MainToolbar(props: Props) {) : (<PerspectiveSettingsIcon />)}- </TsIconButton>+ </TsToolbarButton></Box></Toolbar>);