ui <- page_navbar( id = "main_nav", theme = bs_theme(version = 5, bootswatch = "cosmo"), title = "WMO Normals Explorer", navbar_options = navbar_options(collapsible = TRUE), header = tagList( tags$head( # If you have shinyjs installed, you can uncomment this: # shinyjs::useShinyjs(), tags$link(rel = "stylesheet", type = "text/css", href = "custom.css?v=1.1"), tags$script(src = "fullscreen.js"), tags$script(src = "app.js?v=1.1") ), # Frozen overlay div (startup loading spinner) div( class = "frozen-overlay", div( class = "frozen-overlay-content", div(class = "spinner-border text-primary", role = "status"), p(class = "frozen-overlay-message", "Loading stations...") ) ) ), fillable_mobile = TRUE, sidebar = sidebar( title = "Filters", open = list(desktop = "open", mobile = "closed"), # Normals Period Filter div( style = "display: flex; align-items: center; gap: 8px;", tags$label("Select Normals Period", `for` = "normals_period"), tooltip( bsicons::bs_icon("info-circle", size = "1em"), "Choose the 30-year WMO Climatological Normal baseline period (e.g. 1991–2020, 1981–2010, 1961–1990)." ) ), selectInput("normals_period", label = NULL, choices = NORMALS_PERIOD_CHOICES, selected = "1991-2020"), # Parameter Filter div( style = "display: flex; align-items: center; gap: 8px;", tags$label("Select Parameter", `for` = "parameter"), tooltip( bsicons::bs_icon("info-circle", size = "1em"), "Choose the climate variable to display on the map (e.g. temperature, precipitation, pressure)." ) ), selectInput("parameter", label = NULL, choices = c( "Mean Temperature" = "TAVG", "Max Temperature" = "TMAX", "Min Temperature" = "TMIN", "Precipitation" = "PRCP", "Precipitation Days (>= 1mm)" = "DP01", "Mean Sea Level Pressure" = "MSLP", "Mean Vapor Pressure" = "MNVP", "Sunshine Duration" = "TSUN" ), selected = "TAVG"), # Time Period Filter (Month / Annual) div( style = "display: flex; align-items: center; gap: 8px;", tags$label("Select Month / Annual", `for` = "time_period"), tooltip( bsicons::bs_icon("info-circle", size = "1em"), "Select a month or Annual to view the corresponding climatological normal value." ) ), selectInput("time_period", label = NULL, choices = c("Annual", month.abb), selected = "Annual"), # Country Filter div( style = "display: flex; align-items: center; gap: 8px;", tags$label("Select Country", `for` = "country"), tooltip( bsicons::bs_icon("info-circle", size = "1em"), "Filter stations by country. Select 'All Countries' to show all stations worldwide." ) ), selectInput("country", label = NULL, choices = c("All Countries" = "All", countries_list), selected = "All"), # Station Filter dynamically updated div( style = "display: flex; align-items: center; gap: 8px;", tags$label("Select Station", `for` = "station"), tooltip( bsicons::bs_icon("info-circle", size = "1em"), "Pick a specific station to zoom in and view its full dashboard with climate normals." ) ), selectInput("station", label = NULL, choices = c("All Stations" = "All"), selected = "All"), conditionalPanel( condition = "input.station && input.station !== 'All'", div( class = "mt-1 mb-2", actionButton( "clear_station_sidebar", label = span(bsicons::bs_icon("x-circle-fill", class = "me-1"), "Deselect Station"), class = "sidebar-station-clear-btn", onclick = "Shiny.setInputValue('clear_station_sidebar', Date.now(), {priority: 'event'});" ) ) ), hr(), uiOutput("dataset_info_box"), hr(), tags$small("Tip: Click map points to view detailed weather plots.") ), nav_panel( title = "Map View", div( style = "position: relative; height: 100%; width: 100%;", maplibreOutput("station_map", width = "100%", height = "100%"), # Floating Station Chip absolutePanel( id = "station_chip_panel", top = 15, left = 60, style = "z-index: 1000; pointer-events: none;", uiOutput("station_chip_ui") ), # Layer Control Panel (Collapsible) absolutePanel( top = 130, left = 10, right = "auto", class = "map-layer-control", style = "z-index: 1000;", div(class = "control-icon", icon("layer-group")), div( class = "control-content", radioButtons( inputId = "basemap", label = "Basemap", choices = c( "OpenFreeMap Positron" = "ofm_positron", "OpenFreeMap Bright" = "ofm_bright", "Satellite (Sentinel-2)" = "sentinel" ), selected = "ofm_positron" ), hr(style = "margin: 8px 0;"), checkboxInput( inputId = "show_labels", label = "Show Labels", value = TRUE ) ) ), # Home Button Overlay absolutePanel( id = "zoom_home_panel", top = 80, left = 10, right = "auto", actionButton("home_zoom", bsicons::bs_icon("house-fill"), class = "btn-home", title = "Zoom to home") ), # Map Legend uiOutput("map_legend") ) ), nav_panel( title = "Dashboard", div( class = "container-fluid", style = "padding: 20px;", uiOutput("dashboard_header"), hr(), DT::DTOutput("dashboard_data"), div( style = "margin-top: 20px; margin-bottom: 20px;", uiOutput("plots_grid") ) ) ), nav_spacer(), nav_item( tooltip( tags$a( id = "fullscreen_toggle", href = "#", onclick = "toggleFullScreen(); return false;", style = "display: flex; align-items: center; color: rgba(0,0,0,0.55); padding: 0.5rem 1rem; text-decoration: none;", bsicons::bs_icon("arrows-fullscreen", size = "1.2rem") ), "Toggle Fullscreen", placement = "bottom" ) ) )