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

default view does not get hidden by default #77

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 16 additions & 4 deletions R/router.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,30 @@ ROUTER_UI_ID <- '_router_ui'
#' with 'router-hidden' class is added.
#'
#' @param ui Single page UI content created with proper html tags or tag list.
#' @param path Single page path name. Attached to \code{data-path} attriubute.
attach_attribs <- function(ui, path) {
#' @param path Single page path name. Attached to \code{data-path} attribute.
#' @param not_hidden character with default page that is not hidden by default.
#' this can be controlled globally by option \code{router_default_display} set
#' to the default view of the app.
attach_attribs <- function(ui, path, not_hidden = "/") {
option_not_hidden <- getOption("router_default_display")
if (!is.null(option_not_hidden))
not_hidden <- option_not_hidden
if ("shiny.tag" %in% class(ui)) {
# make pages identification easier
ui$attribs$`data-path` <- path
ui$attribs$class <- paste("router router-hidden", ui$attribs$class)
if (path == not_hidden)
ui$attribs$class <- paste("router", ui$attribs$class)
else
ui$attribs$class <- paste("router router-hidden", ui$attribs$class)
}
if ("shiny.tag.list" %in% class(ui)) {
# make pages identification easier
container <- shiny::div(ui)
container$attribs$`data-path` <- path
container$attribs$class <- "router router-hidden"
if (path == not_hidden)
container$attribs$class <- "router"
else
container$attribs$class <- "router router-hidden"
ui <- container
}
ui
Expand Down