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.

41 lines
762 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. {{ mdiMoonWaxingCrescent }}
  9. </v-icon>
  10. <v-icon v-else>
  11. {{ mdiWhiteBalanceSunny }}
  12. </v-icon>
  13. </v-btn>
  14. </template>
  15. <script lang="ts">
  16. import Vue from 'vue'
  17. import { mdiMoonWaxingCrescent, mdiWhiteBalanceSunny } from '@mdi/js'
  18. export default Vue.extend({
  19. data() {
  20. return {
  21. isDark: false,
  22. mdiMoonWaxingCrescent,
  23. mdiWhiteBalanceSunny
  24. }
  25. },
  26. watch: {
  27. isDark() {
  28. this.$vuetify.theme.dark = this.isDark
  29. localStorage.setItem('dark', JSON.stringify(this.isDark))
  30. }
  31. },
  32. created() {
  33. const dark = localStorage.getItem('dark')
  34. this.isDark = dark ? JSON.parse(dark) : false
  35. }
  36. })
  37. </script>