Skip to content

Commit 3d589cf

Browse files
committed
First pass at page_navbar()
1 parent 4697e97 commit 3d589cf

6 files changed

Lines changed: 1311 additions & 6 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import shiny.experimental as x
2+
from shiny import App, ui
3+
from shiny.types import NavSetArg
4+
5+
6+
def nav_with_content(letter: str, prefix: str) -> ui._navs.Nav:
7+
return ui.nav(letter, ui.markdown(f"`{prefix}`: tab {letter} content"))
8+
9+
10+
def nav_items(prefix: str) -> list[NavSetArg]:
11+
a = nav_with_content("a", prefix)
12+
b = nav_with_content("b", prefix)
13+
github = ui.nav_control(
14+
ui.tags.a(
15+
# ui.icon("github"),
16+
# ui.HTML(
17+
# '<i class="fab fa-github" role="presentation" aria-label="github icon"></i>'
18+
# ),
19+
"Shiny",
20+
href="https://github.com/rstudio/shiny",
21+
target="_blank",
22+
),
23+
)
24+
space = ui.nav_spacer()
25+
other = ui.nav_menu(
26+
"Other links",
27+
nav_with_content("c", prefix),
28+
ui.nav_control(
29+
ui.tags.a(
30+
# icon("r-project"),
31+
"RStudio",
32+
href="https://rstudio.com",
33+
target="_blank",
34+
),
35+
),
36+
align="right",
37+
)
38+
return [a, b, github, space, other]
39+
40+
41+
app = App(
42+
ui=x.ui.page_navbar(
43+
# theme = bs_theme(),
44+
*nav_items("page_navbar()"),
45+
title="page_navbar()",
46+
bg="#0062cc",
47+
header=ui.markdown(
48+
"Testing app for `bslib::nav_spacer()` and `bslib::nav_item()` [#319](https://github.com/rstudio/bslib/pull/319)."
49+
),
50+
footer=ui.div(
51+
{"style": "width:80%; margin: 0 auto"},
52+
ui.h4("navs_tab()"),
53+
ui.navset_tab(*nav_items("navs_tab()")),
54+
ui.h4("navs_pill()"),
55+
ui.navset_pill(*nav_items("navs_pill()")),
56+
ui.h4("navs_tab_card()"),
57+
ui.navset_tab_card(*nav_items("navs_tab_card()")),
58+
ui.h4("navs_pill_card()"),
59+
ui.navset_pill_card(*nav_items("navs_pill_card()")),
60+
ui.h4("navs_pill_list()"),
61+
ui.navset_pill_list(*nav_items("navs_pill_list()")),
62+
# Make sure body height does not change when taking screenshots
63+
ui.tags.style("body { min-height: 100vh; }"),
64+
),
65+
),
66+
server=None,
67+
)

shiny/experimental/ui/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ._sidebar import layout_sidebar, sidebar, sidebar_toggle, panel_main, panel_sidebar
2-
from ._page import page_fillable
2+
from ._page import page_fillable, page_navbar
33
from ._card_item import (
44
CardItem,
55
card_header,
@@ -40,6 +40,7 @@
4040
"panel_sidebar",
4141
# Page
4242
"page_fillable",
43+
"page_navbar",
4344
# Card
4445
"CardItem",
4546
"card",

0 commit comments

Comments
 (0)