Type: | Package |
Title: | Wrapper for the 'Intro.js' Library |
Version: | 0.3.4 |
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. |
License: | AGPL-3 |
Imports: | shiny, jsonlite |
Depends: | R (≥ 3.0.0) |
RoxygenNote: | 7.2.3 |
URL: | https://github.com/carlganz/rintrojs, http://rintrojs.carlganz.com |
BugReports: | https://github.com/carlganz/rintrojs/issues |
Suggests: | testthat, covr |
Config/potools/style: | base |
NeedsCompilation: | no |
Packaged: | 2024-01-11 20:46:10 UTC; carlganz |
Author: | Carl Ganz |
Maintainer: | Carl Ganz <carlganz@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2024-01-11 21:30:02 UTC |
Generate intro elements in UI
Description
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
Usage
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")
)
Arguments
... |
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 |
See Also
Examples
## 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)
Initiate intro.js
Description
Initiates an introduction via the intro.js library
Usage
introjs(session, options = list(), events = list())
hintjs(session, options = list(), events = list())
Arguments
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 |
Note
For documentation on intro.js options and events, see https://introjs.com/docs/.
See Also
Examples
## 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)
Set up Shiny app to use intro.js
Description
This function must be called from a Shiny app's UI in order to use the package.
Usage
introjsUI(includeOnly = FALSE, cdn = FALSE, version = "3.2.1")
Arguments
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 |
Examples
## 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)
Read a JS callback function into rintrojs
Description
Reads a JS callback function into rintrojs
Usage
readCallback(funname = c("switchTabs"))
Arguments
funname |
The name of the function you want to use. Options include:
|
Value
A string containing the body of a callback function
Examples
## Not run:
introjs(session, events = list(onbeforechange = readCallback("switchTabs")))
## End(Not run)