File size: 4,234 Bytes
6feb262 |
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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
class HeaderComponent extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
background-color: white;
border-bottom: 1px solid #e5e7eb;
padding: 1.5rem;
position: sticky;
top: 0;
z-index: 20;
}
.header-container {
display: flex;
align-items: center;
justify-content: space-between;
}
.mobile-menu-button {
display: none;
padding: 0.5rem;
border-radius: 0.375rem;
background-color: #f3f4f6;
}
.mobile-menu-button:hover {
background-color: #e5e7eb;
}
.header-title {
font-size: 1.25rem;
font-weight: 600;
color: #111827;
}
.header-actions {
display: flex;
align-items: center;
gap: 1rem;
}
.action-button {
padding: 0.5rem;
border-radius: 0.375rem;
color: #4b5563;
transition: all 0.2s;
}
.action-button:hover {
background-color: #f3f4f6;
color: #111827;
}
.user-avatar {
width: 2.5rem;
height: 2.5rem;
border-radius: 50%;
background-color: #e5e7eb;
display: flex;
align-items: center;
justify-content: center;
color: #4b5563;
font-weight: 600;
cursor: pointer;
}
@media (max-width: 768px) {
.mobile-menu-button {
display: block;
}
.header-title {
font-size: 1rem;
}
}
</style>
<div class="header-container">
<button class="mobile-menu-button" id="mobile-menu-button">
<i data-feather="menu"></i>
</button>
<h1 class="header-title" id="header-title">Accueil</h1>
<div class="header-actions">
<button class="action-button">
<i data-feather="share-2"></i>
</button>
<button class="action-button">
<i data-feather="bell"></i>
</button>
<div class="user-avatar">JD</div>
</div>
</div>
`;
// Initialize feather icons
const featherScript = document.createElement('script');
featherScript.src = 'https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js';
this.shadowRoot.appendChild(featherScript);
featherScript.onload = () => {
feather.replace();
};
// Mobile menu toggle
this.shadowRoot.getElementById('mobile-menu-button').addEventListener('click', () => {
document.querySelector('sidebar-component').classList.add('open');
document.body.classList.add('overflow-hidden');
});
// Update title based on view
document.addEventListener('navigate', (e) => {
const titles = {
'home': 'Accueil',
'chat': 'Chat Rosalinda',
'projects': 'Mes Projets',
'code': 'Code Généré',
'library': 'Bibliothèque'
};
this.shadowRoot.getElementById('header-title').textContent = titles[e.detail] || 'Accueil';
});
}
}
customElements.define('header-component', HeaderComponent); |