Skip to content
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

added description blocks #174

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export(dashboardBody)
export(dashboardHeader)
export(dashboardPage)
export(dashboardSidebar)
export(descriptionBlock)
export(dropdownMenu)
export(dropdownMenuOutput)
export(infoBox)
Expand Down
36 changes: 36 additions & 0 deletions R/boxes.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,42 @@ valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4,
)
}

#' Create a description block for the main body of a dashboard.
#'
#'
#' @inheritParams box
#' @param header The header to display in the box. Usually a number or short text.
#' @param text Subtitle text.
#' @param percentage percentage to appear in description
#' @param icon An icon tag, created by \code{\link[shiny]{icon}}.
#' @param color A color for the box. Valid colors are listed in
#' \link{validColors}.
#' @param href An optional URL to link to.
#'
#' @family boxes
#' @seealso \code{\link{box}} for usage examples.
#'
#' @export
descriptionBlock <- function(header, text, percentage, icon = 'caret-up', width = 4, href = NULL, color = 'green')
{
validateColor(color)

boxContent <- div(class = paste0("description-block border-right"),
span(class = paste0("description-percentage text-", color),
icon(icon),
percentage),
h5(header),
span(class = 'description-text', text)
)

if (!is.null(href))
boxContent <- a(href = href, boxContent)

div(class = if (!is.null(width)) paste0("col-sm-", width),
boxContent
)
}


#' Create an info box for the main body of a dashboard.
#'
Expand Down
39 changes: 39 additions & 0 deletions man/descriptionBlock.Rd

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