-
Notifications
You must be signed in to change notification settings - Fork 85
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: Move navbar_options
into single argument with helper navbar_options()
#1822
base: main
Are you sure you want to change the base?
Changes from all commits
0527488
2f4b42b
0309d76
5f50b5a
d29617d
d7827b4
c93a257
b483f31
7f5b578
87e4abb
afc0dd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) |
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() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,24 +31,30 @@ | |
from htmltools import TagChild | ||
|
||
from ._docstring import add_example | ||
from ._typing_extensions import NotRequired, TypedDict | ||
from ._typing_extensions import NotRequired, TypedDict, TypeIs | ||
|
||
if TYPE_CHECKING: | ||
from matplotlib.figure import Figure | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
# Sentinel value - indicates a missing value in a function call. | ||
class MISSING_TYPE: | ||
pass | ||
|
||
|
||
MISSING: MISSING_TYPE = MISSING_TYPE() | ||
DEPRECATED: MISSING_TYPE = MISSING_TYPE() # A MISSING that communicates deprecation | ||
MaybeMissing = Union[T, MISSING_TYPE] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find |
||
|
||
|
||
T = TypeVar("T") | ||
ListOrTuple = Union[List[T], Tuple[T, ...]] | ||
|
||
|
||
def is_missing(x: Any) -> TypeIs[MISSING_TYPE]: | ||
return x is MISSING or isinstance(x, MISSING_TYPE) | ||
Comment on lines
+54
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL about the difference between Anyway, this could also just be |
||
|
||
|
||
# Information about a single file, with a structure like: | ||
# {'name': 'mtcars.csv', 'size': 1303, 'type': 'text/csv', 'datapath: '/...../mtcars.csv'} | ||
# The incoming data doesn't include 'datapath'; that field is added by the | ||
|
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.
@schloerke Can you review the changes in this file for me? I wanted an object that operates like
MISSING
but gives a better hint to users in the function signature, so I created a new sentinelDEPRECATED
object. Look atpage_navbar()
ornavset_bar()
(in_navs.py
, which might be hidden for being a large diff) to see how this is used.