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

Utilize bslib's navbar-default/navbar-inverse support to resolve several issues with navbar theming #1124

Merged
merged 6 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions shiny/ui/_navs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,12 +1060,12 @@ def layout(self, nav: Tag, content: Tag) -> TagList:
if self.position != "static-top":
nav_final.add_class(self.position)

nav_final.add_class(f"navbar-{'dark' if self.inverse else 'light'}")
# bslib supports navbar-default/navbar-inverse (which is no longer
# a thing in Bootstrap 5) in a way that's still useful, especially Bootswatch.
nav_final.add_class(f"navbar-{'inverse' if self.inverse else 'default'}")

if self.bg:
nav_final.attrs["style"] = "background-color: " + self.bg
else:
nav_final.add_class(f"bg-{'dark' if self.inverse else 'light'}")
nav_final.add_style(f"background-color: {self.bg} !important;")

content = _make_tabs_fillable(
content,
Expand Down
2 changes: 1 addition & 1 deletion tests/pytest/test_navs.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_nav_markup():

assert TagList(x).render()["html"] == textwrap.dedent(
"""\
<nav class="navbar navbar-expand-md navbar-light bg-light">
<nav class="navbar navbar-expand-md navbar-default">
<div class="container-fluid">
<span class="navbar-brand">Page title</span><button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-collapse-1663" aria-controls="navbar-collapse-1663" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div id="navbar-collapse-1663" class="collapse navbar-collapse">
Expand Down
Loading