-
Notifications
You must be signed in to change notification settings - Fork 151
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
[Tidy] Refactor Vizro chart template generation #967
Conversation
View the example dashboards of the current commit live on PyCafe ☕ 🚀Updated on: 2025-01-27 15:23:16 UTC Link: vizro-core/examples/dev/ Link: vizro-core/examples/scratch_dev |
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.
Looks awesome 🙌 Lots of small comments but definitely it's pretty much as I was expecting so happy to approve in advance and feel free to merge when it's done as far as I'm concerned.
@@ -0,0 +1,48 @@ | |||
<!-- |
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.
If this makes vizro.boostrap
available then that is definitely worth mentioning in the changelog.
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.
No, I didn't add that change in this PR yet. I wan't to wait for the next token update before we make this public 👍
vizro-core/tests/unit/vizro/_themes/test_create_chart_template.py
Outdated
Show resolved
Hide resolved
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.
LGTM!
return None, None | ||
|
||
|
||
def extract_bs_variables_from_css(variables: list[str], css_content: str) -> tuple[dict[str, str], dict[str, str]]: |
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 function only works with vizro-bootstrap.min.css
? Wondering how general this could be and how does it work if users like to try with other bootstrap. Could a user fork the repo and link to other bootstrap css, and generate_json_template
helps generate the *_dark.json and *_light.json?
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.
This depends on the customizations, whether they offer both dark and light themes, and what their default theme is. We needed a custom script because we have many custom changes. In our CSS file, the default Bootstrap theme loads first, followed by our custom changes. This causes elements like [data-bs-theme=light] to appear twice. If they have minimal customization and only change some variables, the logic will be different.
Our default theme is dark, which is different from most other Bootstrap themes. So, if someone else has a different default (like light), they'll need to adjust the function to output the light theme first, as the order in the CSS file changes.
For those with a custom Bootstrap theme that only has a few changes (like just some variables), AM script is better suited for this! It's built on Bootswatch themes and handles generic color calculations and assignments: https://github.com/AnnMarieW/dash-bootstrap-templates/blob/1feb51177d72048f5448925c870a94d44e596409/_create_templates.py#L262
Description
template_dark.py
andtemplate_light.py
vizro_dark.json
andvizro_light.json
Visually, nothing has changed. Under the hood, a few things have changed that make our Plotly template generation a lot more stable:
vizro_dark.json
andvizro_light.json
and these will be read in at run-time. To update them, one would have to runhatch run templates
vizro_light.json
andvizro_dark.json
will also be re-used for better integration of our bootstrap theme as soon as it's published (more on that later)Screenshot
Notice
I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":