diff --git a/src/App.vue b/src/App.vue index a78fb6f..b18ca84 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,7 @@ diff --git a/src/components/layout/AppLayout.vue b/src/components/layout/AppLayout.vue new file mode 100644 index 0000000..a477f85 --- /dev/null +++ b/src/components/layout/AppLayout.vue @@ -0,0 +1,17 @@ + + + diff --git a/src/components/layout/SiteFooter.vue b/src/components/layout/SiteFooter.vue new file mode 100644 index 0000000..98a6cdb --- /dev/null +++ b/src/components/layout/SiteFooter.vue @@ -0,0 +1,29 @@ + + + diff --git a/src/components/layout/SiteHeader.vue b/src/components/layout/SiteHeader.vue new file mode 100644 index 0000000..3472228 --- /dev/null +++ b/src/components/layout/SiteHeader.vue @@ -0,0 +1,80 @@ + + + diff --git a/src/components/layout/ThemeToggle.vue b/src/components/layout/ThemeToggle.vue new file mode 100644 index 0000000..2e8c326 --- /dev/null +++ b/src/components/layout/ThemeToggle.vue @@ -0,0 +1,18 @@ + + + diff --git a/src/composables/useTheme.ts b/src/composables/useTheme.ts new file mode 100644 index 0000000..2b2e0a8 --- /dev/null +++ b/src/composables/useTheme.ts @@ -0,0 +1,27 @@ +import { ref, watchEffect } from 'vue' + +type Theme = 'light' | 'dark' + +const STORAGE_KEY = 'ewd:theme' + +function initialTheme(): Theme { + if (typeof window === 'undefined') return 'light' + const stored = window.localStorage.getItem(STORAGE_KEY) + if (stored === 'light' || stored === 'dark') return stored + return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' +} + +const theme = ref(initialTheme()) + +watchEffect(() => { + if (typeof document === 'undefined') return + document.documentElement.classList.toggle('dark', theme.value === 'dark') + window.localStorage.setItem(STORAGE_KEY, theme.value) +}) + +export function useTheme() { + function toggle() { + theme.value = theme.value === 'dark' ? 'light' : 'dark' + } + return { theme, toggle } +}