ArgoMuk93's picture
I am trying to design an elegant but simple website for the AI consulting service that helps large retail companies determine dynamic pricing
43969da verified
class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
header {
background-color: white;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
position: sticky;
top: 0;
z-index: 50;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 1rem;
display: flex;
justify-content: space-between;
align-items: center;
height: 80px;
}
.logo {
display: flex;
align-items: center;
font-weight: 700;
font-size: 1.5rem;
color: #4f46e5;
text-decoration: none;
}
.logo i {
margin-right: 0.5rem;
}
nav ul {
display: flex;
list-style: none;
}
nav ul li {
margin-left: 2rem;
}
nav ul li a {
text-decoration: none;
color: #374151;
font-weight: 500;
transition: color 0.3s ease;
}
nav ul li a:hover {
color: #4f46e5;
}
.mobile-menu-btn {
display: none;
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: #374151;
}
@media (max-width: 768px) {
.nav-links {
display: none;
}
.mobile-menu-btn {
display: block;
}
nav ul {
flex-direction: column;
position: absolute;
top: 80px;
left: 0;
right: 0;
background: white;
padding: 1rem;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
nav ul li {
margin: 0.5rem 0;
}
.nav-links.active {
display: block;
}
}
</style>
<header>
<div class="container">
<a href="/" class="logo">
<i data-feather="trending-up"></i>
<span>DynamicPricing AI</span>
</a>
<button class="mobile-menu-btn" id="menuBtn">
<i data-feather="menu"></i>
</button>
<nav>
<ul class="nav-links" id="navLinks">
<li><a href="/">Home</a></li>
<li><a href="#solutions">Solutions</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="contact.html">Get Started</a></li>
</ul>
</nav>
</div>
</header>
`;
// Add event listeners after rendering
setTimeout(() => {
const menuBtn = this.shadowRoot.getElementById('menuBtn');
const navLinks = this.shadowRoot.getElementById('navLinks');
menuBtn.addEventListener('click', () => {
navLinks.classList.toggle('active');
const menuIcon = menuBtn.querySelector('i');
if (navLinks.classList.contains('active')) {
menuIcon.setAttribute('data-feather', 'x');
} else {
menuIcon.setAttribute('data-feather', 'menu');
}
feather.replace();
});
}, 0);
}
}
customElements.define('custom-header', CustomHeader);