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

Bootswatch-themes per page don't get applied #54

Open
WurmPeter opened this issue Mar 22, 2023 · 0 comments
Open

Bootswatch-themes per page don't get applied #54

WurmPeter opened this issue Mar 22, 2023 · 0 comments

Comments

@WurmPeter
Copy link

Hello,

I created a brochure app that consists of several pages. In each page I set another bootswatch-theme and experience strange behaviour: I never know which theme I will see. In most cases I get any of the themes and all pages look the same (though they should look different).

This doesn't occur when brochureApp contains only one page.

Maybe related: It seems that not all sessions that these pages spawn are closed in RStudio when closing the window/interrupt R (red stop sign). I removed pages from the brochureApp function and they were still available next time I started the brochureApp.

Here is my code:

library(bslib)
library(shiny)
library(stringi) 

page_names <- list("Home", "App 1", "App 2")
lorem_ipsum_dolor_sit_amet <- HTML(paste0(stri_rand_lipsum(10), 
                                          collapse = '<br><br>'))


home <- function() {
  brochure::page(
    href = "/",
    ui <- 
      bslib::page_navbar(
      theme = bs_theme(version = 5, bootswatch = "quartz"),
      window_title = page_names[1],      
      selected = page_names[1], 
      bslib::nav(
        value = page_names[1],
        tags$a(img(src = "https://www.r-project.org/logo/Rlogo.svg", 
                   height = "50", width = "50"), href = "/"),
        fluidPage(  
          tags$h2("Choose..."),
          tags$ul(
            tags$li(
              tags$a(icon("star"), page_names[2], href = "/1")
            ),
            tags$li(
              tags$a(icon("heart"), page_names[3], href = "/2")
            )
          ) 
        )
      ),
      bslib::nav(
        value = page_names[2],
        tags$a(icon("star"), page_names[2], href = "/1")
      ),
      bslib::nav(
        value = page_names[3],
        tags$a(icon("heart"), page_names[3], href = "/2")
      )
    ),
    server <- function(input, output, session) {
    }
  )
}

page_1 <- function() {
  brochure::page(
    href = "/1",
    ui <- bslib::page_navbar( 
      theme = bs_theme(version = 5, bootswatch = "darkly"),
      window_title = page_names[2],
      selected = page_names[2],
      bslib::nav(
        value = page_names[1],
        tags$a(img(src = "https://www.r-project.org/logo/Rlogo.svg", 
                   height = "50", width = "50"), "", href = "/")
      ),
      bslib::nav(
        value = page_names[2],
        tags$a(icon("star"), page_names[2], href = "/1"),
        fluidPage( 
          tags$h2("About App 1"),
          lorem_ipsum_dolor_sit_amet 
        )
      ),
      bslib::nav(
        value = page_names[3],
        tags$a(icon("heart"), page_names[3], href = "/2")
      )
    ),
    server <- function(input, output, session) {
    }
  )
}

page_2 <- function() {
  brochure::page(
    href = "/2",
    ui <- bslib::page_navbar(
      theme = bs_theme(version = 5, bootswatch = "cyborg"),
      window_title = page_names[3],
      selected = page_names[3], 
      bslib::nav(
        value = page_names[1],
        tags$a(img(src = "https://www.r-project.org/logo/Rlogo.svg", 
                        height = "50", width = "50"), "", href = "/")
      ),
      bslib::nav(
        value = page_names[2],
        tags$a(icon("star"), page_names[2], href = "/1")
      ),
      bslib::nav(
        value = page_names[3],
        tags$a(icon("heart"), page_names[3], href = "/2"),
        fluidPage( 
          tags$h2("About App 2"),
          lorem_ipsum_dolor_sit_amet 
        )
      )
    ),
    server <- function(input, output, session) {
    }
  )
}

brochure::brochureApp(  
  home(),
  page_1(),
  page_2()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant