| #' @export | #' @export | ||||
| theme_xaringan_restore_defaults <- function() { | theme_xaringan_restore_defaults <- function() { | ||||
| requires_package("ggplot2") | requires_package("ggplot2") | ||||
| requires_xaringanthemer_env() | |||||
| requires_xaringanthemer_env(try_css = FALSE, requires_theme = FALSE) | |||||
| if (is.null(xaringanthemer_env$old_ggplot_defaults)) { | if (is.null(xaringanthemer_env$old_ggplot_defaults)) { | ||||
| return(invisible()) | return(invisible()) | ||||
| invisible(TRUE) | invisible(TRUE) | ||||
| } | } | ||||
| requires_xaringanthemer_env <- function(css_file = NULL, try_css = TRUE) { | |||||
| requires_xaringanthemer_env <- function( | |||||
| css_file = NULL, | |||||
| try_css = TRUE, | |||||
| requires_theme = TRUE | |||||
| ) { | |||||
| reload <- !is.null(css_file) && isTRUE(try_css) | reload <- !is.null(css_file) && isTRUE(try_css) | ||||
| if (reload || !exists("xaringanthemer_env") || is.null(xaringanthemer_env$header_color)) { | |||||
| pkg_env_exists <- exists("xaringanthemer_env") | |||||
| missing_theme <- requires_theme && pkg_env_exists && is.null(xaringanthemer_env$header_color) | |||||
| if (reload || !pkg_env_exists || missing_theme) { | |||||
| if (try_css) { | if (try_css) { | ||||
| css_vars <- read_css_vars(css_file) | css_vars <- read_css_vars(css_file) | ||||
| for (css_var in names(css_vars)) { | for (css_var in names(css_vars)) { |