From c2002aac61bf1d7eddc3fb45927f4a81da8d49f5 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Thu, 12 Jan 2017 20:54:59 -0700 Subject: [PATCH 1/2] added description blocks --- NAMESPACE | 1 + R/boxes.R | 36 ++++++++++++++++++++++++++++++++++++ man/descriptionBlock.Rd | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 man/descriptionBlock.Rd 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..6bedada0 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("caret-up"), + 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}} +} + From 6ddf6c81c39db475b189119b858c9b8759115e31 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Thu, 12 Jan 2017 20:58:49 -0700 Subject: [PATCH 2/2] zap small icon bug --- R/boxes.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/boxes.R b/R/boxes.R index 6bedada0..db70db1e 100644 --- a/R/boxes.R +++ b/R/boxes.R @@ -60,7 +60,7 @@ descriptionBlock <- function(header, text, percentage, icon = 'caret-up', width boxContent <- div(class = paste0("description-block border-right"), span(class = paste0("description-percentage text-", color), - icon("caret-up"), + icon(icon), percentage), h5(header), span(class = 'description-text', text)