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!: Use shiny.ui.Theme #39

Merged
merged 29 commits into from
Jun 28, 2024
Merged

feat!: Use shiny.ui.Theme #39

merged 29 commits into from
Jun 28, 2024

Conversation

gadenbuie
Copy link
Contributor

@gadenbuie gadenbuie commented Jun 24, 2024

There are three core changes in this PR:

  1. We now use shiny.ui.Theme as the provider of the Shiny theme, using feat: Dynamic theming py-shiny#1358. This means that the Bootswatch themes are now complete Shiny themes, including built-in Shiny components in the bootswatch.min.css file.

  2. BREAKING CHANGE: As part of this change, shinyswatch no longer suppresses any Shiny component Sass, as that is handled by Shiny directly. shinyswatch now provides only the CSS styles, not a complete Bootswatch dependency. As a result, shinyswatch themes should be provided directly to the theme argument of shiny.ui.page_*() functions rather than being added anywhere in the UI.

    • In feat: Dynamic theming py-shiny#1358, shiny.ui.Theme() objects have a .tagify() method that raises an error, telling users to instead pass the theme object to theme=. We could consider a similar change for shinyswatch, but we'd need to think through the mechanism.
  3. BREAKING CHANGE: The default parameter of shinyswatch.theme_picker_ui() is now deprecated and ignored if provided. Due to the changes in 2 above, the initial theme should be set via shiny.ui.page_*(theme=).

    • The theme picker ui/server logic was updated such that the app will report its current theme on startup and the UI selector will be updated to match the initial theme.
    • We now also support returning to the first theme, which we call "default". This means that an app with shinyswatch can start with the default Shiny theme and users can then switch to a Bootswatch theme (and back again). This option is only available if the initial theme is the Shiny theme.
  4. BREAKING CHANGE: I've removed shinyswatch.get_theme_deps(). It's no longer useful given the current structure.

Example

I've updated the examples, but the most "complete" is now examples/page-sidebar/app.py. This app includes a custom initial theme that is added into the theme picker choices. Notice that bootstrap and shiny are also included in the theme picker choices.

Kapture.2024-06-25.at.15.07.08.mp4

TODO

  • Changelog
  • Throw if shinyswatch theme is tagified in the UI? Yes: by having Shinyswatch theme be a subclass of shiny.ui.Theme.
  • make docs isn't working?

@gadenbuie gadenbuie requested a review from schloerke June 24, 2024 16:19
@gadenbuie gadenbuie merged commit 1a179f8 into main Jun 28, 2024
14 checks passed
@gadenbuie gadenbuie deleted the feat/shiny-ui-theme branch June 28, 2024 18:06
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.

None yet

3 participants