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 1 commit
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
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,
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, this should be a 1 because that's what's expected by AdminLTE. Also, TRUE is not particularly meaningful in HTML. For example,

> tags$section(`foo`=TRUE)
<section foo="TRUE"></section>

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.
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
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.