|
| 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 | +) |
0 commit comments