Skip to content

Commit

Permalink
added collapsed argument to dashboardSidebar() that allows it to st…
Browse files Browse the repository at this point in the history
…art off collapsed (fixes #73)
  • Loading branch information
bborgesr committed Feb 20, 2017
1 parent 79f5039 commit 48bf995
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion R/dashboardPage.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ dashboardPage <- function(header, sidebar, body, title = NULL,
body
)

collapsed <- "start-collapsed" %in% strsplit(sidebar$attribs$class, " ")[[1]]

addDeps(
tags$body(class = paste0("skin-", skin), style = "min-height: 611px;",
tags$body(
class = paste0("skin-", skin, if (collapsed) " sidebar-collapse"),
style = "min-height: 611px;",
shiny::bootstrapPage(content, title = title)
)
)
Expand Down
7 changes: 4 additions & 3 deletions R/dashboardSidebar.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' @param width The width of the sidebar. This must either be a number which
#' specifies the width in pixels, or a string that specifies the width in CSS
#' units.
#' @param collapsed If \code{TRUE}, the sidebar will be collapsed on app startup.
#'
#' @seealso \code{\link{sidebarMenu}}
#'
Expand Down Expand Up @@ -59,7 +60,7 @@
#' )
#' }
#' @export
dashboardSidebar <- function(..., disable = FALSE, width = NULL) {
dashboardSidebar <- function(..., disable = FALSE, width = NULL, collapsed = FALSE) {
width <- validateCssUnit(width)

# Set up custom CSS for custom width
Expand Down Expand Up @@ -113,11 +114,11 @@ dashboardSidebar <- function(..., disable = FALSE, width = NULL) {
'))))
}

tags$aside(class = "main-sidebar",
tags$aside(class = paste("main-sidebar", if (collapsed) "start-collapsed"),
custom_css,
tags$section(
class = "sidebar",
`data-disable` = if(disable) 1 else NULL,
`data-disable` = if (disable) 1 else NULL,
list(...)
)
)
Expand Down
4 changes: 3 additions & 1 deletion man/dashboardSidebar.Rd

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

0 comments on commit 48bf995

Please sign in to comment.