File size: 4,623 Bytes
482f77b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
class CustomHeader extends HTMLElement {
    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
            <style>
                nav {
                    font-family: 'Roboto', sans-serif;
                }
                .nav-link {
                    transition: color 0.3s ease;
                }
                .nav-link:hover {
                    color: var(--primary-500);
                }
                .dropdown:hover .dropdown-menu {
                    display: block;
                }
            </style>
            <header class="bg-white shadow-md">
                <div class="container mx-auto px-4">
                    <div class="flex justify-between items-center py-4">
                        <!-- Logo -->
                        <a href="/" class="flex items-center">
                            <img src="http://static.photos/education/200x200/1" alt="BnF Logo" class="h-12 mr-3">
                            <span class="text-xl font-bold text-primary-700">Bibliographie Nationale</span>
                        </a>
                        
                        <!-- Mobile Menu Button -->
                        <button class="md:hidden focus:outline-none" id="mobile-menu-button">
                            <i data-feather="menu"></i>
                        </button>
                        
                        <!-- Desktop Navigation -->
                        <nav class="hidden md:flex items-center space-x-8">
                            <a href="/" class="nav-link text-secondary-700 hover:text-primary-500">Accueil</a>
                            <a href="/collections" class="nav-link text-secondary-700 hover:text-primary-500">Collections</a>
                            <a href="/recherche" class="nav-link text-secondary-700 hover:text-primary-500">Recherche avancée</a>
                            <a href="/a-propos" class="nav-link text-secondary-700 hover:text-primary-500">À propos</a>
                            
                            <!-- User Actions -->
                            <div class="flex items-center space-x-4 ml-6">
                                <a href="/connexion" class="text-secondary-700 hover:text-primary-500">
                                    <i data-feather="user"></i>
                                </a>
                                <a href="/panier" class="text-secondary-700 hover:text-primary-500">
                                    <i data-feather="shopping-cart"></i>
                                </a>
                            </div>
                        </nav>
                    </div>
                    
                    <!-- Mobile Menu -->
                    <div class="md:hidden hidden py-4" id="mobile-menu">
                        <div class="flex flex-col space-y-3">
                            <a href="/" class="nav-link text-secondary-700 hover:text-primary-500">Accueil</a>
                            <a href="/collections" class="nav-link text-secondary-700 hover:text-primary-500">Collections</a>
                            <a href="/recherche" class="nav-link text-secondary-700 hover:text-primary-500">Recherche avancée</a>
                            <a href="/a-propos" class="nav-link text-secondary-700 hover:text-primary-500">À propos</a>
                            <div class="pt-3 border-t border-gray-200 mt-3">
                                <a href="/connexion" class="inline-flex items-center text-secondary-700 hover:text-primary-500">
                                    <i data-feather="user" class="mr-2"></i> Connexion
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </header>
        `;
        
        // Mobile menu toggle
        const mobileMenuButton = this.shadowRoot.getElementById('mobile-menu-button');
        const mobileMenu = this.shadowRoot.getElementById('mobile-menu');
        
        if (mobileMenuButton && mobileMenu) {
            mobileMenuButton.addEventListener('click', () => {
                const isHidden = mobileMenu.classList.contains('hidden');
                if (isHidden) {
                    mobileMenu.classList.remove('hidden');
                    mobileMenu.classList.add('block');
                } else {
                    mobileMenu.classList.add('hidden');
                    mobileMenu.classList.remove('block');
                }
            });
        }
    }
}

customElements.define('custom-header', CustomHeader);