Nico85525's picture
ameliore cette pages <!doctype html>
c086273 verified
Raw History Blame Contribute Delete
5.38 kB
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: 1000;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 1rem;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 0;
}
.logo {
display: flex;
align-items: center;
text-decoration: none;
}
.logo-icon {
background: linear-gradient(135deg, #3b82f6, #6366f1);
width: 40px;
height: 40px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
}
.logo-text {
font-family: 'Outfit', sans-serif;
font-weight: 800;
font-size: 1.5rem;
color: #1e293b;
}
.logo-highlight {
color: #3b82f6;
}
.nav-links {
display: flex;
list-style: none;
}
.nav-links li {
margin-left: 2rem;
}
.nav-links a {
text-decoration: none;
color: #64748b;
font-weight: 500;
transition: color 0.3s;
position: relative;
}
.nav-links a:hover {
color: #3b82f6;
}
.nav-links a::after {
content: '';
position: absolute;
bottom: -5px;
left: 0;
width: 0;
height: 2px;
background-color: #3b82f6;
transition: width 0.3s;
}
.nav-links a:hover::after {
width: 100%;
}
.cta-button {
background: linear-gradient(135deg, #3b82f6, #6366f1);
color: white;
border: none;
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
text-decoration: none;
display: inline-block;
}
.cta-button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.mobile-menu-button {
display: none;
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: #64748b;
}
@media (max-width: 768px) {
.nav-links {
display: none;
position: absolute;
top: 100%;
left: 0;
width: 100%;
background: white;
flex-direction: column;
padding: 1rem;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.nav-links.active {
display: flex;
}
.nav-links li {
margin: 0.5rem 0;
}
.mobile-menu-button {
display: block;
}
.cta-button {
display: none;
}
}
</style>
<header>
<div class="container">
<nav>
<a href="/" class="logo">
<div class="logo-icon">
<i data-feather="zap" class="text-white" width="24" height="24"></i>
</div>
<div class="logo-text">Square<span class="logo-highlight">Lighting</span></div>
</a>
<ul class="nav-links" id="navLinks">
<li><a href="/">Accueil</a></li>
<li><a href="#services">Solutions</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#" class="cta-button">Audit Gratuit</a></li>
</ul>
<button class="mobile-menu-button" id="mobileMenuButton">
<i data-feather="menu"></i>
</button>
</nav>
</div>
</header>
`;
// Initialize feather icons
const initIcons = () => {
if (typeof feather !== 'undefined') {
feather.replace();
} else {
setTimeout(initIcons, 100);
}
};
initIcons();
// Mobile menu toggle
const mobileMenuButton = this.shadowRoot.getElementById('mobileMenuButton');
const navLinks = this.shadowRoot.getElementById('navLinks');
mobileMenuButton.addEventListener('click', () => {
navLinks.classList.toggle('active');
const menuIcon = mobileMenuButton.querySelector('[data-feather]');
if (navLinks.classList.contains('active')) {
menuIcon.setAttribute('data-feather', 'x');
} else {
menuIcon.setAttribute('data-feather', 'menu');
}
feather.replace();
});
}
}
customElements.define('custom-header', CustomHeader);