Skip to content

Commit

Permalink
Patch auto dark / light mode
Browse files Browse the repository at this point in the history
  • Loading branch information
SliverRiver327 authored and SliverRiver327 committed Jan 7, 2024
1 parent 6a8a1ce commit 98df229
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<script setup lang="ts">
import { useTheme } from 'vuetify';
import { onMounted } from 'vue';
const vuetifyTheme = useTheme()
function toggleTheme(themeName?: string) {
vuetifyTheme.global.name.value = themeName ?? (vuetifyTheme.global.current.value.dark ? 'light' : 'dark')
}
onMounted(() => {
const darkMatch = matchMedia('(prefers-color-scheme: dark)')
toggleTheme(darkMatch.matches ? 'dark' : 'light')
darkMatch.addEventListener('change', (event) =>
toggleTheme(event.matches ? 'dark' : 'light')
)
})
</script>

<template>
Expand Down
4 changes: 0 additions & 4 deletions src/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const vuetify = createVuetify({
themes: {
light: {
colors: {
background: "#ECEFF1",
surface: "#FFFFFF",
primary: "#2196F3",
secondary: "#03A9F4",
blockquote: "#ECEFF1",
Expand All @@ -16,8 +14,6 @@ const vuetify = createVuetify({
},
dark: {
colors: {
background: "#263238",
surface: "#37474F",
primary: "#2196F3",
secondary: "#03A9F4",
blockquote: "#455A64",
Expand Down

0 comments on commit 98df229

Please sign in to comment.