'use client'; import { Bell, Book, ChevronRight, FileText, Globe, Grid, HelpCircle, Info, LucideIcon, Menu, X, } from 'lucide-react'; import { Fragment, useEffect, useState } from 'react'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from '@/components/ui/accordion'; import { Button } from '@/components/ui/button'; import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, navigationMenuTriggerStyle, } from '@/components/ui/navigation-menu'; import { Sheet, SheetContent, SheetTitle } from '@/components/ui/sheet'; interface MenuLink { label: string; description?: string; url?: string; icon?: { component: LucideIcon; color: string; }; } interface MenuItem { title: string; url?: string; links?: MenuLink[]; } interface DesktopMenuItemProps { item: MenuItem; index: number; } interface MobileNavigationMenuProps { open: boolean; } interface MenuSubLinkProps { link: MenuLink; } const LOGO = { url: '#', src: 'https://deifkwefumgah.cloudfront.net/shadcnblocks/block/block-1.svg', alt: 'logo', title: 'Shadcnblocks.com', }; const NAVIGATION: MenuItem[] = [ { title: 'Products', links: [ { label: 'Company Blog', description: 'Insights & updates', url: '#', icon: { component: FileText, color: '#10b981', }, }, { label: 'Our Platform', description: 'Empower your work', url: '#', icon: { component: Grid, color: '#6366f1', }, }, ], }, { title: 'Company', links: [ { label: 'About Our Team', url: '#', description: 'Our mission & values', icon: { component: Info, color: '#f59e0b', }, }, { label: 'Help & Support Center', url: '#', description: 'Get quick help', icon: { component: HelpCircle, color: '#3b82f6', }, }, { label: 'Latest News', url: '#', description: 'Product updates', icon: { component: Bell, color: '#f97316', }, }, ], }, { title: 'Resources', links: [ { label: 'Documentation', url: '#', description: 'Guides & references', icon: { component: Book, color: '#8b5cf6', }, }, { label: 'API Reference', url: '#', description: 'Explore our API', icon: { component: Globe, color: '#ef4444', }, }, ], }, { title: 'Pricing', url: '#', }, { title: 'Contact', url: '#', }, ]; const PRIMARY_BUTTON = { label: 'Sign up', url: '#', }; const MOBILE_BREAKPOINT = 1024; const Navbar = () => { const [open, setOpen] = useState(false); useEffect(() => { const handleResize = () => { if (window.innerWidth > MOBILE_BREAKPOINT) { setOpen(false); } }; handleResize(); window.addEventListener('resize', handleResize); return () => { window.removeEventListener('resize', handleResize); }; }, []); useEffect(() => { document.body.style.overflow = open ? 'hidden' : 'auto'; }, [open]); const handleMobileMenu = () => { const nextOpen = !open; setOpen(nextOpen); }; return (
{LOGO.alt} {NAVIGATION.map((item, index) => ( ))}
); }; const DesktopMenuItem = ({ item, index }: DesktopMenuItemProps) => { if (item.links) { return ( {item.title}
    {item.links.map((link, index) => (
  • ))}
); } return ( {item.title} ); }; const MenuSubLink = ({ link }: MenuSubLinkProps) => { return (
{link.icon && ( )}

{link.label}

{link.description}

); }; const MobileNavigationMenu = ({ open }: MobileNavigationMenuProps) => { return (
Mobile Navigation
{NAVIGATION.map((item, index) => renderMobileMenuItem(item, index))}
); }; const renderMobileMenuItem = (item: MenuItem, index: number) => { if (item.links) { return ( {item.title} {item.links.map((subItem) => ( ))} ); } return ( {item.title} ); }; interface GithubStarsProps { repoUrl: string; } const GithubStars = ({ repoUrl }: GithubStarsProps) => { const [stargazersCount, setStargazersCount] = useState(''); const [owner, repo] = repoUrl.split('github.com/')[1].split('/'); const githubApiEndpoint = `https://api.github.com/repos/${owner}/${repo}`; const formatStargazers = (count: number | ''): string => { if (count === '') return ''; if (count < 1000) return count.toString(); return `${Math.round(count / 1000)}k`; }; useEffect(() => { const getStars = async () => { try { const response = await fetch(githubApiEndpoint); const json = await response.json(); const formattedCount = formatStargazers(json.stargazers_count); setStargazersCount(formattedCount); } catch (error: unknown) { if (error instanceof Error) { console.error(error.message); } } }; getStars(); }, [githubApiEndpoint]); return ( ); }; export { Navbar };