From a191a4ed04087f48394b893124dce46dd419e34a Mon Sep 17 00:00:00 2001 From: ZhuchkaTriplesix Date: Sun, 15 Nov 2026 06:22:22 +0300 Subject: [PATCH] feat(ui): add Querya design tokens as CSS variables Port light/dark QueryaUiColors into --q-* tokens (no shadcn), wire base styles, and demo them on the scaffold splash with a system/light/dark toggle so both palettes are visible immediately. Closes #1860 --- apps/tauri/pnpm-workspace.yaml | 2 + apps/tauri/src/App.vue | 166 +++++++++++++++++++++------- apps/tauri/src/main.ts | 4 + apps/tauri/src/styles/base.css | 28 +++++ apps/tauri/src/styles/tokens.css | 120 ++++++++++++++++++++ apps/tauri/src/theme/queryaTheme.ts | 25 +++++ 6 files changed, 304 insertions(+), 41 deletions(-) create mode 100644 apps/tauri/src/styles/base.css create mode 100644 apps/tauri/src/styles/tokens.css create mode 100644 apps/tauri/src/theme/queryaTheme.ts diff --git a/apps/tauri/pnpm-workspace.yaml b/apps/tauri/pnpm-workspace.yaml index efc037aa..09a02ca1 100644 --- a/apps/tauri/pnpm-workspace.yaml +++ b/apps/tauri/pnpm-workspace.yaml @@ -1,2 +1,4 @@ +allowBuilds: + esbuild: true onlyBuiltDependencies: - esbuild diff --git a/apps/tauri/src/App.vue b/apps/tauri/src/App.vue index 0222f5e9..8fb65fb6 100644 --- a/apps/tauri/src/App.vue +++ b/apps/tauri/src/App.vue @@ -2,11 +2,27 @@ import { onMounted, ref } from "vue"; import { invoke } from "@tauri-apps/api/core"; import { useShellStore } from "./stores/shell"; +import { + applyTheme, + initTheme, + type QueryaThemeMode, +} from "./theme/queryaTheme"; const shell = useShellStore(); const backend = ref("…"); +const theme = ref("system"); + +const swatches = [ + { name: "bg", varName: "--q-background" }, + { name: "card", varName: "--q-card" }, + { name: "primary", varName: "--q-primary" }, + { name: "muted", varName: "--q-muted-foreground" }, + { name: "border", varName: "--q-border" }, + { name: "destructive", varName: "--q-destructive" }, +] as const; onMounted(async () => { + theme.value = initTheme(); try { const info = await invoke<{ name: string; stack: string; version: string }>( "app_info", @@ -18,74 +34,142 @@ onMounted(async () => { shell.markReady(); } }); + +function setTheme(mode: QueryaThemeMode) { + theme.value = mode; + applyTheme(mode); +} - diff --git a/apps/tauri/src/main.ts b/apps/tauri/src/main.ts index 8ba200d9..a54fe294 100644 --- a/apps/tauri/src/main.ts +++ b/apps/tauri/src/main.ts @@ -1,6 +1,10 @@ import { createApp } from "vue"; import { createPinia } from "pinia"; import App from "./App.vue"; +import "./styles/base.css"; +import { initTheme } from "./theme/queryaTheme"; + +initTheme(); const app = createApp(App); app.use(createPinia()); diff --git a/apps/tauri/src/styles/base.css b/apps/tauri/src/styles/base.css new file mode 100644 index 00000000..e0ee58fd --- /dev/null +++ b/apps/tauri/src/styles/base.css @@ -0,0 +1,28 @@ +@import "./tokens.css"; + +*, +*::before, +*::after { + box-sizing: border-box; +} + +html, +body, +#app { + margin: 0; + min-height: 100%; + height: 100%; +} + +body { + font-family: var(--q-font-sans); + font-size: var(--q-text-md); + line-height: 1.45; + font-weight: 400; + color: var(--q-foreground); + background: var(--q-background); + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/apps/tauri/src/styles/tokens.css b/apps/tauri/src/styles/tokens.css new file mode 100644 index 00000000..fdcee6e4 --- /dev/null +++ b/apps/tauri/src/styles/tokens.css @@ -0,0 +1,120 @@ +/** + * Querya design tokens (CSS variables). + * Ported from Flutter QueryaUiColors / QueryaColors — no shadcn. + * + * Usage: `color: var(--q-foreground); background: var(--q-background);` + * Theme: set `data-theme="light"|"dark"` on , or leave unset for + * prefers-color-scheme. + */ + +:root { + /* Radius / elevation / type (shared) */ + --q-radius-sm: 4px; + --q-radius-md: 8px; + --q-radius-lg: 12px; + --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; + --q-font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace; + --q-text-xs: 0.75rem; + --q-text-sm: 0.875rem; + --q-text-md: 1rem; + --q-text-lg: 1.25rem; + --q-text-xl: 1.75rem; + --q-text-hero: clamp(2.5rem, 6vw, 4rem); + --q-space-1: 0.25rem; + --q-space-2: 0.5rem; + --q-space-3: 0.75rem; + --q-space-4: 1rem; + --q-space-6: 1.5rem; + --q-space-8: 2rem; +} + +/* Light — QueryaTheme.lightDefault / QueryaUiColors */ +:root, +:root[data-theme="light"] { + color-scheme: light; + --q-background: #fafafa; + --q-foreground: #0f172a; + --q-card: #ffffff; + --q-card-foreground: #0f172a; + --q-popover: #ffffff; + --q-popover-foreground: #0f172a; + --q-primary: #0e7490; + --q-primary-foreground: #ffffff; + --q-secondary: #f4f4f5; + --q-secondary-foreground: #0f172a; + --q-muted: #f4f4f5; + --q-muted-foreground: #64748b; + --q-accent: #e4e4e7; + --q-accent-foreground: #0f172a; + --q-destructive: #dc2626; + --q-destructive-foreground: #f8fafc; + --q-border: #e4e4e7; + --q-input: #e4e4e7; + --q-ring: #0e7490; + --q-chart-1: #2662d9; + --q-chart-2: #2eb88a; + --q-chart-3: #e88c30; + --q-chart-4: #af57db; + --q-chart-5: #e23670; +} + +/* Dark — QueryaTheme.darkDefault / QueryaColors */ +@media (prefers-color-scheme: dark) { + :root:not([data-theme="light"]) { + color-scheme: dark; + --q-background: #000000; + --q-foreground: #f8fafc; + --q-card: #0c0c0c; + --q-card-foreground: #f8fafc; + --q-popover: #0c0c0c; + --q-popover-foreground: #f8fafc; + --q-primary: #22d3ee; + --q-primary-foreground: #0a0a0a; + --q-secondary: #18181b; + --q-secondary-foreground: #f8fafc; + --q-muted: #18181b; + --q-muted-foreground: #94a3b8; + --q-accent: #27272a; + --q-accent-foreground: #f8fafc; + --q-destructive: #ef4444; + --q-destructive-foreground: #f8fafc; + --q-border: #27272a; + --q-input: #27272a; + --q-ring: #22d3ee; + --q-chart-1: #2662d9; + --q-chart-2: #2eb88a; + --q-chart-3: #e88c30; + --q-chart-4: #af57db; + --q-chart-5: #e23670; + } +} + +:root[data-theme="dark"] { + color-scheme: dark; + --q-background: #000000; + --q-foreground: #f8fafc; + --q-card: #0c0c0c; + --q-card-foreground: #f8fafc; + --q-popover: #0c0c0c; + --q-popover-foreground: #f8fafc; + --q-primary: #22d3ee; + --q-primary-foreground: #0a0a0a; + --q-secondary: #18181b; + --q-secondary-foreground: #f8fafc; + --q-muted: #18181b; + --q-muted-foreground: #94a3b8; + --q-accent: #27272a; + --q-accent-foreground: #f8fafc; + --q-destructive: #ef4444; + --q-destructive-foreground: #f8fafc; + --q-border: #27272a; + --q-input: #27272a; + --q-ring: #22d3ee; + --q-chart-1: #2662d9; + --q-chart-2: #2eb88a; + --q-chart-3: #e88c30; + --q-chart-4: #af57db; + --q-chart-5: #e23670; +} diff --git a/apps/tauri/src/theme/queryaTheme.ts b/apps/tauri/src/theme/queryaTheme.ts new file mode 100644 index 00000000..11163793 --- /dev/null +++ b/apps/tauri/src/theme/queryaTheme.ts @@ -0,0 +1,25 @@ +export type QueryaThemeMode = "system" | "light" | "dark"; + +const STORAGE_KEY = "querya.theme"; + +export function readStoredTheme(): QueryaThemeMode { + const raw = localStorage.getItem(STORAGE_KEY); + if (raw === "light" || raw === "dark" || raw === "system") return raw; + return "system"; +} + +export function applyTheme(mode: QueryaThemeMode): void { + const root = document.documentElement; + if (mode === "system") { + root.removeAttribute("data-theme"); + } else { + root.setAttribute("data-theme", mode); + } + localStorage.setItem(STORAGE_KEY, mode); +} + +export function initTheme(): QueryaThemeMode { + const mode = readStoredTheme(); + applyTheme(mode); + return mode; +}