File size: 3,186 Bytes
eb8c123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
102
103
class CustomNavbar extends HTMLElement {
  connectedCallback() {
    this.attachShadow({ mode: 'open' });
    this.shadowRoot.innerHTML = `
      <style>
        nav {
          background-color: rgba(17, 24, 39, 0.9);
          backdrop-filter: blur(8px);
          position: sticky;
          top: 0;
          z-index: 50;
          border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .nav-container {
          max-width: 1280px;
          margin: 0 auto;
          padding: 0 1rem;
        }
        
        .nav-link {
          position: relative;
          color: rgba(209, 213, 219, 0.9);
          transition: color 0.2s ease;
        }
        
        .nav-link:hover {
          color: white;
        }
        
        .nav-link::after {
          content: '';
          position: absolute;
          bottom: -2px;
          left: 0;
          width: 0;
          height: 2px;
          background-color: #3b82f6;
          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="text-white py-4">
        <div class="nav-container flex items-center justify-between">
          <div class="flex items-center space-x-2">
            <i data-feather="mountain" class="text-blue-400"></i>
            <span class="text-xl font-bold">TerrainGen Explorer</span>
          </div>
          
          <div class="hidden md:flex items-center space-x-6">
            <a href="#" class="nav-link font-medium">Home</a>
            <a href="#" class="nav-link font-medium">Algorithms</a>
            <a href="#" class="nav-link font-medium">Gallery</a>
            <a href="#" class="nav-link font-medium">About</a>
          </div>
          
          <button id="mobile-menu-button" class="md:hidden focus:outline-none">
            <i data-feather="menu" class="w-6 h-6"></i>
          </button>
        </div>
        
        <div id="mobile-menu" class="mobile-menu md:hidden bg-gray-800">
          <div class="px-4 py-2 space-y-3">
            <a href="#" class="block nav-link py-2">Home</a>
            <a href="#" class="block nav-link py-2">Algorithms</a>
            <a href="#" class="block nav-link py-2">Gallery</a>
            <a href="#" class="block nav-link py-2">About</a>
          </div>
        </div>
      </nav>
    `;
    
    // Initialize mobile menu toggle
    this.shadowRoot.getElementById('mobile-menu-button').addEventListener('click', () => {
      const menu = this.shadowRoot.getElementById('mobile-menu');
      menu.classList.toggle('open');
      
      // Change icon
      const icon = this.shadowRoot.querySelector('#mobile-menu-button i');
      if (menu.classList.contains('open')) {
        icon.setAttribute('data-feather', 'x');
      } else {
        icon.setAttribute('data-feather', 'menu');
      }
      feather.replace();
    });
  }
}

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