Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions R/cards.R
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

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