tcu / components /topbar.js
maomaobj's picture
设计一个“云端车辆和 TCU 管理平台”的后台管理界面(Dashboard)。
69fc188 verified
class CustomTopbar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
header {
height: 64px;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 1.5rem;
border-bottom: 1px solid #e5e7eb;
}
.search-container {
position: relative;
width: 360px;
}
.search-input {
width: 100%;
padding: 0.5rem 1rem 0.5rem 2.5rem;
border-radius: 6px;
border: 1px solid #e5e7eb;
background: #f9fafb;
transition: all 0.2s;
}
.search-input:focus {
outline: none;
background: #ffffff;
border-color: #3b82f6;
}
.search-icon {
position: absolute;
left: 1rem;
top: 50%;
transform: translateY(-50%);
color: #9ca3af;
}
.user-info {
display: flex;
align-items: center;
}
.user-avatar {
width: 36px;
height: 36px;
border-radius: 50%;
margin-right: 0.75rem;
}
.user-name {
margin-right: 1rem;
font-size: 0.95rem;
color: #111827;
}
.dropdown-icon {
color: #6b7280;
}
</style>
<header>
<div class="search-container">
<i data-feather="search" class="search-icon"></i>
<input type="text" class="search-input" placeholder="搜索设备ID、车辆ID...">
</div>
<div class="user-info">
<span class="user-name">管理员</span>
<img src="http://static.photos/people/200x200/100" alt="用户头像" class="user-avatar">
<i data-feather="chevron-down" class="dropdown-icon"></i>
</div>
</header>
`;
}
}
customElements.define('custom-topbar', CustomTopbar);