File size: 3,958 Bytes
73f4f81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class CustomNavbar extends HTMLElement {
    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
            <style>
                .navbar {
                    transition: all 0.3s ease;
                }
                .navbar.scrolled {
                    background-color: white;
                    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
                }
                .mobile-menu {
                    max-height: 0;
                    overflow: hidden;
                    transition: max-height 0.3s ease;
                }
                .mobile-menu.open {
                    max-height: 500px;
                }
                @media (min-width: 768px) {
                    .mobile-menu {
                        max-height: none !important;
                    }
                }
            </style>
            <nav class="navbar fixed w-full z-50 bg-transparent text-white">
                <div class="container mx-auto px-6 py-4">
                    <div class="flex justify-between items-center">
                        <a href="#" class="text-2xl font-bold">TechFusion<span class="text-blue-300">2024</span></a>
                        
                        <!-- Desktop Menu -->
                        <div class="hidden md:flex space-x-8">
                            <a href="#speakers" class="hover:text-blue-300 transition">Speakers</a>
                            <a href="#schedule" class="hover:text-blue-300 transition">Schedule</a>
                            <a href="#venue" class="hover:text-blue-300 transition">Venue</a>
                            <a href="#pricing" class="hover:text-blue-300 transition">Pricing</a>
                            <a href="#register" class="bg-white text-blue-600 px-4 py-2 rounded hover:bg-gray-100 transition">Register</a>
                        </div>
                        
                        <!-- Mobile Menu Button -->
                        <button class="md:hidden focus:outline-none menu-toggle">
                            <i data-feather="menu"></i>
                        </button>
                    </div>
                    
                    <!-- Mobile Menu -->
                    <div class="mobile-menu md:hidden bg-white text-gray-800 rounded-lg mt-2">
                        <div class="px-2 pt-2 pb-4 space-y-2">
                            <a href="#speakers" class="block px-3 py-2 rounded hover:bg-gray-100">Speakers</a>
                            <a href="#schedule" class="block px-3 py-2 rounded hover:bg-gray-100">Schedule</a>
                            <a href="#venue" class="block px-3 py-2 rounded hover:bg-gray-100">Venue</a>
                            <a href="#pricing" class="block px-3 py-2 rounded hover:bg-gray-100">Pricing</a>
                            <a href="#register" class="block px-3 py-2 rounded bg-blue-600 text-white hover:bg-blue-700">Register</a>
                        </div>
                    </div>
                </div>
            </nav>
        `;
        
        // Add scroll event listener for navbar effect
        window.addEventListener('scroll', () => {
            const navbar = this.shadowRoot.querySelector('.navbar');
            if (window.scrollY > 50) {
                navbar.classList.add('scrolled', 'text-gray-800');
                navbar.classList.remove('text-white');
            } else {
                navbar.classList.remove('scrolled', 'text-gray-800');
                navbar.classList.add('text-white');
            }
        });
        
        // Mobile menu toggle
        const menuToggle = this.shadowRoot.querySelector('.menu-toggle');
        const mobileMenu = this.shadowRoot.querySelector('.mobile-menu');
        
        menuToggle.addEventListener('click', () => {
            mobileMenu.classList.toggle('open');
        });
    }
}

customElements.define('custom-navbar', CustomNavbar);