Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions src/lib/components/TitleBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
let maximized = $state(false);
let fullscreen = $state(false);

let barWidth = $state(0);
let brandWidth = $state(0);
let actionsWidth = $state(0);
let centeredWidth = $state(0);

const compact = $derived(
barWidth > 0 && barWidth < centeredWidth + 2 * Math.max(brandWidth, actionsWidth),
);

const hasUnread = $derived(Boolean(app.user?.unreadWhispers));

const label = $derived(
Expand All @@ -49,27 +58,44 @@
});

onDestroy(() => unlisten?.());

function measureCenter(width: number) {
if (!compact) centeredWidth = width;
}
</script>

<div
class="title-bar relative flex min-h-title-bar w-full shrink-0 items-center justify-between border-b"
class={[
"title-bar relative grid min-h-title-bar w-full shrink-0 items-center border-b",
compact ? "grid-cols-[auto_minmax(0,1fr)_auto]" : "grid-cols-[1fr_auto_1fr]",
]}
data-compact={compact || undefined}
data-tauri-drag-region
bind:clientWidth={barWidth}
>
<div
class={[
"title-bar-brand flex items-center text-fg-muted",
"title-bar-brand col-start-1 flex items-center justify-self-start text-fg-muted",
platform === "macos" && (fullscreen ? "pl-3" : "pl-20"),
["windows", "linux"].includes(platform) && "pl-3",
]}
data-tauri-drag-region
bind:clientWidth={brandWidth}
>
<a title="Home" href={resolve("/(main)")} draggable="false">
<img class="size-4" src="/logo.svg" alt="Hyperion logo" draggable="false" />
</a>
</div>

{#if app.user}
<div class="flex items-center justify-center gap-1.5" data-tauri-drag-region>
<div
class={[
"col-start-2 flex items-center gap-1.5 px-1.5",
compact ? "min-w-0" : "w-max justify-self-center",
]}
data-tauri-drag-region
bind:clientWidth={null, measureCenter}
>
<Button
class="relative size-min p-1 text-fg-muted"
size="icon"
Expand All @@ -81,10 +107,14 @@
</Button>

<DialogTrigger
class="channel-search flex w-64 items-center justify-center gap-2 rounded-md bg-surface-1 px-2 py-1 text-detail text-fg-muted ring-1 ring-line transition-[background-color,scale] hover:bg-surface-3 active:scale-[0.96]"
class={[
"channel-search flex items-center justify-center gap-2 rounded-md bg-surface-1 px-2 py-1 text-detail text-fg-muted ring-1 ring-line transition-[background-color,scale] hover:bg-surface-3 active:scale-[0.96]",
compact ? "min-w-0 flex-1" : "w-64 shrink-0",
]}
controller={dialogController(dialogs.join)}
>
<IconSearch /> Search channels
<IconSearch class="shrink-0" />
<span class="truncate">Search channels</span>
</DialogTrigger>

<JoinDialog />
Expand Down Expand Up @@ -112,7 +142,11 @@
</div>
{/if}

<div class="flex items-center justify-end" data-tauri-drag-region>
<div
class="col-start-3 flex items-center justify-end justify-self-end"
data-tauri-drag-region
bind:clientWidth={actionsWidth}
>
<div class="flex items-center gap-1.5 pr-3">
{#if updater.ready}
<Tooltip>
Expand Down