Title: | Easily Add Markdown Help Files to 'shiny' App Elements |
---|---|
Description: | Creates a lightweight way to add markdown helpfiles to 'shiny' apps, using modal dialog boxes, with no need to observe each help button separately. |
Authors: | Chris Mason-Thom [aut, cre] |
Maintainer: | Chris Mason-Thom <[email protected]> |
License: | GPL-3 |
Version: | 0.3.2.9000 |
Built: | 2024-10-30 02:59:35 UTC |
Source: | https://github.com/cwthom/shinyhelper |
Helper function to be run interactively - it will initialise a directory of
help files (.md files) in help_dir, using the vector of files. Pass it a vector
of filenames which you which to use with type = "markdown"
in your calls to
helper
.
create_help_files(files, help_dir = "helpfiles")
create_help_files(files, help_dir = "helpfiles")
files |
A character vector of names to use in creating help files. |
help_dir |
A character string of the directory to use for help files. |
create_help_files(files = c("Clusters", "Columns", "PlotHelp"), help_dir = "helpfiles")
create_help_files(files = c("Clusters", "Columns", "PlotHelp"), help_dir = "helpfiles")
Add an action button to your shiny UI with a question mark help icon (by default).
In combination with observe_helpers
this icon will produce a modal
dialog box in the app, with content and title as specified. You may pass inline content
for the modal, or else specify the name of a markdown file to include.
helper(shiny_tag, icon = "question-circle", colour = NULL, type = "markdown", title = "", content = "", size = "m", buttonLabel = "Okay", easyClose = TRUE, fade = FALSE, ...)
helper(shiny_tag, icon = "question-circle", colour = NULL, type = "markdown", title = "", content = "", size = "m", buttonLabel = "Okay", easyClose = TRUE, fade = FALSE, ...)
shiny_tag |
A shiny element, such as an input or output (but any shiny tag will do). |
icon |
A character string of the name of the icon to display (font awesome). |
colour |
Any valid CSS colour for the icon. |
type |
Either 'markdown' to include a helpfile, or 'inline' to specify text. |
title |
The title to use for your modal. Leave as "" to have no title (for example, if your markdown document has a header you wish to use instead). |
content |
If |
size |
Either 's', 'm' or 'l' - the size of the modal dialog to display. |
buttonLabel |
The text for the modal button - "Ok" by default. |
easyClose |
Whether the modal can be dismissed by pressing Escape, or clicking
outside the modal. Defaults to |
fade |
Whether the modal has a fade in animation. Defaults to |
... |
Other arguments to pass to the |
helper(shiny::actionButton("go", "click me!"), icon = "exclamation", colour = "red", type = "markdown", content = "ClickHelp") # looks for 'helpfiles/ClickHelp.md'
helper(shiny::actionButton("go", "click me!"), icon = "exclamation", colour = "red", type = "markdown", content = "ClickHelp") # looks for 'helpfiles/ClickHelp.md'
Function to show a modal dialog, observing each of the help icons in the app.
observe_helpers(session = shiny::getDefaultReactiveDomain(), help_dir = "helpfiles", withMathJax = FALSE)
observe_helpers(session = shiny::getDefaultReactiveDomain(), help_dir = "helpfiles", withMathJax = FALSE)
session |
The session object in your shiny app. |
help_dir |
A character string of the directory containing your helpfiles. |
withMathJax |
If |
server <- function(input, output, session){ # use anywhere in your server.R script observe_helpers() # rest of server.R # ... # ... }
server <- function(input, output, session){ # use anywhere in your server.R script observe_helpers() # rest of server.R # ... # ... }
Easily add markdown helpfiles to your shiny apps, by adding a single function around a shiny app element. This adds a small icon (a question mark, by default) which presents content in a modal dialog box when clicked. The content can be passed inline or given in a markdown file.
There is also a convenient function to initialise a directory of markdown files given a vector of filenames.
A demo is available at https://cwthom94.shinyapps.io/shinyhelper-demo/
For further reference on how to use the package, please refer to https://github.com/cwthom/shinyhelper
An example app demonstrating the use of the shinyhelper
package.
shinyhelper_demo()
shinyhelper_demo()
## Not run: if (interactive()) { shinyhelper_demo() } ## End(Not run)
## Not run: if (interactive()) { shinyhelper_demo() } ## End(Not run)