R/utils_alerts.R

Defines functions ilovesqlnstructor alert_error_msg alert_forbidden_fun alert_no_code

Documented in alert_error_msg alert_forbidden_fun alert_no_code ilovesqlnstructor

# [shiny alerts] utils functions

#' alert_no_code
#'
#' @importFrom shinyalert shinyalert
alert_no_code <- function() {
  shinyalert(
    title = "Oops !",
    text = "maybe you should write some code before to run !",
    closeOnEsc = TRUE,
    closeOnClickOutside = TRUE
  )
}

#' alert_forbidden_fun
#'
#' @importFrom shinyalert shinyalert
alert_forbidden_fun <- function() {
  shinyalert(
    title = "Sorry !",
    text = "you are trying something not expected !",
    type = "warning",
    closeOnEsc = TRUE,
    closeOnClickOutside = TRUE
  )
}

#' alert_error_msg
#'
#' @param error an error message to print
#' @importFrom shinyalert shinyalert
#' @importFrom shiny pre
alert_error_msg <- function(error) {
  shinyalert(
    title = "Stop ! \n An error occured :",
    text = error,
    type = "error",
    closeOnEsc = TRUE,
    closeOnClickOutside = TRUE,
    className = "error"
  )
}

#' ilovesqlnstructor
#' Easter egg - just fun
#'
#' @importFrom shinyalert shinyalert
ilovesqlnstructor <- function() {
  shinyalert(
    title = "oh yes, you found it ! \n you're the best",
    imageUrl = "https://media.giphy.com/media/nEMmyUp4hl1QOzovKh/giphy.gif",
    imageWidth = 350,
    imageHeight = 250,
    closeOnEsc = TRUE,
    closeOnClickOutside = TRUE
  )
}
ArthurData/sqlnstructor documentation built on Dec. 17, 2021, 9:44 a.m.