Skip to content

Commit 06d00b4

Browse files
committed
add wrench to boxes
2 parents fc9413f + b22787f commit 06d00b4

File tree

7 files changed

+34
-42
lines changed

7 files changed

+34
-42
lines changed

R/boxes.R

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#'
1818
#' @export
1919
valueBox <- function(value, subtitle, icon = NULL, color = "aqua", width = 4,
20-
href = NULL)
21-
{
20+
href = NULL) {
2221
validateColor(color)
2322
if (!is.null(icon)) tagAssert(icon, type = "i")
2423

@@ -120,6 +119,7 @@ infoBox <- function(title, value = NULL, subtitle = NULL,
120119
#' @param collapsed If TRUE, start collapsed. This must be used with
121120
#' \code{collapsible=TRUE}.
122121
#' @param ... Contents of the box.
122+
#' @param wrench adds a dropdown menu
123123
#'
124124
#' @family boxes
125125
#'
@@ -250,7 +250,7 @@ infoBox <- function(title, value = NULL, subtitle = NULL,
250250
#' @export
251251
box <- function(..., title = NULL, footer = NULL, status = NULL,
252252
solidHeader = FALSE, background = NULL, width = 6,
253-
height = NULL, collapsible = FALSE, collapsed = FALSE) {
253+
height = NULL, collapsible = FALSE, collapsed = FALSE, wrench = FALSE) {
254254

255255
boxClass <- "box"
256256
if (solidHeader || !is.null(background)) {
@@ -263,6 +263,7 @@ box <- function(..., title = NULL, footer = NULL, status = NULL,
263263
if (collapsible && collapsed) {
264264
boxClass <- paste(boxClass, "collapsed-box")
265265
}
266+
266267
if (!is.null(background)) {
267268
validateColor(background)
268269
boxClass <- paste0(boxClass, " bg-", background)
@@ -279,24 +280,35 @@ box <- function(..., title = NULL, footer = NULL, status = NULL,
279280
}
280281

281282
collapseTag <- NULL
282-
if (collapsible) {
283+
wrenchTag <- NULL
284+
boxToolsTag <- NULL
285+
286+
if (collapsible == TRUE && wrench == TRUE) {
283287
buttonStatus <- status %OR% "default"
284288

285289
collapseIcon <- if (collapsed) "plus" else "minus"
286290

287-
collapseTag <- div(class = "box-tools pull-right",
288-
tags$button(class = paste0("btn btn-box-tool"),
289-
`data-widget` = "collapse",
290-
shiny::icon(collapseIcon)
291-
)
291+
collapseTag <- tags$button(class = paste0("btn btn-box-tool"), `data-widget` = "collapse", shiny::icon(collapseIcon))
292+
wrenchTag <- div(class = paste0("btn-group"),
293+
tags$button(class = "btn btn-box-tool dropdown-toggle", `type` = "button", `data-toggle` = "dropdown", shiny::icon("wrench")),
294+
tags$ul(class = "dropdown-menu", `role` = "menu")
295+
## todo vymyslet jak zaridit abych to pouzivatelne z UI
296+
)
297+
298+
boxToolsTag <- div(class = "box-tools pull-right",
299+
collapseTag,
300+
wrenchTag
292301
)
293302
}
294303

304+
305+
306+
295307
headerTag <- NULL
296308
if (!is.null(titleTag) || !is.null(collapseTag)) {
297309
headerTag <- div(class = "box-header",
298310
titleTag,
299-
collapseTag
311+
boxToolsTag
300312
)
301313
}
302314

@@ -368,8 +380,8 @@ box <- function(..., title = NULL, footer = NULL, status = NULL,
368380
#' }
369381
#' @export
370382
tabBox <- function(..., id = NULL, selected = NULL, title = NULL,
371-
width = 6, height = NULL, side = c("left", "right"))
372-
{
383+
width = 6, height = NULL, side = c("left", "right")) {
384+
373385
side <- match.arg(side)
374386

375387
# The content is basically a tabsetPanel with some custom modifications

man/box.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests-manual/box.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ body <- dashboardBody(
4242
)
4343
),
4444
box(title = "Histogram box title",
45-
status = "warning", solidHeader = TRUE, collapsible = TRUE,
45+
status = "warning", solidHeader = TRUE, collapsible = F, wrench = TRUE,
4646
plotOutput("plot", height = 250)
4747
)
4848
),

tests-manual/repro_issues_110.R renamed to tests-manual/repro_issues_110_94.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
## Tries to reproduce Github Issue: https://github.com/rstudio/shinydashboard/issues/110
1+
## Tries to reproduce Github Issue: https://github.com/rstudio/shinydashboard/issues/110 and 94
2+
23
library(shiny)
34
library(shinydashboard)
45

5-
header <- dashboardHeader(title = "Dashboard Demo")
6+
header <- dashboardHeader(
7+
##title = "Dashboard Demo"
8+
title = span(tagList(icon("diamond",class='fa-lg'), 'Icon not showing'))
9+
)
610

711
body <- dashboardBody()
812

tests-manual/repro_issues_17.R

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
<<<<<<< 7e2d8ee5ec2d42bdf67b396a36e9fce3ce73d0fb
2-
<<<<<<< 31102cf44a0361cb470aaa716f30397a926fddb3
31
## Tries to reproduce Github Issue: https://github.com/rstudio/shinydashboard/issues/17
42

5-
=======
6-
>>>>>>> e4c3bc1ef3418879040e39f52363c8e601b609cd
7-
=======
8-
if(interactive()){
9-
## Tries to reproduce Github Issue: https://github.com/rstudio/shinydashboard/issues/17
10-
>>>>>>> 228ee6faa3c1f4d6827a35be79a240b9027de4bd
113
library(shiny)
124
library(shinydashboard)
135

@@ -31,4 +23,3 @@ shinyApp(
3123
),
3224
server = server
3325
)
34-
}

tests-manual/repro_issues_42.R

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
<<<<<<< 7e2d8ee5ec2d42bdf67b396a36e9fce3ce73d0fb
2-
<<<<<<< 31102cf44a0361cb470aaa716f30397a926fddb3
31
## Tries to reproduce Github Issue: https://github.com/rstudio/shinydashboard/issues/42
42

5-
=======
6-
>>>>>>> e4c3bc1ef3418879040e39f52363c8e601b609cd
7-
=======
8-
if(interactive()) {
9-
## Tries to reproduce Github Issue: https://github.com/rstudio/shinydashboard/issues/42
10-
>>>>>>> 228ee6faa3c1f4d6827a35be79a240b9027de4bd
113
library(shiny)
124
library(shinydashboard)
135

@@ -49,4 +41,3 @@ server <- function(input, output) {
4941
}
5042

5143
shinyApp(ui, server)
52-
}

tests-manual/repro_issues_54.R

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
<<<<<<< 31102cf44a0361cb470aaa716f30397a926fddb3
21
## Tries to reproduce Github Issue: https://github.com/rstudio/shinydashboard/issues/54
3-
=======
4-
# Working example
5-
<<<<<<< 7e2d8ee5ec2d42bdf67b396a36e9fce3ce73d0fb
6-
>>>>>>> e4c3bc1ef3418879040e39f52363c8e601b609cd
7-
=======
8-
## Tries to reproduce Github Issue: https://github.com/rstudio/shinydashboard/issues/54
9-
>>>>>>> 228ee6faa3c1f4d6827a35be79a240b9027de4bd
102

113
# library(shiny)
124
# library(shinydashboard)

0 commit comments

Comments
 (0)