eubottura's picture
import { render } from 'preact';
840b62e verified
class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
:host {
font-family: 'Inter', sans-serif;
background-color: #ffffff;
height: 64px;
border-bottom: 1px solid #e2e8f0; /* slate-200 */
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px;
position: sticky;
top: 0;
z-index: 10;
}
.search-bar {
display: none;
background-color: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 8px;
padding: 8px 16px;
width: 300px;
color: #64748b;
font-size: 0.9rem;
}
.search-icon {
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
color: #94a3b8;
}
@media (min-width: 768px) {
.search-bar {
display: block;
}
}
.profile-section {
display: flex;
align-items: center;
gap: 16px;
}
.icon-btn {
background: none;
border: none;
cursor: pointer;
color: #64748b;
padding: 8px;
border-radius: 50%;
transition: background 0.2s;
display: flex;
align-items: center;
justify-content: center;
}
.icon-btn:hover {
background-color: #f1f5f9;
color: #334155;
}
.user-info {
display: flex;
align-items: center;
gap: 10px;
cursor: pointer;
}
.avatar {
width: 36px;
height: 36px;
border-radius: 50%;
object-fit: cover;
border: 2px solid #e2e8f0;
}
.user-name {
font-weight: 500;
color: #334155;
font-size: 0.9rem;
display: none;
}
@media (min-width: 640px) {
.user-name {
display: block;
}
}
</style>
<div class="search-bar">
<svg class="search-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>
<span style="margin-left: 24px">Buscar pedido ou UTM...</span>
</div>
<div class="profile-section">
<button class="icon-btn">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>
</button>
<div class="user-info">
<img src="http://static.photos/people/100x100/12" alt="User Avatar" class="avatar">
<span class="user-name">Admin User</span>
</div>
</div>
`;
}
}
customElements.define('custom-header', CustomHeader);