Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions apps/tauri/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script setup lang="ts">
import { computed, onMounted, ref } from "vue";
import { invoke } from "@tauri-apps/api/core";
import { storeToRefs } from "pinia";
import { useShellStore } from "./stores/shell";
import { useWorkspaceStore } from "./stores/workspace";
import {
applyTheme,
initTheme,
Expand All @@ -14,8 +16,11 @@ import {
import QueryaGlass from "./ui/QueryaGlass.vue";
import TitleBar from "./ui/TitleBar.vue";
import SidebarShell from "./ui/SidebarShell.vue";
import TabStrip from "./ui/TabStrip.vue";

const shell = useShellStore();
const workspace = useWorkspaceStore();
const { activeTab } = storeToRefs(workspace);
const motion = provideQueryaMotion();
const { level: motionLevel, springsOn, manual: motionManual } = motion;
const backend = ref<string>("…");
Expand Down Expand Up @@ -66,9 +71,12 @@ function setMotion(level: QueryaMotionLevel) {
<div class="body">
<SidebarShell />
<main class="workspace">
<TabStrip />
<div class="hero">
<header class="brand">Querya</header>
<p class="tagline">Tauri 2 + Vue 3 — shell chrome (title + sidebar)</p>
<p class="tagline">
Active tab: {{ activeTab?.title ?? "—" }} ({{ activeTab?.kind }})
</p>
<p class="meta" data-testid="backend-info">{{ backend }}</p>
<p class="meta">
springs: {{ springsOn ? "on" : "off" }} · level: {{ motionLevel }}
Expand Down Expand Up @@ -190,11 +198,15 @@ function setMotion(level: QueryaMotionLevel) {
flex: 1;
min-width: 0;
min-height: 0;
overflow: auto;
display: flex;
flex-direction: column;
overflow: hidden;
}

.hero {
min-height: 100%;
flex: 1;
min-height: 0;
overflow: auto;
display: grid;
place-content: center;
justify-items: center;
Expand Down
63 changes: 63 additions & 0 deletions apps/tauri/src/stores/workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { defineStore } from "pinia";
import { computed, ref } from "vue";

export type WorkspaceTabKind = "welcome" | "sql" | "result";

export type WorkspaceTab = {
id: string;
title: string;
kind: WorkspaceTabKind;
};

let seq = 1;

function nextId(): string {
seq += 1;
return `tab-${seq}`;
}

/** Demo workspace tabs — SQL/result content lands in later issues. */
export const useWorkspaceStore = defineStore("workspace", () => {
const tabs = ref<WorkspaceTab[]>([
{ id: "tab-1", title: "Welcome", kind: "welcome" },
]);
const activeId = ref("tab-1");

const activeTab = computed(
() => tabs.value.find((t) => t.id === activeId.value) ?? null,
);

function activate(id: string) {
if (tabs.value.some((t) => t.id === id)) activeId.value = id;
}

function addTab(partial?: Partial<Pick<WorkspaceTab, "title" | "kind">>) {
const tab: WorkspaceTab = {
id: nextId(),
title: partial?.title ?? `Query ${seq}`,
kind: partial?.kind ?? "sql",
};
tabs.value = [...tabs.value, tab];
activeId.value = tab.id;
return tab;
}

function closeTab(id: string) {
const idx = tabs.value.findIndex((t) => t.id === id);
if (idx < 0) return;
if (tabs.value.length === 1) {
// Keep at least a welcome tab.
tabs.value = [{ id: nextId(), title: "Welcome", kind: "welcome" }];
activeId.value = tabs.value[0].id;
return;
}
const next = tabs.value.filter((t) => t.id !== id);
tabs.value = next;
if (activeId.value === id) {
const fallback = next[Math.max(0, idx - 1)] ?? next[0];
activeId.value = fallback.id;
}
}

return { tabs, activeId, activeTab, activate, addTab, closeTab };
});
150 changes: 150 additions & 0 deletions apps/tauri/src/ui/TabStrip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<script setup lang="ts">
import { computed } from "vue";
import { useWorkspaceStore } from "../stores/workspace";
import { useQueryaMotion } from "../motion";

const workspace = useWorkspaceStore();
const motion = useQueryaMotion();

const stripStyle = computed(() => ({
transitionDuration: `${motion.duration("fast")}ms`,
transitionTimingFunction: motion.easing("standard"),
}));

function onClose(e: MouseEvent, id: string) {
e.stopPropagation();
workspace.closeTab(id);
}
</script>

<template>
<div class="tabstrip" data-testid="tab-strip" :style="stripStyle">
<div class="tabs" role="tablist" aria-label="Workspace tabs">
<button
v-for="tab in workspace.tabs"
:key="tab.id"
type="button"
class="tab"
role="tab"
:aria-selected="tab.id === workspace.activeId"
:class="{ active: tab.id === workspace.activeId }"
:data-testid="`tab-${tab.id}`"
@click="workspace.activate(tab.id)"
>
<span class="title">{{ tab.title }}</span>
<span
class="close"
role="button"
tabindex="0"
aria-label="Close tab"
@click="onClose($event, tab.id)"
@keydown.enter.prevent="workspace.closeTab(tab.id)"
>
×
</span>
</button>
</div>
<button
type="button"
class="add"
data-testid="tab-add"
aria-label="New tab"
@click="workspace.addTab()"
>
+
</button>
</div>
</template>

<style scoped>
.tabstrip {
display: flex;
align-items: stretch;
gap: var(--q-space-1);
min-height: 36px;
padding: var(--q-space-1) var(--q-space-2) 0;
border-bottom: 1px solid var(--q-border);
background: color-mix(in srgb, var(--q-card) 70%, transparent);
transition-property: background-color, border-color;
}

.tabs {
display: flex;
align-items: stretch;
gap: 2px;
min-width: 0;
overflow-x: auto;
flex: 1;
}

.tab {
appearance: none;
border: 1px solid transparent;
border-bottom: 0;
background: transparent;
color: var(--q-muted-foreground);
font: inherit;
font-size: var(--q-text-sm);
padding: 0.35rem 0.55rem 0.45rem 0.75rem;
border-radius: var(--q-radius-md) var(--q-radius-md) 0 0;
display: inline-flex;
align-items: center;
gap: var(--q-space-2);
cursor: pointer;
max-width: 12rem;
transition:
background-color var(--q-motion-fast) var(--q-motion-ease),
color var(--q-motion-fast) var(--q-motion-ease);
}

.tab:hover {
background: var(--q-accent);
color: var(--q-foreground);
}

.tab.active {
background: var(--q-background);
color: var(--q-foreground);
border-color: var(--q-border);
box-shadow: inset 0 -1px 0 var(--q-background);
}

.title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.close {
display: grid;
place-items: center;
width: 1.1rem;
height: 1.1rem;
border-radius: var(--q-radius-sm);
opacity: 0.55;
font-size: 0.95rem;
line-height: 1;
}

.close:hover {
opacity: 1;
background: var(--q-accent);
}

.add {
appearance: none;
border: 0;
background: transparent;
color: var(--q-muted-foreground);
width: 2rem;
border-radius: var(--q-radius-sm);
cursor: pointer;
font-size: 1.1rem;
margin-bottom: 2px;
}

.add:hover {
background: var(--q-accent);
color: var(--q-foreground);
}
</style>
Loading