just a bit of additional theming

This commit is contained in:
Andreas Gammelgaard Damsbo 2024-12-18 10:37:37 +01:00
parent c378b2570b
commit 7877d95176
No known key found for this signature in database
9 changed files with 2795 additions and 27 deletions

View file

@ -43,7 +43,10 @@ Imports:
datamods, datamods,
toastui, toastui,
webshot, webshot,
lubridate lubridate,
bsicons,
thematic,
reshape2
Suggests: Suggests:
styler, styler,
devtools, devtools,

View file

@ -62,24 +62,53 @@
#' purrr::map(regression_table) |> #' purrr::map(regression_table) |>
#' tbl_merge() #' tbl_merge()
#' } #' }
regression_table <- function(x, ...) { #' regression_table <- function(x, ...) {
UseMethod("regression_table") #' UseMethod("regression_table")
} #' }
#'
#' #' @rdname regression_table
#' #' @export
#' regression_table.list <- function(x, ...) {
#' x |>
#' purrr::map(\(.m){
#' regression_table(x = .m, ...) |>
#' gtsummary::add_n()
#' }) |>
#' gtsummary::tbl_stack()
#' }
#'
#' #' @rdname regression_table
#' #' @export
#' regression_table.default <- function(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression") {
#' # Stripping custom class
#' class(x) <- class(x)[class(x) != "webresearch_model"]
#'
#' if (any(c(length(class(x)) != 1, class(x) != "lm"))) {
#' if (!"exponentiate" %in% names(args.list)) {
#' args.list <- c(args.list, list(exponentiate = TRUE))
#' }
#' }
#'
#' out <- do.call(getfun(fun), c(list(x = x), args.list))
#' out |>
#' gtsummary::add_glance_source_note() # |>
#' # gtsummary::bold_p()
#' }
#' @rdname regression_table regression_table <- function(x, ...) {
#' @export if ("list" %in% class(x)){
regression_table.list <- function(x, ...) {
x |> x |>
purrr::map(\(.m){ purrr::map(\(.m){
regression_table(x = .m, ...) |> regression_table_create(x = .m, ...) |>
gtsummary::add_n() gtsummary::add_n()
}) |> }) |>
gtsummary::tbl_stack() gtsummary::tbl_stack()
} else {
regression_table_create(x,...)
}
} }
#' @rdname regression_table regression_table_create <- function(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression") {
#' @export
regression_table.default <- function(x, ..., args.list = NULL, fun = "gtsummary::tbl_regression") {
# Stripping custom class # Stripping custom class
class(x) <- class(x)[class(x) != "webresearch_model"] class(x) <- class(x)[class(x) != "webresearch_model"]

29
R/theme.R Normal file
View file

@ -0,0 +1,29 @@
#' Custom theme based on unity
#'
#' @param ... everything passed on to bslib::bs_theme()
#'
#' @returns theme list
#' @export
custom_theme <- function(...){
bslib::bs_theme(
...,
# preset = "united",
version = 5,
primary = "#1E4A8F",
secondary = "#FF6F61",
# success = "#1E4A8F",
# info = ,
# warning = ,
# danger = ,
# fg = "#000",
# bg="#fff",
bootswatch = "united",
base_font = bslib::font_google("Montserrat"),
# base_font = bslib::font_google("Alice"),
# heading_font = bslib::font_google("Jost", wght = "800"),
# heading_font = bslib::font_google("Noto Serif"),
# heading_font = bslib::font_google("Alice"),
heading_font = bslib::font_google("Public Sans",wght = "700"),
code_font = bslib::font_google("Open Sans")
)
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
shinyApp(ui, server)

View file

@ -4,7 +4,7 @@ username: agdamsbo
account: agdamsbo account: agdamsbo
server: shinyapps.io server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1 hostUrl: https://api.shinyapps.io/v1
appId: 13611073 appId: 13611288
bundleId: 9533439 bundleId: 9533633
url: https://agdamsbo.shinyapps.io/freesearcheR/ url: https://agdamsbo.shinyapps.io/freesearcheR/
version: 1 version: 1

View file

@ -33,19 +33,32 @@ library(DT)
# } # }
# library(webResearch) # library(webResearch)
source(here::here("functions.R")) # source("functions.R")
# light <- custom_theme()
#
# dark <- custom_theme(bg = "#000",
# fg="#fff")
server <- function(input, output, session) { server <- function(input, output, session) {
## Listing files in www in session start to keep when ending and removing ## Listing files in www in session start to keep when ending and removing
## everything else. ## everything else.
files.to.keep <- list.files("www/") files.to.keep <- list.files("www/")
# observeEvent(input$dark_mode,{
# session$setCurrentTheme(
# if (isTRUE(input$dark_mode)) dark else light
# )})
output$docs_file <- renderUI({ output$docs_file <- renderUI({
# shiny::includeHTML("www/docs.html") # shiny::includeHTML("www/docs.html")
HTML(readLines("www/docs.html")) HTML(readLines("www/docs.html"))
}) })
rv <- shiny::reactiveValues( rv <- shiny::reactiveValues(
list = NULL, list = NULL,
ds = NULL, ds = NULL,
@ -491,3 +504,5 @@ server <- function(input, output, session) {
}) })
}) })
} }

View file

@ -258,15 +258,18 @@ ui_elements <- list(
) )
) )
# Initial attempt at creating light and dark versions
light <- custom_theme()
dark <- custom_theme(bg = "#000",
fg="#fff")
# Fonts to consider:
# https://webdesignerdepot.com/17-open-source-fonts-youll-actually-love/
ui <- bslib::page( ui <- bslib::page(
title = "freesearcheR", title = "freesearcheR",
theme = bslib::bs_theme( theme = light,
primary = "#1E4A8F", shiny::useBusyIndicators(),
secondary = "#FF6F61",
bootswatch = "minty",
base_font = bslib::font_google("Montserrat"),
code_font = bslib::font_google("Open Sans")
),
bslib::page_navbar( bslib::page_navbar(
id = "main_panel", id = "main_panel",
ui_elements$import, ui_elements$import,

View file

@ -534,6 +534,20 @@
], ],
"Hash": "53142c51f78663c89ff79091874319e4" "Hash": "53142c51f78663c89ff79091874319e4"
}, },
"bsicons": {
"Package": "bsicons",
"Version": "0.1.2",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"cli",
"htmltools",
"rlang",
"utils"
],
"Hash": "d8f892fbd94d0b9b1f6d688b05b8633c"
},
"bslib": { "bslib": {
"Package": "bslib", "Package": "bslib",
"Version": "0.8.0", "Version": "0.8.0",
@ -2597,6 +2611,19 @@
], ],
"Hash": "244b87e40159d58b8c84cb019e5bd16c" "Hash": "244b87e40159d58b8c84cb019e5bd16c"
}, },
"reshape2": {
"Package": "reshape2",
"Version": "1.4.4",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"Rcpp",
"plyr",
"stringr"
],
"Hash": "bb5996d0bd962d214a11140d77589917"
},
"rio": { "rio": {
"Package": "rio", "Package": "rio",
"Version": "1.2.3", "Version": "1.2.3",
@ -3289,6 +3316,26 @@
], ],
"Hash": "573e0d015b7fc3e555f83e254cad7533" "Hash": "573e0d015b7fc3e555f83e254cad7533"
}, },
"thematic": {
"Package": "thematic",
"Version": "0.1.6",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"farver",
"ggplot2",
"grDevices",
"graphics",
"grid",
"rappdirs",
"rlang",
"rstudioapi",
"scales",
"utils"
],
"Hash": "4682b2074c3822b6e1de33b06a868e3c"
},
"tibble": { "tibble": {
"Package": "tibble", "Package": "tibble",
"Version": "3.2.1", "Version": "3.2.1",