Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

1.6 KB
Raw Blame
<template>
  <div class="tab-navigation">
    <button v-for="tab in tabs" :key="tab.id" class="tab-button" :class="{ active: activeTab === tab.id }" @click="changeTab(tab.id as 'quick' | 'advanced')">
      <Icon :name="tab.icon" class="tab-icon" />
      <span class="tab-label">{{ tab.label }}</span>
    </button>
  </div>
</template>

<script setup lang="ts">
const { changeTab, activeTab } = useCommandCenter();
const { t } = useI18nT();

const tabs = computed(
  () =>
    [
      { id: 'quick', label: t('components.commandCenter.tabs.quick'), icon: 'search' },
      { id: 'advanced', label: t('components.commandCenter.tabs.advanced'), icon: 'layers' },
    ] as const,
);

function handleKeydown(e: KeyboardEvent) {
  if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
    e.stopImmediatePropagation();
    e.preventDefault();
    changeTab(activeTab.value === 'quick' ? 'advanced' : 'quick');
  }
}

onMounted(() => window.addEventListener('keydown', handleKeydown, { capture: true }));
onUnmounted(() => window.removeEventListener('keydown', handleKeydown, { capture: true }));
</script>

<style scoped lang="scss">
.tab-navigation {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-button {
  display: flex;
  flex: 1;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  cursor: pointer;

  &.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
  }
}

.tab-icon {
  width: 16px;
  height: 16px;
}
</style>