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
749 B

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