-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
327 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
|
||
# ------------------------------------------------------------------------ | ||
# | ||
# Title : Shiny App UI | ||
# By : Jimmy Briggs | ||
# Date : 2024-11-08 | ||
# | ||
# ------------------------------------------------------------------------ | ||
|
||
|
||
# internal ---------------------------------------------------------------- | ||
|
||
add_external_resources <- function() { | ||
shiny::addResourcePath( | ||
"www", | ||
system.file("www", package = "gmhdatahub") | ||
) | ||
|
||
htmltools::tags$head( | ||
htmltools::tags$link( | ||
rel = "shortcut icon", | ||
type = "image/x-icon", | ||
href = "www/favicon.ico" | ||
), | ||
golem::bundle_resources( | ||
path = system.file("www", package = "gmhdatahub"), | ||
app_title = "gmhdatahub" | ||
), | ||
shinyjs::useShinyjs(), | ||
waiter::use_waiter() | ||
) | ||
} | ||
|
||
# UI ---------------------------------------------------------------------- | ||
|
||
app_ui <- function(req) { | ||
|
||
force(req) | ||
|
||
htmltools::tagList( | ||
add_external_resources(), | ||
bslib::page_navbar( | ||
id = "nav", | ||
lang = "en", | ||
window_title = "GMH DataHub", | ||
theme = bslib::bs_theme(version = 5), | ||
title = mod_title_ui("app"), | ||
footer = mod_footer_ui("app"), | ||
sidebar = mod_sidebar_ui("app"), | ||
bslib::nav_panel( | ||
title = "Home", | ||
value = "home", | ||
icon = shiny::icon("home")#, | ||
# mod_home_ui("app") | ||
), | ||
bslib::nav_panel( | ||
title = "Data", | ||
value = "data", | ||
icon = shiny::icon("database")#, | ||
# mod_data_ui("app") | ||
), | ||
bslib::nav_panel( | ||
title = "Analysis", | ||
value = "analysis", | ||
icon = shiny::icon("chart-line")#, | ||
# mod_analysis_ui("app") | ||
), | ||
bslib::nav_spacer(), | ||
bslib::nav_menu( | ||
title = "Links", | ||
align = "right", | ||
bslib::nav_item( | ||
htmltools::tags$a( | ||
shiny::icon("github"), "GitHub", | ||
href = .app_info$repo_url, | ||
target = "_blank" | ||
) | ||
), | ||
bslib::nav_item( | ||
htmltools::tags$a( | ||
shiny::icon("book"), "Documentation", | ||
href = .app_info$docs_url, | ||
target = "_blank" | ||
) | ||
), | ||
bslib::nav_item( | ||
htmltools::tags$a( | ||
shiny::icon("envelope"), "Contact", | ||
href = "#", | ||
target = "_blank" | ||
) | ||
) | ||
), | ||
bslib::nav_menu( | ||
title = "Logout", | ||
align = "right", | ||
bslib::nav_item( | ||
htmltools::tags$a( | ||
shiny::icon("sign-out-alt"), "Logout", | ||
href = "#", | ||
target = "_blank" | ||
) | ||
) | ||
) | ||
) | ||
) | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
|
||
# ------------------------------------------------------------------------ | ||
# | ||
# Title : App Sidebar Module | ||
# By : Jimmy Briggs | ||
# Date : 2024-11-08 | ||
# | ||
# ------------------------------------------------------------------------ | ||
|
||
.app_choices <- list( | ||
properties = c("Property 1", "Property 2", "Property 3", "Property 4") | ||
) | ||
|
||
# topic ------------------------------------------------------------------- | ||
|
||
#' App Sidebar Module | ||
#' | ||
#' @name mod_sidebar | ||
#' | ||
#' @description | ||
#' This module creates a sidebar for the app that contains filters, options, and about information. | ||
#' | ||
#' It includes the UI and server functions: | ||
#' | ||
#' - `mod_sidebar_ui()` | ||
#' - `mod_sidebar_server()` | ||
#' | ||
#' @param id The module id. | ||
#' @param ... Additional parameters. | ||
#' | ||
#' @return | ||
#' - `mod_sidebar_ui()`: A shiny UI function. | ||
#' - `mod_sidebar_server()`: A shiny server function. | ||
|
||
|
||
# UI ---------------------------------------------------------------------- | ||
|
||
#' @rdname mod_sidebar | ||
#' @export | ||
#' @importFrom bsicons bs_icon | ||
#' @importFrom bslib sidebar accordion accordion_panel | ||
#' @importFrom htmltools tags | ||
#' @importFrom shiny NS | ||
#' @importFrom shinyWidgets pickerInput | ||
mod_sidebar_ui <- function(id, ...) { | ||
|
||
ns <- shiny::NS(id) | ||
|
||
bslib::sidebar( | ||
htmltools::tags$div( | ||
class = "sidebar-title", | ||
htmltools::tags$h5("Sidebar"), | ||
htmltools::tags$p("Use the sidebar for filtering and other controls.") | ||
), | ||
bslib::accordion( | ||
id = ns("accordion"), | ||
bslib::accordion_panel( | ||
title = "Filters", | ||
value = ns("filters"), | ||
icon = bsicons::bs_icon("filter"), | ||
htmltools::tags$div( | ||
class = "text-center", | ||
shinyWidgets::pickerInput( | ||
ns("properties"), | ||
label = icon_text("building", "Select Properties"), | ||
choices = .app_choices$properties, | ||
multiple = TRUE, | ||
options = list( | ||
`actions-box` = TRUE, | ||
`live-search` = TRUE, | ||
`live-search-normalize` = TRUE, | ||
`live-search-placeholder` = 'Search...', | ||
`selected-text-format` = 'count > 3', | ||
`count-selected-text` = 'Properties Selected' | ||
) | ||
) | ||
), | ||
bslib::accordion_panel( | ||
title = "Options", | ||
value = ns("options"), | ||
icon = bsicons::bs_icon("gear"), | ||
htmltools::tags$div( | ||
class = "text-center"#, | ||
# TODO: Add options here | ||
) | ||
) | ||
), | ||
bslib::accordion_panel( | ||
title = "About", | ||
value = ns("about"), | ||
icon = bsicons::bs_icon("info"), | ||
htmltools::tags$div( | ||
class = "text-center", | ||
htmltools::tags$p("App Version: 0.0.1", align = "center"), | ||
htmltools::tags$p("Author: No Clocks, LLC", align = "center"), | ||
htmltools::tags$p("Date: 2024-11-08", align = "center") | ||
) | ||
) | ||
) | ||
) | ||
|
||
} | ||
|
||
# server ------------------------------------------------------------------ | ||
|
||
#' @rdname mod_sidebar | ||
#' @export | ||
#' @importFrom shiny moduleServer reactive req | ||
mod_sidebar_server <- function(id, ...) { | ||
|
||
shiny::moduleServer( | ||
id, | ||
function(input, output, session) { | ||
|
||
# Server Logic | ||
out <- shiny::reactive({ | ||
shiny::req(input$properties) | ||
list( | ||
properties = input$properties | ||
) | ||
}) | ||
|
||
# Return Reactive Values with Options and Filters | ||
return(out) | ||
|
||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
# ------------------------------------------------------------------------ | ||
# | ||
# Title : App Title Module | ||
# By : Jimmy Briggs | ||
# Date : 2024-11-08 | ||
# | ||
# ------------------------------------------------------------------------ | ||
|
||
mod_title_ui <- function(id, ...) { | ||
|
||
ns <- shiny::NS(id) | ||
|
||
htmltools::tags$div( | ||
id = ns("title"), | ||
class = "navbar-brand", | ||
htmltools::tags$a( | ||
href = "#", | ||
htmltools::tags$img( | ||
src = .app_info$logo, | ||
alt = .app_info$name, | ||
height = 50, | ||
width = "auto" | ||
) | ||
) | ||
) | ||
|
||
} | ||
|
||
mod_title_server <- function(id, ...) { | ||
shiny::server <- function(input, output, session) { | ||
# No server logic needed | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
# ------------------------------------------------------------------------ | ||
# | ||
# Title : Utilities | ||
# By : Jimmy Briggs | ||
# Date : 2024-11-08 | ||
# | ||
# ------------------------------------------------------------------------ | ||
|
||
icon_text <- function(icon, text, .function = shiny::icon) { | ||
if (is.character(icon)) i <- .function(icon) else i <- icon | ||
t <- paste0(" ", text) | ||
htmltools::tagList(htmltools::tags$div(i, t)) | ||
} |
Empty file.
Empty file.
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.