--- output: github_document --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", echo = FALSE, warning = FALSE, message = FALSE, fig.path = "docs/" ) ``` # RStudio Themes `rstudio-scss` provides SCSS/SASS templates for full ![RStudio](https://rstudio.com) themes for RStudio version 1.2 (and possibly RStudio 1.2+). ## Palettes ```{r palettes, echo=FALSE, results="asis", fig.width=10, fig.height=4} library(ggplot2) source("R/make_functions.R") source("R/show_colors.R") fs::dir_create("docs/palettes") themes <- list( "Solarized" = "_solarized.scss", "Nord" = "_nord.scss", "Oceanic Plus" = "_oceanic-plus.scss", "One Light" = "_one-light.scss", "One Dark" = "_one-dark.scss", "GitHub" = "_github.scss" ) pal_files <- c() for (theme in names(themes)) { theme_file <- fs::path("src", "palettes", themes[[theme]]) colors <- read_colors(theme_file) g <- show_colors(colors, ncol = 8) + ggtitle(theme) + coord_equal() + theme( plot.title = element_text(size = rel(2), hjust = 0.5, margin = margin(t = 20, b = 10)) ) knitr::opts_current$set(fig.process = function(x) { x2 <- sub("([.][a-z]+$)", paste0(themes[[theme]], "\\1"), x) if (file.rename(x, x2)) x2 else x1 }) pal_file <- fs::path("docs", "palettes", themes[[theme]]) fs::path_ext(pal_file) <- "png" ggsave(pal_file, g, width = 10, height = 4) pal_files <- c(pal_files, pal_file) } knitr::include_graphics(pal_files) ``` ### Base 16 Palettes ```{r base16, fig.width=10, fig.height=4} base16_palettes <- fs::dir_ls(here::here("src", "palettes", "base16"), regexp = "_base16") pal_files <- c() for (base16_pal in base16_palettes) { base16_info <- base16_get_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)) ) pal_file <- fs::path("docs", "palettes", fs::path_file(base16_pal)) fs::path_ext(pal_file) <- "png" ggsave(pal_file, g, width = 10, height = 4) pal_files <- c(pal_files, pal_file) } knitr::include_graphics(pal_files) ```