File size: 2,506 Bytes
ac3b6d4 e15bd5e ac3b6d4 |
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 |
class CustomNavbar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
background: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
position: sticky;
top: 0;
z-index: 50;
}
nav {
max-width: 1200px;
margin: 0 auto;
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-size: 1.5rem;
font-weight: 700;
color: #2563eb;
display: flex;
align-items: center;
gap: 0.5rem;
}
.nav-links {
display: flex;
gap: 1.5rem;
align-items: center;
}
.nav-link {
color: #4b5563;
font-weight: 500;
transition: color 0.2s;
}
.nav-link:hover {
color: #2563eb;
}
.cart-icon {
position: relative;
}
.cart-count {
position: absolute;
top: -8px;
right: -8px;
background: #ef4444;
color: white;
border-radius: 50%;
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.75rem;
}
@media (max-width: 768px) {
nav {
flex-direction: column;
gap: 1rem;
padding: 1rem;
}
.nav-links {
width: 100%;
justify-content: space-between;
}
}
</style>
<nav>
<a href="/" class="logo">
<i class="fas fa-laptop-code"></i>
<span>Bizrah</span>
</a>
<div class="nav-links">
<a href="/" class="nav-link">Home</a>
<a href="/products.html" class="nav-link">Products</a>
<a href="/about.html" class="nav-link">About</a>
<a href="/contact.html" class="nav-link">Contact</a>
<a href="/cart.html" class="nav-link cart-icon">
<i class="fas fa-shopping-cart"></i>
<span class="cart-count">0</span>
</a>
<a href="/login.html" class="nav-link">
<i class="fas fa-user"></i>
</a>
</div>
</nav>
`;
}
}
customElements.define('custom-navbar', CustomNavbar); |