omni-tools/src/components/ToolLayout.tsx

66 lines
1.7 KiB
TypeScript
Raw Normal View History

2024-06-22 20:38:03 +01:00
import { Box } from '@mui/material';
import React, { ReactNode } from 'react';
import { Helmet } from 'react-helmet';
import ToolHeader from './ToolHeader';
2024-06-27 12:39:38 +01:00
import Separator from './Separator';
2024-06-25 08:39:29 +01:00
import AllTools from './allTools/AllTools';
import { getToolsByCategory } from '@tools/index';
2024-06-25 09:35:44 +01:00
import { capitalizeFirstLetter } from '../utils/string';
2025-02-25 06:17:10 +00:00
import { IconifyIcon } from '@iconify/react';
2024-06-19 21:18:35 +01:00
2024-06-22 20:38:03 +01:00
export default function ToolLayout({
children,
title,
2024-06-23 01:26:04 +01:00
description,
2025-02-25 06:17:10 +00:00
icon,
2024-06-25 19:45:29 +01:00
type
2024-06-22 20:38:03 +01:00
}: {
title: string;
description: string;
2025-02-25 06:17:10 +00:00
icon?: IconifyIcon | string;
2024-06-25 19:45:29 +01:00
type: string;
2024-06-22 20:38:03 +01:00
children: ReactNode;
}) {
2024-06-25 08:39:29 +01:00
const otherCategoryTools =
getToolsByCategory()
.find((category) => category.type === type)
?.tools.filter((tool) => tool.name !== title)
.map((tool) => ({
title: tool.name,
description: tool.shortDescription,
2025-03-02 17:28:45 +00:00
link: '/' + tool.path,
icon: tool.icon
2024-06-25 08:39:29 +01:00
})) ?? [];
2024-06-22 20:38:03 +01:00
return (
<Box
width={'100%'}
display={'flex'}
flexDirection={'column'}
alignItems={'center'}
2025-03-31 01:27:44 +00:00
sx={{ backgroundColor: 'background.default' }}
2024-06-22 20:38:03 +01:00
>
<Helmet>
<title>{`${title} - Omni Tools`}</title>
</Helmet>
<Box width={'85%'}>
2024-06-25 19:45:29 +01:00
<ToolHeader
title={title}
description={description}
2025-02-25 06:17:10 +00:00
icon={icon}
2024-06-25 19:45:29 +01:00
type={type}
/>
2024-06-22 20:38:03 +01:00
{children}
2024-06-25 08:39:29 +01:00
<Separator backgroundColor="#5581b5" margin="50px" />
2024-06-25 09:35:44 +01:00
<AllTools
2025-04-02 04:25:02 +00:00
title={`All ${capitalizeFirstLetter(
getToolsByCategory().find((category) => category.type === type)!
.rawTitle
)} tools`}
2024-06-25 09:35:44 +01:00
toolCards={otherCategoryTools}
/>
2024-06-22 20:38:03 +01:00
</Box>
</Box>
);
2024-06-19 21:18:35 +01:00
}