From dffb8744ef6552a8c4d2854f7a9def7e56bf83ce Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Thu, 14 Dec 2023 15:33:07 -0600 Subject: [PATCH] Deprecate `nav()` in favor of `nav_panel()` (#876) --- CHANGELOG.md | 1 + docs/_quartodoc.yml | 7 +- examples/event/app.py | 4 +- examples/express/nav_app.py | 8 +- examples/inputs-update/app.py | 4 +- examples/static_plots/app.py | 14 +-- shiny/api-examples/nav/app.py | 6 +- shiny/api-examples/navset_hidden/app.py | 6 +- shiny/api-examples/update_navs/app.py | 6 +- shiny/express/layout.py | 6 +- .../app-templates/multi-page/modules.py | 4 +- shiny/ui/__init__.py | 6 +- shiny/ui/_navs.py | 116 +++++++++++------- tests/playwright/shiny/TODO/navbar/app.py | 4 +- .../shiny/bugs/0696-resolve-id/app.py | 4 +- tests/playwright/shiny/components/nav/app.py | 6 +- .../shiny/components/navset_hidden/app.py | 6 +- tests/playwright/shiny/plot-sizing/app.py | 8 +- .../shiny/shiny-express/page_default/app.py | 4 +- tests/pytest/test_navs.py | 6 +- 20 files changed, 126 insertions(+), 100 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e62c9c42..4ec24aff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Other changes +* Closed #492: `shiny.ui.nav()` is now deprecated in favor of the more aptly named `shiny.ui.nav_panel()` (#876). * Update penguins example to credit Allison Horst and drop usage of `shiny.experimental` (#798). * `as_fillable_container()` and `as_fill_item()` no longer mutate the `Tag` object that was passed in. Instead, it returns a new `Tag` object. Also closed #856: these functions now put the `html-fill-container` and `html-fill-item` CSS classes last, instead of first. (#862) diff --git a/docs/_quartodoc.yml b/docs/_quartodoc.yml index 5e70da411..08b9279af 100644 --- a/docs/_quartodoc.yml +++ b/docs/_quartodoc.yml @@ -26,7 +26,7 @@ quartodoc: - express.layout.accordion_panel - express.layout.navset - express.layout.navset_card - - express.layout.nav + - express.layout.nav_panel - express.layout.page_fluid - express.layout.page_fixed - express.layout.page_fillable @@ -87,10 +87,10 @@ quartodoc: - title: Navigation (tab) panels desc: Create segments of UI content. contents: - - ui.nav - - ui.nav_control + - ui.nav_panel - ui.nav_spacer - ui.nav_menu + - ui.nav_control - ui.navset_bar - ui.navset_tab - ui.navset_pill @@ -306,6 +306,7 @@ quartodoc: contents: - ui.panel_main - ui.panel_sidebar + - ui.nav - title: Experimental desc: "These methods are under consideration and are considered unstable. However, if there is a method you are excited about, please let us know!" contents: diff --git a/examples/event/app.py b/examples/event/app.py index 20adf5d25..31ee8eb26 100644 --- a/examples/event/app.py +++ b/examples/event/app.py @@ -12,12 +12,12 @@ """ ), ui.navset_card_tab( - ui.nav( + ui.nav_panel( "Sync", ui.input_action_button("btn", "Click me"), ui.output_ui("btn_value"), ), - ui.nav( + ui.nav_panel( "Async", ui.input_action_button("btn_async", "Click me"), ui.output_ui("btn_async_value"), diff --git a/examples/express/nav_app.py b/examples/express/nav_app.py index e42769167..d4f421ce8 100644 --- a/examples/express/nav_app.py +++ b/examples/express/nav_app.py @@ -6,10 +6,10 @@ with layout.layout_column_wrap(width=1 / 2): with layout.navset(): - with layout.nav(title="One"): + with layout.nav_panel(title="One"): ui.input_slider("n", "N", 1, 100, 50) - with layout.nav(title="Two"): + with layout.nav_panel(title="Two"): @render.plot def histogram(): @@ -18,10 +18,10 @@ def histogram(): plt.hist(x, input.n(), density=True) with layout.navset_card(): - with layout.nav(title="One"): + with layout.nav_panel(title="One"): ui.input_slider("n2", "N", 1, 100, 50) - with layout.nav(title="Two"): + with layout.nav_panel(title="Two"): @render.plot def histogram2(): diff --git a/examples/inputs-update/app.py b/examples/inputs-update/app.py index 133bdbfa9..be210a807 100644 --- a/examples/inputs-update/app.py +++ b/examples/inputs-update/app.py @@ -78,8 +78,8 @@ ), ), ui.navset_tab( - ui.nav("panel1", ui.h2("This is the first panel.")), - ui.nav("panel2", ui.h2("This is the second panel.")), + ui.nav_panel("panel1", ui.h2("This is the first panel.")), + ui.nav_panel("panel2", ui.h2("This is the second panel.")), id="inTabset", ), ), diff --git a/examples/static_plots/app.py b/examples/static_plots/app.py index 043126331..cc99f20c0 100644 --- a/examples/static_plots/app.py +++ b/examples/static_plots/app.py @@ -8,7 +8,7 @@ nav = ui.navset_pill_list( ui.nav_control(ui.p("Choose a package", class_="lead text-center")), - ui.nav( + ui.nav_panel( "Plotnine", ui.output_plot("plotnine"), ui.div( @@ -27,7 +27,7 @@ ), ), ), - ui.nav( + ui.nav_panel( "Seaborn", ui.output_plot("seaborn"), ui.div( @@ -36,11 +36,11 @@ ui.input_slider("cov", "Co-variance", min=0, max=1, value=0.4), ), ), - ui.nav("Pandas", ui.output_plot("pandas")), - ui.nav("Holoviews", ui.output_plot("holoviews", height="600px")), - ui.nav("xarray", ui.output_plot("xarray")), - ui.nav("geopandas", ui.output_plot("geopandas")), - ui.nav("missingno", ui.output_plot("missingno")), + ui.nav_panel("Pandas", ui.output_plot("pandas")), + ui.nav_panel("Holoviews", ui.output_plot("holoviews", height="600px")), + ui.nav_panel("xarray", ui.output_plot("xarray")), + ui.nav_panel("geopandas", ui.output_plot("geopandas")), + ui.nav_panel("missingno", ui.output_plot("missingno")), widths=(2, 10), well=False, ) diff --git a/shiny/api-examples/nav/app.py b/shiny/api-examples/nav/app.py index 48ed374fd..269c6a18e 100644 --- a/shiny/api-examples/nav/app.py +++ b/shiny/api-examples/nav/app.py @@ -6,9 +6,9 @@ def nav_controls(prefix: str) -> List[NavSetArg]: return [ - ui.nav("a", prefix + ": tab a content"), - ui.nav("b", prefix + ": tab b content"), - ui.nav("c", prefix + ": tab c content"), + ui.nav_panel("a", prefix + ": tab a content"), + ui.nav_panel("b", prefix + ": tab b content"), + ui.nav_panel("c", prefix + ": tab c content"), ui.nav_spacer(), ui.nav_menu( "Links", diff --git a/shiny/api-examples/navset_hidden/app.py b/shiny/api-examples/navset_hidden/app.py index 09ff8d859..014869a97 100644 --- a/shiny/api-examples/navset_hidden/app.py +++ b/shiny/api-examples/navset_hidden/app.py @@ -9,9 +9,9 @@ ), ui.panel_main( ui.navset_hidden( - ui.nav(None, "Panel 1 content", value="panel1"), - ui.nav(None, "Panel 2 content", value="panel2"), - ui.nav(None, "Panel 3 content", value="panel3"), + ui.nav_panel(None, "Panel 1 content", value="panel1"), + ui.nav_panel(None, "Panel 2 content", value="panel2"), + ui.nav_panel(None, "Panel 3 content", value="panel3"), id="hidden_tabs", ), ), diff --git a/shiny/api-examples/update_navs/app.py b/shiny/api-examples/update_navs/app.py index e319eba51..6a8e392a9 100644 --- a/shiny/api-examples/update_navs/app.py +++ b/shiny/api-examples/update_navs/app.py @@ -7,9 +7,9 @@ ), ui.panel_main( ui.navset_card_tab( - ui.nav("Panel 1", "Panel 1 content", value="panel1"), - ui.nav("Panel 2", "Panel 2 content", value="panel2"), - ui.nav("Panel 3", "Panel 3 content", value="panel3"), + ui.nav_panel("Panel 1", "Panel 1 content", value="panel1"), + ui.nav_panel("Panel 2", "Panel 2 content", value="panel2"), + ui.nav_panel("Panel 3", "Panel 3 content", value="panel3"), id="inTabset", ), ), diff --git a/shiny/express/layout.py b/shiny/express/layout.py index 2a88f1c50..8c78d8ef0 100644 --- a/shiny/express/layout.py +++ b/shiny/express/layout.py @@ -28,7 +28,7 @@ "accordion_panel", "navset", "navset_card", - "nav", + "nav_panel", "page_fluid", "page_fixed", "page_fillable", @@ -670,7 +670,7 @@ def navset_card( ) -def nav( +def nav_panel( title: TagChild, *, value: Optional[str] = None, @@ -695,7 +695,7 @@ def nav( An icon to appear inline with the button/link. """ return RecallContextManager( - ui.nav, + ui.nav_panel, args=(title,), kwargs=dict( value=value, diff --git a/shiny/templates/app-templates/multi-page/modules.py b/shiny/templates/app-templates/multi-page/modules.py index 0a3532862..3b9081bc3 100644 --- a/shiny/templates/app-templates/multi-page/modules.py +++ b/shiny/templates/app-templates/multi-page/modules.py @@ -8,7 +8,7 @@ @module.ui def training_ui(): - return ui.nav( + return ui.nav_panel( "Training Dashboard", ui.layout_columns( ui.card( @@ -49,7 +49,7 @@ def metric(): @module.ui def data_view_ui(): - return ui.nav( + return ui.nav_panel( "View Data", ui.layout_columns( ui.value_box( diff --git a/shiny/ui/__init__.py b/shiny/ui/__init__.py index 1d2596a8a..39a9f4832 100644 --- a/shiny/ui/__init__.py +++ b/shiny/ui/__init__.py @@ -87,7 +87,7 @@ from ._markdown import markdown from ._modal import modal_button, modal, modal_show, modal_remove from ._navs import ( - nav, + nav_panel, nav_menu, nav_control, nav_spacer, @@ -103,6 +103,7 @@ # Deprecated navset_pill_card, navset_tab_card, + nav, ) from ._notification import notification_show, notification_remove from ._output import ( @@ -269,7 +270,7 @@ "modal_show", "modal_remove", # _navs - "nav", + "nav_panel", "nav_menu", "nav_control", "nav_spacer", @@ -285,6 +286,7 @@ # # Deprecated "navset_pill_card", "navset_tab_card", + "nav", # _notification "notification_show", "notification_remove", diff --git a/shiny/ui/_navs.py b/shiny/ui/_navs.py index 35efadb76..7a16b2823 100644 --- a/shiny/ui/_navs.py +++ b/shiny/ui/_navs.py @@ -1,7 +1,7 @@ from __future__ import annotations __all__ = ( - "nav", + "nav_panel", "nav_menu", "nav_control", "nav_spacer", @@ -17,6 +17,7 @@ # Deprecated - 2023-08-15 "navset_pill_card", "navset_tab_card", + "nav", ) import copy @@ -41,7 +42,7 @@ # ----------------------------------------------------------------------------- # Navigation items # ----------------------------------------------------------------------------- -class Nav: +class NavPanel: nav: Tag content: Optional[Tag] @@ -97,12 +98,12 @@ def tagify(self) -> None: @add_example() -def nav( +def nav_panel( title: TagChild, *args: TagChild, value: Optional[str] = None, icon: TagChild = None, -) -> Nav: +) -> NavPanel: """ Create a nav item pointing to some internal content. @@ -150,13 +151,13 @@ def nav( role="tab", ) - return Nav( + return NavPanel( tags.li(link), div(*args, class_="tab-pane", role="tabpanel", data_value=value), ) -def nav_control(*args: TagChild) -> Nav: +def nav_control(*args: TagChild) -> NavPanel: """ Place a control in the navigation container. @@ -167,7 +168,7 @@ def nav_control(*args: TagChild) -> Nav: See Also -------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_spacer * ~shiny.ui.navset_bar @@ -182,18 +183,18 @@ def nav_control(*args: TagChild) -> Nav: Example ------- - See :func:`~shiny.ui.nav` + See :func:`~shiny.ui.nav_panel` """ - return Nav(tags.li(*args)) + return NavPanel(tags.li(*args)) -def nav_spacer() -> Nav: +def nav_spacer() -> NavPanel: """ Create space between nav items. See Also -------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_control * ~shiny.ui.navset_bar @@ -208,10 +209,10 @@ def nav_spacer() -> Nav: Example ------- - See :func:`~shiny.ui.nav` + See :func:`~shiny.ui.nav_panel` """ - return Nav(tags.li(components_dependency(), class_="bslib-nav-spacer")) + return NavPanel(tags.li(components_dependency(), class_="bslib-nav-spacer")) class NavMenu: @@ -290,12 +291,12 @@ def menu_string_as_nav(x: str | NavSetArg) -> NavSetArg: else: nav = tags.li(x, class_="dropdown-header") - return Nav(nav) + return NavPanel(nav) def nav_menu( title: TagChild, - *args: Nav | str, + *args: NavPanel | str, value: Optional[str] = None, icon: TagChild = None, align: Literal["left", "right"] = "left", @@ -308,7 +309,7 @@ def nav_menu( title A title to display. Can be a character string or UI elements (i.e., tags). *args - A collection of nav items (e.g., :func:`~shiny.ui.nav`) and/or strings. + A collection of nav items (e.g., :func:`~shiny.ui.nav_panel`) and/or strings. Strings will be rendered as a section header unless the string is a set of two or more hyphens (e.g., ``---``), in which case it will be rendered as a divider. @@ -330,7 +331,7 @@ def nav_menu( See Also ------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_control * ~shiny.ui.nav_spacer * ~shiny.ui.navset_bar @@ -345,7 +346,7 @@ def nav_menu( Example ------- - See :func:`~shiny.ui.nav` + See :func:`~shiny.ui.nav_panel` """ if value is None: value = str(title) @@ -413,7 +414,7 @@ def navset_tab( Parameters ---------- *args - A collection of nav items (e.g., :func:`shiny.ui.nav`). + A collection of nav items (e.g., :func:`shiny.ui.nav_panel`). id If provided, will create an input value that holds the currently selected nav item. @@ -428,7 +429,7 @@ def navset_tab( See Also -------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_control * ~shiny.ui.nav_spacer @@ -443,7 +444,7 @@ def navset_tab( Example ------- - See :func:`~shiny.ui.nav` + See :func:`~shiny.ui.nav_panel` """ return NavSet( @@ -469,7 +470,7 @@ def navset_pill( Parameters ---------- *args - A collection of nav items (e.g., :func:`shiny.ui.nav`). + A collection of nav items (e.g., :func:`shiny.ui.nav_panel`). id If provided, will create an input value that holds the currently selected nav item. @@ -483,7 +484,7 @@ def navset_pill( See Also -------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_control * ~shiny.ui.nav_spacer @@ -498,7 +499,7 @@ def navset_pill( Example ------- - See :func:`~shiny.ui.nav` + See :func:`~shiny.ui.nav_panel` """ return NavSet( @@ -524,7 +525,7 @@ def navset_underline( Parameters ---------- *args - A collection of nav items (e.g., :func:`shiny.ui.nav`). + A collection of nav items (e.g., :func:`shiny.ui.nav_panel`). id If provided, will create an input value that holds the currently selected nav item. @@ -538,7 +539,7 @@ def navset_underline( See Also -------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_control * ~shiny.ui.nav_spacer @@ -553,7 +554,7 @@ def navset_underline( Example ------- - See :func:`~shiny.ui.nav` + See :func:`~shiny.ui.nav_panel` """ return NavSet( *args, @@ -579,7 +580,7 @@ def navset_hidden( Parameters ---------- *args - A collection of nav items (e.g., :func:`shiny.ui.nav`). + A collection of nav items (e.g., :func:`shiny.ui.nav_panel`). id If provided, will create an input value that holds the currently selected nav item. @@ -593,7 +594,7 @@ def navset_hidden( See Also -------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_control * ~shiny.ui.nav_spacer @@ -692,7 +693,7 @@ def navset_card_tab( Parameters ---------- *args - A collection of nav items (e.g., :func:`shiny.ui.nav`). + A collection of nav items (e.g., :func:`shiny.ui.nav_panel`). id If provided, will create an input value that holds the currently selected nav item. @@ -725,7 +726,7 @@ def navset_card_tab( See Also -------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_control * ~shiny.ui.nav_spacer @@ -740,7 +741,7 @@ def navset_card_tab( Example ------- - See :func:`~shiny.ui.nav` + See :func:`~shiny.ui.nav_panel` """ return NavSetCard( @@ -772,7 +773,7 @@ def navset_card_pill( Parameters ---------- *args - A collection of nav items (e.g., :func:`shiny.ui.nav`). + A collection of nav items (e.g., :func:`shiny.ui.nav_panel`). id If provided, will create an input value that holds the currently selected nav item. @@ -780,7 +781,7 @@ def navset_card_pill( Choose a particular nav item to select by default value (should match it's ``value``). sidebar - A :class:`shiny.ui.Sidebar` component to display on every :func:`~shiny.ui.nav` page. + A :class:`shiny.ui.Sidebar` component to display on every :func:`~shiny.ui.nav_panel` page. header UI to display above the selected content. footer @@ -790,7 +791,7 @@ def navset_card_pill( See Also -------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_control * ~shiny.ui.nav_spacer @@ -805,7 +806,7 @@ def navset_card_pill( Example ------- - See :func:`~shiny.ui.nav` + See :func:`~shiny.ui.nav_panel` """ return NavSetCard( @@ -837,7 +838,7 @@ def navset_card_underline( Parameters ---------- *args - A collection of nav items (e.g., :func:`shiny.ui.nav`). + A collection of nav items (e.g., :func:`shiny.ui.nav_panel`). id If provided, will create an input value that holds the currently selected nav item. @@ -845,7 +846,7 @@ def navset_card_underline( Choose a particular nav item to select by default value (should match it's ``value``). sidebar - A :class:`shiny.ui.Sidebar` component to display on every :func:`~shiny.ui.nav` page. + A :class:`shiny.ui.Sidebar` component to display on every :func:`~shiny.ui.nav_panel` page. header UI to display above the selected content. footer @@ -855,7 +856,7 @@ def navset_card_underline( See Also -------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_control * ~shiny.ui.nav_spacer @@ -870,7 +871,7 @@ def navset_card_underline( Example ------- - See :func:`~shiny.ui.nav` + See :func:`~shiny.ui.nav_panel` """ return NavSetCard( *args, @@ -934,7 +935,7 @@ def navset_pill_list( Parameters ---------- *args - A collection of nav items (e.g., :func:`shiny.ui.nav`). + A collection of nav items (e.g., :func:`shiny.ui.nav_panel`). id If provided, will create an input value that holds the currently selected nav item. @@ -952,7 +953,7 @@ def navset_pill_list( See Also -------- - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_control * ~shiny.ui.nav_spacer @@ -967,7 +968,7 @@ def navset_pill_list( Example ------- - See :func:`~shiny.ui.nav` + See :func:`~shiny.ui.nav_panel` """ return NavSetPillList( @@ -1181,7 +1182,7 @@ def navset_bar( Parameters ---------- *args - A collection of nav items (e.g., :func:`shiny.ui.nav`). + A collection of nav items (e.g., :func:`shiny.ui.nav_panel`). title Title to display in the navbar. id @@ -1191,7 +1192,7 @@ def navset_bar( Choose a particular nav item to select by default value (should match it's ``value``). sidebar - A :class:`~shiny.ui.Sidebar` component to display on every :func:`~shiny.ui.nav` page. + A :class:`~shiny.ui.Sidebar` component to display on every :func:`~shiny.ui.nav_panel` page. fillable Whether or not to allow fill items to grow/shrink to fit the browser window. If `True`, all `nav()` pages are fillable. A character vector, matching the value @@ -1231,7 +1232,7 @@ def navset_bar( See Also -------- * ~shiny.ui.page_navbar - * ~shiny.ui.nav + * ~shiny.ui.nav_panel * ~shiny.ui.nav_menu * ~shiny.ui.nav_control * ~shiny.ui.nav_spacer @@ -1246,7 +1247,7 @@ def navset_bar( Example ------- - See :func:`~shiny.ui.nav`. + See :func:`~shiny.ui.nav_panel`. """ # If args contains any lists, flatten them into args. @@ -1395,3 +1396,24 @@ def navset_tab_card( header=header, footer=footer, ) + + +# Deprecated 2023-12-07 +def nav( + title: TagChild, + *args: TagChild, + value: Optional[str] = None, + icon: TagChild = None, +) -> NavPanel: + """Deprecated. Please use `nav_panel()` instead of `nav()`.""" + warn_deprecated( + "`nav()` is deprecated. " + "This method will be removed in a future version, " + "please use :func:`~shiny.ui.nav_panel` instead." + ) + return nav_panel( + title, + *args, + value=value, + icon=icon, + ) diff --git a/tests/playwright/shiny/TODO/navbar/app.py b/tests/playwright/shiny/TODO/navbar/app.py index e380cb70d..d1a750dbc 100644 --- a/tests/playwright/shiny/TODO/navbar/app.py +++ b/tests/playwright/shiny/TODO/navbar/app.py @@ -6,8 +6,8 @@ my_sidebar = ui.sidebar("Sidebar content", open="open", title="Sidebar title") -def nav_with_content(letter: str, prefix: str) -> ui._navs.Nav: - return ui.nav(letter, ui.markdown(f"`{prefix}`: tab {letter} content")) +def nav_with_content(letter: str, prefix: str) -> ui._navs.NavPanel: + return ui.nav_panel(letter, ui.markdown(f"`{prefix}`: tab {letter} content")) def nav_items(prefix: str) -> list[NavSetArg]: diff --git a/tests/playwright/shiny/bugs/0696-resolve-id/app.py b/tests/playwright/shiny/bugs/0696-resolve-id/app.py index 0365ae5b7..d1117b688 100644 --- a/tests/playwright/shiny/bugs/0696-resolve-id/app.py +++ b/tests/playwright/shiny/bugs/0696-resolve-id/app.py @@ -74,9 +74,9 @@ # ============================================================ @module.ui def mod_x_ui(label: str) -> ui.TagChild: - def ui_navs(label: str) -> list[ui._navs.Nav]: + def ui_navs(label: str) -> list[ui._navs.NavPanel]: return [ - ui.nav( + ui.nav_panel( letter.capitalize(), f"{label} - {letter.capitalize()} content", value=letter, diff --git a/tests/playwright/shiny/components/nav/app.py b/tests/playwright/shiny/components/nav/app.py index d71038cc2..57279c44c 100644 --- a/tests/playwright/shiny/components/nav/app.py +++ b/tests/playwright/shiny/components/nav/app.py @@ -16,9 +16,9 @@ def nav_controls(prefix: str) -> List[NavSetArg]: return [ - ui.nav("a", prefix + ": tab a content"), - ui.nav("b", prefix + ": tab b content"), - ui.nav("c", prefix + ": tab c content"), + ui.nav_panel("a", prefix + ": tab a content"), + ui.nav_panel("b", prefix + ": tab b content"), + ui.nav_panel("c", prefix + ": tab c content"), ui.nav_spacer(), ui.nav_menu( "Links", diff --git a/tests/playwright/shiny/components/navset_hidden/app.py b/tests/playwright/shiny/components/navset_hidden/app.py index 82771e41e..35462dcc9 100644 --- a/tests/playwright/shiny/components/navset_hidden/app.py +++ b/tests/playwright/shiny/components/navset_hidden/app.py @@ -9,9 +9,9 @@ ), ui.panel_main( ui.navset_hidden( - ui.nav(None, "Panel 1 content", value="panel1"), - ui.nav(None, "Panel 2 content", value="panel2"), - ui.nav(None, "Panel 3 content", value="panel3"), + ui.nav_panel(None, "Panel 1 content", value="panel1"), + ui.nav_panel(None, "Panel 2 content", value="panel2"), + ui.nav_panel(None, "Panel 3 content", value="panel3"), id="hidden_tabs", ), ), diff --git a/tests/playwright/shiny/plot-sizing/app.py b/tests/playwright/shiny/plot-sizing/app.py index f090980e7..646fe7fe4 100644 --- a/tests/playwright/shiny/plot-sizing/app.py +++ b/tests/playwright/shiny/plot-sizing/app.py @@ -61,7 +61,7 @@ def plot_native_size(): app_ui = ui.page_navbar( - ui.nav( + ui.nav_panel( "matplotlib", ui.p( "The following four plots should all be the same size. The last one should have larger text." @@ -69,7 +69,7 @@ def plot_native_size(): plot_ui("mpl"), value="mpl", ), - ui.nav( + ui.nav_panel( "seaborn", ui.p( "The following four plots should all be the same size. The last one should have larger text." @@ -77,14 +77,14 @@ def plot_native_size(): plot_ui("sns"), value="sns", ), - ui.nav( + ui.nav_panel( "plotnine", ui.p( "The following four plots should all be the same size. The last one should have larger text." ), plot_ui("plotnine"), ), - ui.nav( + ui.nav_panel( "pil", ui.p("The following three images should all be the same size."), plot_ui("pil"), diff --git a/tests/playwright/shiny/shiny-express/page_default/app.py b/tests/playwright/shiny/shiny-express/page_default/app.py index 3ee2c02c3..6318139ef 100644 --- a/tests/playwright/shiny/shiny-express/page_default/app.py +++ b/tests/playwright/shiny/shiny-express/page_default/app.py @@ -29,7 +29,7 @@ with layout.column(width=6): # check height is below 300px - bounding box with layout.navset_card(id="express_navset_card_tab", type="tab"): - with layout.nav(title="Two"): + with layout.nav_panel(title="Two"): ... @@ -41,7 +41,7 @@ ("div", layout.div), ("span", layout.span), ]: - with layout.nav(title=fn_txt): + with layout.nav_panel(title=fn_txt): for i in range(3): with fn(): ui.HTML(f"{fn_txt} {i}") diff --git a/tests/pytest/test_navs.py b/tests/pytest/test_navs.py index 4b35769f7..d298a0b1a 100644 --- a/tests/pytest/test_navs.py +++ b/tests/pytest/test_navs.py @@ -21,9 +21,9 @@ def private_seed_n(n: int = 0) -> Generator[None, None, None]: def test_nav_markup(): - a = ui.nav("a", "a") - b = ui.nav("b", "b") - c = ui.nav("c", "c") + a = ui.nav_panel("a", "a") + b = ui.nav_panel("b", "b") + c = ui.nav_panel("c", "c") menu = ui.nav_menu( "Menu", c,