-
Notifications
You must be signed in to change notification settings - Fork 107
feat: Move navbar_options
into single argument with helper navbar_options()
#1822
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0527488
feat(navbar_options): Consolidate options and use in `navset_bar()`
gadenbuie 2f4b42b
feat(navbar_options): Use in `page_navbar()` too
gadenbuie 0309d76
chore: Update deprecation warnings
gadenbuie 5f50b5a
chore(navbar_options): Add docs, rename `type` -> `theme`
gadenbuie d29617d
docs: Add navbar_options to index
gadenbuie d7827b4
chore: Remove deprecated args from internal NavsetBar class
gadenbuie c93a257
chore(express.ui.navbar_options): Reflect changes from core
gadenbuie b483f31
chore: add version and date for deprecations
gadenbuie 7f5b578
docs: Add navbar_options examples
gadenbuie 87e4abb
docs: Fix navbar_optoins parameters
gadenbuie afc0dd2
chore: format
gadenbuie 7d13df9
rename: `Maybe[]` instead of `MaybeMissing[]`
gadenbuie 15f5562
chore: simplify `is_missing()`
gadenbuie 8844d73
Merged origin/main into feat/navbar-options
gadenbuie 4427769
chore: make check-fix
gadenbuie 9b7a62e
chore: Back to `T | MISSING_TYPE = MISSING` instead of `Maybe[T] = MI…
gadenbuie f01ece7
chore: `*T` -> `*Type`
gadenbuie a1f497f
chore: Remove the unused default helper
gadenbuie 6b9274f
chore: Add changelog
gadenbuie c9a242a
chore: remove unused import
gadenbuie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from shiny import App, render, ui | ||
|
||
app_ui = ui.page_fluid( | ||
ui.navset_bar( | ||
ui.nav_panel("A", "Panel A content"), | ||
ui.nav_panel("B", "Panel B content"), | ||
ui.nav_panel("C", "Panel C content"), | ||
ui.nav_menu( | ||
"Other links", | ||
ui.nav_panel("D", "Panel D content"), | ||
"----", | ||
"Description:", | ||
ui.nav_control( | ||
ui.a("Shiny", href="https://shiny.posit.co", target="_blank") | ||
), | ||
), | ||
id="selected_navset_bar", | ||
title="Navset Bar", | ||
navbar_options=ui.navbar_options( | ||
bg="#B73A85", | ||
theme="dark", | ||
underline=False, | ||
), | ||
), | ||
ui.h5("Selected:"), | ||
ui.output_code("selected"), | ||
) | ||
|
||
|
||
def server(input, output, session): | ||
@render.code | ||
def selected(): | ||
return input.selected_navset_bar() | ||
|
||
|
||
app = App(app_ui, server) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from shiny.express import input, render, ui | ||
|
||
with ui.navset_bar( | ||
title="Navset Bar", | ||
id="selected_navset_bar", | ||
navbar_options=ui.navbar_options( | ||
bg="#B73A85", | ||
theme="dark", | ||
underline=False, | ||
), | ||
): | ||
with ui.nav_panel("A"): | ||
"Panel A content" | ||
|
||
with ui.nav_panel("B"): | ||
"Panel B content" | ||
|
||
with ui.nav_panel("C"): | ||
"Panel C content" | ||
|
||
with ui.nav_menu("Other links"): | ||
with ui.nav_panel("D"): | ||
"Page D content" | ||
|
||
"----" | ||
"Description:" | ||
with ui.nav_control(): | ||
ui.a("Shiny", href="https://shiny.posit.co", target="_blank") | ||
ui.h5("Selected:") | ||
|
||
|
||
@render.code | ||
def _(): | ||
return input.selected_navset_bar() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gadenbuie marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel somewhat on the fence about this, but would you be open to having
types.NavbarOptions
inherit fromTypedDict
? The benefit being that we wouldn't needui.navbar_options()
. FWIW, theanimate
argument ofinput_slider()
follows that pattern.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally open to it and it's certainly a route I thought about taking. It's a little more complicated because there are methods on
NavbarOptions
, so we'd need a user-facingNavbarOptions
that inherits fromTypedDict
and a counterpartNavbarOptionsResolved
(or similar name) class that resolves the user-facing options.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out it's a bit more complicated because, unlike
AnimationOptions
, the navbar options are not a closed set, which means we can't just callNavbarOptionsResolved(**navbar_options)
without making the type checker angry.Code sample in pyright playground
It turns out there's a PEP for this but it's still in draft mode: https://peps.python.org/pep-0728/