ui.ts
1import { writable } from 'svelte/store';
2import { browser } from '$app/environment';
3
4export type ViewMode = 'unified' | 'split';
5export type Theme = 'light' | 'dark';
6
7export const viewMode = writable<ViewMode>('unified');
8
9function createThemeStore() {
10 const initial: Theme = browser
11 ? (localStorage.getItem('lcr-theme') as Theme) || 'dark'
12 : 'dark';
13
14 const { subscribe, set } = writable<Theme>(initial);
15
16 return {
17 subscribe,
18 set(value: Theme) {
19 if (browser) {
20 localStorage.setItem('lcr-theme', value);
21 document.documentElement.setAttribute('data-theme', value);
22 }
23 set(value);
24 },
25 toggle() {
26 let current: Theme = 'dark';
27 subscribe((v) => (current = v))();
28 const next = current === 'dark' ? 'light' : 'dark';
29 this.set(next);
30 }
31 };
32}
33
34export const theme = createThemeStore();
35export const sidebarOpen = writable(true);
36export const showCommitDialog = writable(false);
37export const showExportDialog = writable(false);
38export const commentingLine = writable<{
39 filePath: string;
40 lineNumber: number;
41 side: 'old' | 'new';
42 originalLineContent?: string;
43} | null>(null);