dreamRs / shinypop

Collection of notifications, confirm dialogs and alerts for 'Shiny' applications
GNU General Public License v3.0
52 stars 7 forks source link

Vex alert remove close button #3

Open analytichealth opened 3 years ago

analytichealth commented 3 years ago

Hi, very cool package.

I was expecting this example to not show a button (similar to easyClose = FALSE for a shiny::modalDialog). Please advise how I can remove the button.

Thank you

ui <- fluidPage(
  tags$h2("Alert with vex example"),
  use_vex(),
  actionButton("launch", "Launch an alert")
)

server <- function(input, output, session) {

  observeEvent(input$launch, {
    vex(
      showCloseButton = FALSE,
      escapeButtonCloses = FALSE,
      overlayClosesOnClick = FALSE,
      session = session,
      tags$div(
      style = "text-align: center;",
      tags$h3("Attention"),
      tags$br(),
      tags$p("This alert was sent from the server")
    ))
  })

}

shinyApp(ui, server)
pvictor commented 3 years ago

Thanks ! An argument was missing, re-install grom GitHub then try :

library(shiny)
library(shinypop)
library(htmltools)

ui <- fluidPage(
  tags$h2("Alert with vex example"),
  use_vex(),
  actionButton("launch", "Launch an alert")
)

server <- function(input, output, session) {

  observeEvent(input$launch, {
    vex(
      showCloseButton = FALSE,
      showButton = FALSE,
      escapeButtonCloses = FALSE,
      overlayClosesOnClick = FALSE,
      tags$div(
        style = "text-align: center;",
        tags$h3("Attention"),
        tags$br(),
        tags$p("You cannot close this alert, it will automatically disappear after 4 seconds.")
      ))
    Sys.sleep(4)
    vex_close()
  })

}

shinyApp(ui, server)

Victor