import { Box, Button, Stack, styled, useTheme } from '@mui/material';
import Typography from '@mui/material/Typography';
import ToolBreadcrumb from './ToolBreadcrumb';
import { capitalizeFirstLetter } from '../utils/string';
import Grid from '@mui/material/Grid';
import { Icon, IconifyIcon } from '@iconify/react';
import { categoriesColors } from '../config/uiConfig';
import { getToolsByCategory } from '@tools/index';
import { useEffect, useState } from 'react';
import { isBookmarked, toggleBookmarked } from '@utils/bookmark';
import IconButton from '@mui/material/IconButton';
import { useTranslation } from 'react-i18next';
import useMediaQuery from '@mui/material/useMediaQuery';
import { validNamespaces } from '../i18n';
const StyledButton = styled(Button)(({ theme }) => ({
backgroundColor: 'white',
'&:hover': {
backgroundColor: theme.palette.primary.main,
color: 'white'
}
}));
interface ToolHeaderProps {
title: string;
description: string;
icon?: IconifyIcon | string;
type: string;
path: string;
}
function ToolLinks() {
const { t } = useTranslation();
const [examplesVisible, setExamplesVisible] = useState(false);
const theme = useTheme();
const isMd = useMediaQuery(theme.breakpoints.down('md'));
useEffect(() => {
const timeout = setTimeout(() => {
const element = document.getElementById('examples');
if (element && isVisible(element)) {
setExamplesVisible(true);
}
}, 500);
return () => clearTimeout(timeout);
}, []);
const scrollToElement = (id: string) => {
document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' });
};
function isVisible(elm: HTMLElement | null) {
return !!elm;
}
return (
{isMd && (
scrollToElement('tool')}
>
Use This Tool
)}
{examplesVisible && (
scrollToElement('examples')}
>
{t('toolHeader.seeExamples')}
)}
{/**/}
{/* */}
{/* Learn How to Use*/}
{/* */}
{/**/}
);
}
export default function ToolHeader({
icon,
title,
description,
type,
path
}: ToolHeaderProps) {
const theme = useTheme();
const { t } = useTranslation();
const [bookmarked, setBookmarked] = useState(isBookmarked(path));
return (
category.type === type
)!.rawTitle,
link: '/categories/' + type
},
{ title }
]}
/>
{title}
{
toggleBookmarked(path);
setBookmarked(!bookmarked);
}}
>
{description}
{icon && (
)}
);
}