Something went wrong. Try again.
Local-first knowledge base made for Typst and the Atmosphere. typbase.at
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229<script setup lang="ts">import type { WorkspaceInfo } from "@typbase/typing";import type { MaterialSymbol } from "material-symbols";
import { DEFAULT_WORKSPACE_ICON } from "~/lib/symbols";
const props = defineProps<{ info: WorkspaceInfo; /** This workspace is the active one. */ active: boolean; /** A switch to this workspace is in flight. */ switching: boolean; /** The select button is disabled (another switch is in flight). */ disabled?: boolean; /** Ready-made status label: "current" or the opened date. */ status: string; /** The row is first or last in the list, so that move has nowhere to go. */ first?: boolean; last?: boolean; /** This row is the one being dragged. */ dragging?: boolean;}>();
const emit = defineEmits<{ (e: "select"): void; (e: "rename"): void; (e: "remove"): void; (e: "move", delta: -1 | 1): void; (e: "dragStart", event: PointerEvent): void;}>();
const { t } = useI18n();
const icon = computed( () => (props.info.icon as MaterialSymbol | undefined) ?? DEFAULT_WORKSPACE_ICON,);
const rowStyle = computed(() => props.info.accent ? { "--ws-accent": props.info.accent } : undefined,);</script>
<template> <div class="ws-row" :class="{ 'ws-row--active': active, 'ws-row--drag': dragging }" :style="rowStyle" data-drag-workspace @pointerdown="emit('dragStart', $event)" > <button type="button" class="ws-row__open" :disabled="disabled" :aria-current="active ? 'true' : undefined" @click="emit('select')" > <span class="ws-row__icon" aria-hidden="true"> <MsIcon :name="icon" :size="22" /> </span> <span class="ws-row__text"> <UiTruncatedText class="ws-row__name" :text="info.name" /> <span class="ws-row__meta">{{ status }}</span> </span> <span v-if="switching" class="ws-row__spinner" aria-hidden="true" /> <!-- <MsIcon v-else-if="active" name="check" :size="16" class="ws-row__check" /> --> </button>
<UiMenu> <template #trigger> <UiIconButton icon="more_vert" :size="20" :label="t('switcher.actions', { name: info.name })" variant="ghost" class="button--small ws-row__more" @click.stop /> </template>
<UiMenuItem icon="edit" @select="emit('rename')">{{ $t("common.rename") }}</UiMenuItem> <UiMenuItem icon="keyboard_double_arrow_up" :disabled="first" @select="emit('move', -1)"> {{ $t("common.moveUp") }} </UiMenuItem> <UiMenuItem icon="keyboard_double_arrow_down" :disabled="last" @select="emit('move', 1)"> {{ $t("common.moveDown") }} </UiMenuItem> <UiMenuSeparator /> <UiMenuItem icon="delete" danger @select="emit('remove')"> {{ $t("common.delete") }} </UiMenuItem> </UiMenu> </div></template>
<style>.ws-row { display: flex; align-items: center; gap: var(--space-0-5); padding-right: var(--space-2); border-radius: max(0px, calc(var(--radius-md) - var(--space-1))); transition: background var(--motion-fast);}
/* The highlight covers the whole row, trailing actions included, so the row reads as one button surface instead of a button plus a bystander. */.ws-row:hover { background: var(--color-surface-2);}
.ws-row--active,.ws-row--active:hover { background: var(--color-accent-soft);}
/* The dragged row is a card in the hand: the drag takes it out of the flow and follows the pointer, and this makes it read as lifted. */.ws-row--drag { z-index: 2; transform: scale(0.97); background: var(--color-surface); box-shadow: 0 6px 16px rgb(0 0 0 / 0.18);}
.ws-row__open { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); font-family: inherit; font-size: var(--text-md); text-align: left; color: var(--color-text); background: transparent; border: none; border-radius: inherit; cursor: pointer;}
.ws-row__open:disabled { opacity: 0.6; cursor: default;}
.ws-row__icon { display: grid; place-content: center; width: var(--control-sm); height: var(--control-sm); flex: none; color: var(--ws-accent, var(--color-accent)); background: color-mix(in srgb, var(--ws-accent, var(--color-accent)) 16%, transparent); border-radius: var(--radius-sm);}
.ws-row--active .ws-row__icon { background: var(--color-surface);}
.ws-row__text { display: flex; flex-direction: column; gap: var(--space-0-5); min-width: 0;}
.ws-row__name { font-weight: 600;}
.ws-row__meta { font-size: var(--text-xs); color: var(--color-text-secondary);}
.ws-row__check { flex: none; margin-left: auto; color: var(--color-accent);}
/* The row's menu button: revealed on hover/focus and tinted like the row surface instead of adding its own button chrome. */.ws-row .ws-row__more { flex: none; opacity: 0; transition: opacity var(--motion-fast);}
/* Tint the row's own surface instead of painting the ghost button background over it, so the action stays visually inside the row highlight. */.ws-row .ws-row__more:hover,.ws-row .ws-row__more[data-state="open"] { background: color-mix(in srgb, var(--color-text) 10%, transparent);}
.ws-row:hover .ws-row__more,.ws-row .ws-row__more:focus-visible,.ws-row .ws-row__more[data-state="open"] { opacity: 1;}
.ws-row__spinner { flex: none; width: calc(0.95rem * var(--ui-size)); height: calc(0.95rem * var(--ui-size)); margin-left: auto; border: 2px solid var(--color-text-secondary); border-top-color: transparent; border-radius: 50%; animation: ws-row-spin 0.7s linear infinite;}
@keyframes ws-row-spin { to { transform: rotate(360deg); }}
@media (hover: none) { .ws-row .ws-row__more { opacity: 1; }}</style>