Files
zep/src/chat/components/channels/ServerHeader.svelte
T
2026-04-05 22:24:24 -04:00

140 lines
3.3 KiB
Svelte

<script lang="ts">
import { getContext } from "svelte";
import type { ChatService } from "../../services/chat.svelte";
const chat = getContext<ChatService>("chat");
let showServerDropdown = $state(false);
let fileInput = $state<HTMLInputElement | null>(null);
const isOwner = true; // temporarily enabled for everyone
function handleOpenSettings() {
chat.showServerSettings = true;
showServerDropdown = false;
}
</script>
<div class="server-header-container">
<button
class="server-header clickable"
onclick={() => (showServerDropdown = !showServerDropdown)}
>
<h3
style="margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;"
>
{chat.activeServer?.name || "Select a Server"}
</h3>
<span style="font-size: 0.8rem; opacity: 0.6; margin-left: 4px;">
<i class="fas {showServerDropdown ? 'fa-chevron-up' : 'fa-chevron-down'}"></i>
</span>
</button>
{#if showServerDropdown}
<div class="server-dropdown shadow-box">
{#if isOwner}
<button
class="server-dropdown-item"
onclick={handleOpenSettings}
>
<i class="fas fa-cog" style="width: 16px; margin-right: 8px;"></i>
Server Settings
</button>
<div class="dropdown-separator"></div>
{/if}
<button
class="server-dropdown-item danger"
onclick={() => {
if (chat.activeServerId) {
chat.handleLeaveServer(chat.activeServerId);
showServerDropdown = false;
}
}}
>
<i class="fas fa-sign-out-alt" style="width: 16px; margin-right: 8px;"></i>
Leave Server
</button>
</div>
{/if}
</div>
<style>
.server-header-container {
position: relative;
width: 100%;
}
.server-header {
padding: 12px 16px;
height: 48px;
box-sizing: border-box;
display: flex;
align-items: center;
border-bottom: 1px solid var(--background-tertiary);
background: none;
border-left: none;
border-right: none;
border-top: none;
color: var(--text-normal);
cursor: pointer;
font-weight: bold;
width: 100%;
transition: background-color 0.1s;
}
.server-header:hover {
background-color: var(--background-modifier-hover);
}
.server-dropdown {
position: absolute;
top: 100%;
left: 8px;
right: 8px;
margin-top: 4px;
background-color: var(--background-floating);
border-radius: 4px;
padding: 6px;
z-index: 1000;
border: 1px solid var(--background-modifier-accent);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}
.server-dropdown-item {
background: none;
border: none;
color: var(--interactive-normal);
width: 100%;
text-align: left;
padding: 8px 12px;
cursor: pointer;
border-radius: 2px;
font-size: 0.85rem;
font-weight: 500;
display: flex;
align-items: center;
transition: all 0.1s;
}
.server-dropdown-item:hover {
background-color: var(--brand);
color: white;
}
.server-dropdown-item.danger {
color: var(--status-danger);
}
.server-dropdown-item.danger:hover {
background-color: var(--status-danger);
color: white;
}
.dropdown-separator {
height: 1px;
background-color: var(--background-modifier-accent);
margin: 4px 6px;
opacity: 0.5;
}
</style>