R/component-alert.R

Defines functions alertLink alert

#' @export
alert <- function(..., variant = c("success", "info", "warning", "danger"), dismissable = FALSE) {
  variant <- paste0("alert-", match.arg(variant))
  button <- NULL
  if (dismissable) {
    button <- tags$button(
      type = "button", class = "close",
      `data-dismiss` = "alert", `aria-label` = "Close",
      tags$span(`aria-hidden` = "true", shiny::HTML("&times;"))
    )
  }
  shiny::div(
    class = "alert",
    class = variant,
    role = "alert",
    button,
    ...
  )
}

#' @export
alertLink <- function(inputId, label, icon, ...) {
  shiny::actionLink(inputId, label, icon, class = "alert-link", ...)
}
shunsambongi/shuny documentation built on Aug. 19, 2022, 9:57 a.m.