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

chore: Update themes and require Shiny v1.2.0 #48

Merged
merged 8 commits into from
Nov 7, 2024

Conversation

gadenbuie
Copy link
Contributor

@gadenbuie gadenbuie commented Nov 7, 2024

Updates shinyswatch to require Shiny v1.2.0

The biggest change is that in posit-dev/py-shiny#1743 we renamed shiny.ui.Theme._html_dependency() to shiny.ui.Theme._html_dependencies(), only to allow subclasses of Theme, like ThemeBranded, to append additional dependencies.

@gadenbuie gadenbuie changed the title chore: Update themes for Shiny v1.2.0 chore: Update themes and require Shiny v1.2.0 Nov 7, 2024
@gadenbuie gadenbuie marked this pull request as ready for review November 7, 2024 15:55
Copy link
Collaborator

@schloerke schloerke left a comment

Choose a reason for hiding this comment

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

Cosmetic cleanup. Don't know if you want to keep get_theme_deps within shinylive. It could allow for older versions of shiny.

Thank you!

.github/workflows/quartodoc.yaml Outdated Show resolved Hide resolved
.github/workflows/quartodoc.yaml Outdated Show resolved Hide resolved
.github/workflows/quartodoc.yaml Outdated Show resolved Hide resolved
Comment on lines 9 to 23
def get_theme_deps(theme: shiny.ui.Theme) -> htmltools.HTMLDependency:
if hasattr(theme, "_html_dependency"):
# shiny < v1.2.0
deps = getattr(theme, "_html_dependency")()
else:
deps = getattr(theme, "_html_dependencies")()
# In shiny >= v1.2.0, `_html_dependencies()` returns a list of deps, but for
# shinyswatch we're expecting the default case to be a single dependency.
assert isinstance(deps, list)
assert len(deps) == 1
deps = deps[0]

return deps


Copy link
Collaborator

Choose a reason for hiding this comment

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

Code is unused

Suggested change
def get_theme_deps(theme: shiny.ui.Theme) -> htmltools.HTMLDependency:
if hasattr(theme, "_html_dependency"):
# shiny < v1.2.0
deps = getattr(theme, "_html_dependency")()
else:
deps = getattr(theme, "_html_dependencies")()
# In shiny >= v1.2.0, `_html_dependencies()` returns a list of deps, but for
# shinyswatch we're expecting the default case to be a single dependency.
assert isinstance(deps, list)
assert len(deps) == 1
deps = deps[0]
return deps

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or did you want to use this method within the package and then we can relax our shiny version requirement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I originally had an implementation that let us relax that shiny version requirement that I took out on second thought. On the balance, I don't think it's worth maintaining the additional logic, which was repeated in a few places with slight variations because constraints and uses were different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed unused code in cbcdb28

@gadenbuie gadenbuie merged commit 5b764e0 into main Nov 7, 2024
17 checks passed
@gadenbuie gadenbuie deleted the chore/2024-11-07-update-themes branch November 7, 2024 18:18
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.

2 participants