2023-09-18 21:55:40 +00:00
|
|
|
'use client';
|
|
|
|
|
|
2024-01-26 21:34:40 -06:00
|
|
|
import Link from 'next/link';
|
2023-09-24 17:36:20 -05:00
|
|
|
import { usePathname } from 'next/navigation';
|
2024-01-05 15:01:45 -06:00
|
|
|
import { ReactNode, Suspense } from 'react';
|
2023-09-24 17:24:21 -05:00
|
|
|
import { TOOLS } from '../../constants/tools';
|
2023-09-18 21:55:40 +00:00
|
|
|
import { theme } from '../../stitches.config';
|
2024-01-05 15:01:45 -06:00
|
|
|
import { Loader } from './components/Loader';
|
2023-09-18 21:55:40 +00:00
|
|
|
|
|
|
|
|
interface ToolsLayoutProps {
|
|
|
|
|
children: ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function ToolsLayout({ children }: ToolsLayoutProps) {
|
2023-09-24 17:36:20 -05:00
|
|
|
const pathname = usePathname();
|
2024-02-17 10:43:34 -06:00
|
|
|
const pathSplit = pathname.split('/');
|
|
|
|
|
const toolId = pathSplit.at(2);
|
2023-09-18 21:55:40 +00:00
|
|
|
const tool = TOOLS.find((tool) => tool.id === toolId);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2024-02-09 18:09:36 -06:00
|
|
|
{tool && <title>{tool.title}</title>}
|
|
|
|
|
|
2024-02-17 10:43:34 -06:00
|
|
|
{pathSplit.length === 3 && (
|
2023-10-11 21:26:33 -05:00
|
|
|
<div
|
|
|
|
|
style={{
|
2024-02-17 10:43:34 -06:00
|
|
|
height: 128,
|
|
|
|
|
boxShadow: `inset 0 -192px 128px -128px ${theme.colors.appBackground1}`,
|
|
|
|
|
display: 'flex',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
position: 'relative',
|
|
|
|
|
overflow: 'hidden',
|
2023-10-11 21:26:33 -05:00
|
|
|
}}
|
2024-02-17 10:43:34 -06:00
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
backgroundImage: `url(/assets/banners/${toolId}.webp)`,
|
|
|
|
|
backgroundSize: 'cover',
|
|
|
|
|
backgroundPosition: 'center',
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
top: 0,
|
|
|
|
|
left: 0,
|
|
|
|
|
zIndex: -1,
|
|
|
|
|
filter: 'blur(4px)',
|
|
|
|
|
transform: 'scale(calc((128 + 8) / 128))',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-10-11 21:26:33 -05:00
|
|
|
|
2024-02-17 10:43:34 -06:00
|
|
|
<Link
|
|
|
|
|
href={`/tools/${toolId}`}
|
|
|
|
|
style={{
|
|
|
|
|
textDecoration: 'none',
|
|
|
|
|
fontWeight: 900,
|
|
|
|
|
color: theme.colors.textHighContrast,
|
|
|
|
|
fontSize: 32,
|
|
|
|
|
letterSpacing: -1,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{tool?.title}
|
|
|
|
|
</Link>
|
|
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
color: theme.colors.textLowContrast,
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{tool?.description}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2023-09-18 21:55:40 +00:00
|
|
|
|
2024-01-05 15:01:45 -06:00
|
|
|
<Suspense fallback={<Loader />}>{children}</Suspense>
|
2023-09-18 21:55:40 +00:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|