R/app_ui.R

Defines functions app_ui golem_add_external_resources

#' @importFrom shiny tags tagList fluidPage fluidRow conditionalPanel
app_ui <- function() {
  tags$body(
    fluidPage(
      class = "main-page",
      
      tagList(
        golem_add_external_resources()
      ),
      
      # Header:
      fluidRow(
        class = "header",
        
        # Main menu:
        tags$ul(
          class = "header-menu",
          id = "header-menu",
          tags$li(
            id = "btn-header-home",
            "Início"
          ),
          tags$li(
            id = "btn-header-plats",
            "Plataformas"
          )
        )
      ),
      
      # Content:
      fluidRow(
        class = "content",
        conditionalPanel(
          "document.getElementById('btn-header-plats').classList.contains('active') == true",
          mod_covid_ui("covid_ui_1"),
          id = "panel-test"
        )
      )
    ),
    
    # Including JS scripts:
    tags$script(type = "text/javascript", src = "www/resources/js/functions.js")
  )
}

#' @importFrom shiny addResourcePath htmlTemplate tags
#' @importFrom golem activate_js favicon
#' @importFrom shinyjs useShinyjs
golem_add_external_resources <- function(){
  addResourcePath('www', system.file('app/www', package = 'guaradash'))
  
  tags$head(
    # Activating some golem functionalities:
    activate_js(),
    favicon(ico = "www/favicon.ico",
            rel = "shortcut icon"),
    
    # Defining the usage of shinyjs for the app, so we can write JS in the Shiny back-end:
    useShinyjs(),
    
    # Loading our custom head.html file:
    htmlTemplate(system.file('app/www/resources/html/head.html',
                             package = 'guaradash'))
  )
}
guarastats/GuaraDash documentation built on March 31, 2020, 3:37 p.m.