diff --git a/NAMESPACE b/NAMESPACE index d3773d32..5aee58a4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ export(dashboardBody) export(dashboardHeader) export(dashboardPage) export(dashboardSidebar) +export(descriptionBlock) export(dropdownMenu) export(dropdownMenuOutput) export(infoBox) diff --git a/R/boxes.R b/R/boxes.R index 4f287ec9..db70db1e 100644 --- a/R/boxes.R +++ b/R/boxes.R @@ -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. #' diff --git a/man/descriptionBlock.Rd b/man/descriptionBlock.Rd new file mode 100644 index 00000000..b4815c6b --- /dev/null +++ b/man/descriptionBlock.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/boxes.R +\name{descriptionBlock} +\alias{descriptionBlock} +\title{Create a description block for the main body of a dashboard.} +\usage{ +descriptionBlock(header, text, percentage, icon = NULL, width = 4, + href = NULL, color = "green") +} +\arguments{ +\item{header}{The header to display in the box. Usually a number or short text.} + +\item{text}{Subtitle text.} + +\item{percentage}{percentage to appear in description} + +\item{icon}{An icon tag, created by \code{\link[shiny]{icon}}.} + +\item{width}{The width of the box, using the Bootstrap grid system. This is +used for row-based layouts. The overall width of a region is 12, so the +default valueBox width of 4 occupies 1/3 of that width. For column-based +layouts, use \code{NULL} for the width; the width is set by the column that +contains the box.} + +\item{href}{An optional URL to link to.} + +\item{color}{A color for the box. Valid colors are listed in +\link{validColors}.} +} +\description{ +Create a description block for the main body of a dashboard. +} +\seealso{ +\code{\link{box}} for usage examples. + +Other boxes: \code{\link{box}}, \code{\link{infoBox}}, + \code{\link{tabBox}}, \code{\link{valueBox}} +} +