Skip to content

Commit

Permalink
squash several last commits into one because there are just many of them
Browse files Browse the repository at this point in the history
  • Loading branch information
dmpe committed Mar 3, 2016
1 parent bc73dc9 commit 13ff71f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
19 changes: 12 additions & 7 deletions R/boxes.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ infoBox <- function(title, value = NULL, subtitle = NULL,
#' @param collapsed If TRUE, start collapsed. This must be used with
#' \code{collapsible=TRUE}.
#' @param ... Contents of the box.
#' @param wrench Adds a dropdown menu
#' @param wrench Adds a dropdown menu. By default it does not (false).
#' @param wrenchOptions Add menu items to the wrench icon. This must be used with
#' \code{wrench=TRUE}. Can be also a \code{list(...)} of \code{tags$li(...)}.
#'
#' @family boxes
#'
Expand Down Expand Up @@ -251,7 +253,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, wrench = FALSE, wrenchOptions = NULL) {
height = NULL, collapsible = FALSE, collapsed = FALSE,
wrench = FALSE, wrenchOptions = NULL) {

boxClass <- "box"
if (solidHeader || !is.null(background)) {
Expand Down Expand Up @@ -281,6 +284,8 @@ box <- function(..., title = NULL, footer = NULL, status = NULL,
}

boxToolsTag <- NULL
boxTools <- NULL

if (collapsible == TRUE || wrench == TRUE) {
boxToolsTag <- TRUE
} else {
Expand All @@ -296,29 +301,29 @@ box <- function(..., title = NULL, footer = NULL, status = NULL,
collapseIcon <- if (collapsed) "plus" else "minus"

if (collapsible == TRUE) {
collapseTag <- tags$button(class = paste0("btn btn-box-tool"), `data-widget` = "collapse", shiny::icon(collapseIcon))
collapseTag <- tags$button(class = paste0("btn btn-box-tool"),
`data-widget` = "collapse", shiny::icon(collapseIcon))
}

if (wrench == TRUE) {
wrenchTag <- div(class = paste0("btn-group"),
tags$button(class = "btn btn-box-tool dropdown-toggle", `type` = "button",
`data-toggle` = "dropdown", shiny::icon("wrench")),
tags$ul(class = "dropdown-menu", `role` = "menu", wrenchOptions)
## TODO: how to display them ?
)
}

boxToolsTag <- div(class = "box-tools pull-right",
boxTools <- div(class = "box-tools pull-right",
collapseTag,
wrenchTag
)
}

headerTag <- NULL
if (!is.null(titleTag) || !is.null(boxToolsTag)) {
if (!is.null(titleTag) || !is.null(boxTools)) {
headerTag <- div(class = "box-header",
titleTag,
boxToolsTag
boxTools
)
}

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.

2 changes: 1 addition & 1 deletion man/renderMenu.Rd

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

6 changes: 4 additions & 2 deletions tests-manual/box.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ body <- dashboardBody(
)
),
box(title = "Histogram box title",
status = "warning", solidHeader = TRUE, collapsible = F, wrench = T, wrenchOptions = tags$li(a(href="https://google.cz", "Click here!")),
status = "info", solidHeader = TRUE, collapsible = F, wrench = T,
wrenchOptions = list(tags$li(a(href="https://google.cz", "google czech",style="color: red", target="_blank")),
tags$li(a(href="https://www.polygon.com", "polygon!",style="color: yellow", target="_blank"))),
plotOutput("plot", height = 250)
)
),
Expand Down Expand Up @@ -165,7 +167,7 @@ header <- dashboardHeader(
shinyApp(
ui = dashboardPage(
header,
dashboardSidebar(),
dashboardSidebar(disable = T),
body
),
server = server
Expand Down

0 comments on commit 13ff71f

Please sign in to comment.