diff --git a/app.vue b/app.vue index 912a811fd..10773055e 100644 --- a/app.vue +++ b/app.vue @@ -20,11 +20,11 @@ export default { created() { useServerHead({ link: [ - { + /*{ id: 'theme-link', rel: 'stylesheet', href: '/themes/lara-light-green/theme.css' - }, + }*/ { id: 'home-table-link', rel: 'stylesheet', @@ -57,12 +57,16 @@ export default { document.startViewTransition(() => this.applyTheme(event)); }, applyTheme(event) { - this.$primevue.changeTheme(this.$appState.theme, event.theme, 'theme-link', () => { + /*this.$primevue.changeTheme(this.$appState.theme, event.theme, 'theme-link', () => { this.$appState.theme = event.theme; this.$appState.darkTheme = event.dark; EventBus.emit('theme-change-complete', { theme: event.theme, dark: event.dark }); - }); + });*/ + // @todo + this.$appState.theme = event.theme; + this.$appState.darkTheme = event.dark; + document.documentElement.className = this.$appState.darkTheme ? 'p-dark' : ''; } } }; diff --git a/components/lib/base/style/BaseStyle.js b/components/lib/base/style/BaseStyle.js index a1e73d0db..88c5d327b 100644 --- a/components/lib/base/style/BaseStyle.js +++ b/components/lib/base/style/BaseStyle.js @@ -35,6 +35,9 @@ export default { loadStyle(options = {}) { return this.css ? useStyle(this.css, { name: this.name, ...options }) : {}; }, + loadTheme(theme, options = {}) { + return theme ? useStyle(theme, { name: `${this.name}-style`, ...options }) : {}; + }, getStyleSheet(extendedCSS = '', props = {}) { if (this.css) { const _props = Object.entries(props) diff --git a/components/lib/basecomponent/BaseComponent.vue b/components/lib/basecomponent/BaseComponent.vue index fa3b2267e..682381999 100644 --- a/components/lib/basecomponent/BaseComponent.vue +++ b/components/lib/basecomponent/BaseComponent.vue @@ -1,5 +1,6 @@