Title: | Wrapper for the 'Intro.js' Library |
---|---|
Description: | A wrapper for the 'Intro.js' library (For more info: <https://introjs.com/>). This package makes it easy to include step-by-step introductions, and clickable hints in a 'Shiny' application. It supports both static introductions in the UI, and programmatic introductions from the server-side. |
Authors: | Carl Ganz [aut, cre] , Afshin Mehrabani [ctb, cph] (intro.js in javascript/introjs) |
Maintainer: | Carl Ganz <[email protected]> |
License: | AGPL-3 |
Version: | 0.3.4 |
Built: | 2024-11-14 04:14:13 UTC |
Source: | https://github.com/carlganz/rintrojs |
Wrap introBox
around elements you want to include in introduction.
Use data.step to order the boxes and data.intro to specify the comment in the introduction
introBox( ..., data.step, data.intro, data.hint, data.position = c("bottom", "auto", "top", "left", "right", "bottom", "bottom-left_aligned", "bottom-middle-aligned", "bottom-right-aligned", "auto") )
introBox( ..., data.step, data.intro, data.hint, data.position = c("bottom", "auto", "top", "left", "right", "bottom", "bottom-left_aligned", "bottom-middle-aligned", "bottom-right-aligned", "auto") )
... |
Elements in introduction element |
data.step |
a number indicating its spot in the order in the intro |
data.intro |
text for introduction |
data.hint |
text for clickable hints |
data.position |
position of intro |
## Not run: library(rintrojs) library(shiny) ui <- shinyUI(fluidPage( introjsUI(), # must include in UI mainPanel( introBox( tableOutput("mtcars"), data.step = 1, data.intro = "This is the table" ), introBox( actionButton("btn","Intro"), data.step = 2, data.intro = "This is the button" ) ))) server <- shinyServer(function(input, output, session) { output$mtcars <- renderTable({ head(mtcars) }) observeEvent(input$btn, introjs(session)) }) # Run the application shinyApp(ui = ui, server = server) ## End(Not run)
## Not run: library(rintrojs) library(shiny) ui <- shinyUI(fluidPage( introjsUI(), # must include in UI mainPanel( introBox( tableOutput("mtcars"), data.step = 1, data.intro = "This is the table" ), introBox( actionButton("btn","Intro"), data.step = 2, data.intro = "This is the button" ) ))) server <- shinyServer(function(input, output, session) { output$mtcars <- renderTable({ head(mtcars) }) observeEvent(input$btn, introjs(session)) }) # Run the application shinyApp(ui = ui, server = server) ## End(Not run)
Initiates an introduction via the intro.js library
introjs(session, options = list(), events = list()) hintjs(session, options = list(), events = list())
introjs(session, options = list(), events = list()) hintjs(session, options = list(), events = list())
session |
the Shiny session object (from the server function of the Shiny app) |
options |
List of options to be passed to intro.js |
events |
List of text that are the body of a Javascript function. Must wrap in |
For documentation on intro.js options and events, see https://introjs.com/docs/.
## Not run: library(rintrojs) library(shiny) ui <- shinyUI(fluidPage( introjsUI(), # must include in UI mainPanel( introBox( tableOutput("mtcars"), data.step = 1, data.intro = "This is the table" ), introBox( actionButton("btn","Intro"), data.step = 2, data.intro = "This is the button", data.hint = "Here is clue" ) ))) server <- shinyServer(function(input, output, session) { hintjs(session, options = list("hintButtonLabel"="That was a hint")) output$mtcars <- renderTable({ head(mtcars) }) observeEvent(input$btn, introjs(session, options = list("nextLabel"="Onwards and Upwards"), events = list("oncomplete"=I('alert("It is over")')))) }) # Run the application shinyApp(ui = ui, server = server) ## End(Not run)
## Not run: library(rintrojs) library(shiny) ui <- shinyUI(fluidPage( introjsUI(), # must include in UI mainPanel( introBox( tableOutput("mtcars"), data.step = 1, data.intro = "This is the table" ), introBox( actionButton("btn","Intro"), data.step = 2, data.intro = "This is the button", data.hint = "Here is clue" ) ))) server <- shinyServer(function(input, output, session) { hintjs(session, options = list("hintButtonLabel"="That was a hint")) output$mtcars <- renderTable({ head(mtcars) }) observeEvent(input$btn, introjs(session, options = list("nextLabel"="Onwards and Upwards"), events = list("oncomplete"=I('alert("It is over")')))) }) # Run the application shinyApp(ui = ui, server = server) ## End(Not run)
This function must be called from a Shiny app's UI in order to use the package.
introjsUI(includeOnly = FALSE, cdn = FALSE, version = "3.2.1")
introjsUI(includeOnly = FALSE, cdn = FALSE, version = "3.2.1")
includeOnly |
Only include intro.js files. For users who will write their own javascript |
cdn |
Indicate whether to include intro.js files from CDN |
version |
Specify intro.js version to use from cdn |
## Not run: library(rintrojs) library(shiny) shinyApp( ui = fluidPage( introjsUI(), # must include in UI actionButton("btn", "Click me") ), server = function(input, output, session) { observeEvent(input$btn, { intro <- data.frame(element="#btn", intro="In Codd we trust") introjs(session, options = list(steps= intro)) }) } ) ## End(Not run)
## Not run: library(rintrojs) library(shiny) shinyApp( ui = fluidPage( introjsUI(), # must include in UI actionButton("btn", "Click me") ), server = function(input, output, session) { observeEvent(input$btn, { intro <- data.frame(element="#btn", intro="In Codd we trust") introjs(session, options = list(steps= intro)) }) } ) ## End(Not run)
Reads a JS callback function into rintrojs
readCallback(funname = c("switchTabs"))
readCallback(funname = c("switchTabs"))
funname |
The name of the function you want to use. Options include:
|
A string containing the body of a callback function
## Not run: introjs(session, events = list(onbeforechange = readCallback("switchTabs"))) ## End(Not run)
## Not run: introjs(session, events = list(onbeforechange = readCallback("switchTabs"))) ## End(Not run)