TuSKan / materializer

Materialize for Shiny - A modern responsive front-end framework based on Material Design for Shiny

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

renderUI issue with material_tabs

nali-raz opened this issue · comments

Hello,

First I'd like to thank you for this great package.

However, maybe I've missed out something, but while using material_tabs inside renderUI, I'm facing issues.
Here's a minimal code example for my app.

library(shiny)
library(materializer)
library(shinyauthr)


user_base <- data.frame(
  user = c("user1", "user2"),
  password = c("pass1", "pass2"), 
  permissions = c("admin", "standard"),
  name = c("User One", "User Two")
)
## ui.R
# Wrap materialize apps in material_page
ui <- material_body(
  title = "Basic Page",
  # must turn shinyjs on
  shinyjs::useShinyjs(),
  # add logout button UI
  div(class = "right-align", shinyauthr::logoutUI(id = "logout")),
  # add login panel UI function
  shinyauthr::loginUI(id = "login"),
  uiOutput("tabs")
)
## server.UI

server <- function(input, output, session) {
  # call the logout module with reactive trigger to hide/show
  logout_init <- callModule(shinyauthr::logout, 
                            id = "logout", 
                            active = reactive(credentials()$user_auth))
  
  # call login module supplying data frame, user and password cols
  # and reactive trigger
  credentials <- callModule(shinyauthr::login, 
                            id = "login", 
                            data = user_base,
                            user_col = user,
                            pwd_col = password,
                            log_out = reactive(logout_init()))
  
  # pulls out the user information returned from login module
  user_data <- reactive({credentials()$info})

output$tabs <- renderUI({
  material_tabs(
        active = "test",
        tabs = c(
          "Global" = "global",
          "Analysis" = "analysis",
          "Data" = "data"
        ),
        material_tab_content(
          inputId = "global",
          material_card(
            title = "Global tab",
            shiny::h5("Global Tab"),
            footer = hr()
          )
        ),
        material_tab_content(
          inputId = "analysis",
          material_card(
            title = "Global tab",
            shiny::h5("Analysis Tab"),
            footer = hr()
          )
        ),
        material_tab_content(
          inputId = "data",
          shiny::h5("Data Tab")
        )
      )
})
}

Thanks in advance.

Try the same of #2