Skip to content

Commit 7e7f2a1

Browse files
committed
Fourth attempt.
1 parent 06d00b4 commit 7e7f2a1

File tree

16 files changed

+153
-95
lines changed

16 files changed

+153
-95
lines changed

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ Depends:
1515
License: GPL-2 | file LICENSE
1616
Imports:
1717
utils,
18-
shiny (>= 0.12.2),
18+
shiny (>= 0.12.1),
1919
htmltools (>= 0.2.6)
2020
BugReports: https://github.com/rstudio/shinydashboard
2121
RoxygenNote: 5.0.1
22-

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(box)
4+
export(boxItem)
5+
export(boxMenuOutput)
46
export(dashboardBody)
57
export(dashboardHeader)
68
export(dashboardPage)

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ shinydashboard 0.5.1.9000
22
--------------------------------------------------------------------------------
33
* Updated to AdminLTE 2.3.2 (1ee281b).
44

5+
* Add wrench icon to the box-header (and a log more by using dropdown box-menu)
6+
57
shinydashboard 0.5.1
68
--------------------------------------------------------------------------------
79

R/boxes.R

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

@@ -118,8 +119,8 @@ infoBox <- function(title, value = NULL, subtitle = NULL,
118119
#' the user to collapse the box.
119120
#' @param collapsed If TRUE, start collapsed. This must be used with
120121
#' \code{collapsible=TRUE}.
121-
#' @param ... Contents of the box.
122-
#' @param wrench adds a dropdown menu
122+
#' @param ... Contents of the box/boxItem.
123+
#' @param boxMenu Adds a box menu consisting of \link{boxItem}.
123124
#'
124125
#' @family boxes
125126
#'
@@ -250,7 +251,8 @@ infoBox <- function(title, value = NULL, subtitle = NULL,
250251
#' @export
251252
box <- function(..., title = NULL, footer = NULL, status = NULL,
252253
solidHeader = FALSE, background = NULL, width = 6,
253-
height = NULL, collapsible = FALSE, collapsed = FALSE, wrench = FALSE) {
254+
height = NULL, collapsible = FALSE, collapsed = FALSE,
255+
boxMenu = NULL) {
254256

255257
boxClass <- "box"
256258
if (solidHeader || !is.null(background)) {
@@ -263,7 +265,6 @@ box <- function(..., title = NULL, footer = NULL, status = NULL,
263265
if (collapsible && collapsed) {
264266
boxClass <- paste(boxClass, "collapsed-box")
265267
}
266-
267268
if (!is.null(background)) {
268269
validateColor(background)
269270
boxClass <- paste0(boxClass, " bg-", background)
@@ -279,36 +280,26 @@ box <- function(..., title = NULL, footer = NULL, status = NULL,
279280
titleTag <- h3(class = "box-title", title)
280281
}
281282

283+
boxTools <- NULL
282284
collapseTag <- NULL
283-
wrenchTag <- NULL
284-
boxToolsTag <- NULL
285-
286-
if (collapsible == TRUE && wrench == TRUE) {
287-
buttonStatus <- status %OR% "default"
288285

286+
if (collapsible) {
289287
collapseIcon <- if (collapsed) "plus" else "minus"
290288

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
301-
)
289+
collapseTag <- tags$button(class = "btn btn-box-tool",
290+
`data-widget` = "collapse",
291+
shiny::icon(collapseIcon))
302292
}
303293

304-
305-
294+
if (!is.null(collapseTag) || !is.null(boxMenu)) {
295+
boxTools <- div(class = "box-tools pull-right", collapseTag, boxMenu)
296+
}
306297

307298
headerTag <- NULL
308-
if (!is.null(titleTag) || !is.null(collapseTag)) {
299+
if (!is.null(titleTag) || !is.null(boxTools)) {
309300
headerTag <- div(class = "box-header",
310301
titleTag,
311-
boxToolsTag
302+
boxTools
312303
)
313304
}
314305

@@ -322,6 +313,26 @@ box <- function(..., title = NULL, footer = NULL, status = NULL,
322313
)
323314
}
324315

316+
#' @inheritParams box
317+
#' @param icon Default icon (if boxMenu is used) is wrench
318+
#' @rdname box
319+
#' @export
320+
boxItem <- function(..., icon = shiny::icon("wrench")) {
321+
listOfValues <- list(...)
322+
# include each arg into <li> </li> tags
323+
listOfLi <- lapply(listOfValues, tags$li)
324+
325+
tags$div(class = "btn-group",
326+
tags$button(class = "btn btn-box-tool dropdown-toggle",
327+
`type` = "button",
328+
`data-toggle` = "dropdown",
329+
icon),
330+
tags$ul(class = "dropdown-menu",
331+
`role` = "menu",
332+
listOfLi)
333+
)
334+
}
335+
325336
#' Create a tabbed box
326337
#'
327338
#' @inheritParams shiny::tabsetPanel
@@ -380,8 +391,8 @@ box <- function(..., title = NULL, footer = NULL, status = NULL,
380391
#' }
381392
#' @export
382393
tabBox <- function(..., id = NULL, selected = NULL, title = NULL,
383-
width = 6, height = NULL, side = c("left", "right")) {
384-
394+
width = 6, height = NULL, side = c("left", "right"))
395+
{
385396
side <- match.arg(side)
386397

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

R/deps.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ addDeps <- function(x) {
2020
}
2121

2222
dashboardDeps <- list(
23-
htmlDependency("AdminLTE", "2.0.6",
23+
htmlDependency("AdminLTE", "2.3.2",
2424
c(file = system.file("AdminLTE", package = "shinydashboard")),
2525
script = adminLTE_js,
2626
stylesheet = adminLTE_css

R/menuOutput.R

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ menuOutput <- function(outputId, tag = tags$li) {
1919
}
2020

2121

22+
#' Create a sidebar menu item output (client side)
23+
#'
24+
#' This is the UI-side function for creating a dynamic sidebar menu item.
25+
#'
26+
#' @inheritParams menuOutput
27+
#' @family menu outputs
28+
#' @seealso \code{\link{renderMenu}} for the corresponding server-side function
29+
#' and examples, and \code{\link{menuItem}} for the corresponding function
30+
#' for generating static sidebar menus.
31+
#' @export
32+
menuItemOutput <- function(outputId) {
33+
menuOutput(outputId = outputId, tag = tags$li)
34+
}
35+
36+
2237
#' Create a dropdown menu output (client side)
2338
#'
2439
#' This is the UI-side function for creating a dynamic dropdown menu.
@@ -34,35 +49,35 @@ dropdownMenuOutput <- function(outputId) {
3449
}
3550

3651

37-
#' Create a sidebar menu output (client side)
52+
#' Create a dropdown box-menu output (client side)
3853
#'
39-
#' This is the UI-side function for creating a dynamic sidebar menu.
54+
#' This is the UI-side function for creating a dynamic dropdown box-menu.
4055
#'
4156
#' @inheritParams menuOutput
4257
#' @family menu outputs
4358
#' @seealso \code{\link{renderMenu}} for the corresponding server-side function
44-
#' and examples, and \code{\link{sidebarMenu}} for the corresponding function
45-
#' for generating static sidebar menus.
59+
#' and examples, and \code{\link{dropdownMenu}} for the corresponding function
60+
#' for generating static menus.
4661
#' @export
47-
sidebarMenuOutput <- function(outputId) {
48-
menuOutput(outputId = outputId, tag = tags$ul)
62+
boxMenuOutput <- function(outputId) {
63+
menuOutput(outputId = outputId, tag = tags$div)
4964
}
5065

51-
#' Create a sidebar menu item output (client side)
66+
67+
#' Create a sidebar menu output (client side)
5268
#'
53-
#' This is the UI-side function for creating a dynamic sidebar menu item.
69+
#' This is the UI-side function for creating a dynamic sidebar menu.
5470
#'
5571
#' @inheritParams menuOutput
5672
#' @family menu outputs
5773
#' @seealso \code{\link{renderMenu}} for the corresponding server-side function
58-
#' and examples, and \code{\link{menuItem}} for the corresponding function
74+
#' and examples, and \code{\link{sidebarMenu}} for the corresponding function
5975
#' for generating static sidebar menus.
6076
#' @export
61-
menuItemOutput <- function(outputId) {
62-
menuOutput(outputId = outputId, tag = tags$li)
77+
sidebarMenuOutput <- function(outputId) {
78+
menuOutput(outputId = outputId, tag = tags$ul)
6379
}
6480

65-
6681
#' Create dynamic menu output (server side)
6782
#'
6883
#' @inheritParams shiny::renderUI

man/box.Rd

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

man/boxMenuOutput.Rd

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dropdownMenuOutput.Rd

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

man/menuItemOutput.Rd

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

0 commit comments

Comments
 (0)