alexlebrun's picture
---
99fe303 verified
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 {
font-weight: 700;
font-size: 1.5rem;
background: linear-gradient(90deg, #10b981 0%, #d946ef 100%);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
ul {
display: flex;
gap: 1.5rem;
list-style: none;
margin: 0;
padding: 0;
align-items: center;
}
a {
color: #4b5563;
text-decoration: none;
font-weight: 500;
transition: color 0.2s;
}
a:hover {
color: #10b981;
}
.active {
color: #d946ef;
}
.cta-button {
background: linear-gradient(90deg, #10b981 0%, #d946ef 100%);
color: white;
padding: 0.5rem 1.25rem;
border-radius: 0.375rem;
transition: all 0.2s;
}
.cta-button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
color: white;
}
.mobile-menu-button {
display: none;
background: none;
border: none;
color: #4b5563;
cursor: pointer;
}
@media (max-width: 768px) {
ul {
display: none;
}
.mobile-menu-button {
display: block;
}
}
</style>
<nav>
<div class="logo">CodeCraft</div>
<button class="mobile-menu-button">
<i data-feather="menu"></i>
</button>
<ul>
<li><a href="/" class="active">Home</a></li>
<li><a href="/features.html">Features</a></li>
<li><a href="/pricing.html">Pricing</a></li>
<li><a href="/docs.html">Docs</a></li>
<li><a href="/contact.html" class="cta-button">Get Started</a></li>
</ul>
</nav>
`;
}
}
customElements.define('custom-navbar', CustomNavbar);