File size: 4,897 Bytes
6166c49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
90
91
92
93
94
95
96
97
98
99
100
101
class CustomNavbar extends HTMLElement {
    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
            <style>
                .navbar {
                    transition: all 0.3s ease;
                }
                .navbar.scrolled {
                    @apply shadow-md bg-white;
                }
                .nav-link {
                    position: relative;
                }
                .nav-link::after {
                    content: '';
                    position: absolute;
                    width: 0;
                    height: 2px;
                    bottom: -2px;
                    left: 0;
                    background-color: #6366f1;
                    transition: width 0.3s ease;
                }
                .nav-link:hover::after {
                    width: 100%;
                }
                .mobile-menu {
                    max-height: 0;
                    overflow: hidden;
                    transition: max-height 0.3s ease-out;
                }
                .mobile-menu.open {
                    max-height: 500px;
                }
            </style>
            <nav class="navbar fixed w-full z-50 bg-white/80 backdrop-blur-sm">
                <div class="container mx-auto px-4 py-4">
                    <div class="flex justify-between items-center">
                        <a href="/" class="flex items-center">
                            <i data-feather="shield" class="text-indigo-600 mr-2"></i>
                            <span class="text-xl font-bold text-gray-800">TrackMeNot</span>
                        </a>
                        
                        <div class="hidden md:flex items-center space-x-8">
                            <a href="#features" class="nav-link text-gray-600 hover:text-gray-900">Features</a>
                            <a href="#how-it-works" class="nav-link text-gray-600 hover:text-gray-900">How It Works</a>
                            <a href="#download" class="nav-link text-gray-600 hover:text-gray-900">Download</a>
                            <a href="#" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg font-medium transition duration-300">Get Started</a>
                        </div>
                        
                        <button id="mobile-menu-button" class="md:hidden text-gray-600 focus:outline-none">
                            <i data-feather="menu"></i>
                        </button>
                    </div>
                    
                    <div id="mobile-menu" class="mobile-menu md:hidden">
                        <div class="pt-4 pb-2 space-y-2">
                            <a href="#features" class="block px-3 py-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100">Features</a>
                            <a href="#how-it-works" class="block px-3 py-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100">How It Works</a>
                            <a href="#download" class="block px-3 py-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100">Download</a>
                            <a href="#" class="block mt-2 bg-indigo-600 text-white px-4 py-2 rounded-lg font-medium text-center">Get Started</a>
                        </div>
                    </div>
                </div>
            </nav>

            <script>
                feather.replace();
                
                document.addEventListener('DOMContentLoaded', function() {
                    const mobileMenuButton = this.shadowRoot.getElementById('mobile-menu-button');
                    const mobileMenu = this.shadowRoot.getElementById('mobile-menu');
                    
                    mobileMenuButton.addEventListener('click', function() {
                        mobileMenu.classList.toggle('open');
                        const icon = mobileMenuButton.querySelector('i');
                        if (mobileMenu.classList.contains('open')) {
                            icon.setAttribute('data-feather', 'x');
                        } else {
                            icon.setAttribute('data-feather', 'menu');
                        }
                        feather.replace();
                    });
                    
                    // Change navbar style on scroll
                    window.addEventListener('scroll', function() {
                        const navbar = this.shadowRoot.querySelector('.navbar');
                        if (window.scrollY > 10) {
                            navbar.classList.add('scrolled');
                        } else {
                            navbar.classList.remove('scrolled');
                        }
                    });
                });
            </script>
        `;
    }
}

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