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

feat: marimo.app_meta.theme and custom themers to auto switch plotting themes based on the display theme #2126

Merged
merged 32 commits into from
Aug 29, 2024

Conversation

metaboulie
Copy link
Contributor

@metaboulie metaboulie commented Aug 27, 2024

📝 Summary

This pull request introduces a new mechanism for managing and applying themes across different plotting libraries used within Marimo notebooks.

Changes Made

  • App Metadata: A new AppMeta class is introduced to store application metadata like the current display theme (light or dark).
  • app_meta() function: Added a function to retrieve the current application metadata.
  • Theming Integration: Implemented a theme application mechanism within various formatters for plotting libraries like Plotly, Altair, Matplotlib/Seaborn, Holoviews, and Bokeh.
    • This ensures that plots automatically adapt their appearance based on the chosen notebook theme.
  • System Theme Handling: If the display theme is set to "system," the default theme becomes "light."
  • Formatter Registration Updates: The register_formatters function now accepts a theme parameter to pass the current theme to formatters at runtime.
  • Testing: Smoke tests are added to verify the functionality of different formatters with theming enabled.

Problem Addressed

Previously, customizing the theme of visualizations required manual adjustments within each plotting library. This pull request simplifies theme management and ensures consistent theme application across all charts.

Resolution

By introducing a centralized theme management system, this PR allows for seamless theme application across various plotting libraries, enhancing the user experience and visual consistency within Marimo notebooks.

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • I have added tests for the changes made.
  • I have run the code and verified that it works as expected.

📜 Reviewers

@akshayka OR @mscolnick

Copy link

vercel bot commented Aug 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 29, 2024 1:27pm
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 29, 2024 1:27pm

marimo/__init__.py Outdated Show resolved Hide resolved
marimo/_ast/app.py Outdated Show resolved Hide resolved
@mscolnick
Copy link
Contributor

@metaboulie, this should fix the bokeh background: #2128

Copy link
Contributor

@akshayka akshayka left a comment

Choose a reason for hiding this comment

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

Whoa, this is cool, nice work @metaboulie!

I have just a comment on the public API. I noticed AppMeta was added to __init__.py. Instead, I would suggest having each library's theming function run when its formatter is registered (e.g., for altair, here: https://github.com/marimo-team/marimo/blob/main/marimo/_output/formatters/altair_formatters.py#L17, and similarly for the other libraries).

That way we wouldn't need to add anything to the public API (but could later if we needed to), and theming application would be lazy (performant) and automatic.

(cc @mscolnick)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this the right file to put AppMeta?

@mscolnick
Copy link
Contributor

nice job @metaboulie! this is awesome

Copy link

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.8.5-dev3

@metaboulie metaboulie changed the title marimo.app_meta.theme and custom themers to auto switch plotting themes based on the display theme feat: marimo.app_meta.theme and custom themers to auto switch plotting themes based on the display theme Sep 2, 2024
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