-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-theme.R
More file actions
43 lines (36 loc) · 1.66 KB
/
Copy pathbuild-theme.R
File metadata and controls
43 lines (36 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Description --------------------------------------------------------------------------------------
# This script builds ggplot2 and quarto themes from templates.
# Resources:
# https://quarto.org/docs/output-formats/html-themes.html#theme-options
# https://davidchall.github.io/jinjar/articles/template-syntax.html
# Setup --------------------------------------------------------------------------------------------
suppressPackageStartupMessages({
# Data manipulation
library(dplyr)
library(tidyr)
# FileIO
library(fs)
library(readr)
# Templating
library(jinjar)
})
# Define themes ------------------------------------------------------------------------------------
# The default minty theme
minty <- read_csv("meta-R/color-themes/minty.icsv", show_col_types = F)
fairyfloss <- read_csv("meta-R/color-themes/fairyfloss.icsv", show_col_types = F)
theme_to_use <- fairyfloss
# Build ggplot2 theme ------------------------------------------------------------------------------
read_lines("meta-R/templates/ggplot2-template.R") |>
paste0(collapse = "\n") |>
render(palette = theme_to_use) |>
write_lines("themes/improper-prior-ggtheme.R")
# Build observable theme ---------------------------------------------------------------------------
paste0('"', {theme_to_use$hex}, '"') |>
paste0(collapse = ",") %>%
paste0('{"scheme": [', ., ']}') |>
write_lines("themes/improper-prior-observable.json")
# Build quarto theme -------------------------------------------------------------------------------
read_lines("meta-R/templates/quarto-template.scss") |>
paste0(collapse = "\n") |>
render(palette = theme_to_use) |>
write_lines("themes/improper-prior.scss")