diff --git a/R/useful-items.R b/R/useful-items.R index b2f55b57..6dbd464b 100644 --- a/R/useful-items.R +++ b/R/useful-items.R @@ -549,7 +549,7 @@ bs4CarouselItem <- function(..., caption = NULL, active = FALSE) { #' @export bs4ProgressBar <- function (value, min = 0, max = 100, vertical = FALSE, striped = FALSE, animated = FALSE, status = "primary", size = NULL, - label = NULL) { + label = NULL, id = NULL) { if (!is.null(status)) validateStatusPlus(status) stopifnot(value >= min) @@ -567,17 +567,13 @@ bs4ProgressBar <- function (value, min = 0, max = 100, vertical = FALSE, striped # wrapper barTag <- shiny::tags$div( + id = id, class = barCl, role = "progressbar", `aria-valuenow` = value, `aria-valuemin` = min, `aria-valuemax` = max, - style = if (vertical) { - paste0("height: ", paste0(value, "%")) - } - else { - paste0("width: ", paste0(value, "%")) - }, + style = paste0(ifelse(vertical, "height: ", "width: "), ((value - min) / (max - min) * 100), "%"), if(!is.null(label)) label ) @@ -598,7 +594,8 @@ bs4MultiProgressBar <- animated = FALSE, status = "primary", size = NULL, - label = NULL + label = NULL, + id = NULL ) { status <- verify_compatible_lengths(value, status) striped <- verify_compatible_lengths(value, striped) @@ -623,12 +620,7 @@ bs4MultiProgressBar <- `aria-valuenow` = value, `aria-valuemin` = min, `aria-valuemax` = max, - style = if (vertical) { - paste0("height: ", paste0(value, "%")) - } - else { - paste0("width: ", paste0(value, "%")) - }, + style = paste0(ifelse(vertical, "height: ", "width: "), ((value - min) / (max - min) * 100), "%"), if(!is.null(label)) label ) } @@ -649,7 +641,7 @@ bs4MultiProgressBar <- # wrapper class progressCl <- if (isTRUE(vertical)) "progress vertical" else "progress mb-3" if (!is.null(size)) progressCl <- paste0(progressCl, " progress-", size) - progressTag <- shiny::tags$div(class = progressCl) + progressTag <- shiny::tags$div(class = progressCl, id = id) progressTag <- shiny::tagAppendChild(progressTag, barSegs) progressTag }