-
Notifications
You must be signed in to change notification settings - Fork 15.2k
feat(theming): support user OS-level dark/light mode configuration #33890
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
base: master
Are you sure you want to change the base?
Conversation
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.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
Category | Issue | Status |
---|---|---|
Unvalidated Cookie Value Setting ▹ view | 🧠 Not in scope | |
No UI Theme Update ▹ view | 🧠 Not in scope | |
Missing Fallback Theme Logic ▹ view | 🧠 Not in scope | |
Documentation Accuracy Issue ▹ view | 🧠 Not in standard | |
Unnecessary Lambda Functions for Static Config Values ▹ view | 🧠 Not in scope | |
Missing OS Theme Change Listener ▹ view | 🧠 Not in standard |
Files scanned
File Path | Reviewed |
---|---|
superset-frontend/src/views/RootContextProviders.tsx | ✅ |
superset-frontend/src/setup/setupApp.ts | ✅ |
superset-frontend/src/theme/ThemeController.tsx | ✅ |
superset/views/base.py | ✅ |
superset/config.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
: 'light'; | ||
|
||
const setThemeCookie = theme => { | ||
document.cookie = `superset_theme=${theme}; path=/; SameSite=Lax; secure`; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
function syncBrowserThemePreferenceWithCookie() { | ||
try { | ||
const getCurrentPreference = () => | ||
window.matchMedia('(prefers-color-scheme: dark)').matches |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
const cookies = parseCookie(); | ||
|
||
if (cookies.superset_theme !== currentPreference) { | ||
setThemeCookie(currentPreference); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
if (bootstrapData.themes[preferred]) { | ||
themeConfig = bootstrapData.themes[preferred]; | ||
} |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -292,6 +293,27 @@ def menu_data(user: User) -> dict[str, Any]: | |||
} | |||
|
|||
|
|||
def get_theme_bootstrap_data() -> dict[str, Any]: | |||
""" | |||
On frst call, the cookie related to light/dark may not be set, |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
THEME: dict[str, Any] = lambda: {} # NOQA | ||
THEME_DARK: dict[str, Any] = lambda: {"algorithm": "dark"} # NOQA |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This PR introduce new
superset_config
settings:Some of the logic:
boostrapData.themes
, letting the frontend to pick the right oneboostrapData.themes