| fs::path_ext(output) <- "rstheme" | fs::path_ext(output) <- "rstheme" | ||||
| } | } | ||||
| output <- fs::path(outdir, output) | output <- fs::path(outdir, output) | ||||
| cliapp::cli_alert_success("{path {fs::path_rel(file, getwd())}}") | |||||
| # cliapp::cli_alert_success("{path {fs::path_rel(file, getwd())}}") | |||||
| sass::sass(sass::sass_file(paste(file)), output = output) | sass::sass(sass::sass_file(paste(file)), output = output) | ||||
| } | } | ||||
| } | } | ||||
| cp_to_rstudio <- function(file) { | cp_to_rstudio <- function(file) { | ||||
| cliapp::cli_alert("{arg \"{get_theme_name(file)}\"}") | |||||
| # cliapp::cli_alert("{arg \"{get_theme_name(file)}\"}") | |||||
| fs::file_copy( | fs::file_copy( | ||||
| file, | file, | ||||
| fs::path_home_r(".R", "rstudio", "themes", fs::path_file(file)), | fs::path_home_r(".R", "rstudio", "themes", fs::path_file(file)), | ||||
| overwrite = TRUE | overwrite = TRUE | ||||
| ) | ) | ||||
| } | |||||
| make_base16_theme <- function(palette_file) { | |||||
| base16_palette <- fs::path_file(palette_file) | |||||
| base16_info <- get_base16_theme_info(palette_file) | |||||
| base16_attribution <- base16_info$attribution | |||||
| base16_rstudio_style <- base16_info$rstudio_style | |||||
| base16_name <- base16_info$name | |||||
| base16_theme <- whisker::whisker.render( | |||||
| readLines(here::here("src/base16/base16_template.scss"), warn = FALSE) | |||||
| ) | |||||
| base16_theme_file <- sub("^_", "", base16_palette) | |||||
| # cliapp::cli_alert("Creating src/{arg {base16_theme_file}}") | |||||
| writeLines(base16_theme, fs::path(here::here("src", base16_theme_file))) | |||||
| } | |||||
| get_base16_theme_info <- function(palette_file) { | |||||
| info <- list() | |||||
| base16_meta <- readLines(palette_file, n = 2) | |||||
| info$attribution <- base16_meta[1] | |||||
| info$rstudio_style <- base16_meta[2] | |||||
| if (base16_meta[2] == "") { | |||||
| info$rstudio_style <- "/* rs-theme-is-dark: TRUE */" | |||||
| } | |||||
| info$name <- stringr::str_match(info$attribution, "\\s*([\\w ]+) by")[1, 2] | |||||
| info | |||||
| } | } |
| ) | ) | ||||
| print(g) | print(g) | ||||
| } | } | ||||
| ``` | |||||
| ### Base 16 Palettes | |||||
| ```{r base16, fig.width=10, fig.height=4} | |||||
| base16_palettes <- fs::dir_ls(here::here("src", "palettes", "base16"), regexp = "_base16") | |||||
| for (base16_pal in base16_palettes) { | |||||
| base16_info <- get_base16_theme_info(base16_pal) | |||||
| attribution <- stringr::str_remove_all(base16_info$attribution, "(\\s*?(/?\\*/?)\\s*?)") | |||||
| attribution <- stringr::str_split(attribution, "by")[[1]] | |||||
| attribution <- stringr::str_trim(attribution) | |||||
| attribution_subtitle <- NULL | |||||
| if (length(attribution) == 2) { | |||||
| attribution_subtitle <- attribution[2] | |||||
| } | |||||
| attribution <- paste("base16", attribution[1]) | |||||
| colors <- read_colors(base16_pal) | |||||
| g <- show_colors(colors, ncol = 8) + | |||||
| ggtitle(attribution, if (!is.null(attribution_subtitle)) attribution_subtitle) + | |||||
| coord_equal() + | |||||
| theme( | |||||
| plot.title = element_text(size = rel(2), hjust = 0.5, margin = margin(t = 20, b = 10)), | |||||
| plot.subtitle = element_text(hjust = 0.5, margin = margin(b = 10)) | |||||
| ) | |||||
| print(g) | |||||
| } | |||||
| ``` | ``` |
| <!-- badges: end --> | <!-- badges: end --> | ||||
| `rstudio-scss` provides SCSS/SASS templates for full RStudio themes for | `rstudio-scss` provides SCSS/SASS templates for full RStudio themes for | ||||
| RStudio version 1.2 (and possibly RStudio | |||||
| 1.2+). | |||||
| RStudio version 1.2 (and possibly RStudio 1.2+). | |||||
| ## Palettes | ## Palettes | ||||
| <!-- --><!-- --><!-- --><!-- --><!-- --> | <!-- --><!-- --><!-- --><!-- --><!-- --> | ||||
| ### Base 16 Palettes | |||||
| <!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --> |
| /* ---- RStudio Theme ---- */ | /* ---- RStudio Theme ---- */ | ||||
| /* background */ | /* background */ | ||||
| .rstudio-themes-flat .rstudio-themes-default { | .rstudio-themes-flat .rstudio-themes-default { | ||||
| background: #f9fafb !important; | |||||
| background: #fafafa !important; | |||||
| color: #4c566a !important; | color: #4c566a !important; | ||||
| } | } | ||||
| .rstudio-themes-flat .rstudio-themes-default .rstudio-themes-background { | .rstudio-themes-flat .rstudio-themes-default .rstudio-themes-background { | ||||
| background: #f9fafb !important; | |||||
| background: #fafafa !important; | |||||
| } | } | ||||
| /* inactive tabs */ | /* inactive tabs */ |