146 lines
4.7 KiB
TypeScript
Raw Normal View History

2025-03-31 01:27:44 +00:00
import { Autocomplete, Box, Stack, TextField, useTheme } from '@mui/material';
2024-06-25 09:35:44 +01:00
import Typography from '@mui/material/Typography';
import SearchIcon from '@mui/icons-material/Search';
import Grid from '@mui/material/Grid';
2025-03-06 17:54:36 +00:00
import { useState } from 'react';
2024-06-25 09:35:44 +01:00
import { DefinedTool } from '@tools/defineTool';
import { filterTools, tools } from '@tools/index';
import { useNavigate } from 'react-router-dom';
2024-06-26 02:00:54 +01:00
import _ from 'lodash';
2025-03-02 02:58:50 +00:00
import { Icon } from '@iconify/react';
2024-06-25 09:35:44 +01:00
const exampleTools: { label: string; url: string }[] = [
{
label: 'Create a transparent image',
2025-04-05 00:12:51 +00:00
url: '/image-generic/create-transparent'
2024-06-25 09:35:44 +01:00
},
2025-02-27 13:15:52 +00:00
{ label: 'Prettify JSON', url: '/json/prettify' },
2024-06-27 12:39:38 +01:00
{ label: 'Change GIF speed', url: '/gif/change-speed' },
2025-02-25 13:02:00 +00:00
{ label: 'Sort a list', url: '/list/sort' },
{ label: 'Compress PNG', url: '/png/compress-png' },
2025-02-23 01:38:42 +01:00
{ label: 'Split a text', url: '/string/split' },
2025-03-27 05:03:06 +00:00
{ label: 'Split PDF', url: '/pdf/split-pdf' },
{ label: 'Trim video', url: '/video/trim' },
{ label: 'Calculate number sum', url: '/number/sum' }
2024-06-25 09:35:44 +01:00
];
export default function Hero() {
const [inputValue, setInputValue] = useState<string>('');
2025-03-31 01:27:44 +00:00
const theme = useTheme();
2024-06-26 02:00:54 +01:00
const [filteredTools, setFilteredTools] = useState<DefinedTool[]>(
_.shuffle(tools)
);
2024-06-25 09:35:44 +01:00
const navigate = useNavigate();
const handleInputChange = (
event: React.ChangeEvent<{}>,
newInputValue: string
) => {
setInputValue(newInputValue);
2025-04-05 00:28:31 +00:00
setFilteredTools(filterTools(tools, newInputValue));
2024-06-25 09:35:44 +01:00
};
2025-02-27 00:09:15 +00:00
2024-06-25 09:35:44 +01:00
return (
2024-06-26 00:29:53 +01:00
<Box width={{ xs: '90%', md: '80%', lg: '60%' }}>
<Stack mb={1} direction={'row'} spacing={1} justifyContent={'center'}>
<Typography sx={{ textAlign: 'center' }} fontSize={{ xs: 25, md: 30 }}>
2025-02-23 00:41:04 +01:00
Get Things Done Quickly with{' '}
2024-06-26 00:29:53 +01:00
<Typography
fontSize={{ xs: 25, md: 30 }}
display={'inline'}
color={'primary'}
>
Omni Tools
</Typography>
2024-06-25 09:35:44 +01:00
</Typography>
</Stack>
2024-06-26 00:29:53 +01:00
<Typography
sx={{ textAlign: 'center' }}
fontSize={{ xs: 15, md: 20 }}
mb={2}
>
2024-06-25 09:35:44 +01:00
Boost your productivity with Omni Tools, the ultimate toolkit for
getting things done quickly! Access thousands of user-friendly utilities
for editing images, text, lists, and data, all directly from your
browser.
</Typography>
<Autocomplete
sx={{ mb: 2 }}
autoHighlight
options={filteredTools}
2024-06-26 02:00:54 +01:00
inputValue={inputValue}
2024-06-25 09:35:44 +01:00
getOptionLabel={(option) => option.name}
renderInput={(params) => (
<TextField
{...params}
fullWidth
placeholder={'Search all tools'}
InputProps={{
...params.InputProps,
2025-02-23 14:11:21 +00:00
endAdornment: <SearchIcon />,
sx: {
2025-02-25 06:17:10 +00:00
borderRadius: 4,
2025-03-31 01:27:44 +00:00
backgroundColor: 'background.paper'
2025-02-23 14:11:21 +00:00
}
2024-06-25 09:35:44 +01:00
}}
onChange={(event) => handleInputChange(event, event.target.value)}
/>
)}
renderOption={(props, option) => (
2024-06-27 20:27:03 +01:00
<Box
component="li"
{...props}
onClick={() => navigate('/' + option.path)}
>
2025-03-02 02:58:50 +00:00
<Stack direction={'row'} spacing={2} alignItems={'center'}>
<Icon fontSize={20} icon={option.icon} />
<Box>
<Typography fontWeight={'bold'}>{option.name}</Typography>
<Typography fontSize={12}>{option.shortDescription}</Typography>
</Box>
</Stack>
2024-06-25 09:35:44 +01:00
</Box>
)}
2025-03-06 17:54:36 +00:00
onChange={(event, newValue) => {
if (newValue) {
navigate('/' + newValue.path);
2025-02-27 00:09:15 +00:00
}
}}
2024-06-25 09:35:44 +01:00
/>
<Grid container spacing={2} mt={2}>
{exampleTools.map((tool) => (
2024-06-26 00:29:53 +01:00
<Grid
2025-02-25 13:02:00 +00:00
onClick={() =>
navigate(tool.url.startsWith('/') ? tool.url : `/${tool.url}`)
}
2024-06-26 00:29:53 +01:00
item
xs={12}
md={6}
lg={4}
key={tool.label}
>
2024-06-25 09:35:44 +01:00
<Box
sx={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderWidth: 1,
padding: 1,
borderRadius: 3,
2025-03-31 01:27:44 +00:00
borderColor: theme.palette.mode === 'dark' ? '#363b41' : 'grey',
2024-06-25 09:35:44 +01:00
borderStyle: 'solid',
2025-03-31 01:27:44 +00:00
backgroundColor: 'background.paper',
2025-02-23 14:11:21 +00:00
cursor: 'pointer',
2025-03-31 01:27:44 +00:00
'&:hover': {
backgroundColor: 'background.hover'
}
2024-06-25 09:35:44 +01:00
}}
>
<Typography>{tool.label}</Typography>
</Box>
</Grid>
))}
</Grid>
</Box>
);
}