Skip to content

Commit

Permalink
Merge 3ce2dc9 into e1b5c0f
Browse files Browse the repository at this point in the history
  • Loading branch information
m7pr authored Oct 13, 2023
2 parents e1b5c0f + 3ce2dc9 commit 1a178ab
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ S3method(create_sparklines,logical)
S3method(create_sparklines,numeric)
export(add_facet_labels)
export(get_scatterplotmatrix_stats)
export(landing_popup)
export(tm_a_pca)
export(tm_a_regression)
export(tm_data_table)
Expand Down
58 changes: 58 additions & 0 deletions R/tm_landing_popup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#' Landing Popup
#'
#' @description This function creates a simple landing welcome popup for `teal` applications and
#' can be used in a `teal::init(extra_server = )` parameter.
#'
#' @param title `character(1)` the text to be displayed as a title of the popup.
#' @param content `character(1)` the content of the popup. Passed to `...` of `shiny::modalDialog`. Can be a `character`
#' or a text input control (like `textInput`) or a list of `shiny` tags. See examples.
#' @param buttons `shiny` tag or a list of tags (`tagList`). Typically a `modalButton` or `actionButton`. See examples.
#'
#' @examples
#' app1 <- teal::init(
#' data = teal.data::dataset("iris", iris),
#' modules = teal::modules(
#' teal.modules.general::tm_front_page('A')
#' ),
#' extra_server = teal.modules.general::landing_popup(
#' title = "Welcome",
#' content = "A place for the welcome message or a disclaimer statement.",
#' buttons = modalButton("Proceed")
#' )
#' )
#' if (interactive()) {
#' shinyApp(app1$ui, app1$server)
#' }
#'
#' app2 <- teal::init(
#' data = teal.data::dataset("iris", iris),
#' modules = teal::modules(
#' teal.modules.general::tm_front_page('A')
#' ),
#' extra_server = teal.modules.general::landing_popup(
#' title = "Welcome",
#' content = div(tags$b("A place for the welcome message or a disclaimer statement.", style = "color: red;")),
#' buttons = tagList(modalButton("Proceed"), actionButton('close', 'Read more', onclick = "window.open('http://google.com', '_blank')"))
#' )
#' )
#'
#' if (interactive()) {
#' shinyApp(app2$ui, app2$server)
#' }
#'
#'
#' @export
landing_popup <- function(title = NULL, content = NULL, buttons = modalButton("Accept")) {
checkmate::assert_string(title, null.ok = TRUE)
checkmate::assert_multi_class(content, classes = c('character', 'shiny.tag', 'shiny.tag.list', 'html'), null.ok = TRUE)
checkmate::assert_multi_class(buttons, classes = c('shiny.tag', 'shiny.tag.list'), null.ok = TRUE)

showModal(
modalDialog(
title = title,
content,
footer = buttons
)
)
# div(class="sweet-overlay", tabindex = "-1", style = "opacity: 1.17;display: block;backdrop-filter: blur(10px);")
}
54 changes: 54 additions & 0 deletions man/landing_popup.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1a178ab

Please sign in to comment.