asmoura's picture
Include a toggle for light and dark mode including a theme selector that can pull themes from https://github.com/Vector35/community-themes and set the mode automatically if the the is light or dark or follow the macos operating system setting for light or dark mode
aea32b5 verified
Raw
History Blame Contribute Delete
4.35 kB
class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
header {
background-color: white;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
position: sticky;
top: 0;
z-index: 50;
}
.header-container {
max-width: 100%;
margin: 0 auto;
padding: 1rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
display: flex;
align-items: center;
font-weight: 700;
font-size: 1.25rem;
color: var(--primary);
}
.logo i {
margin-right: 0.5rem;
}
.nav-links {
display: flex;
gap: 1.5rem;
}
.nav-links a {
display: flex;
align-items: center;
color: #4b5563;
font-weight: 500;
transition: color 0.2s;
}
.nav-links a:hover {
color: var(--primary);
}
.nav-links i {
margin-right: 0.25rem;
width: 1rem;
height: 1rem;
}
.user-menu {
display: flex;
align-items: center;
gap: 1rem;
}
.avatar {
width: 2.5rem;
height: 2.5rem;
border-radius: 9999px;
background-color: #e5e7eb;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
@media (max-width: 768px) {
.nav-links {
display: none;
}
}
</style>
<header>
<div class="header-container">
<a href="/" class="logo">
<i data-feather="cpu"></i>
<span>NetMind Nexus</span>
</a>
<div class="nav-links">
<a href="#">
<i data-feather="home"></i>
<span>Home</span>
</a>
<a href="#">
<i data-feather="briefcase"></i>
<span>Projects</span>
</a>
<a href="#">
<i data-feather="file-text"></i>
<span>Docs</span>
</a>
<a href="#">
<i data-feather="settings"></i>
<span>Settings</span>
</a>
</div>
<div class="user-menu">
<div class="theme-selector relative">
<select id="themeSelect" class="appearance-none bg-transparent border border-gray-300 rounded-md px-3 py-1 pr-8 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="" disabled>Select Theme</option>
</select>
<div class="absolute right-2 top-1/2 transform -translate-y-1/2 pointer-events-none">
<i data-feather="chevron-down" class="w-4 h-4 text-gray-500"></i>
</div>
</div>
<div class="avatar">
<i data-feather="user"></i>
</div>
</div>
</div>
</header>
`;
}
}
customElements.define('custom-header', CustomHeader);