Skip to content

Commit

Permalink
Rebase and update theme logic handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Dec 5, 2023
1 parent e77a186 commit f3abe3f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/change-theme-handling
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ https://github.com/owncloud/web/issues/2404
https://github.com/owncloud/web/issues/8424
https://github.com/owncloud/web/issues/9403
https://github.com/owncloud/web/issues/9885
https://github.com/owncloud/web/issues/9939

https://github.com/owncloud/web/pull/8855
https://github.com/owncloud/web/pull/9396
Expand Down
4 changes: 3 additions & 1 deletion packages/web-pkg/src/composables/piniaStores/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ interface WebTheme {

const themeNameLight = 'default'
const themeNameDark = 'default-dark'
const themeStorageKey = 'oc_currentThemeName'

export const useThemeStore = defineStore('theme', () => {
const commonTheme = ref<CommonTheme | undefined>()
Expand All @@ -63,7 +64,7 @@ export const useThemeStore = defineStore('theme', () => {
availableThemes.value = themes
commonTheme.value = newCommonTheme

const currentThemeName = useLocalStorage('oc_currentThemeName', null) // note: use null as default so that we can fall back to system preferences
const currentThemeName = useLocalStorage(themeStorageKey, null) // null as default to make fallback possible
// Set default theme name as fallback
if (unref(currentThemeName) === null) {
const isDark = usePreferredDark()
Expand All @@ -77,6 +78,7 @@ export const useThemeStore = defineStore('theme', () => {

const setAndApplyTheme = (theme: WebTheme) => {
currentTheme.value = theme
useLocalStorage(themeStorageKey, currentTheme.value.general.name)

for (const param in currentTheme.value.designTokens.colorPalette) {
;(document.querySelector(':root') as HTMLElement).style.setProperty(
Expand Down
11 changes: 9 additions & 2 deletions packages/web-runtime/themes/owncloud/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
"common": {
"name": "ownCloud",
"slogan": "ownCloud – A safe home for all your data",
"logo": "themes/owncloud/assets/logo.svg"
"logo": "themes/owncloud/assets/logo.svg",
"urls": {
"accessDeniedHelp": "",
"imprint": "",
"privacy": ""
}
},
"ios": {},
"android": [],
"ios": [],
"desktop": [],
"web": [
{
"isDark": false,
Expand Down

0 comments on commit f3abe3f

Please sign in to comment.