feat: move invite button to unified header, hide duplicate channel-sidebar-header

This commit is contained in:
jevb
2026-03-27 14:51:38 +01:00
parent bd11642ffc
commit 46b54794ac
2 changed files with 24 additions and 17 deletions
@@ -119,6 +119,18 @@ export function createSidebarArea(opts: SidebarAreaOptions): SidebarAreaResult {
serverInfoCol.appendChild(serverOnlineEl);
serverHeader.appendChild(serverIcon);
serverHeader.appendChild(serverInfoCol);
// Invite button in the server header (proper styled button)
const headerInviteCtrl = createInviteManagerController({ api, getRoot, getToast });
const headerInviteBtn = createElement("button", {
class: "sidebar-invite-btn",
title: "Invite people",
"data-testid": "invite-btn",
}, "Invite");
headerInviteBtn.addEventListener("click", () => { void headerInviteCtrl.open(); });
serverHeader.appendChild(headerInviteBtn);
unsubscribers.push(() => { headerInviteCtrl.cleanup(); });
sidebarWrapper.appendChild(serverHeader);
// Load per-server collapsed category state from localStorage
@@ -505,23 +517,10 @@ export function createSidebarArea(opts: SidebarAreaOptions): SidebarAreaResult {
// the ChannelSidebar owns its own root element so we keep it nested.
contentSlot.appendChild(innerSlot);
// Wire up the invite button into the channel sidebar header
const sidebarHeader = innerSlot.querySelector(".channel-sidebar-header");
if (sidebarHeader !== null) {
const inviteCtrl = createInviteManagerController({
api,
getRoot,
getToast,
});
const inviteBtn = createElement("button", {
class: "invite-btn",
title: "Invite",
}, "Invite");
inviteBtn.addEventListener("click", () => {
void inviteCtrl.open();
});
sidebarHeader.appendChild(inviteBtn);
inviteCleanup = () => { inviteCtrl.cleanup(); };
// Hide the redundant channel-sidebar-header (server name + invite are now in the unified header)
const oldSidebarHeader = innerSlot.querySelector(".channel-sidebar-header");
if (oldSidebarHeader !== null) {
(oldSidebarHeader as HTMLElement).style.display = "none";
}
// --- DM section (between channels and members) ---
+8
View File
@@ -29,6 +29,14 @@
}
.unified-sidebar-header .server-name { color: white; font-weight: 700; font-size: 13px; }
.unified-sidebar-header .server-online { color: var(--text-micro); font-size: 9px; }
.sidebar-invite-btn {
margin-left: auto; padding: 4px 10px; border-radius: var(--radius-sm);
background: var(--accent-primary, var(--accent)); color: white;
font-size: 11px; font-weight: 600; cursor: pointer;
transition: background var(--transition-fast), opacity var(--transition-fast);
flex-shrink: 0;
}
.sidebar-invite-btn:hover { opacity: 0.85; }
.sidebar-divider { height: 1px; background: var(--border-glow, var(--border)); margin: 8px 12px; }
/* ── Channel Sidebar ── */