-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Custom Dark Theme - add light/dark section configurations for theme & theme.sidebar
#12680
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
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
✅ PR preview is ready!
|
📈 Python coverage change detectedThe Python unit test coverage has increased by 0.0282%
✅ Coverage change is within normal range. Coverage by files
|
theme & theme.sidebartheme & theme.sidebar
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.
Pull Request Overview
This PR implements the first part of a custom dark theme feature by adding new light/dark theme configuration sections. It establishes the foundational structure for theme sections that can be customized separately for light and dark modes, as well as for the sidebar component in both modes.
Key changes:
- Added new theme configuration sections:
[theme.light],[theme.dark],[theme.sidebar.light], and[theme.sidebar.dark] - Implemented validation to prevent invalid theme section nesting patterns
- Updated protobuf definitions to support the new theme sections
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| proto/streamlit/proto/NewSession.proto | Added light and dark theme fields to CustomThemeConfig message |
| lib/streamlit/errors.py | Added StreamlitInvalidThemeSectionError for theme validation |
| lib/streamlit/config.py | Extended CustomThemeCategories enum and updated theme option creation to support new sections |
| lib/streamlit/config_util.py | Added theme nesting validation logic and deep merge functionality for nested configurations |
| lib/tests/streamlit/config_test.py | Added comprehensive tests for new theme sections and validation |
| lib/tests/streamlit/config_util_test.py | Added tests for nested theme configuration handling |
| lib/tests/streamlit/proto_compatibility_test.py | Updated protobuf compatibility tests for new theme fields |
226a139 to
121635d
Compare
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.
Overall, LGTM 👍 Just one question about the category order to double check with @jrieke
lib/streamlit/config.py
Outdated
| SIDEBAR_LIGHT = "sidebar.light" | ||
| SIDEBAR_DARK = "sidebar.dark" |
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.
Just double-checking: are we sure we want to have theme.sidebar.<light/dark> instead of theme.<light/dark>.sidebar? I think both notation make sense, but theme.<light/dark>.sidebar feels slightly more semantically correct since I think the sidebar theme is a sub-aspect part of the overall dark & light theme. cc @jrieke
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.
Fair point, I leaned toward theme.sidebar.<light/dark> myself, since I thought about [theme] and [theme.sidebar] as the main sections, with their respective mode modifiers light/dark but happy to change if you guys prefer the alternative 👍🏼
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.
Yeah I think theme.dark.sidebar is more intuitive (I would consider dark and light as separate themes, and main area and sidebar are just two areas you can style differently within these themes) and it's also how it's in the product spec, so I'd go with that.
lib/streamlit/config.py
Outdated
| "theme", | ||
| CustomThemeCategories.SIDEBAR, | ||
| CustomThemeCategories.LIGHT, | ||
| CustomThemeCategories.DARK, | ||
| CustomThemeCategories.SIDEBAR_LIGHT, | ||
| CustomThemeCategories.SIDEBAR_DARK, |
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.
nit: we could put this into an ALL_THEME_CATEGORIES constant or similar...
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.
Echo approval above
Describe your changes
Part 1 of Custom Dark Theme Feature
PR adds the following new sections under
[theme]configuration options (viaconfig.py&NewSession.proto):[theme.light][theme.dark][theme.light.sidebar][theme.dark.sidebar]Invalid sections (ex:
[theme.sidebar.light]) throw an error.Note: Logic in this PR does not fully handle setting of values in the theme input of new session message / proper section precedence between a base theme
.tomlfile,config.toml, CLI/env vars). The next PR will handle the rest of the backend logic to fully support these new light/dark section configurations.Testing Plan