Skip to content
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

Support nav_panel within apps using the page_navbar template #190

Closed
rpodcast opened this issue Sep 21, 2023 · 2 comments · Fixed by #215
Closed

Support nav_panel within apps using the page_navbar template #190

rpodcast opened this issue Sep 21, 2023 · 2 comments · Fixed by #215
Labels
enhancement New feature or request
Milestone

Comments

@rpodcast
Copy link

After creating a simple app in the editor based on the navbar template (which had no issues), I decided to try loading a pre-made app based on this example with a few modifications. In my adapted example, I'm using nav_panel instead of tabPanel which is used in the fresh template. Would it be possible to have nav_panel supported? I know it's not trivial to add support for additional UI elements coming from separate packages, but this would be a great value to future uses of the editor with bslib- powered dashboards.

Example application

library(shiny)
library(bslib)
library(ggplot2)

# install.packages("palmerpenguins")
data(penguins, package = "palmerpenguins")

ui <- page_navbar(
  title = "Penguins dashboard",
  sidebar = selectInput(
    selected = "species",
    inputId = "color_by",
    label = "Color by",
    choices = c(
      "species",
      "island",
      "sex"
    )
  ),
  collapsible = nav_spacer(),
  nav_panel(
        "Bill Length", 
        card(
          full_screen = TRUE,
          card_header("Bill Length"),
          plotOutput("bill_length")
        )
      ),
  nav_panel(
        "Bill Depth", 
        card(
          full_screen = TRUE,
          card_header("Bill depth"),
          plotOutput("bill_depth")
        )
      ),
  nav_panel(
        "Body Mass", 
        card(
          full_screen = TRUE,
          card_header("Body Mass"),
          plotOutput("body_mass")
        )
      ),
  nav_item(tags$a("Posit", href = "https://posit.co"))
)

server <- function(input, output) {
  gg_plot <- reactive({
    ggplot(penguins) +
      geom_density(aes(fill = !!input$color_by), alpha = 0.2) +
      theme_bw(base_size = 16) +
      theme(axis.title = element_blank())
  })
  
  output$bill_length <- renderPlot(gg_plot() + aes(bill_length_mm))
  output$bill_depth <- renderPlot(gg_plot() + aes(bill_depth_mm))
  output$body_mass <- renderPlot(gg_plot() + aes(body_mass_g))
}

shinyApp(ui, server)
@nstrayer
Copy link
Collaborator

Absolutely, nav_panel() should be supported. Putting this into the queue of next steps.

@nstrayer nstrayer added the enhancement New feature or request label Sep 27, 2023
@nstrayer nstrayer added this to the v0.5.1 milestone Sep 27, 2023
@nstrayer
Copy link
Collaborator

nstrayer commented Oct 11, 2023

As of #215, most of that example app will work. There are a few areas where the UI editor still gets tripped up.

  1. It wants to the sidebar wrapped in a sidebar call. This can/ probably should be updated. Handle un-wrapped sidebar arguments in navbar_page() #217
  2. It doesn't know how to deal with collapsible = nav_spacer().
  3. nav_item() isn't supported. Support for nav_item() #216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants