Skip to content

Conversation

@gadenbuie
Copy link
Collaborator

Fixes #1270

This approach supercedes #1275 as a smaller, more targeted change. This PR:

  • Adds a theme argument to shiny.ui.page_() functions.
  • When theme is provided, i.e. is not None, it represents a complete replacement for Bootstrap's CSS files.
    • The primary use case is for users to provide a path to a locally-stored Bootstrap theme.
    • Alternatively, for advanced use cases, e.g. shinyswatch, theme accepts a tagifiable, or html dependency or a list of html dependencies.

The scope of this PR is different from #1275 in that theme is exclusively for the replacement of Bootstrap's CSS, all other scenarios are easily accomplished using ui.include_css() or html dependencies.

If moving forward with this iteration, we also aren't going to separate the Bootstrap dependency into bootstrap-css and bootstrap-js. That approach is inconsistent with how we handle dependencies otherwise and possibly points to a need for an HTMLDependencyPartial.

Closes #1275 (supercedes)
Closes #1282 (supercedes)

Expands the carve-outs to include `Tagifiable`,
`HTMLDependency`, and `list[HTMLDependency]`.
This improves usability for shinyswatch, but also hides
the `ThemeProvider` type behind a type alias,
pushing focus on the typical `str | Path` use case.
@gadenbuie gadenbuie requested a review from cpsievert April 24, 2024 16:16
"css",
]

subprocess.run(args)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If purgecss isn't installed, you'll see: FileNotFoundError: [Errno 2] No such file or directory: 'purgecss'.

Probably worth a check + more informative error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This isn't officially part of the example, just used to create it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a note at the top of the file that purgecss is required and how to install it

Copy link
Collaborator

@cpsievert cpsievert left a comment

Choose a reason for hiding this comment

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

Nice, thanks! Let's add an to the changelog before merging?

@gadenbuie gadenbuie added this pull request to the merge queue Apr 24, 2024
Merged via the queue into main with commit 2c2b075 Apr 24, 2024
@gadenbuie gadenbuie deleted the feat/theme-css-path branch April 24, 2024 21:50
@gadenbuie gadenbuie mentioned this pull request May 8, 2024
6 tasks
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.

Allow users or third-party packages to replace Bootstrap CSS

3 participants