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 expandHeader func to add left menu of header (in-progress) #24

Open
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Description: This is a package to collect essential modules and useful functions
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.2
RoxygenNote: 7.2.1
Imports:
shiny,
shinydashboard,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(arrowButton)
export(dcaFooter)
export(dca_waiter)
export(drop_empty)
export(expandHeader)
export(get_tab_names)
export(insert_attr_box)
export(mediaButton)
Expand Down
31 changes: 31 additions & 0 deletions R/expand_header.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#' Expand dashboardheader
#'
#' @description Expand the ui to \code{dashboardheader}.
#' @param header \code{dashboardheader}.
#' @param left The left menu in the header.
#' @examples
#' if (interactive()) {
#' library(shinydashboard)
#' dashboardheader() %>%
#' expandHeader()
#' )
#' }
#' @rdname expandHeader
#' @export
expandHeader <- function(.header, left = NULL) {
header <- htmltools::as.tags(.header)
nav_index <- which(as.character(sapply(header$children, `[[`, 1)) == "nav")

if (!is.null(left)) {
left_menu <- shiny::tags$div(
class = "navbar-custom-menu left",
style = "float: left; margin-left: 10px;",
shiny::tags$ul(
class = "nav navbar-nav",
left
)
)
header$children[[nav_index]] <- htmltools::tagInsertChildren(header$children[[nav_index]], after = 2, left_menu)
}
return(header)
}
2 changes: 1 addition & 1 deletion inst/examples/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ui <- dashboardPage(
)
),
palettePanelUI("palette-panel")
),
) %>% expandHeader(left = actionButton("test-left", "Test")),
dashboardSidebar(
sidebarMenu(
id = "tabs",
Expand Down
24 changes: 24 additions & 0 deletions man/expandHeader.Rd

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