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
345 changes: 83 additions & 262 deletions apps/tauri/src/App.vue

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions apps/tauri/src/stores/shell.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { defineStore } from "pinia";
import { ref } from "vue";

/** Flutter MainContentSplit / AppSettings defaults. */
const SIDEBAR_KEY = "querya.sidebar.width";
const SIDEBAR_OPEN_KEY = "querya.sidebar.open";
const MIN_WIDTH = 180;
const MAX_WIDTH = 420;
const DEFAULT_WIDTH = 240;
export const SIDEBAR_MIN = 180;
export const SIDEBAR_MAX = 500;
export const SIDEBAR_DEFAULT = 260;

function readWidth(): number {
const raw = Number(localStorage.getItem(SIDEBAR_KEY));
if (Number.isFinite(raw) && raw >= MIN_WIDTH && raw <= MAX_WIDTH) return raw;
return DEFAULT_WIDTH;
if (Number.isFinite(raw) && raw >= SIDEBAR_MIN && raw <= SIDEBAR_MAX) {
return raw;
}
return SIDEBAR_DEFAULT;
}

function readOpen(): boolean {
Expand All @@ -19,7 +22,7 @@ function readOpen(): boolean {
return raw !== "0";
}

/** Shell chrome store — sidebar / ready flags for later connection tree. */
/** Shell chrome — Flutter MainScreen sidebar + ready flag. */
export const useShellStore = defineStore("shell", () => {
const ready = ref(false);
const sidebarOpen = ref(readOpen());
Expand All @@ -39,7 +42,7 @@ export const useShellStore = defineStore("shell", () => {
}

function setSidebarWidth(width: number) {
const next = Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, Math.round(width)));
const next = Math.min(SIDEBAR_MAX, Math.max(SIDEBAR_MIN, Math.round(width)));
sidebarWidth.value = next;
localStorage.setItem(SIDEBAR_KEY, String(next));
}
Expand All @@ -52,7 +55,7 @@ export const useShellStore = defineStore("shell", () => {
setSidebarOpen,
toggleSidebar,
setSidebarWidth,
minSidebarWidth: MIN_WIDTH,
maxSidebarWidth: MAX_WIDTH,
minSidebarWidth: SIDEBAR_MIN,
maxSidebarWidth: SIDEBAR_MAX,
};
});
56 changes: 56 additions & 0 deletions apps/tauri/src/stores/shellStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { defineStore } from "pinia";
import { ref } from "vue";

/** Flutter QueryaShellStatus — workspaces publish busy/metrics here. */
export const useShellStatusStore = defineStore("shellStatus", () => {
const statusMessage = ref<string | null>(null);
const isBusy = ref(false);
const rowCount = ref<number | null>(null);
const columnCount = ref<number | null>(null);
const lastQueryMs = ref<number | null>(null);
const connectionName = ref<string | null>(null);
const connectionHost = ref<string | null>(null);
const isReadOnly = ref(false);

function clear() {
statusMessage.value = null;
isBusy.value = false;
rowCount.value = null;
columnCount.value = null;
lastQueryMs.value = null;
}

function setConnection(name: string | null, host: string | null = null) {
connectionName.value = name;
connectionHost.value = host;
if (!name) clear();
}

function setQueryMetrics(opts: {
message?: string | null;
busy?: boolean;
rows?: number | null;
cols?: number | null;
durationMs?: number | null;
}) {
if (opts.message !== undefined) statusMessage.value = opts.message;
if (opts.busy !== undefined) isBusy.value = opts.busy;
if (opts.rows !== undefined) rowCount.value = opts.rows;
if (opts.cols !== undefined) columnCount.value = opts.cols;
if (opts.durationMs !== undefined) lastQueryMs.value = opts.durationMs;
}

return {
statusMessage,
isBusy,
rowCount,
columnCount,
lastQueryMs,
connectionName,
connectionHost,
isReadOnly,
clear,
setConnection,
setQueryMetrics,
};
});
33 changes: 32 additions & 1 deletion apps/tauri/src/styles/tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@
*/

:root {
/* Radius / elevation / type (shared) */
/* Radius / elevation / type — Flutter QueryaControlMetrics + chrome */
--q-radius-control: 6px;
--q-radius-sm: 4px;
--q-radius-md: 8px;
--q-radius-lg: 12px;
--q-radius-surface: 14px;
--q-control-h-sm: 28px;
--q-control-h-md: 32px;
--q-control-h-lg: 36px;
--q-titlebar-h: 40px;
--q-statusbar-h: 26px;
--q-split-handle: 6px;
--q-sidebar-min: 180px;
--q-sidebar-max: 500px;
--q-sidebar-default: 260px;
--q-hairline-alpha: 0.22;
--q-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.08);
--q-shadow-md: 0 4px 16px rgb(0 0 0 / 0.12);
--q-font-sans: "Segoe UI", "SF Pro Text", system-ui, sans-serif;
Expand Down Expand Up @@ -58,6 +70,13 @@
--q-chart-3: #e88c30;
--q-chart-4: #af57db;
--q-chart-5: #e23670;
/* Workbench — QueryaWorkbenchTheme.lightDefault */
--q-canvas: #fafafa;
--q-surface: #ffffff;
--q-sidebar-bg: #f4f4f5;
--q-editor-bg: #ffffff;
--q-success: #16a34a;
--q-warning: #d97706;
}

/* Dark — QueryaTheme.darkDefault / QueryaColors */
Expand Down Expand Up @@ -88,6 +107,12 @@
--q-chart-3: #e88c30;
--q-chart-4: #af57db;
--q-chart-5: #e23670;
--q-canvas: #000000;
--q-surface: #0c0c0c;
--q-sidebar-bg: #000000;
--q-editor-bg: #0c0c0c;
--q-success: #4caf50;
--q-warning: #e88c30;
}
}

Expand Down Expand Up @@ -117,4 +142,10 @@
--q-chart-3: #e88c30;
--q-chart-4: #af57db;
--q-chart-5: #e23670;
--q-canvas: #000000;
--q-surface: #0c0c0c;
--q-sidebar-bg: #000000;
--q-editor-bg: #0c0c0c;
--q-success: #4caf50;
--q-warning: #e88c30;
}
227 changes: 227 additions & 0 deletions apps/tauri/src/ui/ConnectionsPanel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
<script setup lang="ts">
import { computed, onUnmounted, ref } from "vue";
import { useShellStore } from "../stores/shell";
import { useQueryaMotion } from "../motion";
import SplitHandle from "./SplitHandle.vue";

const emit = defineEmits<{
openSqlite: [];
newConnection: [];
}>();

const shell = useShellStore();
const motion = useQueryaMotion();
const filter = ref("");
const dragging = ref(false);

const panelStyle = computed(() => ({
width: shell.sidebarOpen ? `${shell.sidebarWidth}px` : "0px",
transitionProperty: dragging.value ? "none" : "width",
transitionDuration: `${motion.duration("sidebarCubic")}ms`,
transitionTimingFunction: motion.easing("standard"),
}));

function onResizeStart(e: PointerEvent) {
if (!shell.sidebarOpen) return;
e.preventDefault();
dragging.value = true;
const startX = e.clientX;
const startW = shell.sidebarWidth;

const onMove = (ev: PointerEvent) => {
shell.setSidebarWidth(startW + (ev.clientX - startX));
};
const onUp = () => {
dragging.value = false;
// Flutter collapse threshold: flick under ~100px closes.
if (shell.sidebarWidth < 100) shell.setSidebarOpen(false);
window.removeEventListener("pointermove", onMove);
window.removeEventListener("pointerup", onUp);
};
window.addEventListener("pointermove", onMove);
window.addEventListener("pointerup", onUp);
}

onUnmounted(() => {
dragging.value = false;
});
</script>

<template>
<aside
class="connections"
data-testid="connections-panel"
:class="{ open: shell.sidebarOpen, dragging }"
:style="panelStyle"
:aria-hidden="!shell.sidebarOpen"
>
<div class="inner">
<div class="servers-header" data-testid="connections-servers-header">
<span class="servers-label">SERVERS</span>
<span class="count">0</span>
</div>
<div class="filter-row">
<input
v-model="filter"
class="filter"
type="search"
placeholder="Filter connections…"
aria-label="Filter connections"
data-testid="connections-filter"
/>
</div>
<div class="body">
<p class="empty-title">No connections yet</p>
<p class="empty-hint">
Open a SQLite file or add a server — drivers land with the vertical
slice.
</p>
<div class="actions">
<button
type="button"
class="btn primary"
data-testid="connections-open-sqlite"
@click="emit('openSqlite')"
>
Open SQLite…
</button>
<button
type="button"
class="btn"
data-testid="connections-new"
@click="emit('newConnection')"
>
New connection
</button>
</div>
</div>
</div>
<SplitHandle v-if="shell.sidebarOpen" @pointerdown="onResizeStart" />
</aside>
</template>

<style scoped>
.connections {
position: relative;
flex: 0 0 auto;
height: 100%;
min-width: 0;
overflow: hidden;
display: flex;
flex-direction: row;
}

.inner {
flex: 1;
min-width: var(--q-sidebar-min);
height: 100%;
display: flex;
flex-direction: column;
background: var(--q-sidebar-bg);
border-right: 1px solid
color-mix(
in srgb,
var(--q-border) calc(var(--q-hairline-alpha) * 100%),
transparent
);
}

.servers-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 12px 6px;
}

.servers-label {
font-family: var(--q-font-mono);
font-size: 11px;
font-weight: 600;
letter-spacing: 0.85px;
color: var(--q-muted-foreground);
}

.count {
font-size: 11px;
color: var(--q-muted-foreground);
background: var(--q-accent);
border-radius: 999px;
padding: 0 6px;
line-height: 18px;
}

.filter-row {
padding: 0 10px 8px;
}

.filter {
width: 100%;
height: var(--q-control-h-sm);
border: 1px solid var(--q-border);
border-radius: var(--q-radius-control);
background: var(--q-surface);
color: var(--q-foreground);
padding: 0 8px;
font: inherit;
font-size: 12px;
}

.filter:focus {
outline: 2px solid color-mix(in srgb, var(--q-primary) 45%, transparent);
outline-offset: 0;
}

.body {
flex: 1;
padding: 16px 12px;
overflow: auto;
}

.empty-title {
margin: 0;
font-size: 13px;
font-weight: 600;
color: var(--q-foreground);
}

.empty-hint {
margin: 6px 0 0;
font-size: 12px;
color: var(--q-muted-foreground);
line-height: 1.4;
}

.actions {
display: flex;
flex-direction: column;
gap: 6px;
margin-top: 14px;
}

.btn {
appearance: none;
height: var(--q-control-h-sm);
border: 1px solid var(--q-border);
border-radius: var(--q-radius-control);
background: var(--q-surface);
color: var(--q-foreground);
font: inherit;
font-size: 12px;
cursor: pointer;
padding: 0 8px;
}

.btn:hover {
background: var(--q-accent);
}

.btn.primary {
background: var(--q-primary);
border-color: transparent;
color: var(--q-primary-foreground);
}

.btn.primary:hover {
filter: brightness(1.05);
}
</style>
Loading
Loading