diff --git a/R/cards.R b/R/cards.R index 4f6e3fd1..3e805213 100644 --- a/R/cards.R +++ b/R/cards.R @@ -135,11 +135,29 @@ #' @author David Granjon, \email{dgranjon@@ymail.com} #' #' @export -bs4Card <- function(..., title = NULL, footer = NULL, status = NULL, - solidHeader = FALSE, background = NULL, width = 6, height = NULL, - collapsible = TRUE, collapsed = FALSE, closable = FALSE, maximizable = FALSE, icon = NULL, - gradient = FALSE, boxToolSize = "sm", elevation = NULL, headerBorder = TRUE, label = NULL, dropdownMenu = NULL, - sidebar = NULL, id = NULL) { +bs4Card <- function(..., + title = NULL, + footer = NULL, + status = NULL, + solidHeader = FALSE, + background = NULL, + width = 6, + height = NULL, + collapsible = TRUE, + collapsed = FALSE, + closable = FALSE, + maximizable = FALSE, + icon = NULL, + tip_icon = NULL, + gradient = FALSE, + boxToolSize = "sm", + elevation = NULL, + headerBorder = TRUE, + label = NULL, + dropdownMenu = NULL, + sidebar = NULL, + id = NULL) { + if (is.null(status)) solidHeader <- TRUE @@ -242,7 +260,7 @@ bs4Card <- function(..., title = NULL, footer = NULL, status = NULL, headerTag <- shiny::tags$div( class = if (headerBorder) "card-header" else "card-header border-0", - shiny::tags$h3(class = "card-title", icon, title) + shiny::tags$h3(class = "card-title", tip_icon, icon, title) ) headerTag <- shiny::tagAppendChild(headerTag, cardToolTag) diff --git a/R/useful-items.R b/R/useful-items.R index b2f55b57..75a5dcf2 100644 --- a/R/useful-items.R +++ b/R/useful-items.R @@ -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 @@ -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) @@ -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 ) @@ -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) @@ -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 ) } @@ -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 }