From 716eca3dca111771ae31952e3c94142bb4feb0b6 Mon Sep 17 00:00:00 2001 From: Tyler Bradley Date: Tue, 12 Feb 2019 11:08:01 -0500 Subject: [PATCH 1/2] added option to create a box that allows scrolling if a height is specified --- R/boxes.R | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/R/boxes.R b/R/boxes.R index 4f287ec9..354a93e1 100644 --- a/R/boxes.R +++ b/R/boxes.R @@ -119,6 +119,8 @@ infoBox <- function(title, value = NULL, subtitle = NULL, #' the user to collapse the box. #' @param collapsed If TRUE, start collapsed. This must be used with #' \code{collapsible=TRUE}. +#' @param scroll If TRUE and height is specified the box includes a scroll bar and +#' will allow vertical scroll if contents exceeds height of box #' @param ... Contents of the box. #' #' @family boxes @@ -250,7 +252,8 @@ infoBox <- function(title, value = NULL, subtitle = NULL, #' @export box <- function(..., title = NULL, footer = NULL, status = NULL, solidHeader = FALSE, background = NULL, width = 6, - height = NULL, collapsible = FALSE, collapsed = FALSE) { + height = NULL, collapsible = FALSE, collapsed = FALSE, + scroll = FALSE) { boxClass <- "box" if (solidHeader || !is.null(background)) { @@ -267,10 +270,17 @@ box <- function(..., title = NULL, footer = NULL, status = NULL, validateColor(background) boxClass <- paste0(boxClass, " bg-", background) } + if (scroll & !is.null(height)){ + boxClass <- paste(boxClass, "scroll-box") + } style <- NULL if (!is.null(height)) { - style <- paste0("height: ", validateCssUnit(height)) + style <- paste0("height: ", validateCssUnit(height), ";") + + if (scroll){ + style <- paste0(style, "overflow-y: scroll;") + } } titleTag <- NULL From 6c640c3b2151da802ca6696fb46c0e15169b64b6 Mon Sep 17 00:00:00 2001 From: Tyler Bradley Date: Tue, 12 Feb 2019 13:31:14 -0500 Subject: [PATCH 2/2] updated docs for box --- man/box.Rd | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/man/box.Rd b/man/box.Rd index d1064b1c..67e66824 100644 --- a/man/box.Rd +++ b/man/box.Rd @@ -6,7 +6,7 @@ \usage{ box(..., title = NULL, footer = NULL, status = NULL, solidHeader = FALSE, background = NULL, width = 6, height = NULL, - collapsible = FALSE, collapsed = FALSE) + collapsible = FALSE, collapsed = FALSE, scroll = FALSE) } \arguments{ \item{...}{Contents of the box.} @@ -38,6 +38,9 @@ the user to collapse the box.} \item{collapsed}{If TRUE, start collapsed. This must be used with \code{collapsible=TRUE}.} + +\item{scroll}{If TRUE and height is specified the box includes a scroll bar and +will allow vertical scroll if contents exceeds height of box} } \description{ Boxes can be used to hold content in the main body of a dashboard.