File size: 4,002 Bytes
819efbb |
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 |
class CustomSidebar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
height: 100%;
}
.sidebar {
display: flex;
flex-direction: column;
height: 100%;
background-color: #111827;
color: white;
}
.sidebar-header {
display: flex;
justify-content: space-between;
padding: 1rem;
border-bottom: 1px solid #374151;
}
.sidebar-content {
flex: 1;
overflow-y: auto;
padding: 1rem;
}
.sidebar-footer {
padding: 1rem;
border-top: 1px solid #374151;
}
.conversation-btn {
width: 100%;
text-align: left;
padding: 0.5rem;
border-radius: 0.375rem;
display: flex;
align-items: center;
transition: background-color 0.2s;
}
.conversation-btn:hover {
background-color: #374151;
}
.section-title {
font-size: 0.75rem;
color: #9CA3AF;
margin-top: 1rem;
margin-bottom: 0.5rem;
padding-left: 0.5rem;
}
.user-btn {
width: 100%;
display: flex;
align-items: center;
padding: 0.5rem;
border-radius: 0.375rem;
transition: background-color 0.2s;
}
.user-btn:hover {
background-color: #374151;
}
.user-avatar {
width: 2rem;
height: 2rem;
border-radius: 9999px;
background-color: #3B82F6;
display: flex;
align-items: center;
justify-content: center;
margin-right: 0.5rem;
}
</style>
<div class="sidebar">
<div class="sidebar-header">
<button class="rounded-lg p-2 hover:bg-gray-700">
<i data-feather="plus"></i>
</button>
<button class="rounded-lg p-2 hover:bg-gray-700">
<i data-feather="menu"></i>
</button>
</div>
<div class="sidebar-content">
<button class="conversation-btn">
<i data-feather="message-square" class="mr-2 w-4 h-4"></i>
<span class="truncate">New Conversation</span>
</button>
<div class="section-title">Today</div>
<button class="conversation-btn">
<i data-feather="message-square" class="mr-2 w-4 h-4"></i>
<span class="truncate">How to center a div?</span>
</button>
</div>
<div class="sidebar-footer">
<button class="user-btn">
<div class="user-avatar">
<i data-feather="user" class="w-4 h-4 text-white"></i>
</div>
<span class="truncate">User Account</span>
</button>
</div>
</div>
`;
}
}
customElements.define('custom-sidebar', CustomSidebar); |