-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new ThemeSwitcher logic #9698
Add new ThemeSwitcher logic #9698
Conversation
b233efc
to
93a9bd0
Compare
9e8b5f0
to
8ad955a
Compare
3df7eb7
to
be849e0
Compare
f3abe3f
to
acced1a
Compare
@@ -16,6 +16,7 @@ | |||
"peerDependencies": { | |||
"@ownclouders/design-system": "workspace:*", | |||
"@ownclouders/web-client": "workspace:*", | |||
"@ownclouders/web-pkg": "workspace:*" | |||
"@ownclouders/web-pkg": "workspace:*", | |||
"pinia": "^2.1.7" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should re-export the required part (storeToRefs) from web-pkg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's fine to have pinia
as peerDependency in most of our packages since that will probably be the case anyway after fully switching to it.
privacyUrl: '', | ||
imprintUrl: '', | ||
accessDeniedHelpUrl: '', | ||
logoutUrl: '', // Fixme: why was this missing before? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this a conscious omission?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think so, I feel like we sometimes forget adding new configs here 😅
const currentLocalStorageThemeName = useLocalStorage(themeStorageKey, theme.name) | ||
currentLocalStorageThemeName.value = currentTheme.value.name | ||
|
||
// TODO: Shouldn't we loop over all designTokens and set them? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kulmann do you remember if we only applied the colorPalette on purpose instead of applying all designTokens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't remember it. but yes, we should loop over all design tokens... otherwise one theme would leak into the other, newly selected theme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It technically still could since we're not resetting everything, but at least with the change I just pushed one isn't left wondering why the e.g. fontsize never changes even though a theme might re-define it 😋
const currentLocalStorageThemeName = useLocalStorage(themeStorageKey, theme.name) | ||
currentLocalStorageThemeName.value = currentTheme.value.name | ||
|
||
// TODO: Shouldn't we loop over all designTokens and set them? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't remember it. but yes, we should loop over all design tokens... otherwise one theme would leak into the other, newly selected theme.
} | ||
const theme = await response.json() | ||
return { web: theme.web || theme, common: theme.common || {} } | ||
|
||
if (WebThemeConfigSchema.safeParse(theme).success) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dschmidt is this roughly what you had in mind?
@@ -16,6 +16,7 @@ | |||
"peerDependencies": { | |||
"@ownclouders/design-system": "workspace:*", | |||
"@ownclouders/web-client": "workspace:*", | |||
"@ownclouders/web-pkg": "workspace:*" | |||
"@ownclouders/web-pkg": "workspace:*", | |||
"pinia": "^2.1.7" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's fine to have pinia
as peerDependency in most of our packages since that will probably be the case anyway after fully switching to it.
privacyUrl: '', | ||
imprintUrl: '', | ||
accessDeniedHelpUrl: '', | ||
logoutUrl: '', // Fixme: why was this missing before? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think so, I feel like we sometimes forget adding new configs here 😅
- `options.imprintUrl` Specifies the target URL for the imprint link valid for the ocis instance in the account menu. | ||
- `options.privacyUrl` Specifies the target URL for the privacy link valid for the ocis instance in the account menu. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the config for this has been removed intentionally? Because then we need to remove it in oCIS as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should. The way to go is the theme, so that all clients can use the URLs. Config is only for web.
currentThemeName.value = useDefaultThemeName() | ||
} | ||
await store.dispatch('loadTheme', { theme: web[unref(currentThemeName)] || web.default }) | ||
const themeStore = useThemeStore() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not in an injection context here... I know we currently don't have an alternative, but one day that might become a problem 😬 @dschmidt Maybe also something to consider for a future refactoring.
…ction and dedicated client key
b72b176
to
ccf3493
Compare
@@ -89,6 +91,9 @@ export default defineComponent({ | |||
const { getInternalSpace } = useGetMatchingSpace() | |||
useUpload({ uppyService }) | |||
|
|||
const { currentTheme } = storeToRefs(themeStore) | |||
const themeSlogan = computed(() => currentTheme.value.common.slogan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be computed, as storeToRefs builds already a reactive object, or does this not apply to nested objects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand it: It's not necessary in this case. currentTheme
is already a Ref
because of storeToRefs
. Meaning the consuming code could go directly via unref(currentTheme).common.slogan
.
It doesn't hurt to have a computed here though, I guess it's used as a "shortcut".
SonarCloud Quality Gate failed. 0 Bugs 61.0% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work 💪
) | ||
}) | ||
|
||
const imprintUrl = computed(() => themeStore.currentTheme.common.urls.imprint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, we might need to re-introduce setting the imprint and privacy urls via config.json for short term deployment reasons.
to be solved in a followup if needed
New theme structure --------- Co-authored-by: Jannik Stehle <jannik.stehle@gmail.com>
New theme structure --------- Co-authored-by: Jannik Stehle <jannik.stehle@gmail.com>
Update theming docs after #9698
Update theming docs after #9698
Description
Overhaul of theme loading (used to be object key-value instead of an array of themes, which seems more desireable)-
Motivation and Context
Supersede && finish some draft PRs, take advantage of upcoming major release
Open tasks: