💄 day/night themes

This commit is contained in:
2026-02-21 10:26:50 +10:00
parent 9bd46127a6
commit 740faae8c8
5 changed files with 76 additions and 11 deletions

View File

@@ -42,6 +42,10 @@ interface EditorState {
// Editor font size
fontSize: number
setFontSize: (size: number) => void
// Theme
theme: 'dark' | 'light'
toggleTheme: () => void
}
export const useEditorStore = create<EditorState>((set, get) => ({
@@ -133,5 +137,15 @@ export const useEditorStore = create<EditorState>((set, get) => ({
const clamped = Math.max(11, Math.min(24, size))
localStorage.setItem('editorFontSize', String(clamped))
set({ fontSize: clamped })
},
theme: (localStorage.getItem('editorTheme') as 'dark' | 'light') || 'dark',
toggleTheme: () => {
set((s) => {
const next = s.theme === 'dark' ? 'light' : 'dark'
localStorage.setItem('editorTheme', next)
document.documentElement.classList.toggle('light', next === 'light')
return { theme: next }
})
}
}))