Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add collapsible sidebar which is capable of showing only icons #133

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ shinydashboard 0.5.1.9000
--------------------------------------------------------------------------------
* Updated to AdminLTE 2.3.2 (1ee281b).

* Adds collapsible sidebar which is capable of showing only icons (PR #133)

* Sidebar can animate into the page when clicked on the menu hide/show item
in the top header (#79)

shinydashboard 0.5.1
--------------------------------------------------------------------------------

Expand Down
9 changes: 7 additions & 2 deletions R/dashboardHeader.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#' will also be used as the title shown in the browser's title bar. If you
#' want that to be different from the text in the dashboard header bar, set
#' the \code{title} in \code{\link{dashboardPage}}.
#' @param shortTitle A short title for responsive dashboards. Only relevant if
#' \code{dashboardSidebar(sideBarMini = T)}
#' @param titleWidth The width of the title area. This must either be a number
#' which specifies the width in pixels, or a string that specifies the width
#' in CSS units.
Expand Down Expand Up @@ -86,7 +88,8 @@
#' )
#' }
#' @export
dashboardHeader <- function(..., title = NULL, titleWidth = NULL, disable = FALSE, .list = NULL) {
dashboardHeader <- function(..., title = NULL, shortTitle = NULL, titleWidth = NULL,
disable = FALSE, .list = NULL) {
items <- c(list(...), .list)
lapply(items, tagAssert, type = "li", class = "dropdown")

Expand Down Expand Up @@ -115,7 +118,9 @@ dashboardHeader <- function(..., title = NULL, titleWidth = NULL, disable = FALS
tags$header(class = "main-header",
custom_css,
style = if (disable) "display: none;",
span(class = "logo", title),
a(class = "logo",
span(class = "logo-lg", title),
span(class = "logo-mini", shortTitle)),
tags$nav(class = "navbar navbar-static-top", role = "navigation",
# Embed hidden icon so that we get the font-awesome dependency
span(shiny::icon("bars"), style = "display:none;"),
Expand Down
9 changes: 7 additions & 2 deletions R/dashboardSidebar.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#' @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 sideBarMini TRUE or FALSE (default). False collapses sidebar completly
#' while TRUE will show collapsed sidebar with icon(s). Use
#' \code{dashboardHeader(shortTitle = "DB Demo")} for responsive title.
#'
#' @seealso \code{\link{sidebarMenu}}
#'
Expand Down Expand Up @@ -59,7 +62,8 @@
#' )
#' }
#' @export
dashboardSidebar <- function(..., disable = FALSE, width = NULL) {
dashboardSidebar <- function(..., disable = FALSE, width = NULL,
sideBarMini = FALSE) {
width <- validateCssUnit(width)

# Set up custom CSS for custom width
Expand Down Expand Up @@ -117,7 +121,8 @@ dashboardSidebar <- function(..., disable = FALSE, width = NULL) {
custom_css,
tags$section(
class = "sidebar",
`data-disable` = if(disable) 1 else NULL,
`data-disable` = if (disable) 1 else NULL,
`data-minify` = if (sideBarMini) 1 else NULL,
list(...)
)
)
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it adresses #79 which I included because it made sense to me (at that time at least). Sorry forgot to mention it. Should (Can) I open a new PR for it ?

.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
4 changes: 4 additions & 0 deletions inst/shinydashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ $(function() {
$(".navbar > .sidebar-toggle").hide();
}

// Optionally display only sidebar icons
if ($("section.sidebar").data("minify")) {
$("body").addClass("sidebar-mini sidebar-collapse");
}

// menuOutputBinding
// ------------------------------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions man/dashboardHeader.Rd

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

6 changes: 5 additions & 1 deletion man/dashboardSidebar.Rd

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