rstudio / shinyuieditor

A GUI for laying out a Shiny application that generates clean and human-readable UI code
https://rstudio.github.io/shinyuieditor/
MIT License
209 stars 29 forks source link

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

Closed nstrayer closed 8 months ago

nstrayer commented 8 months ago

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().

netlify[bot] commented 8 months ago

Deploy Preview for shinyuieditor-storybook failed.

Name Link
Latest commit 833e1d808986c261757b4c8512a4bccc28c483d1
Latest deploy log https://app.netlify.com/sites/shinyuieditor-storybook/deploys/6527f7e6de89590008455de0
nstrayer commented 8 months ago

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 commented 8 months ago

/update-snapshots