| #' @param blockquote_left_border_color Blockquote Left Border Color. Defaults to `apply_alpha(secondary_color, 0.5)`. Modifies the `blockquote` element. | #' @param blockquote_left_border_color Blockquote Left Border Color. Defaults to `apply_alpha(secondary_color, 0.5)`. Modifies the `blockquote` element. | ||||
| #' @param table_border_color Table top/bottom border. Defaults to #666. Modifies the `table: border-top, border-bottom` elements. | #' @param table_border_color Table top/bottom border. Defaults to #666. Modifies the `table: border-top, border-bottom` elements. | ||||
| #' @param table_row_border_color Table row inner bottom border. Defaults to #ddd. Modifies the `table thead th: border-bottom` elements. | #' @param table_row_border_color Table row inner bottom border. Defaults to #ddd. Modifies the `table thead th: border-bottom` elements. | ||||
| #' @param table_row_even_background_color Table Even Row Background Color. Defaults to `lighten_color(primary_color, 0.3)`. Modifies the `thead, tfoot, tr:nth-child(even)` elements. | |||||
| #' @param table_row_even_background_color Table Even Row Background Color. Defaults to `lighten_color(primary_color, 0.1)`. Modifies the `thead, tfoot, tr:nth-child(even)` elements. | |||||
| #' @param base_font_size Base Font Size for All Slide Elements (must be `px`). Defaults to 20px. Modifies the `html` element. | #' @param base_font_size Base Font Size for All Slide Elements (must be `px`). Defaults to 20px. Modifies the `html` element. | ||||
| #' @param text_font_size Slide Body Text Font Size. Defaults to 1rem. Modifies the `.remark-slide-content` class. | #' @param text_font_size Slide Body Text Font Size. Defaults to 1rem. Modifies the `.remark-slide-content` class. | ||||
| #' @param header_h1_font_size h1 Header Text Font Size. Defaults to 2.75rem. Modifies the `.remark-slide-content h1` class. | #' @param header_h1_font_size h1 Header Text Font Size. Defaults to 2.75rem. Modifies the `.remark-slide-content h1` class. | ||||
| blockquote_left_border_color = apply_alpha(secondary_color, 0.5), | blockquote_left_border_color = apply_alpha(secondary_color, 0.5), | ||||
| table_border_color = "#666", | table_border_color = "#666", | ||||
| table_row_border_color = "#ddd", | table_row_border_color = "#ddd", | ||||
| table_row_even_background_color = lighten_color(primary_color, 0.3), | |||||
| table_row_even_background_color = lighten_color(primary_color, 0.1), | |||||
| base_font_size = "20px", | base_font_size = "20px", | ||||
| text_font_size = "1rem", | text_font_size = "1rem", | ||||
| header_h1_font_size = "2.75rem", | header_h1_font_size = "2.75rem", |
| #' @param blockquote_left_border_color Blockquote Left Border Color. Defaults to `apply_alpha(secondary_color, 0.5)`. Modifies the `blockquote` element. | #' @param blockquote_left_border_color Blockquote Left Border Color. Defaults to `apply_alpha(secondary_color, 0.5)`. Modifies the `blockquote` element. | ||||
| #' @param table_border_color Table top/bottom border. Defaults to #666. Modifies the `table: border-top, border-bottom` elements. | #' @param table_border_color Table top/bottom border. Defaults to #666. Modifies the `table: border-top, border-bottom` elements. | ||||
| #' @param table_row_border_color Table row inner bottom border. Defaults to #ddd. Modifies the `table thead th: border-bottom` elements. | #' @param table_row_border_color Table row inner bottom border. Defaults to #ddd. Modifies the `table thead th: border-bottom` elements. | ||||
| #' @param table_row_even_background_color Table Even Row Background Color. Defaults to `lighten_color(secondary_color, 0.3)`. Modifies the `thead, tfoot, tr:nth-child(even)` elements. | |||||
| #' @param table_row_even_background_color Table Even Row Background Color. Defaults to `lighten_color(secondary_color, 0.2)`. Modifies the `thead, tfoot, tr:nth-child(even)` elements. | |||||
| #' @param base_font_size Base Font Size for All Slide Elements (must be `px`). Defaults to 20px. Modifies the `html` element. | #' @param base_font_size Base Font Size for All Slide Elements (must be `px`). Defaults to 20px. Modifies the `html` element. | ||||
| #' @param text_font_size Slide Body Text Font Size. Defaults to 1rem. Modifies the `.remark-slide-content` class. | #' @param text_font_size Slide Body Text Font Size. Defaults to 1rem. Modifies the `.remark-slide-content` class. | ||||
| #' @param header_h1_font_size h1 Header Text Font Size. Defaults to 2.75rem. Modifies the `.remark-slide-content h1` class. | #' @param header_h1_font_size h1 Header Text Font Size. Defaults to 2.75rem. Modifies the `.remark-slide-content h1` class. | ||||
| blockquote_left_border_color = apply_alpha(secondary_color, 0.5), | blockquote_left_border_color = apply_alpha(secondary_color, 0.5), | ||||
| table_border_color = "#666", | table_border_color = "#666", | ||||
| table_row_border_color = "#ddd", | table_row_border_color = "#ddd", | ||||
| table_row_even_background_color = lighten_color(secondary_color, 0.3), | |||||
| table_row_even_background_color = lighten_color(secondary_color, 0.2), | |||||
| base_font_size = "20px", | base_font_size = "20px", | ||||
| text_font_size = "1rem", | text_font_size = "1rem", | ||||
| header_h1_font_size = "2.75rem", | header_h1_font_size = "2.75rem", |
| #' @param blockquote_left_border_color Blockquote Left Border Color. Defaults to `apply_alpha(secondary_color, 0.5)`. Modifies the `blockquote` element. | #' @param blockquote_left_border_color Blockquote Left Border Color. Defaults to `apply_alpha(secondary_color, 0.5)`. Modifies the `blockquote` element. | ||||
| #' @param table_border_color Table top/bottom border. Defaults to #666. Modifies the `table: border-top, border-bottom` elements. | #' @param table_border_color Table top/bottom border. Defaults to #666. Modifies the `table: border-top, border-bottom` elements. | ||||
| #' @param table_row_border_color Table row inner bottom border. Defaults to #ddd. Modifies the `table thead th: border-bottom` elements. | #' @param table_row_border_color Table row inner bottom border. Defaults to #ddd. Modifies the `table thead th: border-bottom` elements. | ||||
| #' @param table_row_even_background_color Table Even Row Background Color. Defaults to `darken_color(choose_dark_or_light(primary_color, secondary_color, primary_color), 0.3)`. Modifies the `thead, tfoot, tr:nth-child(even)` elements. | |||||
| #' @param table_row_even_background_color Table Even Row Background Color. Defaults to `darken_color(choose_dark_or_light(primary_color, secondary_color, primary_color), 0.2)`. Modifies the `thead, tfoot, tr:nth-child(even)` elements. | |||||
| #' @param base_font_size Base Font Size for All Slide Elements (must be `px`). Defaults to 20px. Modifies the `html` element. | #' @param base_font_size Base Font Size for All Slide Elements (must be `px`). Defaults to 20px. Modifies the `html` element. | ||||
| #' @param text_font_size Slide Body Text Font Size. Defaults to 1rem. Modifies the `.remark-slide-content` class. | #' @param text_font_size Slide Body Text Font Size. Defaults to 1rem. Modifies the `.remark-slide-content` class. | ||||
| #' @param header_h1_font_size h1 Header Text Font Size. Defaults to 2.75rem. Modifies the `.remark-slide-content h1` class. | #' @param header_h1_font_size h1 Header Text Font Size. Defaults to 2.75rem. Modifies the `.remark-slide-content h1` class. | ||||
| blockquote_left_border_color = apply_alpha(secondary_color, 0.5), | blockquote_left_border_color = apply_alpha(secondary_color, 0.5), | ||||
| table_border_color = "#666", | table_border_color = "#666", | ||||
| table_row_border_color = "#ddd", | table_row_border_color = "#ddd", | ||||
| table_row_even_background_color = darken_color(choose_dark_or_light(primary_color, secondary_color, primary_color), 0.3), | |||||
| table_row_even_background_color = darken_color(choose_dark_or_light(primary_color, secondary_color, primary_color), 0.2), | |||||
| base_font_size = "20px", | base_font_size = "20px", | ||||
| text_font_size = "1rem", | text_font_size = "1rem", | ||||
| header_h1_font_size = "2.75rem", | header_h1_font_size = "2.75rem", |
| #' @param header_h1_font_size h1 Header Text Font Size. Defaults to 2.75rem. Modifies the `.remark-slide-content h1` class. | #' @param header_h1_font_size h1 Header Text Font Size. Defaults to 2.75rem. Modifies the `.remark-slide-content h1` class. | ||||
| #' @param header_h2_font_size h2 Header Text Font Size. Defaults to 2.25rem. Modifies the `.remark-slide-content h2` class. | #' @param header_h2_font_size h2 Header Text Font Size. Defaults to 2.25rem. Modifies the `.remark-slide-content h2` class. | ||||
| #' @param header_h3_font_size h3 Header Text Font Size. Defaults to 1.75rem. Modifies the `.remark-slide-content h3` class. | #' @param header_h3_font_size h3 Header Text Font Size. Defaults to 1.75rem. Modifies the `.remark-slide-content h3` class. | ||||
| #' @param header_background_auto Add background under slide title automatically for h1 header elements. If not enabled, use `class: header_background` to enable. Defaults to `FALSE`. | |||||
| #' @param header_background_auto Add background under slide title automatically for h1 header elements. If not enabled, use `class: header_background` to enable. Defaults to `FALSE`. | |||||
| #' @param header_background_color Background Color for h1 Header with Background. Defaults to `header_color`. Modifies the `.remark-slide-content h1` class. | #' @param header_background_color Background Color for h1 Header with Background. Defaults to `header_color`. Modifies the `.remark-slide-content h1` class. | ||||
| #' @param header_background_text_color Text Color for h1 Header with Background. Defaults to `background_color`. Modifies the `.remark-slide-content h1` class. | #' @param header_background_text_color Text Color for h1 Header with Background. Defaults to `background_color`. Modifies the `.remark-slide-content h1` class. | ||||
| #' @param header_background_padding Padding for h1 Header with Background. Defaults to `NULL`. Modifies the `.remark-slide-content h1` class. | #' @param header_background_padding Padding for h1 Header with Background. Defaults to `NULL`. Modifies the `.remark-slide-content h1` class. | ||||
| # set an is_google flag default of FALSE that is possibly overwritten later | # set an is_google flag default of FALSE that is possibly overwritten later | ||||
| eval(parse(text = paste0(sub("font_family$", "font_is_google", var), "<-0"))) | eval(parse(text = paste0(sub("font_family$", "font_is_google", var), "<-0"))) | ||||
| } | } | ||||
| # Warn if base_font_size isn't absolute | # Warn if base_font_size isn't absolute | ||||
| css_abs_units <- c("cm", "mm", "Q", "in", "pc", "pt", "px") | css_abs_units <- c("cm", "mm", "Q", "in", "pc", "pt", "px") | ||||
| if (!grepl(paste(tolower(css_abs_units), collapse = "|"), tolower(base_font_size))) { | if (!grepl(paste(tolower(css_abs_units), collapse = "|"), tolower(base_font_size))) { | ||||
| immediate. = TRUE | immediate. = TRUE | ||||
| ) | ) | ||||
| } | } | ||||
| # Use font_..._google args to overwrite font args | # Use font_..._google args to overwrite font args | ||||
| for (var in f_args[grepl("font_google$", f_args)]) { | for (var in f_args[grepl("font_google$", f_args)]) { | ||||
| gf <- eval(parse(text = var)) | gf <- eval(parse(text = var)) | ||||
| } | } | ||||
| eval(parse(text = paste0(group, "_font_is_google <- 1"))) | eval(parse(text = paste0(group, "_font_is_google <- 1"))) | ||||
| } | } | ||||
| is_default <- function(type, suffix, reference = style_xaringan) { | is_default <- function(type, suffix, reference = style_xaringan) { | ||||
| var <- paste0(type, "_", suffix) | var <- paste0(type, "_", suffix) | ||||
| default_value <- formals(reference)[[var]] | default_value <- formals(reference)[[var]] | ||||
| if (suffix == "font_family") { | if (suffix == "font_family") { | ||||
| default_value <- quote_elements_w_spaces(default_value) | default_value <- quote_elements_w_spaces(default_value) | ||||
| } | } | ||||
| get(var, envir = parent.frame(2), inherits = FALSE) == default_value | get(var, envir = parent.frame(2), inherits = FALSE) == default_value | ||||
| } | } | ||||
| # the defaults are google fonts | # the defaults are google fonts | ||||
| for (var in c("text", "header", "code")) { | for (var in c("text", "header", "code")) { | ||||
| suffixes <- c("font_family", "font_weight", "font_url") | suffixes <- c("font_family", "font_weight", "font_url") | ||||
| eval(parse(text = paste0(var, "_font_is_google <- 1"))) | eval(parse(text = paste0(var, "_font_is_google <- 1"))) | ||||
| } | } | ||||
| } | } | ||||
| extra_font_imports <- if (is.null(extra_fonts)) "" else list2fonts(extra_fonts) | extra_font_imports <- if (is.null(extra_fonts)) "" else list2fonts(extra_fonts) | ||||
| extra_font_imports <- paste(extra_font_imports, collapse = "\n") | extra_font_imports <- paste(extra_font_imports, collapse = "\n") | ||||
| # convert NA arguments to NULL | # convert NA arguments to NULL | ||||
| for (var in f_args) { | for (var in f_args) { | ||||
| val <- eval(parse(text = var)) | val <- eval(parse(text = var)) | ||||
| is_na <- length(val) == 0 | is_na <- length(val) == 0 | ||||
| if (is_na) assign(var, NULL) | if (is_na) assign(var, NULL) | ||||
| } | } | ||||
| # prepare variables for template | # prepare variables for template | ||||
| body_font_family <- paste(c(text_font_family, text_font_family_fallback, text_font_base), collapse = ", ") | body_font_family <- paste(c(text_font_family, text_font_family_fallback, text_font_base), collapse = ", ") | ||||
| background_size_fallback <- if (is.null(background_position)) "cover" else "100%" | background_size_fallback <- if (is.null(background_position)) "cover" else "100%" | ||||
| title_slide_background_image %??% "cover" | title_slide_background_image %??% "cover" | ||||
| ) | ) | ||||
| table_row_even_background_color <- table_row_even_background_color %||% background_color | table_row_even_background_color <- table_row_even_background_color %||% background_color | ||||
| # stash theme settings in package env | # stash theme settings in package env | ||||
| lapply(f_args, function(n) assign(n, get(n), envir = xaringanthemer_env)) | lapply(f_args, function(n) assign(n, get(n), envir = xaringanthemer_env)) | ||||
| for (font_is_google in paste0(c("text", "code", "header"), "_font_is_google")) { | for (font_is_google in paste0(c("text", "code", "header"), "_font_is_google")) { | ||||
| envir = xaringanthemer_env | envir = xaringanthemer_env | ||||
| ) | ) | ||||
| } | } | ||||
| xaringanthemer_version <- utils::packageVersion("xaringanthemer") | xaringanthemer_version <- utils::packageVersion("xaringanthemer") | ||||
| # prepare header background object | # prepare header background object | ||||
| needs_leading_dot <- !grepl("^\\.", header_background_ignore_classes) | needs_leading_dot <- !grepl("^\\.", header_background_ignore_classes) | ||||
| header_background_ignore_classes[needs_leading_dot] <- paste0( | header_background_ignore_classes[needs_leading_dot] <- paste0( | ||||
| content_padding_top = header_background_content_padding_top, | content_padding_top = header_background_content_padding_top, | ||||
| ignore = header_background_ignore_classes | ignore = header_background_ignore_classes | ||||
| ) | ) | ||||
| colors <- prepare_colors(colors) | colors <- prepare_colors(colors) | ||||
| tf <- system.file("resources", "template.css", package = "xaringanthemer") | tf <- system.file("resources", "template.css", package = "xaringanthemer") | ||||
| template <- readLines(tf, warn = FALSE) | template <- readLines(tf, warn = FALSE) | ||||
| template <- paste(template, collapse = "\n") | template <- paste(template, collapse = "\n") |
| left_column_subtle_color = "{apply_alpha(secondary_color, 0.6)}", | left_column_subtle_color = "{apply_alpha(secondary_color, 0.6)}", | ||||
| left_column_selected_color = "{secondary_color}", | left_column_selected_color = "{secondary_color}", | ||||
| blockquote_left_border_color = "{apply_alpha(secondary_color, 0.5)}", | blockquote_left_border_color = "{apply_alpha(secondary_color, 0.5)}", | ||||
| table_row_even_background_color = "{lighten_color(secondary_color, 0.7)}") | |||||
| table_row_even_background_color = "{lighten_color(secondary_color, 0.9)}") | |||||
| template_duo <- tibble::tribble( | template_duo <- tibble::tribble( | ||||
| ~ variable, ~ default, ~ element, ~ description | ~ variable, ~ default, ~ element, ~ description | ||||
| left_column_subtle_color = "{apply_alpha(secondary_color, 0.6)}", | left_column_subtle_color = "{apply_alpha(secondary_color, 0.6)}", | ||||
| left_column_selected_color = "{secondary_color}", | left_column_selected_color = "{secondary_color}", | ||||
| blockquote_left_border_color = "{apply_alpha(secondary_color, 0.5)}", | blockquote_left_border_color = "{apply_alpha(secondary_color, 0.5)}", | ||||
| table_row_even_background_color = "{lighten_color(primary_color, 0.3)}") | |||||
| table_row_even_background_color = "{lighten_color(primary_color, 0.1)}") | |||||
| template_duo_accent <- tibble::tribble( | template_duo_accent <- tibble::tribble( | ||||
| ~ variable, ~ default, ~ element, ~ description | ~ variable, ~ default, ~ element, ~ description | ||||
| left_column_subtle_color = "{apply_alpha(primary_color, 0.6)}", | left_column_subtle_color = "{apply_alpha(primary_color, 0.6)}", | ||||
| left_column_selected_color = "{primary_color}", | left_column_selected_color = "{primary_color}", | ||||
| blockquote_left_border_color = "{apply_alpha(secondary_color, 0.5)}", | blockquote_left_border_color = "{apply_alpha(secondary_color, 0.5)}", | ||||
| table_row_even_background_color = "{lighten_color(secondary_color, 0.3)}") | |||||
| table_row_even_background_color = "{lighten_color(secondary_color, 0.2)}") | |||||
| template_duo_accent_inverse <- set_default( | template_duo_accent_inverse <- set_default( | ||||
| template_duo_accent, | template_duo_accent, | ||||
| left_column_subtle_color = "{apply_alpha(primary_color, 0.6)}", | left_column_subtle_color = "{apply_alpha(primary_color, 0.6)}", | ||||
| left_column_selected_color = "{primary_color}", | left_column_selected_color = "{primary_color}", | ||||
| blockquote_left_border_color = "{apply_alpha(secondary_color, 0.5)}", | blockquote_left_border_color = "{apply_alpha(secondary_color, 0.5)}", | ||||
| table_row_even_background_color = "{darken_color(choose_dark_or_light(primary_color, secondary_color, primary_color), 0.3)}") | |||||
| table_row_even_background_color = "{darken_color(choose_dark_or_light(primary_color, secondary_color, primary_color), 0.2)}") | |||||
| solarized <- list( | solarized <- list( | ||||
| "base03" = "#002b36", | "base03" = "#002b36", |
| blockquote_left_border_color = apply_alpha(secondary_color, 0.5), | blockquote_left_border_color = apply_alpha(secondary_color, 0.5), | ||||
| table_border_color = "#666", | table_border_color = "#666", | ||||
| table_row_border_color = "#ddd", | table_row_border_color = "#ddd", | ||||
| table_row_even_background_color = lighten_color(primary_color, 0.3), | |||||
| table_row_even_background_color = lighten_color(primary_color, 0.1), | |||||
| base_font_size = "20px", | base_font_size = "20px", | ||||
| text_font_size = "1rem", | text_font_size = "1rem", | ||||
| header_h1_font_size = "2.75rem", | header_h1_font_size = "2.75rem", | ||||
| \item{table_row_border_color}{Table row inner bottom border. Defaults to #ddd. Modifies the \verb{table thead th: border-bottom} elements.} | \item{table_row_border_color}{Table row inner bottom border. Defaults to #ddd. Modifies the \verb{table thead th: border-bottom} elements.} | ||||
| \item{table_row_even_background_color}{Table Even Row Background Color. Defaults to \code{lighten_color(primary_color, 0.3)}. Modifies the \verb{thead, tfoot, tr:nth-child(even)} elements.} | |||||
| \item{table_row_even_background_color}{Table Even Row Background Color. Defaults to \code{lighten_color(primary_color, 0.1)}. Modifies the \verb{thead, tfoot, tr:nth-child(even)} elements.} | |||||
| \item{base_font_size}{Base Font Size for All Slide Elements (must be \code{px}). Defaults to 20px. Modifies the \code{html} element.} | \item{base_font_size}{Base Font Size for All Slide Elements (must be \code{px}). Defaults to 20px. Modifies the \code{html} element.} | ||||
| blockquote_left_border_color = apply_alpha(secondary_color, 0.5), | blockquote_left_border_color = apply_alpha(secondary_color, 0.5), | ||||
| table_border_color = "#666", | table_border_color = "#666", | ||||
| table_row_border_color = "#ddd", | table_row_border_color = "#ddd", | ||||
| table_row_even_background_color = lighten_color(secondary_color, 0.3), | |||||
| table_row_even_background_color = lighten_color(secondary_color, 0.2), | |||||
| base_font_size = "20px", | base_font_size = "20px", | ||||
| text_font_size = "1rem", | text_font_size = "1rem", | ||||
| header_h1_font_size = "2.75rem", | header_h1_font_size = "2.75rem", | ||||
| \item{table_row_border_color}{Table row inner bottom border. Defaults to #ddd. Modifies the \verb{table thead th: border-bottom} elements.} | \item{table_row_border_color}{Table row inner bottom border. Defaults to #ddd. Modifies the \verb{table thead th: border-bottom} elements.} | ||||
| \item{table_row_even_background_color}{Table Even Row Background Color. Defaults to \code{lighten_color(secondary_color, 0.3)}. Modifies the \verb{thead, tfoot, tr:nth-child(even)} elements.} | |||||
| \item{table_row_even_background_color}{Table Even Row Background Color. Defaults to \code{lighten_color(secondary_color, 0.2)}. Modifies the \verb{thead, tfoot, tr:nth-child(even)} elements.} | |||||
| \item{base_font_size}{Base Font Size for All Slide Elements (must be \code{px}). Defaults to 20px. Modifies the \code{html} element.} | \item{base_font_size}{Base Font Size for All Slide Elements (must be \code{px}). Defaults to 20px. Modifies the \code{html} element.} | ||||
| table_border_color = "#666", | table_border_color = "#666", | ||||
| table_row_border_color = "#ddd", | table_row_border_color = "#ddd", | ||||
| table_row_even_background_color = darken_color(choose_dark_or_light(primary_color, | table_row_even_background_color = darken_color(choose_dark_or_light(primary_color, | ||||
| secondary_color, primary_color), 0.3), | |||||
| secondary_color, primary_color), 0.2), | |||||
| base_font_size = "20px", | base_font_size = "20px", | ||||
| text_font_size = "1rem", | text_font_size = "1rem", | ||||
| header_h1_font_size = "2.75rem", | header_h1_font_size = "2.75rem", | ||||
| \item{table_row_border_color}{Table row inner bottom border. Defaults to #ddd. Modifies the \verb{table thead th: border-bottom} elements.} | \item{table_row_border_color}{Table row inner bottom border. Defaults to #ddd. Modifies the \verb{table thead th: border-bottom} elements.} | ||||
| \item{table_row_even_background_color}{Table Even Row Background Color. Defaults to \code{darken_color(choose_dark_or_light(primary_color, secondary_color, primary_color), 0.3)}. Modifies the \verb{thead, tfoot, tr:nth-child(even)} elements.} | |||||
| \item{table_row_even_background_color}{Table Even Row Background Color. Defaults to \code{darken_color(choose_dark_or_light(primary_color, secondary_color, primary_color), 0.2)}. Modifies the \verb{thead, tfoot, tr:nth-child(even)} elements.} | |||||
| \item{base_font_size}{Base Font Size for All Slide Elements (must be \code{px}). Defaults to 20px. Modifies the \code{html} element.} | \item{base_font_size}{Base Font Size for All Slide Elements (must be \code{px}). Defaults to 20px. Modifies the \code{html} element.} | ||||