if (FALSE) { # rlang::is_interactive()
library(bslib)
card_ui <- function(id, spinner_type = id) {
card(
busyIndicatorOptions(spinner_type = spinner_type),
card_header(paste("Spinner:", spinner_type)),
plotOutput(shiny::NS(id, "plot"))
)
}
card_server <- function(id, simulate = reactive()) {
moduleServer(
id = id,
function(input, output, session) {
output$plot <- renderPlot({
Sys.sleep(1)
simulate()
plot(x = rnorm(100), y = rnorm(100))
})
}
)
}
ui <- page_fillable(
useBusyIndicators(),
input_task_button("simulate", "Simulate", icon = icon("refresh")),
layout_columns(
card_ui("ring"),
card_ui("bars"),
card_ui("dots"),
card_ui("pulse"),
col_widths = 6
)
)
server <- function(input, output, session) {
simulate <- reactive(input$simulate)
card_server("ring", simulate)
card_server("bars", simulate)
card_server("dots", simulate)
card_server("pulse", simulate)
}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab