Skip to content

Commit

Permalink
add collapsible sidebar which is capable of showing only icons
Browse files Browse the repository at this point in the history
Addresses: rstudio#74
  • Loading branch information
dmpe authored and jackolney committed Apr 13, 2016
1 parent f689436 commit fddfdb1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
12 changes: 6 additions & 6 deletions R/dashboardHeader.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ dashboardHeader <- function(..., title = NULL, titleWidth = NULL, disable = FALS
#' @export
dropdownMenu <- function(...,
type = c("messages", "notifications", "tasks"),
badgeStatus = "primary", icon = NULL, .list = NULL)
{
badgeStatus = "primary", icon = NULL, .list = NULL) {

type <- match.arg(type)
if (!is.null(badgeStatus)) validateStatus(badgeStatus)
items <- c(list(...), .list)
Expand Down Expand Up @@ -220,8 +220,8 @@ dropdownMenu <- function(...,
#' @seealso \code{\link{dashboardHeader}} for example usage.
#' @export
messageItem <- function(from, message, icon = shiny::icon("user"), time = NULL,
href = NULL)
{
href = NULL) {

tagAssert(icon, type = "i")
if (is.null(href)) href <- "#"

Expand Down Expand Up @@ -250,8 +250,8 @@ messageItem <- function(from, message, icon = shiny::icon("user"), time = NULL,
#' @seealso \code{\link{dashboardHeader}} for example usage.
#' @export
notificationItem <- function(text, icon = shiny::icon("warning"),
status = "success", href = NULL)
{
status = "success", href = NULL) {

tagAssert(icon, type = "i")
validateStatus(status)
if (is.null(href)) href <- "#"
Expand Down
16 changes: 12 additions & 4 deletions R/dashboardPage.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#' provided, it will try to extract the title from the \code{dashboardHeader}.
#' @param skin A color theme. One of \code{"blue"}, \code{"black"},
#' \code{"purple"}, \code{"green"}, \code{"red"}, or \code{"yellow"}.
#' @param sideBarMini TRUE or FALSE (default). False collapses sidebar completly
#' while TRUE will show collapsed sidebar with icon(s). Title will, however,
#' not become responsive.
#'
#' @seealso \code{\link{dashboardHeader}}, \code{\link{dashboardSidebar}},
#' \code{\link{dashboardBody}}.
Expand All @@ -29,7 +32,7 @@
#' }
#' @export
dashboardPage <- function(header, sidebar, body, title = NULL,
skin = c("blue", "black", "purple", "green", "red", "yellow")) {
skin = c("blue", "black", "purple", "green", "red", "yellow"), sideBarMini = FALSE) {

tagAssert(header, type = "header", class = "main-header")
tagAssert(sidebar, type = "aside", class = "main-sidebar")
Expand All @@ -41,8 +44,8 @@ dashboardPage <- function(header, sidebar, body, title = NULL,
if (x$name == "span" &&
!is.null(x$attribs$class) &&
x$attribs$class == "logo" &&
length(x$children) != 0)
{
length(x$children) != 0) {

x$children[[1]]
} else {
""
Expand All @@ -57,8 +60,13 @@ dashboardPage <- function(header, sidebar, body, title = NULL,
body
)

sideBar <- NULL
if (sideBarMini == TRUE) {
sideBar <- " sidebar-mini"
}

addDeps(
tags$body(class = paste0("skin-", skin), style = "min-height: 611px;",
tags$body(class = paste0("skin-", skin, sideBar), style = "min-height: 611px;",
shiny::bootstrapPage(content, title = title)
)
)
Expand Down
5 changes: 2 additions & 3 deletions R/dashboardSidebar.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ dashboardSidebar <- function(..., disable = FALSE, width = NULL) {
custom_css,
tags$section(
class = "sidebar",
`data-disable` = if(disable) 1 else NULL,
`data-disable` = if(disable) TRUE else NULL,
list(...)
)
)
Expand Down Expand Up @@ -320,8 +320,7 @@ menuItem <- function(text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "gr
#' @rdname sidebarMenu
#' @export
menuSubItem <- function(text, tabName = NULL, href = NULL, newtab = TRUE,
icon = shiny::icon("angle-double-right"), selected = NULL)
{
icon = shiny::icon("angle-double-right"), selected = NULL) {

if (!is.null(href) && !is.null(tabName)) {
stop("Can't specify both href and tabName")
Expand Down
4 changes: 2 additions & 2 deletions inst/shinydashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ a > .info-box {
color: #333;
}

/* Disable bouncy transition for sidebar toggle. */
/* Disable bouncy transition for sidebar toggle.
.content-wrapper,
.right-side,
.main-footer {
Expand All @@ -74,7 +74,7 @@ a > .info-box {
-o-transition: all 0 none;
transition: none;
}

*/

/* Shiny Server Pro logout panel needs to be raised above menu bar */
.shiny-server-account {
Expand Down
6 changes: 5 additions & 1 deletion man/dashboardPage.Rd

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

0 comments on commit fddfdb1

Please sign in to comment.