Hide unused workspaces

This commit is contained in:
SirBlob committed 2026-10-31 22:53:17 -04:00
1 parent 490b3b87c5
commit cc7e8b0497
1 file changed
+6 -31
+6 -31
View File
@@ -3,30 +3,18 @@
import { desktop } from '#lib/content'; import { desktop } from '#lib/content';
import { activeWorkspace, openPage } from '#lib/desktop/actions'; import { activeWorkspace, openPage } from '#lib/desktop/actions';
const workspaceSlots = [1, 2, 3, 4, 5, 6, 7, 8, 9]; const workspaces = [...desktop.workspaces].sort((first, second) => first.number - second.number);
const currentWorkspace = $derived(activeWorkspace(page.url.pathname)); const currentWorkspace = $derived(activeWorkspace(page.url.pathname));
function workspaceFor(number: number) {
return desktop.workspaces.find((workspace) => workspace.number === number);
}
</script> </script>
<div class="workspaces"> <div class="workspaces">
{#each workspaceSlots as number (number)} {#each workspaces as workspace (workspace.number)}
{@const workspace = workspaceFor(number)} <button class="workspace" title={workspace.name} onclick={() => openPage(workspace.path)}>
{@const isFocused = currentWorkspace?.number === number} {#if currentWorkspace?.number === workspace.number}
<button
class="workspace"
class:occupied={!!workspace}
title={workspace?.name}
disabled={!workspace}
onclick={() => workspace && openPage(workspace.path)}
>
{#if isFocused}
<span class="focused-marker"></span> <span class="focused-marker"></span>
{:else} {:else}
{number} {workspace.number}
{/if} {/if}
</button> </button>
{/each} {/each}
@@ -47,26 +35,13 @@
padding: 0; padding: 0;
background: none; background: none;
border: none; border: none;
opacity: 0.5;
} }
.workspace:disabled { .workspace:hover {
cursor: default;
}
.workspace.occupied {
opacity: 1;
}
.workspace.occupied:hover {
color: var(--accent); color: var(--accent);
} }
@media (max-width: 640px) { @media (max-width: 640px) {
.workspace:not(.occupied) {
display: none;
}
.workspace { .workspace {
width: 22px; width: 22px;
} }