'use client';
import { Fragment, PropsWithChildren, useEffect, useState } from 'react';
import { Dialog, Popover } from '@headlessui/react';
import clsx from 'clsx';
import { componentsRounded, iconsCountRounded, sponsorsUrl, uiGithubUrl } from '@/config/site';
import Icon from '@/components/Icon';
import GoToTop from '@/components/layout/GoToTop';
import Link from '@/components/Link';
import NavLink from '@/components/NavLink';
import Shape from '@/components/Shape';
// import { useRouter } from 'next/router'
const NavDropdown = ({ title, children, active, footer = false }) => {
return (
{({ open }) => (
<>
{title}
{children}
{footer && {footer}
}
>
)}
);
};
const menuLinks = [
{
title: 'UI Kit',
menu: 'ui',
children: [
{
icon: 'home',
href: '/',
title: 'About',
description: 'Develop beautiful web apps with Tabler',
},
{
icon: 'layout-dashboard',
href: '/preview',
title: 'Preview template',
description: 'See what Tabler looks like and offers',
},
{
icon: 'script',
href: '/docs',
title: 'Documentation',
description: 'Read how to develop apps with Tabler',
},
{
icon: 'lego',
href: '/features',
title: 'Features',
description: 'See what kind of features you can find here',
},
{
icon: 'lifebuoy',
href: '/support',
title: 'Support',
description: 'Write to us if you need anything!',
},
{
icon: 'brand-github',
href: uiGithubUrl,
title: 'Source code',
description: 'View Tabler\'s source code ',
props: {
target: '_blank',
rel: 'nofollow',
},
},
],
},
{
href: '/emails',
menu: 'emails',
title: 'Email templates',
},
{
href: '/icons',
menu: 'icons',
title: (
<>
Over {iconsCountRounded}
Icons
>
),
},
{
href: '/blog',
menu: 'blog',
title: (
<>
Blog
>
),
},
{
href: '/docs',
menu: 'docs',
title: 'Documentation',
},
// {
// href: '/guides',
// menu: 'guides',
// title: 'Guides',
// },
{
menu: 'sponsors',
href: sponsorsUrl,
type: 'button',
title: (
Sponsor project
),
icon: ,
},
];
const NavbarLink = (link, menu) => {
// const router = useRouter()
if (link.type === 'button') {
return (
);
} else if (link.children) {
return (
{link.children.map((link) => (
true}
{...link.props}
>
{link.title}
{link.description}
))}
);
}
return (
// router.pathname.replace(/^\//, '').startsWith(link.menu)
{link.title}
);
};
const SidebarLink = (link, menu, onClick) => {
if (link.type === 'button') {
return (
);
} else if (link.children) {
return (
{link.title}
{link.children.map((link) => (
{link.title}
))}
);
}
return (
{link.title}
);
};
const Navbar = ({
menu,
opened,
onClick,
...props
}: {
menu?: string
opened?: boolean
onClick?: (event: React.MouseEvent) => void,
className?: string,
}) => {
return (
{menuLinks.map((link) => (
{NavbarLink(link, menu)}
))}
);
};
export default function Header({ headerStatic, className, pageProps, ...props }:{
headerStatic?: boolean,
className?: string,
pageProps?: any,
}) {
const bannerId = 'tabler-icons-v2';
const [sticky, setSticky] = useState(false);
const [isOpen, setIsOpen] = useState(false);
const [showBanner, setShowBanner] = useState(false);
const pop = () => {
setSticky(window.pageYOffset > 0);
};
function closeModal() {
setIsOpen(false);
}
function toggleModal() {
setIsOpen(!isOpen);
}
function closeBanner() {
localStorage.setItem(`banner-${bannerId}`, '1');
setShowBanner(false);
}
useEffect(() => {
window.addEventListener('scroll', pop);
if (window.localStorage.getItem(`banner-${bannerId}`) !== '1') {
setShowBanner(true);
}
return () => window.removeEventListener('scroll', pop);
}, []);
// const router = useRouter()
return (
<>
{/* {showBanner && (
🎉 Tabler Icons v2.0 has been released: filled icons, new packages: React, Vue, Preact, Svelte, SolidJS
and more!
Learn more →
)} */}
>
);
}