aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/components
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-08-28 15:14:33 -0700
committerAnton Tananaev <anton@traccar.org>2022-08-28 15:14:33 -0700
commit4e61ae214d7c9c54851261734837521f2f77b4e5 (patch)
tree403a25bed46b2645a17fef4d09a139bf6426068b /modern/src/settings/components
parentcd7c15987c08a875386e860a11f6533423709bc2 (diff)
downloadtrackermap-web-4e61ae214d7c9c54851261734837521f2f77b4e5.tar.gz
trackermap-web-4e61ae214d7c9c54851261734837521f2f77b4e5.tar.bz2
trackermap-web-4e61ae214d7c9c54851261734837521f2f77b4e5.zip
Mobile setting search
Diffstat (limited to 'modern/src/settings/components')
-rw-r--r--modern/src/settings/components/SearchHeader.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/modern/src/settings/components/SearchHeader.js b/modern/src/settings/components/SearchHeader.js
new file mode 100644
index 00000000..25757ed2
--- /dev/null
+++ b/modern/src/settings/components/SearchHeader.js
@@ -0,0 +1,38 @@
+import React from 'react';
+import { TextField, useTheme, useMediaQuery } from '@mui/material';
+import makeStyles from '@mui/styles/makeStyles';
+import { useTranslation } from '../../common/components/LocalizationProvider';
+
+export const filterByKeyword = (keyword) => (item) => !keyword || JSON.stringify(item).toLowerCase().includes(keyword.toLowerCase());
+
+const useStyles = makeStyles((theme) => ({
+ header: {
+ position: 'sticky',
+ left: 0,
+ display: 'flex',
+ flexDirection: 'column',
+ alignItems: 'stretch',
+ padding: theme.spacing(3, 2, 2),
+ },
+}));
+
+const SearchHeader = ({ keyword, setKeyword }) => {
+ const theme = useTheme();
+ const classes = useStyles();
+ const t = useTranslation();
+
+ const phone = useMediaQuery(theme.breakpoints.down('sm'));
+
+ return phone ? (
+ <div className={classes.header}>
+ <TextField
+ variant="outlined"
+ placeholder={t('sharedSearch')}
+ value={keyword}
+ onChange={(e) => setKeyword(e.target.value)}
+ />
+ </div>
+ ) : '';
+};
+
+export default SearchHeader;