File size: 2,622 Bytes
e350275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
        nav {
          background: white;
          padding: 1rem 2rem;
          display: flex;
          justify-content: space-between;
          align-items: center;
          box-shadow: 0 2px 4px rgba(0,0,0,0.05);
          position: sticky;
          top: 0;
          z-index: 50;
        }
        .logo {
          color: #ef4444;
          font-weight: bold;
          font-size: 1.5rem;
          display: flex;
          align-items: center;
          gap: 0.5rem;
        }
        ul {
          display: flex;
          gap: 1.5rem;
          list-style: none;
          margin: 0;
          padding: 0;
        }
        a {
          color: #4b5563;
          text-decoration: none;
          font-weight: 500;
          transition: color 0.2s;
          display: flex;
          align-items: center;
          gap: 0.25rem;
        }
        a:hover {
          color: #ef4444;
        }
        .active {
          color: #ef4444;
        }
        .menu-btn {
          display: none;
          background: none;
          border: none;
          color: #ef4444;
          font-size: 1.5rem;
          cursor: pointer;
        }
        @media (max-width: 768px) {
          ul {
            display: none;
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            background: white;
            flex-direction: column;
            padding: 1rem;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
          }
          ul.active {
            display: flex;
          }
          .menu-btn {
            display: block;
          }
        }
      </style>
      <nav>
        <a href="/" class="logo">
          <i data-feather="droplet"></i>
          Crimson Canvas
        </a>
        <button class="menu-btn">
          <i data-feather="menu"></i>
        </button>
        <ul>
          <li><a href="/" class="active"><i data-feather="home"></i> Home</a></li>
          <li><a href="#"><i data-feather="image"></i> Portfolio</a></li>
          <li><a href="#"><i data-feather="info"></i> About</a></li>
          <li><a href="#"><i data-feather="mail"></i> Contact</a></li>
        </ul>
      </nav>
    `;

    const menuBtn = this.shadowRoot.querySelector('.menu-btn');
    const menu = this.shadowRoot.querySelector('ul');
    
    menuBtn.addEventListener('click', () => {
      menu.classList.toggle('active');
    });
  }
}

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