Title: | Glide Component for Shiny Applications |
---|---|
Description: | Insert Glide JavaScript component into Shiny applications for carousel or assistant-like user interfaces. |
Authors: | Julien Barnier [aut, cre] |
Maintainer: | Julien Barnier <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.4.9000 |
Built: | 2024-10-29 05:16:43 UTC |
Source: | https://github.com/juba/shinyglide |
Create a glide control only shown on first or last screen
firstButton(class = c("btn", "btn-default"), ...) lastButton(class = c("btn", "btn-success"), ...)
firstButton(class = c("btn", "btn-default"), ...) lastButton(class = c("btn", "btn-success"), ...)
class |
CSS classes of the control. The needed class is automatically added. |
... |
content of the control |
These controls generate an <a>
tag, so you can use href
attributes.
firstButton
is only shown on the first screen of the app, and finalButton
only
on the last screen.
firstButton("Go to website", href = "https://example.com", class = "btn btn-primary")
firstButton("Go to website", href = "https://example.com", class = "btn btn-primary")
Insert a glide component in the current shiny app UI
glide( ..., id = NULL, next_label = paste("Next", shiny::icon("chevron-right", lib = "glyphicon")), previous_label = paste(shiny::icon("chevron-left", lib = "glyphicon"), "Back"), loading_label = span(span(class = "shinyglide-spinner"), span("Loading")), loading_class = "loading", disable_type = c("disable", "hide"), height = "100%", keyboard = TRUE, swipe = TRUE, start_at = 0, custom_controls = NULL, controls_position = c("bottom", "top") )
glide( ..., id = NULL, next_label = paste("Next", shiny::icon("chevron-right", lib = "glyphicon")), previous_label = paste(shiny::icon("chevron-left", lib = "glyphicon"), "Back"), loading_label = span(span(class = "shinyglide-spinner"), span("Loading")), loading_class = "loading", disable_type = c("disable", "hide"), height = "100%", keyboard = TRUE, swipe = TRUE, start_at = 0, custom_controls = NULL, controls_position = c("bottom", "top") )
... |
content of the glide. |
id |
optional HTML id of the glide root element. |
next_label |
label to be used in the "next" control. |
previous_label |
label to be used in the "back" control. |
loading_label |
label to be used in the "next" control when the next screen is still loading. |
loading_class |
class to add to the "next" control when the next screen is still loading. |
disable_type |
either to "disable" or "hide" the next or back control when it is disabled by a condition. |
height |
height of the glide (something like "400px" or "100%"). |
keyboard |
set this to FALSE to disable keyboard navigation. |
swipe |
set this to FALSE to disable swipe navigation. |
start_at |
start at specific slide number defined with zero-based index (default 0). |
custom_controls |
custom HTML or shiny tags to be used for the controls. If 'NULL“, use the default ones. |
controls_position |
either to place the default or custom controls on "top" or "bottom" of the glide. |
screen nextButton prevButton firstButton lastButton
## Only run examples in interactive R sessions if (interactive()) { ui <- fixedPage( h3("Simple shinyglide app"), glide( screen( p("First screen.") ), screen( p("Second screen.") ) ) ) server <- function(input, output, session) { } shinyApp(ui, server) }
## Only run examples in interactive R sessions if (interactive()) { ui <- fixedPage( h3("Simple shinyglide app"), glide( screen( p("First screen.") ), screen( p("Second screen.") ) ) ) server <- function(input, output, session) { } shinyApp(ui, server) }
Creates an horizontal layout with both "previous" and "next" contents side by side.
glideControls(previous_content = prevButton(), next_content = nextButton())
glideControls(previous_content = prevButton(), next_content = nextButton())
previous_content |
Content of the "previous" (left) zone. |
next_content |
Content of the "next" (right) zone. |
glideControls( prevButton("Back"), list( lastButton(href = "https://example.com", "Go to website"), nextButton("Next") ) )
glideControls( prevButton("Back"), list( lastButton(href = "https://example.com", "Go to website"), nextButton("Next") ) )
This generates the code of the default controls, and can be used in custom controls.
nextButton(class = c("btn", "btn-primary")) prevButton(class = c("btn", "btn-default"))
nextButton(class = c("btn", "btn-primary")) prevButton(class = c("btn", "btn-default"))
class |
control CSS classes. The needed class is automatically added. |
prevButton
is hidden on the first screen, while nextButton
is hidden on
the last one.
The buttons labels are set with the next_label
and previous_label
arguments of glide()
.
glide
Insert a new screen into a glide component.
screen( ..., next_label = NULL, previous_label = NULL, next_condition = NULL, previous_condition = NULL, class = NULL )
screen( ..., next_label = NULL, previous_label = NULL, next_condition = NULL, previous_condition = NULL, class = NULL )
... |
content of the screen. |
next_label |
specific label of the "next" control for this screen. If |
previous_label |
specific label of the "back" control for this screen. If |
next_condition |
condition for the "next" control to be enabled. Same syntax
as |
previous_condition |
condition for the "back" control to be enabled. Same syntax
as |
class |
screen CSS classes. |
This function inserts a new "screen" into an existing glide
component. It
can only be used inside a glide()
call, in a shiny app UI.
glide
## Only run examples in interactive R sessions if (interactive()) { ui <- fixedPage( h3("Simple shinyglide app"), glide( screen( next_label = "Go next", next_condition = "input.x > 0", p("First screen."), numericInput("x", "x", value = 0) ), screen( p("Final screen."), ) ) ) server <- function(input, output, session) { } shinyApp(ui, server) }
## Only run examples in interactive R sessions if (interactive()) { ui <- fixedPage( h3("Simple shinyglide app"), glide( screen( next_label = "Go next", next_condition = "input.x > 0", p("First screen."), numericInput("x", "x", value = 0) ), screen( p("Final screen."), ) ) ) server <- function(input, output, session) { } shinyApp(ui, server) }
Insert a screen output element in a shiny app UI. This must be used with a
renderUI
reactive expression in the app server.
screenOutput( outputId, next_label = NULL, prev_label = NULL, next_condition = NULL, prev_condition = NULL, class = NULL, ... )
screenOutput( outputId, next_label = NULL, prev_label = NULL, next_condition = NULL, prev_condition = NULL, class = NULL, ... )
outputId |
output variable to read the value from |
next_label |
specific label of the "next" control for this screen. If |
prev_label |
specific label of the "back" control for this screen. If |
next_condition |
condition for the "next" control to be enabled. Same syntax
as |
prev_condition |
condition for the "back" control to be enabled. Same syntax
as |
class |
screen CSS classes. |
... |
other arguments to pass to the container tag function. |
Important : for this to work, you have to add a
outputOptions(output, id, suspendWhenHidden = FALSE)
in your app
server. See example.
## Only run examples in interactive R sessions if (interactive()) { ui <- fixedPage( h3("Simple shinyglide app"), glide( screen( p("First screen."), ), screenOutput("screen"), screen( p("Final screen."), ) ) ) server <- function(input, output, session) { output$screen <- renderUI({ p("Second screen.") }) outputOptions(output, "screen", suspendWhenHidden = FALSE) } shinyApp(ui, server) }
## Only run examples in interactive R sessions if (interactive()) { ui <- fixedPage( h3("Simple shinyglide app"), glide( screen( p("First screen."), ), screenOutput("screen"), screen( p("Final screen."), ) ) ) server <- function(input, output, session) { output$screen <- renderUI({ p("Second screen.") }) outputOptions(output, "screen", suspendWhenHidden = FALSE) } shinyApp(ui, server) }