brochure icon indicating copy to clipboard operation
brochure copied to clipboard

Bootswatch-themes per page don't get applied

Open WurmPeter opened this issue 3 years ago • 0 comments

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()
)

WurmPeter avatar Mar 22 '23 20:03 WurmPeter