Skip to content
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

Do most of the theme handling from the Theme component #2390

Merged
merged 8 commits into from
Mar 14, 2024

Conversation

matc-pub
Copy link
Collaborator

@matc-pub matc-pub commented Mar 12, 2024

Description

I noticed some issues with the current way of handling themes:

  • Code blocks briefly use light theme after page refresh for "browser" theme in dark mode
  • "browser-compact" is not compact and always in light mode
  • Live theme preview:
    • sometimes mixes light and dark elements
    • "browser" theme can be in wrong dark/light variant
    • Navigating away from dialog without saving keeps theme active
  • Unrelated: AdminSettings doesn't have a theme list after page refresh

This change moves all decisions about the current theme into the Theme component. The only thing outside of the Theme component is a script embedded in the SSR which sets the data-bs-theme attribute for "browser" and "browser-compact", as the server doesn't know the correct value and waiting for all scripts to load would be to slow. The Theme and Settings components communicate using "refresh-theme" and "set-theme-override" CustomEvents.

Screenshots

Before

Code syntax highlight in wrong color scheme while loading

code-block-wrong-color-scheme

Live Preview

Screenshot made without saving the theme. Only "browser-compact" has problems after saving and reloading.

"browser-compact" live preview not compact

browser-compact-preview-not-compact

Live preview with mixed dark/light elements

browser-preview-mixed

Live preview "vaporwave-dark" in light

vaporwave-dark-preview-mixed

After

No screenshots. Things look as they should.

@matc-pub
Copy link
Collaborator Author

One sequence to reproduce the light/dark mixed element. With "darkly-red" saved, change to "darkly", then "browser-compat", then "browser".

Looks like "browser-compact" has to be involved.

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested this out, and it seemed to work well, thx!

@SleeplessOne1917 SleeplessOne1917 enabled auto-merge (squash) March 14, 2024 12:31
@SleeplessOne1917 SleeplessOne1917 merged commit 9a5f9dd into LemmyNet:main Mar 14, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants