Skip to content

Commit

Permalink
[Fix] Theme remembering #12
Browse files Browse the repository at this point in the history
  • Loading branch information
camarm-dev committed Jan 4, 2024
1 parent 8292dd8 commit 2423a13
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions components/FloatingThemeButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default {
},
mounted() {
this.theme = this.getTheme()
this.start()
},
methods: {
changeTheme () {
Expand All @@ -30,13 +31,17 @@ export default {
break
default:
localStorage.setItem('theme', 'dark')
break
}
const newTheme = this.getTheme()
document.body.classList.add(newTheme)
this.theme = newTheme
},
getTheme () {
return localStorage.getItem('theme') || 'dark'
},
start () {
document.body.classList.add(this.theme)
}
}
}
Expand Down

0 comments on commit 2423a13

Please sign in to comment.