|
| 1 | +### Keep this line to manually test this shiny application. Do not edit this line; shinycoreci::::is_manual_app |
| 2 | + |
| 3 | +library(shiny) |
| 4 | +library(bslib) |
| 5 | +library(ggplot2) |
| 6 | +library(plotly) |
| 7 | + |
| 8 | +lorem1 <- p( |
| 9 | + "Dolor cursus quis sociis, tempus laoreet integer vel,", |
| 10 | + "nam suscipit sodales curabitur tristique. Hac massa", |
| 11 | + "fames auctor ac posuere, non: primis semper egestas!", |
| 12 | + "Porttitor interdum lobortis elementum arcu." |
| 13 | +) |
| 14 | + |
| 15 | +lorem2 <- p( |
| 16 | + "Elit aptent vivamus, eu habitasse fringilla venenatis", |
| 17 | + "viverra tellus metus. Maecenas ultrices fermentum", |
| 18 | + "nunc turpis libero nascetur!" |
| 19 | +) |
| 20 | + |
| 21 | +ui <- page_fixed( |
| 22 | + titlePanel("Sidebar Resize", "312 | bslib-sidebar-resize"), |
| 23 | + h2("Static plot resizing"), |
| 24 | + p( |
| 25 | + "The plot in the layout below should stretch while the sidebar is opening", "or closing. After the transition is complete, the server will update the", |
| 26 | + "plot with the final dimensions." |
| 27 | + ), |
| 28 | + layout_sidebar( |
| 29 | + sidebar = sidebar(title = "Toggle me", lorem1, lorem2, lorem1), |
| 30 | + lorem1, |
| 31 | + plotOutput("plot_static"), |
| 32 | + lorem2 |
| 33 | + ), |
| 34 | + h2("Widget plot resizing", class = "mt-4 mb-2"), |
| 35 | + p( |
| 36 | + "The plot in the layout below should stretch while the sidebar is opening", "or closing. There should be no layout shift after the transition is", "complete." |
| 37 | + ), |
| 38 | + layout_sidebar( |
| 39 | + sidebar = sidebar(title = "Toggle me", lorem1, lorem2, lorem1), |
| 40 | + lorem1, |
| 41 | + plotlyOutput("plot_widget"), |
| 42 | + lorem2 |
| 43 | + ), |
| 44 | + div(style = "min-height: 100vh") |
| 45 | +) |
| 46 | + |
| 47 | +server <- function(input, output, session) { |
| 48 | + plot <- reactive({ |
| 49 | + ggplot(mtcars, aes(mpg, wt)) + geom_point() |
| 50 | + }) |
| 51 | + |
| 52 | + output$plot_static <- renderPlot(plot()) |
| 53 | + output$plot_widget <- renderPlotly(ggplotly(plot())) |
| 54 | +} |
| 55 | + |
| 56 | +shinyApp(ui, server) |
0 commit comments