262 lines
8.9 KiB
TypeScript
262 lines
8.9 KiB
TypeScript
import React, { useEffect } from 'react';
|
|
import Link from 'next/link';
|
|
import { Button } from '@/components/common/Button';
|
|
import { Logo } from './navbar/Logo';
|
|
import { X, Menu, Globe, Home, Info, Package, Phone, User } from 'lucide-react';
|
|
import { useTranslation } from '@/lib/hooks/useTranslation';
|
|
import { URLS } from '@/lib/config/constants';
|
|
import { cn, commonClasses, createNavClickHandler } from '@/lib/utils';
|
|
import { DiscordLogo } from '@/components/ui/DiscordLogo';
|
|
import type { Translation } from '@/types/i18n';
|
|
|
|
interface MobileMenuProps {
|
|
isOpen: boolean;
|
|
onClose: () => void;
|
|
translations: Translation['navigation'];
|
|
}
|
|
|
|
interface MobileNavItemProps {
|
|
icon: React.ReactNode;
|
|
title: string;
|
|
description: string;
|
|
href: string;
|
|
isExternal?: boolean;
|
|
onClick?: () => void;
|
|
}
|
|
|
|
const MobileNavItem: React.FC<MobileNavItemProps> = ({
|
|
icon,
|
|
title,
|
|
description,
|
|
href,
|
|
isExternal = false,
|
|
onClick
|
|
}) => {
|
|
const handleClick = (e: React.MouseEvent) => {
|
|
if (onClick) {
|
|
e.preventDefault();
|
|
onClick();
|
|
}
|
|
};
|
|
|
|
return (
|
|
<a
|
|
href={href}
|
|
onClick={handleClick}
|
|
className={cn(
|
|
commonClasses.mobileMenuItem,
|
|
commonClasses.hoverScale,
|
|
'hover:shadow-lg hover:shadow-blue-500/20'
|
|
)}
|
|
target={isExternal ? '_blank' : undefined}
|
|
rel={isExternal ? 'noopener noreferrer' : undefined}
|
|
>
|
|
<div className="flex items-center space-x-4">
|
|
<div className={cn(
|
|
'flex items-center justify-center w-10 h-10 rounded-xl',
|
|
'bg-gradient-to-br from-blue-400/20 to-blue-600/20',
|
|
'border border-blue-300/20',
|
|
'group-hover:scale-110 transition-transform duration-300'
|
|
)}>
|
|
{icon}
|
|
</div>
|
|
<div className="flex-1">
|
|
<span className="block text-white font-semibold text-base group-hover:text-blue-200 transition-colors">
|
|
{title}
|
|
</span>
|
|
<p className="text-white/60 text-sm mt-0.5 group-hover:text-white/80 transition-colors">
|
|
{description}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Arrow Icon */}
|
|
<div className={cn(
|
|
'flex items-center justify-center w-6 h-6 rounded-full',
|
|
'text-white/40 group-hover:text-white/80 transition-all duration-300',
|
|
'group-hover:translate-x-1'
|
|
)}>
|
|
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
|
|
</svg>
|
|
</div>
|
|
</a>
|
|
);
|
|
};
|
|
|
|
export const MobileMenu: React.FC<MobileMenuProps> = ({ isOpen, onClose, translations }) => {
|
|
const { t } = useTranslation();
|
|
|
|
// Gérer le scroll du body - simplifié avec notre utilitaire
|
|
useEffect(() => {
|
|
const originalStyle = document.body.style.overflow;
|
|
|
|
if (isOpen) {
|
|
document.body.style.overflow = 'hidden';
|
|
} else {
|
|
document.body.style.overflow = originalStyle || 'unset';
|
|
}
|
|
|
|
return () => {
|
|
document.body.style.overflow = originalStyle || 'unset';
|
|
};
|
|
}, [isOpen]);
|
|
|
|
// Gestionnaire de navigation optimisé
|
|
const handleNavClick = createNavClickHandler(onClose);
|
|
|
|
// Configuration des icônes SVG - factorisation
|
|
const icons = {
|
|
home: (
|
|
<svg className="w-5 h-5 text-blue-200" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
|
|
</svg>
|
|
),
|
|
services: (
|
|
<svg className="w-5 h-5 text-blue-200" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />
|
|
</svg>
|
|
),
|
|
about: (
|
|
<svg className="w-5 h-5 text-blue-200" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
</svg>
|
|
),
|
|
contact: (
|
|
<svg className="w-5 h-5 text-blue-200" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
|
|
</svg>
|
|
),
|
|
discord: (
|
|
<DiscordLogo size="sm" className="text-[#5865F2]" />
|
|
),
|
|
user: (
|
|
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
|
</svg>
|
|
)
|
|
};
|
|
|
|
return (
|
|
<div className={cn(
|
|
'md:hidden fixed inset-0 z-[100] transition-all duration-300',
|
|
isOpen ? 'visible' : 'invisible'
|
|
)}>
|
|
{/* Overlay avec effet de blur moderne */}
|
|
<div className={cn(
|
|
'absolute inset-0 transition-all duration-300',
|
|
'bg-gradient-to-br from-black/80 via-blue-900/60 to-black/80',
|
|
'backdrop-blur-lg',
|
|
isOpen ? 'opacity-100' : 'opacity-0'
|
|
)}
|
|
onClick={onClose}
|
|
/>
|
|
|
|
{/* Menu Panel */}
|
|
<div className={cn(
|
|
'absolute top-0 right-0 h-full w-80 max-w-[90vw]',
|
|
'bg-gradient-to-b from-blue-900/98 via-blue-900/95 to-blue-900/90',
|
|
'backdrop-blur-2xl shadow-2xl',
|
|
'border-l border-blue-300/20',
|
|
'transition-transform duration-300 ease-out',
|
|
isOpen ? 'translate-x-0' : 'translate-x-full'
|
|
)}>
|
|
|
|
{/* Header avec Logo */}
|
|
<div className="flex items-center justify-between p-6 pt-8 border-b border-blue-300/20">
|
|
<Logo scrolled={false} />
|
|
|
|
<button
|
|
className={cn(
|
|
'group relative p-3 rounded-xl',
|
|
commonClasses.transition,
|
|
'bg-white/10 hover:bg-white/20 active:bg-white/25',
|
|
'border border-white/20 hover:border-white/30',
|
|
commonClasses.hoverScale,
|
|
'focus:outline-none focus:ring-2 focus:ring-blue-400/50'
|
|
)}
|
|
onClick={onClose}
|
|
aria-label="Fermer le menu"
|
|
>
|
|
<svg className="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
{/* Navigation Items */}
|
|
<div className="flex flex-col h-full overflow-y-auto p-6 space-y-4">
|
|
|
|
{/* Section Navigation */}
|
|
<div className="space-y-3">
|
|
<MobileNavItem
|
|
icon={icons.home}
|
|
title={translations.home}
|
|
description={t.common.backToHome}
|
|
href="#home"
|
|
onClick={() => handleNavClick('home')}
|
|
/>
|
|
|
|
<MobileNavItem
|
|
icon={icons.services}
|
|
title={translations.services}
|
|
description={t.common.discoverOffer}
|
|
href="#services"
|
|
onClick={() => handleNavClick('services')}
|
|
/>
|
|
|
|
<MobileNavItem
|
|
icon={icons.about}
|
|
title={translations.about}
|
|
description={t.common.learnMoreAboutUs}
|
|
href="#about"
|
|
onClick={() => handleNavClick('about')}
|
|
/>
|
|
|
|
<MobileNavItem
|
|
icon={icons.contact}
|
|
title={translations.contact}
|
|
description={t.common.sendEmail}
|
|
href="mailto:contact@la-banquise.fr"
|
|
onClick={() => handleNavClick('contact')}
|
|
/>
|
|
</div>
|
|
|
|
{/* Divider */}
|
|
<div className="border-t border-blue-300/20 my-6" />
|
|
|
|
{/* Social & External Links */}
|
|
<div className="space-y-3">
|
|
<MobileNavItem
|
|
icon={icons.discord}
|
|
title="Discord"
|
|
description={t.common.joinCommunity}
|
|
href={URLS.social.discord}
|
|
isExternal={true}
|
|
/>
|
|
</div>
|
|
|
|
{/* CTA Button */}
|
|
<div className="mt-8 pb-6">
|
|
<Button
|
|
variant="primary"
|
|
size="lg"
|
|
leftIcon={icons.user}
|
|
onClick={() => {
|
|
window.open(URLS.services.auth, '_blank');
|
|
onClose();
|
|
}}
|
|
className="w-full shadow-xl"
|
|
>
|
|
{t.common.login}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Effet de gradient overlay */}
|
|
<div className="absolute inset-0 bg-gradient-to-b from-transparent via-transparent to-blue-900/10 pointer-events-none" />
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|