Skip to content

Commit

Permalink
feat: Modify color mode when the defaultMode prop changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ktquez committed Jun 23, 2020
1 parent 4302d19 commit 5604170
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/DarkMode.vue
Expand Up @@ -118,6 +118,10 @@ export default {
}
},
watch: {
defaultMode: 'handleSetMode'
},
created () {
if (this.getPrefersColorScheme && this.isSystem) {
this.currentMode = this.getPrefersColorScheme
Expand Down Expand Up @@ -189,6 +193,10 @@ export default {
toggleColorMode () {
const selectedMode = this.getNextMode
this.handleSetMode(selectedMode)
},
handleSetMode (selectedMode) {
this.handleColorModeClass('remove')
this.currentMode = selectedMode === 'system' ? this.getPrefersColorScheme : selectedMode
this.setMode(selectedMode)
Expand Down

0 comments on commit 5604170

Please sign in to comment.