Files
FabledScribe/frontend/src/composables/useTheme.ts
T
bvandeusen 22a3a3c1d1 Initial commit: note-taking/task-tracking app with LLM integration scaffold
Vue 3 + TypeScript frontend with Pinia stores, markdown rendering (marked + DOMPurify),
wikilink/tag linkification, and autocomplete. Quart async backend with SQLAlchemy 2.0,
PostgreSQL ARRAY columns, task-note companion linking, backlinks, and note-to-task
conversion. Docker Compose setup with PostgreSQL 16 and Ollama.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:35:44 -05:00

30 lines
721 B
TypeScript

import { ref } from "vue";
type Theme = "light" | "dark";
const theme = ref<Theme>(getInitialTheme());
function getInitialTheme(): Theme {
const stored = localStorage.getItem("theme");
if (stored === "light" || stored === "dark") return stored;
if (window.matchMedia("(prefers-color-scheme: light)").matches) return "light";
return "dark";
}
function applyTheme(t: Theme) {
document.documentElement.setAttribute("data-theme", t);
localStorage.setItem("theme", t);
}
export function useTheme() {
// Apply on first use
applyTheme(theme.value);
function toggleTheme() {
theme.value = theme.value === "dark" ? "light" : "dark";
applyTheme(theme.value);
}
return { theme, toggleTheme };
}