From 0475131b371933ad0065d7a49386734d67bdcd21 Mon Sep 17 00:00:00 2001 From: matthieu Date: Thu, 23 Oct 2025 16:20:09 +0200 Subject: [PATCH] Update components with CSS animations --- src/components/Navigation.tsx | 396 +++++++++++++++++----------------- 1 file changed, 198 insertions(+), 198 deletions(-) diff --git a/src/components/Navigation.tsx b/src/components/Navigation.tsx index a6a215c..23f1151 100644 --- a/src/components/Navigation.tsx +++ b/src/components/Navigation.tsx @@ -1,199 +1,199 @@ -import React, { useState, useRef, useEffect } from 'react'; - import { Home, PlusSquare, Library, LogOut, Settings, ChevronDown, Search, Heart, Menu } from 'lucide-react'; - import { useAuth } from '../contexts/AuthContext'; - import { supabase } from '../lib/supabase'; - - type Page = 'home' | 'deck' | 'login' | 'collection' | 'profile' | 'search' | 'life-counter'; - - interface NavigationProps { - currentPage: Page; - setCurrentPage: (page: Page) => void; - } - - export default function Navigation({ currentPage, setCurrentPage }: NavigationProps) { - const { user, signOut } = useAuth(); - const [showDropdown, setShowDropdown] = useState(false); - const [showMobileMenu, setShowMobileMenu] = useState(false); - const dropdownRef = useRef(null); - const mobileMenuRef = useRef(null); - const [username, setUsername] = useState(null); - - useEffect(() => { - const fetchProfile = async () => { - if (user) { - const { data } = await supabase - .from('profiles') - .select('username') - .eq('id', user.id) - .single(); - - if (data) { - setUsername(data.username); - } - } - }; - - fetchProfile(); - }, [user]); - - useEffect(() => { - const handleClickOutside = (event: MouseEvent) => { - if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) { - setShowDropdown(false); - } - if (mobileMenuRef.current && !mobileMenuRef.current.contains(event.target as Node)) { - setShowMobileMenu(false); - } - }; - - document.addEventListener('mousedown', handleClickOutside); - return () => document.removeEventListener('mousedown', handleClickOutside); - }, []); - - const navItems = [ - { id: 'home' as const, label: 'Home', icon: Home }, - { id: 'deck' as const, label: 'New Deck', icon: PlusSquare }, - { id: 'collection' as const, label: 'Collection', icon: Library }, - { id: 'search' as const, label: 'Search', icon: Search }, - { id: 'life-counter' as const, label: 'Life Counter', icon: Heart }, - ]; - - const handleSignOut = async () => { - try { - await signOut(); - setCurrentPage('login'); - } catch (error) { - console.error('Error signing out:', error); - } - }; - - const getAvatarUrl = (userId: string) => { - return `https://api.dicebear.com/7.x/avataaars/svg?seed=${userId}&backgroundColor=b6e3f4,c0aede,d1d4f9`; - }; - - return ( - <> - {/* Desktop Navigation - Top */} - - - {/* Mobile Navigation - Bottom */} - - - {/* Content Padding */} -
- - ); +import React, { useState, useRef, useEffect } from 'react'; + import { Home, PlusSquare, Library, LogOut, Settings, ChevronDown, Search, Heart, Menu } from 'lucide-react'; + import { useAuth } from '../contexts/AuthContext'; + import { supabase } from '../lib/supabase'; + + type Page = 'home' | 'deck' | 'login' | 'collection' | 'profile' | 'search' | 'life-counter'; + + interface NavigationProps { + currentPage: Page; + setCurrentPage: (page: Page) => void; + } + + export default function Navigation({ currentPage, setCurrentPage }: NavigationProps) { + const { user, signOut } = useAuth(); + const [showDropdown, setShowDropdown] = useState(false); + const [showMobileMenu, setShowMobileMenu] = useState(false); + const dropdownRef = useRef(null); + const mobileMenuRef = useRef(null); + const [username, setUsername] = useState(null); + + useEffect(() => { + const fetchProfile = async () => { + if (user) { + const { data } = await supabase + .from('profiles') + .select('username') + .eq('id', user.id) + .single(); + + if (data) { + setUsername(data.username); + } + } + }; + + fetchProfile(); + }, [user]); + + useEffect(() => { + const handleClickOutside = (event: MouseEvent) => { + if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) { + setShowDropdown(false); + } + if (mobileMenuRef.current && !mobileMenuRef.current.contains(event.target as Node)) { + setShowMobileMenu(false); + } + }; + + document.addEventListener('mousedown', handleClickOutside); + return () => document.removeEventListener('mousedown', handleClickOutside); + }, []); + + const navItems = [ + { id: 'home' as const, label: 'Home', icon: Home }, + { id: 'deck' as const, label: 'New Deck', icon: PlusSquare }, + { id: 'collection' as const, label: 'Collection', icon: Library }, + { id: 'search' as const, label: 'Search', icon: Search }, + { id: 'life-counter' as const, label: 'Life Counter', icon: Heart }, + ]; + + const handleSignOut = async () => { + try { + await signOut(); + setCurrentPage('login'); + } catch (error) { + console.error('Error signing out:', error); + } + }; + + const getAvatarUrl = (userId: string) => { + return `https://api.dicebear.com/7.x/avataaars/svg?seed=${userId}&backgroundColor=b6e3f4,c0aede,d1d4f9`; + }; + + return ( + <> + {/* Desktop Navigation - Top */} + + + {/* Mobile Navigation - Bottom */} + + + {/* Content Padding */} +
+ + ); }