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 { 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));
function workspaceFor(number: number) {
return desktop.workspaces.find((workspace) => workspace.number === number);
}
</script>
<div class="workspaces">
{#each workspaceSlots as number (number)}
{@const workspace = workspaceFor(number)}
{@const isFocused = currentWorkspace?.number === number}
<button
class="workspace"
class:occupied={!!workspace}
title={workspace?.name}
disabled={!workspace}
onclick={() => workspace && openPage(workspace.path)}
>
{#if isFocused}
{#each workspaces as workspace (workspace.number)}
<button class="workspace" title={workspace.name} onclick={() => openPage(workspace.path)}>
{#if currentWorkspace?.number === workspace.number}
<span class="focused-marker"></span>
{:else}
{number}
{workspace.number}
{/if}
</button>
{/each}
@@ -47,26 +35,13 @@
padding: 0;
background: none;
border: none;
opacity: 0.5;
}
.workspace:disabled {
cursor: default;
}
.workspace.occupied {
opacity: 1;
}
.workspace.occupied:hover {
.workspace:hover {
color: var(--accent);
}
@media (max-width: 640px) {
.workspace:not(.occupied) {
display: none;
}
.workspace {
width: 22px;
}