Spaces:
Running
Running
File size: 5,913 Bytes
24834c1 | 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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | class CustomNavbar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
nav {
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.nav-container {
max-width: 1280px;
margin: 0 auto;
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
display: flex;
align-items: center;
gap: 0.75rem;
color: white;
font-size: 1.25rem;
font-weight: 700;
text-decoration: none;
}
.nav-menu {
display: flex;
gap: 2rem;
list-style: none;
}
.nav-link {
color: rgba(255, 255, 255, 0.9);
text-decoration: none;
font-size: 0.95rem;
font-weight: 500;
padding: 0.5rem 0;
transition: color 0.2s;
position: relative;
}
.nav-link:hover,
.nav-link.active {
color: white;
}
.nav-link.active::after {
content: '';
position: absolute;
bottom: -4px;
left: 0;
right: 0;
height: 2px;
background: #eab308;
border-radius: 1px;
}
.user-menu {
display: flex;
align-items: center;
gap: 1rem;
}
.notification-btn {
background: rgba(255, 255, 255, 0.1);
border: none;
padding: 0.5rem;
border-radius: 0.5rem;
color: white;
cursor: pointer;
transition: background 0.2s;
position: relative;
}
.notification-btn:hover {
background: rgba(255, 255, 255, 0.2);
}
.notification-badge {
position: absolute;
top: -2px;
right: -2px;
background: #eab308;
color: #1f2937;
width: 18px;
height: 18px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.7rem;
font-weight: 700;
}
.user-avatar {
width: 36px;
height: 36px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.2);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: 600;
}
@media (max-width: 768px) {
.nav-container {
padding: 1rem;
}
.nav-menu {
display: none;
}
}
</style>
<nav>
<div class="nav-container">
<a href="#" class="logo">
<i data-feather="trending-up" style="width: 24px; height: 24px;"></i>
SalesFlow
</a>
<ul class="nav-menu">
<li><a href="#" class="nav-link active">แดชบอร์ด</a></li>
<li><a href="#" class="nav-link">รายงาน</a></li>
<li><a href="#" class="nav-link">สินค้า</a></li>
<li><a href="#" class="nav-link">ลูกค้า</a></li>
<li><a href="#" class="nav-link">การตั้งค่า</a></li>
</ul>
<div class="user-menu">
<button class="notification-btn">
<i data-feather="bell" style="width: 20px; height: 20px;"></i>
<span class="notification-badge">3</span>
</button>
<div class="user-avatar">AD</div>
</div>
</div>
</nav>
`;
// Initialize Feather Icons inside Shadow DOM
const icons = this.shadowRoot.querySelectorAll('[data-feather]');
icons.forEach(icon => {
const iconName = icon.getAttribute('data-feather');
icon.outerHTML = feather.icons[iconName].toSvg({
width: icon.style.width || '24',
height: icon.style.height || '24'
});
});
}
}
customElements.define('custom-navbar', CustomNavbar); |