galleryOutput: Helper Functions for Using Shinygallery in Shiny

Description Usage Arguments Examples

View source: R/inputs-shiny.R

Description

These functions are like most fooOutput() and renderFoo() functions in the shiny package. The former is used to create a container for a gallery, and the latter is used in the server logic to render the gallery.

Usage

1
2
3
galleryOutput(outputId, width = "100%", height = "150px")

renderGallery(expr, env = parent.frame(), quoted = FALSE)

Arguments

outputId

The output slot that will be used to access the values.

width

The width of the input container, e.g., '100%'; see validateCssUnit.

height

The height of each input image, e.g., '200px'; see validateCssUnit.

expr

An expression to create an image gallery widget (normally via gallery()), or a data object to be passed to gallery() to create an image gallery widget.

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Only run examples in interactive R sessions
if (interactive()) {
  library(shiny)
  library(shinygallery)

  get_uri <- function(file) {
    file_ext <- paste0("image/", tools::file_ext(file))
    base64enc::dataURI(file = file, mime = file_ext)
  }

  file_path <- system.file("extdata", package = "shinygallery")

  files <- list.files(file_path, full.names = TRUE)
  values <- rep(sapply(files, get_uri), 10)

  ui <- fluidPage(galleryOutput("gallery"))

  server <- function(input, output, session) {
    output$gallery <- renderGallery({
      gallery(values, height = 150, options = list(
        "detailsLabel" = "Details", "addLabel" = "Add"
      ))
    })
  }

  shinyApp(ui, server)
}

stefanieschneider/shinygallery documentation built on July 6, 2020, 7:46 p.m.