omni-tools/src/components/ToolHeader.tsx

99 lines
2.4 KiB
TypeScript
Raw Normal View History

2025-02-25 13:41:57 +00:00
import { Box, Button, styled, useTheme } from '@mui/material';
2024-06-22 22:06:16 +01:00
import Typography from '@mui/material/Typography';
2024-06-25 19:45:29 +01:00
import ToolBreadcrumb from './ToolBreadcrumb';
import { capitalizeFirstLetter } from '../utils/string';
2024-06-26 00:47:21 +01:00
import Grid from '@mui/material/Grid';
2025-02-25 06:17:10 +00:00
import { Icon, IconifyIcon } from '@iconify/react';
import { categoriesColors } from '../config/uiConfig';
2024-06-19 21:18:35 +01:00
2025-02-25 13:41:57 +00:00
const StyledButton = styled(Button)(({ theme }) => ({
backgroundColor: 'white',
'&:hover': {
backgroundColor: theme.palette.primary.main,
color: 'white'
}
}));
2024-06-19 21:18:35 +01:00
interface ToolHeaderProps {
title: string;
description: string;
2025-02-25 06:24:00 +00:00
icon?: IconifyIcon | string;
2024-06-25 19:45:29 +01:00
type: string;
2024-06-19 21:18:35 +01:00
}
2024-06-23 01:35:40 -07:00
function ToolLinks() {
2025-02-25 13:41:57 +00:00
const theme = useTheme();
2024-06-23 01:35:40 -07:00
return (
2024-06-26 00:47:21 +01:00
<Grid container spacing={2} mt={1}>
<Grid item md={12} lg={4}>
2025-02-25 13:41:57 +00:00
<StyledButton
2025-02-25 06:17:10 +00:00
sx={{ backgroundColor: 'white' }}
fullWidth
variant="outlined"
href="#tool"
>
2024-06-26 00:47:21 +01:00
Use This Tool
2025-02-25 13:41:57 +00:00
</StyledButton>
2024-06-26 00:47:21 +01:00
</Grid>
<Grid item md={12} lg={4}>
2025-02-25 13:41:57 +00:00
<StyledButton fullWidth variant="outlined" href="#examples">
2024-06-26 00:47:21 +01:00
See Examples
2025-02-25 13:41:57 +00:00
</StyledButton>
2024-06-26 00:47:21 +01:00
</Grid>
<Grid item md={12} lg={4}>
2025-02-25 13:41:57 +00:00
<StyledButton fullWidth variant="outlined" href="#tour">
2024-06-26 00:47:21 +01:00
Learn How to Use
2025-02-25 13:41:57 +00:00
</StyledButton>
2024-06-26 00:47:21 +01:00
</Grid>
</Grid>
2024-06-23 01:35:40 -07:00
);
}
2024-06-23 01:26:04 +01:00
export default function ToolHeader({
2025-02-25 06:17:10 +00:00
icon,
2024-06-23 01:26:04 +01:00
title,
2024-06-25 19:45:29 +01:00
description,
type
2024-06-23 01:26:04 +01:00
}: ToolHeaderProps) {
2024-06-22 22:06:16 +01:00
return (
2024-06-25 19:45:29 +01:00
<Box my={4}>
<ToolBreadcrumb
items={[
{ title: 'All tools', link: '/' },
{
title: capitalizeFirstLetter(type),
link: '/categories/' + type
},
{ title }
]}
/>
2024-06-26 00:47:21 +01:00
<Grid mt={1} container spacing={2}>
<Grid item xs={12} md={8}>
2024-06-25 19:45:29 +01:00
<Typography mb={2} fontSize={30} color={'primary'}>
{title}
</Typography>
<Typography fontSize={20}>{description}</Typography>
<ToolLinks />
2024-06-26 00:47:21 +01:00
</Grid>
2025-02-25 06:17:10 +00:00
{icon && (
2024-06-26 00:47:21 +01:00
<Grid item xs={12} md={4}>
<Box sx={{ display: 'flex', justifyContent: 'center' }}>
2025-02-25 06:17:10 +00:00
<Icon
icon={icon}
fontSize={'250'}
color={
categoriesColors[
Math.floor(Math.random() * categoriesColors.length)
]
}
/>
2024-06-26 00:47:21 +01:00
</Box>
</Grid>
)}
</Grid>
2024-06-25 19:45:29 +01:00
</Box>
2024-06-22 22:06:16 +01:00
);
2024-06-19 21:18:35 +01:00
}