From 55560b3b38ca543548a8343f8f17a7b850ff2732 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Mon, 29 Jul 2024 13:50:45 +0530 Subject: [PATCH 1/6] Add examples for both core and express navset documentation --- shiny/api-examples/navset_bar/app-core.py | 27 +++++++++++++++++++ shiny/api-examples/navset_bar/app-express.py | 20 ++++++++++++++ .../api-examples/navset_card_pill/app-core.py | 26 ++++++++++++++++++ .../navset_card_pill/app-express.py | 20 ++++++++++++++ .../api-examples/navset_card_tab/app-core.py | 26 ++++++++++++++++++ .../navset_card_tab/app-express.py | 20 ++++++++++++++ .../navset_card_underline/app-core.py | 26 ++++++++++++++++++ .../navset_card_underline/app-express.py | 20 ++++++++++++++ shiny/api-examples/navset_pill/app-core.py | 26 ++++++++++++++++++ shiny/api-examples/navset_pill/app-express.py | 20 ++++++++++++++ .../api-examples/navset_pill_list/app-core.py | 26 ++++++++++++++++++ .../navset_pill_list/app-express.py | 20 ++++++++++++++ shiny/api-examples/navset_tab/app-core.py | 26 ++++++++++++++++++ shiny/api-examples/navset_tab/app-express.py | 20 ++++++++++++++ .../api-examples/navset_underline/app-core.py | 26 ++++++++++++++++++ .../navset_underline/app-express.py | 20 ++++++++++++++ shiny/express/ui/_cm_components.py | 16 +++++------ shiny/ui/_navs.py | 16 +++++------ 18 files changed, 385 insertions(+), 16 deletions(-) create mode 100644 shiny/api-examples/navset_bar/app-core.py create mode 100644 shiny/api-examples/navset_bar/app-express.py create mode 100644 shiny/api-examples/navset_card_pill/app-core.py create mode 100644 shiny/api-examples/navset_card_pill/app-express.py create mode 100644 shiny/api-examples/navset_card_tab/app-core.py create mode 100644 shiny/api-examples/navset_card_tab/app-express.py create mode 100644 shiny/api-examples/navset_card_underline/app-core.py create mode 100644 shiny/api-examples/navset_card_underline/app-express.py create mode 100644 shiny/api-examples/navset_pill/app-core.py create mode 100644 shiny/api-examples/navset_pill/app-express.py create mode 100644 shiny/api-examples/navset_pill_list/app-core.py create mode 100644 shiny/api-examples/navset_pill_list/app-express.py create mode 100644 shiny/api-examples/navset_tab/app-core.py create mode 100644 shiny/api-examples/navset_tab/app-express.py create mode 100644 shiny/api-examples/navset_underline/app-core.py create mode 100644 shiny/api-examples/navset_underline/app-express.py diff --git a/shiny/api-examples/navset_bar/app-core.py b/shiny/api-examples/navset_bar/app-core.py new file mode 100644 index 000000000..fbfd47e75 --- /dev/null +++ b/shiny/api-examples/navset_bar/app-core.py @@ -0,0 +1,27 @@ +from shiny import App, 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="tab", + title="Navset Bar", + ) +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/navset_bar/app-express.py b/shiny/api-examples/navset_bar/app-express.py new file mode 100644 index 000000000..bf76d5d70 --- /dev/null +++ b/shiny/api-examples/navset_bar/app-express.py @@ -0,0 +1,20 @@ +from shiny.express import ui + +with ui.navset_bar(id="tab"): + 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") diff --git a/shiny/api-examples/navset_card_pill/app-core.py b/shiny/api-examples/navset_card_pill/app-core.py new file mode 100644 index 000000000..b88bb0197 --- /dev/null +++ b/shiny/api-examples/navset_card_pill/app-core.py @@ -0,0 +1,26 @@ +from shiny import App, ui + +app_ui = ui.page_fluid( + ui.navset_card_pill( + 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="tab", + ) +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/navset_card_pill/app-express.py b/shiny/api-examples/navset_card_pill/app-express.py new file mode 100644 index 000000000..d934b5cbe --- /dev/null +++ b/shiny/api-examples/navset_card_pill/app-express.py @@ -0,0 +1,20 @@ +from shiny.express import ui + +with ui.navset_card_pill(id="tab"): + 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") diff --git a/shiny/api-examples/navset_card_tab/app-core.py b/shiny/api-examples/navset_card_tab/app-core.py new file mode 100644 index 000000000..d314ddb35 --- /dev/null +++ b/shiny/api-examples/navset_card_tab/app-core.py @@ -0,0 +1,26 @@ +from shiny import App, ui + +app_ui = ui.page_fluid( + ui.navset_card_tab( + 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="tab", + ) +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/navset_card_tab/app-express.py b/shiny/api-examples/navset_card_tab/app-express.py new file mode 100644 index 000000000..97c3f0570 --- /dev/null +++ b/shiny/api-examples/navset_card_tab/app-express.py @@ -0,0 +1,20 @@ +from shiny.express import ui + +with ui.navset_card_tab(id="tab"): + 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") diff --git a/shiny/api-examples/navset_card_underline/app-core.py b/shiny/api-examples/navset_card_underline/app-core.py new file mode 100644 index 000000000..40996cb64 --- /dev/null +++ b/shiny/api-examples/navset_card_underline/app-core.py @@ -0,0 +1,26 @@ +from shiny import App, ui + +app_ui = ui.page_fluid( + ui.navset_card_underline( + 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="tab", + ) +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/navset_card_underline/app-express.py b/shiny/api-examples/navset_card_underline/app-express.py new file mode 100644 index 000000000..467acc081 --- /dev/null +++ b/shiny/api-examples/navset_card_underline/app-express.py @@ -0,0 +1,20 @@ +from shiny.express import ui + +with ui.navset_card_underline(id="tab"): + 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") diff --git a/shiny/api-examples/navset_pill/app-core.py b/shiny/api-examples/navset_pill/app-core.py new file mode 100644 index 000000000..4be31b113 --- /dev/null +++ b/shiny/api-examples/navset_pill/app-core.py @@ -0,0 +1,26 @@ +from shiny import App, ui + +app_ui = ui.page_fluid( + ui.navset_pill( + 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="tab", + ) +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/navset_pill/app-express.py b/shiny/api-examples/navset_pill/app-express.py new file mode 100644 index 000000000..b367d5072 --- /dev/null +++ b/shiny/api-examples/navset_pill/app-express.py @@ -0,0 +1,20 @@ +from shiny.express import ui + +with ui.navset_pill(id="tab"): + 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") diff --git a/shiny/api-examples/navset_pill_list/app-core.py b/shiny/api-examples/navset_pill_list/app-core.py new file mode 100644 index 000000000..f67349883 --- /dev/null +++ b/shiny/api-examples/navset_pill_list/app-core.py @@ -0,0 +1,26 @@ +from shiny import App, ui + +app_ui = ui.page_fluid( + ui.navset_pill_list( + 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="tab", + ) +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/navset_pill_list/app-express.py b/shiny/api-examples/navset_pill_list/app-express.py new file mode 100644 index 000000000..38b961593 --- /dev/null +++ b/shiny/api-examples/navset_pill_list/app-express.py @@ -0,0 +1,20 @@ +from shiny.express import ui + +with ui.navset_pill_list(id="tab"): + 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") diff --git a/shiny/api-examples/navset_tab/app-core.py b/shiny/api-examples/navset_tab/app-core.py new file mode 100644 index 000000000..bbabfb320 --- /dev/null +++ b/shiny/api-examples/navset_tab/app-core.py @@ -0,0 +1,26 @@ +from shiny import App, ui + +app_ui = ui.page_fluid( + ui.navset_tab( + 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="tab", + ) +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/navset_tab/app-express.py b/shiny/api-examples/navset_tab/app-express.py new file mode 100644 index 000000000..1b49ce692 --- /dev/null +++ b/shiny/api-examples/navset_tab/app-express.py @@ -0,0 +1,20 @@ +from shiny.express import ui + +with ui.navset_tab(id="tab"): + 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") diff --git a/shiny/api-examples/navset_underline/app-core.py b/shiny/api-examples/navset_underline/app-core.py new file mode 100644 index 000000000..06f67de4b --- /dev/null +++ b/shiny/api-examples/navset_underline/app-core.py @@ -0,0 +1,26 @@ +from shiny import App, ui + +app_ui = ui.page_fluid( + ui.navset_underline( + 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="tab", + ) +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/navset_underline/app-express.py b/shiny/api-examples/navset_underline/app-express.py new file mode 100644 index 000000000..0868fc6e6 --- /dev/null +++ b/shiny/api-examples/navset_underline/app-express.py @@ -0,0 +1,20 @@ +from shiny.express import ui + +with ui.navset_underline(id="tab"): + 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") diff --git a/shiny/express/ui/_cm_components.py b/shiny/express/ui/_cm_components.py index c8b915ddc..bf0fb2c2e 100644 --- a/shiny/express/ui/_cm_components.py +++ b/shiny/express/ui/_cm_components.py @@ -726,7 +726,7 @@ def accordion_panel( # ====================================================================================== -@no_example() +@add_example() def navset_tab( *, id: Optional[str] = None, @@ -763,7 +763,7 @@ def navset_tab( ) -@no_example() +@add_example() def navset_pill( *, id: Optional[str] = None, @@ -800,7 +800,7 @@ def navset_pill( ) -@no_example() +@add_example() def navset_underline( *, id: Optional[str] = None, @@ -875,7 +875,7 @@ def navset_hidden( ) -@no_example() +@add_example() def navset_card_tab( *, id: Optional[str] = None, @@ -918,7 +918,7 @@ def navset_card_tab( ) -@no_example() +@add_example() def navset_card_pill( *, id: Optional[str] = None, @@ -961,7 +961,7 @@ def navset_card_pill( ) -@no_example() +@add_example() def navset_card_underline( *, id: Optional[str] = None, @@ -1008,7 +1008,7 @@ def navset_card_underline( ) -@no_example() +@add_example() def navset_pill_list( *, id: Optional[str] = None, @@ -1053,7 +1053,7 @@ def navset_pill_list( ) -@no_example() +@add_example() def navset_bar( *, title: TagChild, diff --git a/shiny/ui/_navs.py b/shiny/ui/_navs.py index 41cf1b492..e026186d9 100644 --- a/shiny/ui/_navs.py +++ b/shiny/ui/_navs.py @@ -400,7 +400,7 @@ def layout(self, nav: Tag, content: Tag) -> TagList | Tag: # ----------------------------------------------------------------------------- # Navigation containers # ----------------------------------------------------------------------------- -@no_example() +@add_example() def navset_tab( *args: NavSetArg | MetadataNode | Sequence[MetadataNode], id: Optional[str] = None, @@ -457,7 +457,7 @@ def navset_tab( ) -@no_example() +@add_example() def navset_pill( *args: NavSetArg | MetadataNode | Sequence[MetadataNode], id: Optional[str] = None, @@ -513,7 +513,7 @@ def navset_pill( ) -@no_example() +@add_example() def navset_underline( *args: NavSetArg | MetadataNode | Sequence[MetadataNode], id: Optional[str] = None, @@ -680,7 +680,7 @@ def layout(self, nav: Tag, content: Tag) -> Tag: ) -@no_example() +@add_example() def navset_card_tab( *args: NavSetArg | MetadataNode | Sequence[MetadataNode], id: Optional[str] = None, @@ -743,7 +743,7 @@ def navset_card_tab( ) -@no_example() +@add_example() def navset_card_pill( *args: NavSetArg | MetadataNode | Sequence[MetadataNode], id: Optional[str] = None, @@ -809,7 +809,7 @@ def navset_card_pill( ) -@no_example() +@add_example() def navset_card_underline( *args: NavSetArg | MetadataNode | Sequence[MetadataNode], id: Optional[str] = None, @@ -908,7 +908,7 @@ def layout(self, nav: TagChild, content: TagChild) -> Tag: ) -@no_example() +@add_example() def navset_pill_list( *args: NavSetArg | MetadataNode | Sequence[MetadataNode], id: Optional[str] = None, @@ -1154,7 +1154,7 @@ def _make_tabs_fillable( # TODO-future; Content should not be indented unless when called from `page_navbar()` -@no_example() +@add_example() def navset_bar( *args: NavSetArg | MetadataNode | Sequence[MetadataNode], title: TagChild, From 260ea77ac3f3265956304f939ad331db4fe872fc Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Mon, 29 Jul 2024 14:13:38 +0530 Subject: [PATCH 2/6] add nav_menu examples --- shiny/api-examples/nav_menu/app-core.py | 20 ++++++++++++++++++++ shiny/api-examples/nav_menu/app-express.py | 11 +++++++++++ shiny/express/ui/_cm_components.py | 2 +- shiny/ui/_navs.py | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 shiny/api-examples/nav_menu/app-core.py create mode 100644 shiny/api-examples/nav_menu/app-express.py diff --git a/shiny/api-examples/nav_menu/app-core.py b/shiny/api-examples/nav_menu/app-core.py new file mode 100644 index 000000000..3b96625e7 --- /dev/null +++ b/shiny/api-examples/nav_menu/app-core.py @@ -0,0 +1,20 @@ +from shiny import App, ui + +app_ui = ui.page_fluid( + ui.navset_card_pill( + ui.nav_menu( + "Nav Menu items", + ui.nav_panel("A", "Panel A content"), + ui.nav_panel("B", "Panel B content"), + ui.nav_panel("C", "Panel C content"), + ), + id="card_pill", + ), +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/nav_menu/app-express.py b/shiny/api-examples/nav_menu/app-express.py new file mode 100644 index 000000000..ca3137465 --- /dev/null +++ b/shiny/api-examples/nav_menu/app-express.py @@ -0,0 +1,11 @@ +from shiny.express import ui + +with ui.navset_card_pill(id="card_pill"): + with ui.nav_menu("Nav Menu items"): + with ui.nav_panel("A"): + "Page A content" + with ui.nav_panel("B"): + "Page B content" + with ui.nav_panel("C"): + "Page C content" + diff --git a/shiny/express/ui/_cm_components.py b/shiny/express/ui/_cm_components.py index bf0fb2c2e..b737847f0 100644 --- a/shiny/express/ui/_cm_components.py +++ b/shiny/express/ui/_cm_components.py @@ -1197,7 +1197,7 @@ def nav_control() -> RecallContextManager[NavPanel]: return RecallContextManager(ui.nav_control) -@no_example() +@add_example() def nav_menu( title: TagChild, *, diff --git a/shiny/ui/_navs.py b/shiny/ui/_navs.py index e026186d9..10309da8b 100644 --- a/shiny/ui/_navs.py +++ b/shiny/ui/_navs.py @@ -292,7 +292,7 @@ def menu_string_as_nav(x: str | NavSetArg) -> NavSetArg: return NavPanel(nav) -@no_example() +@add_example() def nav_menu( title: TagChild, *args: NavPanel | str, From 801682a180fae51ebb25380df8f2f42fbd14124d Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Mon, 29 Jul 2024 14:23:20 +0530 Subject: [PATCH 3/6] add nav_control example --- shiny/api-examples/nav_control/app-core.py | 22 +++++++++++++++++++ shiny/api-examples/nav_control/app-express.py | 12 ++++++++++ shiny/api-examples/nav_menu/app-express.py | 1 - shiny/express/ui/_cm_components.py | 2 +- shiny/ui/_navs.py | 2 +- 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 shiny/api-examples/nav_control/app-core.py create mode 100644 shiny/api-examples/nav_control/app-express.py diff --git a/shiny/api-examples/nav_control/app-core.py b/shiny/api-examples/nav_control/app-core.py new file mode 100644 index 000000000..84dbb3a53 --- /dev/null +++ b/shiny/api-examples/nav_control/app-core.py @@ -0,0 +1,22 @@ +from shiny import App, ui + +app_ui = ui.page_fluid( + ui.navset_card_underline( + ui.nav_control(ui.a("Shiny", href="https://shiny.posit.co", target="_blank")), + ui.nav_control( + ui.a( + "Learn Shiny", + href="https://shiny.posit.co/py/docs/overview.html", + target="_blank", + ) + ), + ), + id="tab", +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/nav_control/app-express.py b/shiny/api-examples/nav_control/app-express.py new file mode 100644 index 000000000..ed1ed38e3 --- /dev/null +++ b/shiny/api-examples/nav_control/app-express.py @@ -0,0 +1,12 @@ +from shiny.express import ui + +with ui.navset_card_underline(id="tab"): + with ui.nav_control(): + ui.a("Shiny", href="https://shiny.posit.co", target="_blank") + + with ui.nav_control(): + ui.a( + "Learn Shiny", + href="https://shiny.posit.co/py/docs/overview.html", + target="_blank", + ) diff --git a/shiny/api-examples/nav_menu/app-express.py b/shiny/api-examples/nav_menu/app-express.py index ca3137465..50d70e552 100644 --- a/shiny/api-examples/nav_menu/app-express.py +++ b/shiny/api-examples/nav_menu/app-express.py @@ -8,4 +8,3 @@ "Page B content" with ui.nav_panel("C"): "Page C content" - diff --git a/shiny/express/ui/_cm_components.py b/shiny/express/ui/_cm_components.py index b737847f0..96fa410a1 100644 --- a/shiny/express/ui/_cm_components.py +++ b/shiny/express/ui/_cm_components.py @@ -1187,7 +1187,7 @@ def nav_panel( ) -@no_example() +@add_example() def nav_control() -> RecallContextManager[NavPanel]: """ Context manager for a control in the navigation container. diff --git a/shiny/ui/_navs.py b/shiny/ui/_navs.py index 10309da8b..b9ef6c89f 100644 --- a/shiny/ui/_navs.py +++ b/shiny/ui/_navs.py @@ -153,7 +153,7 @@ def nav_panel( ) -@no_example() +@add_example() def nav_control(*args: TagChild) -> NavPanel: """ Place a control in the navigation container. From 5ef9eb240f8c5565a8c00fcb421e93fc782a695d Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Mon, 29 Jul 2024 14:43:57 +0530 Subject: [PATCH 4/6] Add example apps for nav_spacer --- shiny/api-examples/nav_spacer/app-core.py | 19 +++++++++++++++++++ shiny/api-examples/nav_spacer/app-express.py | 11 +++++++++++ shiny/ui/_navs.py | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 shiny/api-examples/nav_spacer/app-core.py create mode 100644 shiny/api-examples/nav_spacer/app-express.py diff --git a/shiny/api-examples/nav_spacer/app-core.py b/shiny/api-examples/nav_spacer/app-core.py new file mode 100644 index 000000000..7c99549ed --- /dev/null +++ b/shiny/api-examples/nav_spacer/app-core.py @@ -0,0 +1,19 @@ +from shiny import App, ui + +app_ui = ui.page_fluid( + ui.navset_underline( + ui.nav_panel("A", "Panel A content"), + ui.nav_spacer(), + ui.nav_spacer(), + ui.nav_panel("B", "Panel B content"), + ui.nav_panel("C", "Panel C content"), + id="navset_underline", + ) +) + + +def server(input, output, session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/nav_spacer/app-express.py b/shiny/api-examples/nav_spacer/app-express.py new file mode 100644 index 000000000..b893d798b --- /dev/null +++ b/shiny/api-examples/nav_spacer/app-express.py @@ -0,0 +1,11 @@ +from shiny.express import ui + +with ui.navset_underline(): + with ui.nav_panel("Tab 1"): + "Tab 1 content" + ui.nav_spacer() + ui.nav_spacer() + with ui.nav_panel("Tab 2"): + "Tab 2 content" + with ui.nav_panel("Tab 3"): + "Tab 3 content" diff --git a/shiny/ui/_navs.py b/shiny/ui/_navs.py index b9ef6c89f..5015a7dc1 100644 --- a/shiny/ui/_navs.py +++ b/shiny/ui/_navs.py @@ -185,7 +185,7 @@ def nav_control(*args: TagChild) -> NavPanel: return NavPanel(tags.li(*args)) -@no_example() +@add_example() def nav_spacer() -> NavPanel: """ Create space between nav items. From 44a9b1ebd34824da088acb13beb1832054a8b584 Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Mon, 29 Jul 2024 14:56:10 +0530 Subject: [PATCH 5/6] Address linting errors --- shiny/ui/_navs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shiny/ui/_navs.py b/shiny/ui/_navs.py index 5015a7dc1..be17edc93 100644 --- a/shiny/ui/_navs.py +++ b/shiny/ui/_navs.py @@ -23,7 +23,7 @@ from htmltools import MetadataNode, Tag, TagAttrs, TagChild, TagList, css, div, tags -from .._docstring import add_example, no_example +from .._docstring import add_example from .._namespaces import resolve_id_or_none from .._utils import private_random_int from ..types import NavSetArg From c96e81ca32991ddc6e8744d2a0089531f378d22b Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Mon, 29 Jul 2024 14:58:30 +0530 Subject: [PATCH 6/6] Add title for navset_bar --- shiny/api-examples/navset_bar/app-express.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shiny/api-examples/navset_bar/app-express.py b/shiny/api-examples/navset_bar/app-express.py index bf76d5d70..8ca935e0e 100644 --- a/shiny/api-examples/navset_bar/app-express.py +++ b/shiny/api-examples/navset_bar/app-express.py @@ -1,6 +1,6 @@ from shiny.express import ui -with ui.navset_bar(id="tab"): +with ui.navset_bar(title="Navset Bar", id="tab"): with ui.nav_panel("A"): "Panel A content"