summaryrefslogtreecommitdiffstats
path: root/apps/theming/src/UserThemes.vue
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2022-10-20 13:18:06 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2022-11-29 11:22:13 +0100
commitcedae7c6d74e11c8aaa59b09a38db04dbebc818d (patch)
treeb95c77675542e0654084dd41f5d1f07a413b4db7 /apps/theming/src/UserThemes.vue
parenta884f311b78341612adeb6d62f707dda1bae39e7 (diff)
downloadnextcloud-server-cedae7c6d74e11c8aaa59b09a38db04dbebc818d.tar.gz
nextcloud-server-cedae7c6d74e11c8aaa59b09a38db04dbebc818d.zip
Allow to remove the background and select a custom colour
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/src/UserThemes.vue')
-rw-r--r--apps/theming/src/UserThemes.vue25
1 files changed, 16 insertions, 9 deletions
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 @@
</template>
<template v-else>
<p>{{ t('theming', 'Set a custom background') }}</p>
- <BackgroundSettings class="background__grid"
- :background="background"
- :theming-default-background="themingDefaultBackground"
- @update:background="updateBackground" />
+ <BackgroundSettings class="background__grid" @update:background="refreshGlobalStyles" />
</template>
</NcSettingsSection>
</section>
@@ -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 }) {