Skip to content

Commit

Permalink
added example for loading()
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Sep 30, 2024
1 parent 534764e commit dbbf67b
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 7 deletions.
5 changes: 3 additions & 2 deletions R/loading.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#'
#' @return a `list` that can be used in [capture()] or [capture_pdf()].
#' @export
#'
loading <- function(text = "Generating PDF, please wait...",
#'
#' @example examples/loading.R
loading <- function(text = "Capturing screenshot, please wait...",
type = c("standard", "hourglass", "circle", "arrows", "dots", "pulse"),
color = "#246abe",
background = "rgba(0,0,0,0.8)",
Expand Down
5 changes: 1 addition & 4 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ url: https://dreamrs.github.io/capture

template:
bootstrap: 5
bootswatch: zephyr
bootswatch: sandstone
bslib:
base_font: {google: "Poppins"}
primary: "#112446"

navbar:
bg: primary

authors:
Victor Perrier:
href: https://twitter.com/_pvictorr
Expand Down
70 changes: 70 additions & 0 deletions examples/loading.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
library(shiny)
library(capture)

ui <- fluidPage(
tags$h2("Capture (loading) example"),
capture(
selector = "body",
filename = "all-page",
scale = 5,
icon("camera"), "Auto loading indicator",
loading = loading(
text = "Capturing screenshot...",
type = "arrows",
color = "firebrick",
size = "160px"
)
),
tags$br(),
fluidRow(
column(
width = 4,
wellPanel(
tags$b("Parameters :"),
selectInput(
inputId = "loi",
label = "Law:",
choices = c("normal", "uniform", "exponential")
)
)
),
column(
width = 8,
tags$div(
id = "result-block",
tags$b("Results :"),
plotOutput(outputId = "plot"),
uiOutput(outputId = "mean"),
verbatimTextOutput(outputId = "raw")
)
)
)
)

server <- function(input, output, session) {

distrib_r <- reactive({
switch(
input$loi,
"normal" = rnorm(1000),
"uniform" = runif(1000),
"exponential" = rexp(1000)
)
})

output$plot <- renderPlot({
hist(distrib_r())
})

output$mean <- renderUI({
tags$p(tags$b("The mean is :"), round(mean(distrib_r()), 2))
})

output$raw <- renderPrint({
summary(distrib_r())
})

}

if (interactive())
shinyApp(ui, server)
74 changes: 73 additions & 1 deletion man/loading.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dbbf67b

Please sign in to comment.