From 9fcb56abb1f9885a0a9e50f505b9d5a146e12836 Mon Sep 17 00:00:00 2001 From: detule Date: Sat, 25 Feb 2017 11:37:03 -0500 Subject: [PATCH 1/2] sidebar: Ability to minimize (rather than collapse entirely) --- R/dashboardPage.R | 5 ++++- R/dashboardSidebar.R | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/R/dashboardPage.R b/R/dashboardPage.R index e35c9eca..8ef8f6b5 100644 --- a/R/dashboardPage.R +++ b/R/dashboardPage.R @@ -60,12 +60,15 @@ dashboardPage <- function(header, sidebar, body, title = NULL, # if the sidebar has the attribute `data-collapsed = "true"`, it means that # the user set the `collapsed` argument of `dashboardSidebar` to TRUE collapsed <- findAttribute(sidebar, "data-collapsed", "true") + mini <- findAttribute(sidebar, "data-mini", "true") addDeps( tags$body( # the "sidebar-collapse" class on the body means that the sidebar should # the collapsed (AdminLTE code) - class = paste0("skin-", skin, if (collapsed) " sidebar-collapse"), + class = paste0("skin-", skin + ,if (collapsed) " sidebar-collapse" + ,if (mini) " sidebar-mini"), style = "min-height: 611px;", shiny::bootstrapPage(content, title = title) ) diff --git a/R/dashboardSidebar.R b/R/dashboardSidebar.R index 4cb17764..d5e1640d 100644 --- a/R/dashboardSidebar.R +++ b/R/dashboardSidebar.R @@ -9,6 +9,9 @@ #' 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. +#' @param mini If \code{TRUE}, when collapsing the sidebar a thin ribon will +#' remain alowing the user to navigate using a minified version of the +#' menues in the sidebar. #' #' @seealso \code{\link{sidebarMenu}} #' @@ -60,7 +63,7 @@ #' ) #' } #' @export -dashboardSidebar <- function(..., disable = FALSE, width = NULL, collapsed = FALSE) { +dashboardSidebar <- function(..., disable = FALSE, width = NULL, collapsed = FALSE, mini = FALSE) { width <- validateCssUnit(width) # Set up custom CSS for custom width @@ -120,18 +123,24 @@ dashboardSidebar <- function(..., disable = FALSE, width = NULL, collapsed = FAL # If we're restoring a bookmarked app, this holds the value of whether or not the # sidebar was collapsed. If this is not the case, the default is whatever the user # specified in the `collapsed` argument. - dataValue <- shiny::restoreInput(id = "sidebarCollapsed", default = collapsed) - if (disable) dataValue <- TRUE # this is a workaround to fix #209 - dataValueString <- if (dataValue) "true" else "false" + dataCollapsedValue <- shiny::restoreInput(id = "sidebarCollapsed", default = collapsed) + if (disable) dataCollapsedValue <- TRUE # this is a workaround to fix #209 + dataCollapsedValueString <- if (dataCollapsedValue) "true" else "false" + dataMiniValue <- shiny::restoreInput(id = "sidebarMini", default = mini) + dataMiniValueString <- if (dataMiniValue) "true" else "false" # The expanded/collapsed state of the sidebar is actually set by adding a # class to the body (not to the sidebar). However, it makes sense for the # `collapsed` argument to belong in this function. So this information is # just passed through (as the `data-collapsed` attribute) to the - # `dashboardPage()` function + # `dashboardPage()` function. A similar argument applies to the `mini` + # parameter. tags$aside( id = "sidebarCollapsed", - class = "main-sidebar", `data-collapsed` = dataValueString, custom_css, + class = "main-sidebar", + `data-collapsed` = dataCollapsedValueString, + `data-mini` = dataMiniValueString, + custom_css, tags$section( id = "sidebarItemExpanded", class = "sidebar", From eec01566fa8798879b75ad7a7f001b6955065dac Mon Sep 17 00:00:00 2001 From: detule Date: Mon, 20 May 2019 09:36:32 -0400 Subject: [PATCH 2/2] sidebar: roxygenize to document `mini` parameter --- man/dashboardSidebar.Rd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/man/dashboardSidebar.Rd b/man/dashboardSidebar.Rd index 20aa54ed..9db65e2c 100644 --- a/man/dashboardSidebar.Rd +++ b/man/dashboardSidebar.Rd @@ -4,7 +4,8 @@ \alias{dashboardSidebar} \title{Create a dashboard sidebar.} \usage{ -dashboardSidebar(..., disable = FALSE, width = NULL, collapsed = FALSE) +dashboardSidebar(..., disable = FALSE, width = NULL, collapsed = FALSE, + mini = FALSE) } \arguments{ \item{...}{Items to put in the sidebar.} @@ -16,6 +17,10 @@ specifies the width in pixels, or a string that specifies the width in CSS units.} \item{collapsed}{If \code{TRUE}, the sidebar will be collapsed on app startup.} + +\item{mini}{If \code{TRUE}, when collapsing the sidebar a thin ribon will +remain alowing the user to navigate using a minified version of the +menues in the sidebar.} } \description{ A dashboard sidebar typically contains a \code{\link{sidebarMenu}}, although