Files
omni-tools/src/pages/tools-by-category/index.tsx

86 lines
3.0 KiB
TypeScript
Raw Normal View History

2024-06-26 09:02:05 +01:00
import { Box, Divider, Stack, useTheme } from '@mui/material';
2024-06-25 09:35:44 +01:00
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import { Link, useNavigate, useParams } from 'react-router-dom';
2024-06-26 09:02:05 +01:00
import { getToolsByCategory } from '../../tools';
2024-06-25 09:35:44 +01:00
import Hero from 'components/Hero';
2025-03-09 19:20:40 +00:00
import { capitalizeFirstLetter } from '@utils/string';
2025-02-25 06:17:10 +00:00
import { Icon } from '@iconify/react';
import { categoriesColors } from 'config/uiConfig';
2025-03-09 19:20:40 +00:00
import React, { useEffect } from 'react';
2024-06-25 09:35:44 +01:00
export default function Home() {
const navigate = useNavigate();
const theme = useTheme();
2025-03-09 19:20:40 +00:00
const mainContentRef = React.useRef<HTMLDivElement>(null);
2024-06-25 09:35:44 +01:00
const { categoryName } = useParams();
2025-03-09 19:20:40 +00:00
useEffect(() => {
if (mainContentRef.current) {
mainContentRef.current.scrollIntoView({ behavior: 'smooth' });
}
}, []);
2024-06-25 09:35:44 +01:00
return (
2025-02-25 06:17:10 +00:00
<Box sx={{ backgroundColor: '#F5F5FA' }}>
2024-06-25 09:35:44 +01:00
<Box
2024-06-26 00:29:53 +01:00
padding={{ xs: 1, md: 3, lg: 5 }}
2024-06-25 09:35:44 +01:00
display={'flex'}
flexDirection={'column'}
alignItems={'center'}
justifyContent={'center'}
width={'100%'}
>
<Hero />
</Box>
<Divider sx={{ borderColor: theme.palette.primary.main }} />
2025-03-09 19:20:40 +00:00
<Box ref={mainContentRef} mt={3} ml={{ xs: 1, md: 2, lg: 3 }} padding={3}>
2024-06-25 09:35:44 +01:00
<Typography
fontSize={22}
color={theme.palette.primary.main}
>{`All ${capitalizeFirstLetter(categoryName)} Tools`}</Typography>
<Grid container spacing={2} mt={2}>
{getToolsByCategory()
.find(({ type }) => type === categoryName)
2025-02-25 06:17:10 +00:00
?.tools?.map((tool, index) => (
2024-06-26 00:29:53 +01:00
<Grid item xs={12} md={6} lg={4} key={tool.path}>
2024-06-25 09:35:44 +01:00
<Stack
sx={{
2025-02-25 06:17:10 +00:00
backgroundColor: 'white',
boxShadow: '5px 4px 2px #E9E9ED',
2024-06-25 09:35:44 +01:00
cursor: 'pointer',
2025-03-08 07:33:07 +00:00
height: '100%',
2024-06-25 09:35:44 +01:00
'&:hover': {
backgroundColor: theme.palette.background.default // Change this to your desired hover color
}
}}
onClick={() => navigate('/' + tool.path)}
direction={'row'}
2025-02-25 13:47:53 +00:00
alignItems={'center'}
2024-06-25 09:35:44 +01:00
spacing={2}
padding={2}
2025-02-25 06:17:10 +00:00
border={`1px solid ${theme.palette.background.default}`}
2024-06-25 09:35:44 +01:00
borderRadius={2}
>
2025-02-25 06:17:10 +00:00
<Icon
icon={tool.icon ?? 'ph:compass-tool-thin'}
2025-02-25 13:47:53 +00:00
fontSize={'60px'}
2025-02-25 06:17:10 +00:00
color={categoriesColors[index % categoriesColors.length]}
/>
2024-06-25 09:35:44 +01:00
<Box>
2025-02-25 13:47:53 +00:00
<Link style={{ fontSize: 20 }} to={'/' + tool.path}>
{tool.name}
</Link>
2024-06-25 09:35:44 +01:00
<Typography sx={{ mt: 2 }}>
{tool.shortDescription}
</Typography>
</Box>
</Stack>
</Grid>
))}
</Grid>
</Box>
</Box>
);
}