Skip to content
2 changes: 1 addition & 1 deletion R/dashboardSidebar.R
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ bs4SidebarMenuItem <- function(text, ..., icon = NULL, badgeLabel = NULL, badgeC
subItems <- list(...)

if (!is.null(icon)) {
tagAssert(icon, type = "i")
tagAssert(icon, type = c("i", "img"))
icon$attribs$class <- paste0(icon$attribs$class, " nav-icon")
}

Expand Down
31 changes: 16 additions & 15 deletions R/useful-items.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ bs4Badge <- function(..., color, position = c("left", "right"),
)
}

#' @title Bootstrap 4 Alert box
#'
#' @param style \code{(character)} Inline style parameters to add
#' @inherit bs4Dash::bs4Card params return
#' @export

bs4Alert <- function(..., status = "primary", style = NULL, id = NULL, width = 6) {
bs4Dash:::validateStatus(status)
shiny::tags$div(class = paste0("alert alert-",status), role = "alert", ..., style = paste0("margin: 6px 5px 6px 15px;", sapply(\(x) {ifelse(grepl(";$", x), x, paste0(x, ";"))}), id = id))
}


#' Bootstrap 4 accordion container
Expand Down Expand Up @@ -549,7 +558,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)
Expand All @@ -567,17 +576,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
)

Expand All @@ -598,7 +603,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)
Expand All @@ -623,12 +629,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
)
}
Expand All @@ -649,7 +650,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
}
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ tagAssert <- function(tag, type = NULL, class = NULL, allowUI = TRUE) {
return()
}

if (!is.null(type) && tag$name != type) {
stop("Expected tag to be of type ", type)
if (!is.null(type) && !tag$name %in% type) {
stop("Expected tag to be of type(s) ", paste0(type, collapse = ", "))
}

if (!is.null(class)) {
Expand Down