-
Notifications
You must be signed in to change notification settings - Fork 297
[WIP] progress bar in infoBox #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
543ee4d
53160e1
c8fe446
4613d28
c4b6eb9
f689436
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4, | |
|
||
#' Create an info box for the main body of a dashboard. | ||
#' | ||
#' An info box displays a large icon on the left side, and a title, value | ||
#' @description An info box displays a large icon on the left side, and a title, value | ||
#' (usually a number), and an optional smaller subtitle on the right side. Info | ||
#' boxes are meant to be placed in the main body of a dashboard. | ||
#' | ||
|
@@ -58,14 +58,15 @@ valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4, | |
#' content; the icon will use the same color with a slightly darkened | ||
#' background. | ||
#' @param href An optional URL to link to. | ||
#' @param progressValue Must be between 0 and 100. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to have a more detailed description of what this does. |
||
#' | ||
#' @family boxes | ||
#' @seealso \code{\link{box}} for usage examples. | ||
#' | ||
#' @export | ||
infoBox <- function(title, value = NULL, subtitle = NULL, | ||
icon = shiny::icon("bar-chart"), color = "aqua", width = 4, href = NULL, | ||
fill = FALSE) { | ||
fill = FALSE, progressValue = NULL) { | ||
|
||
validateColor(color) | ||
tagAssert(icon, type = "i") | ||
|
@@ -83,7 +84,8 @@ infoBox <- function(title, value = NULL, subtitle = NULL, | |
div(class = "info-box-content", | ||
span(class = "info-box-text", title), | ||
if (!is.null(value)) span(class = "info-box-number", value), | ||
if (!is.null(subtitle)) p(subtitle) | ||
if (!is.null(progressValue)) div(class = "progress", progressValue), | ||
if (!is.null(subtitle)) span(class = "progress-description", subtitle) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
) | ||
) | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
# A dashboard body with a row of infoBoxes and valueBoxes, and two rows of other boxes | ||
|
||
library(shiny) | ||
library(shinydashboard) | ||
|
||
body <- dashboardBody( | ||
|
||
# infoBoxes | ||
# infoBoxes -> first row | ||
fluidRow( | ||
infoBox( | ||
"Orders", uiOutput("orderNum2"), "Subtitle", icon = icon("credit-card") | ||
"Orders", uiOutput("orderNum2"), subtitle = "Test", icon = icon("credit-card"), | ||
fill = T, progressValue = uiOutput("progressBarValue") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I think it wouldn't really make sense for users to be able to enter in a numeric value when the value is static, but have to manually create a div for dynamic output here. Probably the best thing for users to do is dynamically output the entire |
||
), | ||
infoBox( | ||
"Approval Rating", "60%", icon = icon("line-chart"), color = "green", | ||
fill = TRUE | ||
"Approval Rating", "60%", icon = icon("line-chart"), color = "green", fill = TRUE | ||
), | ||
infoBox( | ||
"Progress", uiOutput("progress2"), icon = icon("users"), color = "purple" | ||
) | ||
), | ||
|
||
# valueBoxes | ||
# valueBoxes -> second row | ||
fluidRow( | ||
valueBox( | ||
uiOutput("orderNum"), "New Orders", icon = icon("credit-card"), | ||
|
@@ -90,6 +92,10 @@ server <- function(input, output) { | |
paste0(input$progress, "%") | ||
}) | ||
|
||
output$progressBarValue <- renderUI({ | ||
div(class = "progress-bar", style = paste0("width: ", input$progress, "%; height: 2px;")) | ||
}) | ||
|
||
output$status <- renderText({ | ||
paste0("There are ", input$orders, | ||
" orders, and so the current progress is ", input$progress, "%.") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change is unneeded.