Files
website/src/lib/components/shell/Workspaces.svelte
T
2026-10-31 22:53:17 -04:00

57 lines
1.1 KiB
Svelte

<script lang="ts">
import { page } from '$app/state';
import { desktop } from '#lib/content';
import { activeWorkspace, openPage } from '#lib/desktop/actions';
const workspaces = [...desktop.workspaces].sort((first, second) => first.number - second.number);
const currentWorkspace = $derived(activeWorkspace(page.url.pathname));
</script>
<div class="workspaces">
{#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}
{workspace.number}
{/if}
</button>
{/each}
</div>
<style>
.workspaces {
display: flex;
align-items: center;
margin-left: 4px;
}
.workspace {
display: grid;
place-items: center;
width: 26px;
height: var(--bar-height);
padding: 0;
background: none;
border: none;
}
.workspace:hover {
color: var(--accent);
}
@media (max-width: 640px) {
.workspace {
width: 22px;
}
}
.focused-marker {
width: 12px;
height: 12px;
border-radius: 2px;
background: currentColor;
}
</style>