pulse-flow / components /navbar.js
CSNET's picture
ทำต่อให้เสร็จ
8b26d10 verified
Raw History Blame Contribute Delete
6.5 kB
class ThaiNavbar extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
}
render() {
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 40;
}
nav {
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(255, 255, 255, 0.18);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
padding: 1rem;
}
.dark nav {
background: rgba(15, 23, 42, 0.9);
border-color: rgba(255, 255, 255, 0.08);
}
.container {
display: flex;
justify-content: space-between;
align-items: center;
max-width: 1200px;
margin: 0 auto;
}
.logo {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 1.25rem;
font-weight: 700;
color: #7c3aed;
text-decoration: none;
}
.dark .logo {
color: #c4b5fd;
}
.nav-links {
display: flex;
gap: 1rem;
align-items: center;
}
button {
background: none;
border: none;
cursor: pointer;
padding: 0.5rem;
border-radius: 0.5rem;
transition: all 0.2s;
}
button:hover {
background: rgba(124, 58, 237, 0.1);
}
.dark button:hover {
background: rgba(196, 181, 253, 0.1);
}
.icon {
width: 1.5rem;
height: 1.5rem;
stroke: #7c3aed;
}
.dark .icon {
stroke: #c4b5fd;
}
.badge {
position: absolute;
top: -4px;
right: -4px;
background: #ef4444;
color: white;
font-size: 0.625rem;
padding: 0.125rem 0.375rem;
border-radius: 9999px;
font-weight: 600;
}
.relative {
position: relative;
}
@media (max-width: 640px) {
nav {
padding: 0.75rem;
}
.logo {
font-size: 1rem;
}
.nav-links {
gap: 0.5rem;
}
}
</style>
<nav>
<div class="container">
<a href="/" class="logo">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
<polyline points="9 22 9 12 15 12 15 22"></polyline>
</svg>
ชีพจร Pulse
</a>
<div class="nav-links">
<button id="theme-toggle" aria-label="Toggle theme">
<svg class="icon" id="theme-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
</button>
<div class="relative">
<button aria-label="Notifications">
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<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>
<span class="badge">3</span>
</div>
<button aria-label="Settings">
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"></circle>
<path d="M12 1v6m0 6v6m4.22-10.22l1.42-1.42M6.36 17.64l1.42-1.42M1 12h6m6 0h6m-10.22 4.22l-1.42 1.42M17.64 6.36l-1.42 1.42"></path>
</svg>
</button>
</div>
</div>
</nav>
`;
}
}
customElements.define('thai-navbar', ThaiNavbar);