primevue-mirror/apps/showcase/app.vue

40 lines
967 B
Vue
Raw Normal View History

2022-09-06 11:52:18 +00:00
<template>
2023-10-10 05:41:15 +00:00
<NuxtLayout>
2022-09-14 14:26:41 +00:00
<NuxtPage />
</NuxtLayout>
2022-09-06 11:52:18 +00:00
</template>
<script>
2024-11-10 19:16:58 +00:00
import EventBus from '@/app/AppEventBus';
export default {
mounted() {
EventBus.on('dark-mode-toggle', this.darkModeToggleListener);
},
beforeUnmount() {
EventBus.off('dark-mode-toggle', this.darkModeToggleListener);
},
methods: {
darkModeToggleListener(event) {
if (!document.startViewTransition) {
this.toggleDarkMode(event);
return;
}
document.startViewTransition(() => this.toggleDarkMode(event));
},
toggleDarkMode(event) {
const isDark = event.dark;
if (isDark) document.documentElement.classList.add('p-dark');
else document.documentElement.classList.remove('p-dark');
this.$appState.darkTheme = isDark;
EventBus.emit('dark-mode-toggle-complete');
}
}
};
</script>