edsaga's picture
did you even look at the webpage? the name is christen
6588175 verified
class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
}
.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1000;
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
transition: all 0.3s ease;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.header.scrolled {
padding: 0.5rem 0;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 1rem;
display: flex;
justify-content: space-between;
align-items: center;
height: 70px;
}
.logo {
font-size: 1.5rem;
font-weight: 700;
color: #3b82f6;
text-decoration: none;
display: flex;
align-items: center;
}
.logo i {
margin-right: 0.5rem;
}
.nav-links {
display: flex;
list-style: none;
}
.nav-links li {
margin-left: 2rem;
}
.nav-links a {
text-decoration: none;
color: #374151;
font-weight: 500;
transition: color 0.3s ease;
display: flex;
align-items: center;
}
.nav-links a:hover {
color: #3b82f6;
}
.nav-links a i {
margin-right: 0.5rem;
}
.mobile-menu-btn {
display: none;
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: #374151;
}
@media (max-width: 768px) {
.nav-links {
position: fixed;
top: 70px;
left: 0;
right: 0;
background: white;
flex-direction: column;
align-items: center;
padding: 1rem 0;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
transform: translateY(-150%);
transition: transform 0.3s ease;
}
.nav-links.active {
transform: translateY(0);
}
.nav-links li {
margin: 1rem 0;
}
.mobile-menu-btn {
display: block;
}
}
</style>
<header class="header">
<div class="container">
<a href="/" class="logo">
<i data-feather="code"></i>
Christen1
</a>
<button class="mobile-menu-btn" id="menuBtn">
<i data-feather="menu"></i>
</button>
<ul class="nav-links" id="navLinks">
<li><a href="/"><i data-feather="home"></i> Home</a></li>
<li><a href="#"><i data-feather="briefcase"></i> Projects</a></li>
<li><a href="#"><i data-feather="user"></i> About</a></li>
<li><a href="#"><i data-feather="mail"></i> Contact</a></li>
</ul>
</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();
});
// Close menu when clicking on a link
this.shadowRoot.querySelectorAll('.nav-links a').forEach(link => {
link.addEventListener('click', () => {
navLinks.classList.remove('active');
const menuIcon = menuBtn.querySelector('i');
menuIcon.setAttribute('data-feather', 'menu');
feather.replace();
});
});
feather.replace();
}, 0);
}
}
customElements.define('custom-header', CustomHeader);