Skip to content

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

feat: new search widget instead of search icon

Ilian Sapundshiev247bebd2e8f4
diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsx
index 7040ffd7e..2c036771a 100644
--- a/app/components/FolderContainer.tsx
+++ b/app/components/FolderContainer.tsx
@@ -25,6 +25,7 @@ import CircularProgress from '@material-ui/core/CircularProgress';
import Popover from '@material-ui/core/Popover';
import Tooltip from '@material-ui/core/Tooltip';
import Typography from '@material-ui/core/Typography';
+import InputAdornment from '@material-ui/core/InputAdornment';
import SearchIcon from '@material-ui/icons/Search';
import AdvancedSearchIcon from '@material-ui/icons/Tune';
import MenuIcon from '@material-ui/icons/MenuOpen';
@@ -70,6 +71,7 @@ import {
import Links from '-/links';
import PlatformIO from '-/services/platform-facade';
import { PerspectiveIDs, AvailablePerspectives } from '-/perspectives';
+import MainSearchField from '-/components/MainSearchField';
const GridPerspective = React.lazy(() =>
import(
@@ -592,26 +594,40 @@ const FolderContainer = (props: Props) => {
/>
<Tooltip
title={
- i18n.t('showSearch') + ' (CTRL/⌘+SHIFT+F)'
+ i18n.t('showSearch') + ' (CTRL/⌘ + SHIFT + F)'
// +
// ' - ' +
// keyBindings['openSearch'].toUpperCase()
}
>
- <CustomButton
- data-tid="toggleSearch"
- onClick={() => {
- if (isSearchVisible) {
- props.setSearchQuery({});
- props.openCurrentDirectory();
- } else {
- setSearchVisible(!isSearchVisible);
- }
- return true;
+ <MainSearchField
+ fullWidth
+ id="textQuery"
+ name="textQuery"
+ defaultValue=""
+ variant="outlined"
+ size="small"
+ style={{
+ marginTop: 10,
+ width: 'calc(200px)'
}}
- >
- <SearchIcon />
- </CustomButton>
+ onKeyDown={() => setSearchVisible(!isSearchVisible)}
+ onClick={() => setSearchVisible(!isSearchVisible)}
+ margin="dense"
+ placeholder={i18n.t('core:searchTitle')}
+ InputProps={{
+ startAdornment: (
+ <InputAdornment
+ position="start"
+ style={{ marginRight: 0 }}
+ >
+ <IconButton size="small" edge="end">
+ <SearchIcon />
+ </IconButton>
+ </InputAdornment>
+ )
+ }}
+ />
</Tooltip>
{props.progress && props.progress.length > 0 && (
<CustomButton
diff --git a/app/components/MainSearchField.tsx b/app/components/MainSearchField.tsx
new file mode 100644
index 000000000..6bbca03db
--- /dev/null
+++ b/app/components/MainSearchField.tsx
@@ -0,0 +1,64 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * 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, { useEffect, useRef, useState } from 'react';
+import { withStyles, Theme, createStyles } from '@material-ui/core/styles';
+import TextField from '@material-ui/core/TextField';
+
+const MainSearchField = withStyles((theme: Theme) =>
+ createStyles({
+ root: {
+ overflow: 'hidden',
+ '& input': {
+ padding: 6
+ },
+ '& .MuiInputBase-root': {
+ borderRadius: 7,
+ paddingRight: 5,
+ paddingLeft: 5
+ },
+ '& .Mui-focused': {
+ color:
+ theme.palette.type === 'light'
+ ? theme.palette.grey[900]
+ : theme.palette.grey[200],
+ backgroundColor:
+ theme.palette.type === 'light'
+ ? theme.palette.grey[200]
+ : theme.palette.grey[900]
+ // backgroundColor: 'gray',
+ // outline: '2px solid red',
+ // border: 'none',
+ // boxShadow: 'none'
+ },
+ // '&$focused': {
+ // outline: 'none',
+ // boxShadow: '0 0 0 4px rgba(21, 156, 228, 0.4)'
+ // },
+ '&:hover': {
+ backgroundColor: theme.palette.background.paper
+ // boxShadow: `${alpha(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`
+ }
+ // '&:active': {
+ // backgroundColor: theme.palette.background.paper
+ // }
+ }
+ })
+)(TextField);
+
+export default MainSearchField;
diff --git a/app/components/SearchInline.tsx b/app/components/SearchInline.tsx
index abd5cb5d4..580b4ccc0 100644
--- a/app/components/SearchInline.tsx
+++ b/app/components/SearchInline.tsx
@@ -19,19 +19,13 @@
import React, { useEffect, useRef, useState } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
-import {
- withStyles,
- Theme,
- createStyles,
- makeStyles
-} from '@material-ui/core/styles';
+import { makeStyles } from '@material-ui/core/styles';
import ClearSearchIcon from '@material-ui/icons/Close';
import HelpOutlineIcon from '@material-ui/icons/HelpOutline';
import Button from '@material-ui/core/Button';
import Tooltip from '@material-ui/core/Tooltip';
import IconButton from '@material-ui/core/IconButton';
import InputAdornment from '@material-ui/core/InputAdornment';
-import TextField from '@material-ui/core/TextField';
import Typography from '@material-ui/core/Typography';
import { actions as AppActions, getDirectoryPath } from '../reducers/app';
import {
@@ -45,7 +39,7 @@ import {
getMaxSearchResults,
getShowUnixHiddenEntries
} from '-/reducers/settings';
-import i18n from '../services/i18n';
+import i18n from '-/services/i18n';
import { FileTypeGroups } from '-/services/search';
import { TS } from '-/tagspaces.namespace';
import { Pro } from '../pro';
@@ -55,7 +49,7 @@ import {
removeAllTagsFromSearchQuery
} from '-/utils/misc';
import useFirstRender from '-/utils/useFirstRender';
-import { ProLabel, BetaLabel, ProTooltip } from '-/components/HelperComponents';
+import MainSearchField from '-/components/MainSearchField';
// type PropsClasses = Record<keyof StyleProps, string>;
@@ -77,47 +71,6 @@ interface Props {
isDesktopMode: boolean;
}
-const MainSearchField = withStyles((theme: Theme) =>
- createStyles({
- root: {
- overflow: 'hidden',
- '& input': {
- padding: 6
- },
- '& .MuiInputBase-root': {
- borderRadius: 7,
- paddingRight: 5,
- paddingLeft: 5
- },
- '& .Mui-focused': {
- color:
- theme.palette.type === 'light'
- ? theme.palette.grey[900]
- : theme.palette.grey[200],
- backgroundColor:
- theme.palette.type === 'light'
- ? theme.palette.grey[200]
- : theme.palette.grey[900]
- // backgroundColor: 'gray',
- // outline: '2px solid red',
- // border: 'none',
- // boxShadow: 'none'
- },
- // '&$focused': {
- // outline: 'none',
- // boxShadow: '0 0 0 4px rgba(21, 156, 228, 0.4)'
- // },
- '&:hover': {
- backgroundColor: theme.palette.background.paper
- // boxShadow: `${alpha(theme.palette.primary.main, 0.25)} 0 0 0 0.2rem`
- }
- // '&:active': {
- // backgroundColor: theme.palette.background.paper
- // }
- }
- })
-)(TextField);
-
const useStyles = makeStyles(theme => ({
customWidth: {
maxWidth: 550