You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
628 B

4 years ago
  1. <template>
  2. <v-btn
  3. icon
  4. fab
  5. @click="isDark=!isDark"
  6. >
  7. <v-icon v-if="isDark">
  8. mdi-moon-waxing-crescent
  9. </v-icon>
  10. <v-icon v-else>
  11. mdi-white-balance-sunny
  12. </v-icon>
  13. </v-btn>
  14. </template>
  15. <script lang="ts">
  16. import Vue from 'vue'
  17. export default Vue.extend({
  18. data() {
  19. return {
  20. isDark: false
  21. }
  22. },
  23. watch: {
  24. isDark() {
  25. this.$vuetify.theme.dark = this.isDark
  26. localStorage.setItem('dark', JSON.stringify(this.isDark))
  27. }
  28. },
  29. created() {
  30. const dark = localStorage.getItem('dark')
  31. this.isDark = dark ? JSON.parse(dark) : false
  32. }
  33. })
  34. </script>