github.com/System-Glitch/goyave/v2@v2.10.3-0.20200819142921-51011e75d504/docs_src/src/.vuepress/theme/mixins/darkThemeHandler.js (about) 1 export default { 2 data() { 3 return { 4 darkTheme: false, 5 }; 6 }, 7 8 mounted() { 9 this.darkTheme = localStorage.getItem('dark-theme') === 'true'; 10 this.updateTheme(); 11 }, 12 13 methods: { 14 toggleDarkTheme() { 15 this.darkTheme = !this.darkTheme; 16 this.updateTheme(); 17 }, 18 updateTheme() { 19 if (this.darkTheme) { 20 document.body.classList.add('yuu-theme-dark'); 21 return localStorage.setItem('dark-theme', true); 22 } 23 24 document.body.classList.remove('yuu-theme-dark'); 25 localStorage.setItem('dark-theme', false); 26 } 27 }, 28 };