import React, { forwardRef } from 'react'; import { clsx } from 'clsx'; import { Link } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { Button, ThemeToggle } from '../../ui'; import { CompactLanguageSelector } from '../../ui/LanguageSelector'; import { getRegisterUrl, getLoginUrl } from '../../../utils/navigation'; export interface PublicHeaderProps { className?: string; /** * Custom logo component */ logo?: React.ReactNode; /** * Show theme toggle */ showThemeToggle?: boolean; /** * Show authentication buttons (login/register) */ showAuthButtons?: boolean; /** * Show language selector */ showLanguageSelector?: boolean; /** * Custom navigation items */ navigationItems?: Array<{ id: string; label: string; href: string; external?: boolean; }>; /** * Header variant */ variant?: 'default' | 'transparent' | 'minimal'; } export interface PublicHeaderRef { scrollIntoView: () => void; } /** * PublicHeader - Header component for public pages (landing, login, register) * * Features: * - Clean, minimal design suitable for public pages * - Integrated theme toggle for consistent theming * - Authentication buttons (login/register) * - Optional custom navigation items * - Multiple visual variants * - Responsive design with mobile optimization * - Accessible navigation structure */ export const PublicHeader = forwardRef(({ className, logo, showThemeToggle = true, showAuthButtons = true, showLanguageSelector = true, navigationItems = [], variant = 'default', }, ref) => { const { t } = useTranslation(); const headerRef = React.useRef(null); // Default navigation items const defaultNavItems = [ // { id: 'features', label: 'Características', href: '#features', external: false }, // { id: 'pricing', label: 'Precios', href: '#pricing', external: false }, // { id: 'contact', label: 'Contacto', href: '#contact', external: false }, ]; const navItems = navigationItems.length > 0 ? navigationItems : defaultNavItems; // Scroll into view const scrollIntoView = React.useCallback(() => { headerRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' }); }, []); // Expose ref methods React.useImperativeHandle(ref, () => ({ scrollIntoView, }), [scrollIntoView]); // Render navigation link const renderNavLink = (item: typeof navItems[0]) => { const linkContent = ( {item.label} ); if (item.external || item.href.startsWith('http') || item.href.startsWith('#')) { return ( {linkContent} ); } return ( {linkContent} ); }; return (
{/* Logo and brand */}
{logo || ( <>
PI

Panadería IA

)}
{/* Desktop navigation */} {/* Right side actions */}
{/* Language selector - More compact */} {showLanguageSelector && (
)} {/* Theme toggle */} {showThemeToggle && ( )} {/* Authentication buttons - Enhanced */} {showAuthButtons && (
)} {/* Mobile theme toggle */} {showThemeToggle && ( )} {/* Mobile menu button */}
{/* Mobile navigation */}
); }); PublicHeader.displayName = 'PublicHeader';