Closed agilly closed 8 months ago
Hello,
Yes you're right, text
is used to put the progress bar, there's no easy way to put some text at the moment, beside of title
.
But progressSweetAlert()
is just a wrapper around sendSweetAlert()
and progressBar()
, so you can easily make a version that suit your needs, for example something like :
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
actionButton("show", "Show progress")
)
server <- function(input, output, session) {
observeEvent(input$show, {
sendSweetAlert(
session = session,
title = NULL,
btn_labels = NA,
text = tags$div(
progressBar(
id = "myprogress",
title = "Work in progress",
display_pct = TRUE,
value = 0
),
tags$div(
id = "mytext",
tags$p("Here you can put some text")
)
),
closeOnClickOutside = FALSE,
backdrop = TRUE
)
for (i in seq_len(50)) {
Sys.sleep(0.1)
updateProgressBar(
session = session,
id = "myprogress",
title = "Work in progress",
value = i*2
)
if (i == 25) {
removeUI("#mytext p", immediate = TRUE)
insertUI(
selector = "#mytext",
ui = tags$p("This text has been updated"),
immediate = TRUE
)
}
}
closeSweetAlert(session = session)
})
}
shinyApp(ui, server)
There's also some alternative for a progress modal here : https://dreamrs.github.io/shinybusy/reference/modal-progress.html if you're interested.
Victor
Thank you very much @pvictor , this is super useful. I tried the shinybusy
solution and it works great! Will update my current progress bars with the wrapper you suggested soon.
Also tested your solution for the progress bar, it works well. The style of "#mytext"
is a bit heavy but I assume p()
can be replaced or styled to a lighter/smaller font.
Hi!
This is more of a feature request than an issue. Currently, we are able to create
sweetAlerts
of various types with a title and text:We are also able to use a progress bar modal in a sweet alert:
In the documentation, it says that progressSweetAlert's remaining arguments are passed to sendSweetAlert:
... Arguments passed to sendSweetAlert()
However that doesn't extend to the
text
argument, because if I use it, I get:My guess is that
text
is overloaded to contain the progress bar. Is there a way, however, to makeprogressSweetAlert
andupdateProgressBar
accept some additional text? It would help building more dynamic and informative progress bars.Even if this suggestion is rejected, any workaround is also appreciated!