Skip to content
Merged
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
18 changes: 15 additions & 3 deletions R/progressBars.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#' @param striped logical, add a striped effect.
#' @param title character, optional title.
#' @param range_value Default is to display percentage (\code{[0, 100]}), but you can specify a custom range, e.g. \code{-50, 50}.
#' @param commas logical, add commas on total and value.
#' @param unit_mark Unit for value displayed on the progress bar, default to \code{"\%"}.
#'
#' @return A progress bar that can be added to a UI definition.
Expand Down Expand Up @@ -90,6 +91,7 @@ progressBar <- function(id,
striped = FALSE,
title = NULL,
range_value = NULL,
commas = TRUE,
unit_mark = "%") {
if (!is.null(total)) {
percent <- round(value / total * 100)
Expand All @@ -110,12 +112,20 @@ progressBar <- function(id,
)
}

if(commas) {
value_for_display <- prettyNum(value, big.mark = ",", scientific = FALSE)
total_for_display <- prettyNum(total, big.mark = ",", scientific = FALSE)
} else {
value_for_display <- value
total_for_display <- total
}

if (!is.null(total)) {
total <- tags$span(
class = "progress-number",
tags$b(value, id = paste0(id, "-value")),
tags$b(value_for_display, id = paste0(id, "-value")),
"/",
tags$span(id = paste0(id, "-total"), total)
tags$span(id = paste0(id, "-total"), total_for_display)
)
}

Expand Down Expand Up @@ -156,7 +166,8 @@ progressBar <- function(id,
#' @rdname progress-bar
updateProgressBar <- function(session, id, value, total = NULL,
title = NULL, status = NULL,
range_value = NULL, unit_mark = "%") {
range_value = NULL, commas = TRUE,
unit_mark = "%") {
message <- "update-progressBar-shinyWidgets"
if (!is.null(range_value)) {
percent <- rescale(x = value, from = range_value, to = c(0, 100))
Expand All @@ -177,6 +188,7 @@ updateProgressBar <- function(session, id, value, total = NULL,
total = if (is.null(total)) -1 else total,
title = title,
status = status,
commas = commas,
unit_mark = unit_mark
)
)
Expand Down
Binary file removed inst/assets/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions inst/assets/progress-bars/progress-bars-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Shiny.addCustomMessageHandler("update-progressBar-shinyWidgets", function(
if (total > 0) {
pct = Math.round((value / total) * 100);
if (elVal !== null)
elVal.innerText = value;
elVal.innerText = data.commas ? value.toLocaleString("en-US") : value;
if (elTot !== null)
elTot.innerText = total;
elTot.innerText = data.commas ? total.toLocaleString("en-US") : total;
value = Math.round((value / total) * 100);
} else {
pct = data.percent > 0 ? data.percent : value;
Expand Down
2 changes: 1 addition & 1 deletion inst/assets/shinyWidgets-bindings.min.js

Large diffs are not rendered by default.

203 changes: 110 additions & 93 deletions inst/assets/shinyWidgets.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


/* CSS icone btn */
/* CSS checkbox buttons for icons */


.btn.checkbtn:focus {
Expand All @@ -24,6 +24,15 @@
}


.btn.checkbtn.disabled > .check-btn-icon-yes {
pointer-events: none;
}
.btn.checkbtn.disabled > .check-btn-icon-no {
pointer-events: none;
}





/*
Expand All @@ -37,6 +46,106 @@




/* CSS radio buttons for icons */


.btn.radiobtn:focus {
outline: none !important;
}

.btn.radiobtn .radio-btn-icon-yes {
opacity: 0;
display: none;
}
.btn.radiobtn.active .radio-btn-icon-yes {
opacity: 1;
display: inline-block;
}

.btn.radiobtn.active .radio-btn-icon-no {
opacity: 0;
display: none;
}
.btn.radiobtn .radio-btn-icon-no {
opacity: 1;
display: inline-block;
}

.btn.radiobtn.disabled > .radio-btn-icon-yes {
pointer-events: none;
}
.btn.radiobtn.disabled > .radio-btn-icon-no {
pointer-events: none;
}




/* Option 1 */
/*
.btn.radiobtn span.glyphicon-unchecked {
opacity: 1; display: inline-block;
}
.btn.radiobtn.active span.glyphicon-unchecked {
opacity: 1; display: none;
}

.btn.radiobtn span.glyphicon-check {
opacity: 1; display: none;
}
.btn.radiobtn.active span.glyphicon-check {
opacity: 1; display: inline-block;
}
*/



/* Option 2*/
/*
.btn.radiobtn span.glyphicon-remove {
opacity: 1; display: inline-block;
}
.btn.radiobtn.active span.glyphicon-remove {
opacity: 1; display: none;
}

.btn.radiobtn span.glyphicon-ok {
opacity: 1; display: none;
}
.btn.radiobtn.active span.glyphicon-ok {
opacity: 1; display: inline-block;
}
*/


/* Option 3*/
/*
.btn.radiobtn span.glyphicon-ok.blank.hide {
opacity: 0; display: none;
}
.btn.radiobtn.active span.glyphicon-ok.blank.hide {
opacity: 0; display: inline-block;
}
.btn.radiobtn span.glyphicon-ok.blank {
opacity: 0; display: none;
}
.btn.radiobtn.active span.glyphicon-ok.blank {
opacity: 1; display: inline-block;
}
*/

/* Option 4*/
/*
.btn.radiobtn span.glyphicon-check.blank {
opacity: 0; display: none;
}
.btn.radiobtn.active span.glyphicon-check.blank {
opacity: 1; display: inline-block;
}
*/


/* http://bootsnipp.com/snippets/8deZ */


Expand Down Expand Up @@ -203,95 +312,3 @@
background: inherit;
left: 20px;
}


/* CSS icone btn */


.btn.radiobtn:focus {
outline: none !important;
}

.btn.radiobtn .radio-btn-icon-yes {
opacity: 0; display: none;
}
.btn.radiobtn.active .radio-btn-icon-yes {
opacity: 1; display: inline-block;
}

.btn.radiobtn.active .radio-btn-icon-no {
opacity: 0; display: none;
}
.btn.radiobtn .radio-btn-icon-no {
opacity: 1; display: inline-block;
}







/* Option 1 */
/*
.btn.radiobtn span.glyphicon-unchecked {
opacity: 1; display: inline-block;
}
.btn.radiobtn.active span.glyphicon-unchecked {
opacity: 1; display: none;
}

.btn.radiobtn span.glyphicon-check {
opacity: 1; display: none;
}
.btn.radiobtn.active span.glyphicon-check {
opacity: 1; display: inline-block;
}
*/



/* Option 2*/
/*
.btn.radiobtn span.glyphicon-remove {
opacity: 1; display: inline-block;
}
.btn.radiobtn.active span.glyphicon-remove {
opacity: 1; display: none;
}

.btn.radiobtn span.glyphicon-ok {
opacity: 1; display: none;
}
.btn.radiobtn.active span.glyphicon-ok {
opacity: 1; display: inline-block;
}
*/


/* Option 3*/
/*
.btn.radiobtn span.glyphicon-ok.blank.hide {
opacity: 0; display: none;
}
.btn.radiobtn.active span.glyphicon-ok.blank.hide {
opacity: 0; display: inline-block;
}
.btn.radiobtn span.glyphicon-ok.blank {
opacity: 0; display: none;
}
.btn.radiobtn.active span.glyphicon-ok.blank {
opacity: 1; display: inline-block;
}
*/

/* Option 4*/
/*
.btn.radiobtn span.glyphicon-check.blank {
opacity: 0; display: none;
}
.btn.radiobtn.active span.glyphicon-check.blank {
opacity: 1; display: inline-block;
}
*/

6 changes: 3 additions & 3 deletions inst/assets/uglify.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ bindings_files <- paste(unlist(bindings_files), collapse = "\n")
library("js")
bindings_files <- uglify_optimize(text = bindings_files)

writeLines(text = bindings_files, con = "inst/www/shinyWidgets-bindings.min.js")
writeLines(text = bindings_files, con = "inst/assets/shinyWidgets-bindings.min.js")



# css ----

# all files
css_files <- list.files(path = "inst/www/", pattern = "\\.css$", full.names = TRUE, recursive = TRUE)
css_files <- list.files(path = "inst/assets/", pattern = "\\.css$", full.names = TRUE, recursive = TRUE)

# keep the ones not integrated via a widgets
css_files <- css_files[
Expand All @@ -57,7 +57,7 @@ css_files <- lapply(css_files, paste, collapse = "\n")
css_files <- paste(unlist(css_files), collapse = "\n")

# write them all
writeLines(text = css_files, con = "inst/www/shinyWidgets.css")
writeLines(text = css_files, con = "inst/assets/shinyWidgets.css")

# go here to minify the file
# https://cssminifier.com/
Expand Down
4 changes: 4 additions & 0 deletions man/progress-bar.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/updateNumericInputIcon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions man/updateTextInputIcon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.