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

add scroll option to box #311

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
14 changes: 12 additions & 2 deletions R/boxes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion man/box.Rd

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