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

190 support nav panel within apps using the page navbar template #215

Merged

Conversation

nstrayer
Copy link
Collaborator

This PR adds support for the newer nav_panel function to make tabs. The old tabPanel() support has been moved into an alias for nav_panel() which will result in an automatic updating of code to nav_panel().

@nstrayer nstrayer linked an issue Oct 11, 2023 that may be closed by this pull request
@netlify
Copy link

netlify bot commented Oct 11, 2023

Deploy Preview for shinyuieditor-storybook failed.

Name Link
🔨 Latest commit 833e1d8
🔍 Latest deploy log https://app.netlify.com/sites/shinyuieditor-storybook/deploys/6527f7e6de89590008455de0

@nstrayer
Copy link
Collaborator Author

Here's what a sample app looks like:
image

From code:

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

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

ui <- page_navbar(
  title = "Penguins dashboard",
  sidebar = sidebar(
    title = "Sidebar Title",
    selectInput(
       selected = "species",
       inputId = "color_by",
       label = "Color by",
       choices = list(
         "species" = "species",
         "island" = "island",
         "sex" = "sex"
       )
     ),
  ),
  nav_panel(
    title = "Bill Length",
    card(
      full_screen = TRUE,
      card_header("Bill Length"),
      plotOutput(outputId = "bill_length")
    )
  ),
  nav_panel(
    title = "Bill Depth",
    card(
      full_screen = TRUE,
      card_header("Bill depth"),
      card_body(),
      plotOutput(outputId = "bill_depth")
    )
  ),
  nav_panel(
    title = "Body Mass",
    card(
      full_screen = TRUE,
      card_header("Body Mass"),
      plotOutput(outputId = "body_mass")
    )
  )
)

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 Author

/update-snapshots

@nstrayer nstrayer merged commit d34ead4 into main Oct 12, 2023
@nstrayer nstrayer deleted the 190-support-nav_panel-within-apps-using-the-page_navbar-template branch October 12, 2023 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support nav_panel within apps using the page_navbar template
1 participant