From cedae7c6d74e11c8aaa59b09a38db04dbebc818d Mon Sep 17 00:00:00 2001 From: John Molakvoæ Date: Thu, 20 Oct 2022 13:18:06 +0200 Subject: Allow to remove the background and select a custom colour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/theming/src/UserThemes.vue | 25 ++- apps/theming/src/components/BackgroundSettings.vue | 215 ++++++++++++--------- apps/theming/src/helpers/getBackgroundUrl.js | 49 ----- apps/theming/src/helpers/prefixWithBaseUrl.js | 25 --- 4 files changed, 143 insertions(+), 171 deletions(-) delete mode 100644 apps/theming/src/helpers/getBackgroundUrl.js delete mode 100644 apps/theming/src/helpers/prefixWithBaseUrl.js (limited to 'apps/theming/src') diff --git a/apps/theming/src/UserThemes.vue b/apps/theming/src/UserThemes.vue index 5a41c019017..7220820a3c3 100644 --- a/apps/theming/src/UserThemes.vue +++ b/apps/theming/src/UserThemes.vue @@ -69,10 +69,7 @@ @@ -92,8 +89,6 @@ const availableThemes = loadState('theming', 'themes', []) const enforceTheme = loadState('theming', 'enforceTheme', '') const shortcutsDisabled = loadState('theming', 'shortcutsDisabled', false) -const background = loadState('theming', 'background') -const themingDefaultBackground = loadState('theming', 'themingDefaultBackground') const isUserThemingDisabled = loadState('theming', 'isUserThemingDisabled') console.debug('Available themes', availableThemes) @@ -111,10 +106,10 @@ export default { data() { return { availableThemes, + + // Admin defined configs enforceTheme, shortcutsDisabled, - background, - themingDefaultBackground, isUserThemingDisabled, } }, @@ -173,9 +168,21 @@ export default { }, methods: { + // Refresh server-side generated theming CSS + refreshGlobalStyles() { + [...document.head.querySelectorAll('link.theme')].forEach(theme => { + const url = new URL(theme.href) + url.searchParams.set('v', Date.now()) + const newTheme = theme.cloneNode() + newTheme.href = url.toString() + newTheme.onload = () => theme.remove() + document.head.append(newTheme) + }) + }, + updateBackground(data) { this.background = (data.type === 'custom' || data.type === 'default') ? data.type : data.value - this.$emit('update:background') + this.refreshGlobalStyles() }, changeTheme({ enabled, id }) { diff --git a/apps/theming/src/components/BackgroundSettings.vue b/apps/theming/src/components/BackgroundSettings.vue index 45e627fd378..9890f9ad3f0 100644 --- a/apps/theming/src/components/BackgroundSettings.vue +++ b/apps/theming/src/components/BackgroundSettings.vue @@ -26,68 +26,75 @@