😎 Give your xaringan slides some style
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

491 líneas
26KB

  1. # Generated by inst/scripts/generate_theme_functions.R: do not edit by hand
  2. #' @param text_color Text Color. Defaults to #000. Modifies the `body` element.
  3. #' The value of this variable is also stored as a CSS variable that can be
  4. #' referenced with `var(--text_color)` in any argument of a style function or
  5. #' in custom CSS.
  6. #' @param header_color Header Color. Defaults to #000. Modifies the
  7. #' `h1, h2, h3` elements. The value of this variable is also stored as a CSS
  8. #' variable that can be referenced with `var(--header-color)` in any argument
  9. #' of a style function or in custom CSS.
  10. #' @param background_color Slide Background Color. Defaults to #FFF. Modifies
  11. #' the `.remark-slide-content` class. The value of this variable is also
  12. #' stored as a CSS variable that can be referenced with
  13. #' `var(--background-color)` in any argument of a style function or in custom
  14. #' CSS.
  15. #' @param link_color Link Color. Defaults to rgb(249, 38, 114). Modifies the
  16. #' `a, a > code` elements. The value of this variable is also stored as a CSS
  17. #' variable that can be referenced with `var(--link-color)` in any argument
  18. #' of a style function or in custom CSS.
  19. #' @param text_bold_color Bold Text Color. Defaults to `NULL`. Modifies the
  20. #' `strong` element. The value of this variable is also stored as a CSS
  21. #' variable that can be referenced with `var(--text-bold-color)` in any
  22. #' argument of a style function or in custom CSS.
  23. #' @param text_slide_number_color Slide Number Color. Defaults to
  24. #' `inverse_background_color`. Modifies the `.remark-slide-number` class. The
  25. #' value of this variable is also stored as a CSS variable that can be
  26. #' referenced with `var(NA)` in any argument of a style function or in custom
  27. #' CSS.
  28. #' @param padding Slide Padding in `top right [bottom left]` format. Defaults
  29. #' to 16px 64px 16px 64px. Modifies the `.remark-slide-content` class. The
  30. #' value of this variable is also stored as a CSS variable that can be
  31. #' referenced with `var(NA)` in any argument of a style function or in custom
  32. #' CSS.
  33. #' @param background_image Background image applied to each *and every* slide.
  34. #' Set `title_slide_background_image = "none"` to remove the background image
  35. #' from the title slide. Defaults to `NULL`. Modifies the
  36. #' `.remark-slide-content` class. The value of this variable is also stored
  37. #' as a CSS variable that can be referenced with `var(NA)` in any argument of
  38. #' a style function or in custom CSS.
  39. #' @param background_size Background image size, requires `background_image` to
  40. #' be set. If `background_image` is set, `background_size` will default to
  41. #' `cover` so the backround fills the screen. If both `background_image` and
  42. #' `background_position` are set, will default to 100 percent. Defaults to
  43. #' `NULL`. Modifies the `.remark-slide-content` class. The value of this
  44. #' variable is also stored as a CSS variable that can be referenced with
  45. #' `var(NA)` in any argument of a style function or in custom CSS.
  46. #' @param background_position Background image position, requires
  47. #' `background_image` to be set, and it is recommended to adjust
  48. #' `background_size`. Defaults to `NULL`. Modifies the
  49. #' `.remark-slide-content` class. The value of this variable is also stored
  50. #' as a CSS variable that can be referenced with `var(NA)` in any argument of
  51. #' a style function or in custom CSS.
  52. #' @param code_highlight_color Code Line Highlight. Defaults to
  53. #' rgba(255,255,0,0.5). Modifies the `.remark-code-line-highlighted` class.
  54. #' The value of this variable is also stored as a CSS variable that can be
  55. #' referenced with `var(--code-highlight-color)` in any argument of a style
  56. #' function or in custom CSS.
  57. #' @param code_inline_color Inline Code Color. Defaults to #000. Modifies the
  58. #' `.remark-inline-code` class. The value of this variable is also stored as
  59. #' a CSS variable that can be referenced with `var(NA)` in any argument of a
  60. #' style function or in custom CSS.
  61. #' @param code_inline_background_color Inline Code Background Color. Defaults
  62. #' to `NULL`. Modifies the `.remark-inline-code` class. The value of this
  63. #' variable is also stored as a CSS variable that can be referenced with
  64. #' `var(NA)` in any argument of a style function or in custom CSS.
  65. #' @param code_inline_font_size Inline Code Text Font Size. Defaults to 1em.
  66. #' Modifies the `.remark-inline-code` class. The value of this variable is
  67. #' also stored as a CSS variable that can be referenced with
  68. #' `var(--code-inline-font-size)` in any argument of a style function or in
  69. #' custom CSS.
  70. #' @param inverse_background_color Inverse Background Color. Defaults to
  71. #' #272822. Modifies the `.inverse` class. The value of this variable is also
  72. #' stored as a CSS variable that can be referenced with
  73. #' `var(--inverse-background-color)` in any argument of a style function or
  74. #' in custom CSS.
  75. #' @param inverse_text_color Inverse Text Color. Defaults to #d6d6d6. Modifies
  76. #' the `.inverse` class. The value of this variable is also stored as a CSS
  77. #' variable that can be referenced with `var(--inverse-text-color)` in any
  78. #' argument of a style function or in custom CSS.
  79. #' @param inverse_text_shadow Enables Shadow on text of inverse slides.
  80. #' Defaults to `FALSE`. Modifies the `.inverse` class. The value of this
  81. #' variable is also stored as a CSS variable that can be referenced with
  82. #' `var(NA)` in any argument of a style function or in custom CSS.
  83. #' @param inverse_header_color Inverse Header Color. Defaults to #f3f3f3.
  84. #' Modifies the `.inverse h1, .inverse h2, .inverse h3` classes. The value of
  85. #' this variable is also stored as a CSS variable that can be referenced with
  86. #' `var(--inverse-header-color)` in any argument of a style function or in
  87. #' custom CSS.
  88. #' @param title_slide_text_color Title Slide Text Color. Defaults to
  89. #' `inverse_text_color`. Modifies the `.title-slide` class. The value of this
  90. #' variable is also stored as a CSS variable that can be referenced with
  91. #' `var(--title-slide-text-color)` in any argument of a style function or in
  92. #' custom CSS.
  93. #' @param title_slide_background_color Title Slide Background Color. Defaults
  94. #' to `inverse_background_color`. Modifies the `.title-slide` class. The
  95. #' value of this variable is also stored as a CSS variable that can be
  96. #' referenced with `var(--title-slide-background-color)` in any argument of a
  97. #' style function or in custom CSS.
  98. #' @param title_slide_background_image Title Slide Background Image URL.
  99. #' Defaults to `NULL`. Modifies the `.title-slide` class. The value of this
  100. #' variable is also stored as a CSS variable that can be referenced with
  101. #' `var(NA)` in any argument of a style function or in custom CSS.
  102. #' @param title_slide_background_size Title Slide Background Image Size,
  103. #' defaults to "cover" if background image is set. Defaults to `NULL`.
  104. #' Modifies the `.title-slide` class. The value of this variable is also
  105. #' stored as a CSS variable that can be referenced with `var(NA)` in any
  106. #' argument of a style function or in custom CSS.
  107. #' @param title_slide_background_position Title Slide Background Image
  108. #' Position. Defaults to `NULL`. Modifies the `.title-slide` class. The value
  109. #' of this variable is also stored as a CSS variable that can be referenced
  110. #' with `var(NA)` in any argument of a style function or in custom CSS.
  111. #' @param footnote_color Footnote text color (if `NA`, then it will be the same
  112. #' color as `text_color`). Defaults to `NULL`. Modifies the `.footnote`
  113. #' class. The value of this variable is also stored as a CSS variable that
  114. #' can be referenced with `var(NA)` in any argument of a style function or in
  115. #' custom CSS.
  116. #' @param footnote_font_size Footnote font size. Defaults to 0.9em. Modifies
  117. #' the `.footnote` class. The value of this variable is also stored as a CSS
  118. #' variable that can be referenced with `var(NA)` in any argument of a style
  119. #' function or in custom CSS.
  120. #' @param footnote_position_bottom Footnote location from bottom of screen.
  121. #' Defaults to 60px. Modifies the `.footnote` class. The value of this
  122. #' variable is also stored as a CSS variable that can be referenced with
  123. #' `var(NA)` in any argument of a style function or in custom CSS.
  124. #' @param left_column_subtle_color Left Column Text (not last). Defaults to
  125. #' #777. Modifies the `.left-column h2, .left-column h3` classes. The value
  126. #' of this variable is also stored as a CSS variable that can be referenced
  127. #' with `var(NA)` in any argument of a style function or in custom CSS.
  128. #' @param left_column_selected_color Left Column Current Selection. Defaults to
  129. #' #000. Modifies the
  130. #' `.left-column h2:last-of-type, .left-column h3:last-child` classes. The
  131. #' value of this variable is also stored as a CSS variable that can be
  132. #' referenced with `var(NA)` in any argument of a style function or in custom
  133. #' CSS.
  134. #' @param blockquote_left_border_color Blockquote Left Border Color. Defaults
  135. #' to lightgray. Modifies the `blockquote` element. The value of this
  136. #' variable is also stored as a CSS variable that can be referenced with
  137. #' `var(NA)` in any argument of a style function or in custom CSS.
  138. #' @param table_border_color Table top/bottom border. Defaults to #666.
  139. #' Modifies the `table: border-top, border-bottom` elements. The value of
  140. #' this variable is also stored as a CSS variable that can be referenced with
  141. #' `var(NA)` in any argument of a style function or in custom CSS.
  142. #' @param table_row_border_color Table row inner bottom border. Defaults to
  143. #' #ddd. Modifies the `table thead th: border-bottom` elements. The value of
  144. #' this variable is also stored as a CSS variable that can be referenced with
  145. #' `var(NA)` in any argument of a style function or in custom CSS.
  146. #' @param table_row_even_background_color Table Even Row Background Color.
  147. #' Defaults to #eee. Modifies the `thead, tfoot, tr:nth-child(even)`
  148. #' elements. The value of this variable is also stored as a CSS variable that
  149. #' can be referenced with `var(NA)` in any argument of a style function or in
  150. #' custom CSS.
  151. #' @param base_font_size Base Font Size for All Slide Elements (must be `px`).
  152. #' Defaults to 20px. Modifies the `html` element. The value of this variable
  153. #' is also stored as a CSS variable that can be referenced with
  154. #' `var(--base-font-size)` in any argument of a style function or in custom
  155. #' CSS.
  156. #' @param text_font_size Slide Body Text Font Size. Defaults to 1rem. Modifies
  157. #' the `.remark-slide-content` class. The value of this variable is also
  158. #' stored as a CSS variable that can be referenced with
  159. #' `var(--text-font-size)` in any argument of a style function or in custom
  160. #' CSS.
  161. #' @param header_h1_font_size h1 Header Text Font Size. Defaults to 2.75rem.
  162. #' Modifies the `.remark-slide-content h1` class. The value of this variable
  163. #' is also stored as a CSS variable that can be referenced with
  164. #' `var(--header-h1-font-size)` in any argument of a style function or in
  165. #' custom CSS.
  166. #' @param header_h2_font_size h2 Header Text Font Size. Defaults to 2.25rem.
  167. #' Modifies the `.remark-slide-content h2` class. The value of this variable
  168. #' is also stored as a CSS variable that can be referenced with
  169. #' `var(--header-h2-font-size)` in any argument of a style function or in
  170. #' custom CSS.
  171. #' @param header_h3_font_size h3 Header Text Font Size. Defaults to 1.75rem.
  172. #' Modifies the `.remark-slide-content h3` class. The value of this variable
  173. #' is also stored as a CSS variable that can be referenced with
  174. #' `var(--header-h3-font-size)` in any argument of a style function or in
  175. #' custom CSS.
  176. #' @param header_background_auto Add background under slide title automatically
  177. #' for h1 header elements. If not enabled, use `class: header_background` to
  178. #' enable. Defaults to `FALSE`. The value of this variable is also stored as
  179. #' a CSS variable that can be referenced with `var(NA)` in any argument of a
  180. #' style function or in custom CSS.
  181. #' @param header_background_color Background Color for h1 Header with
  182. #' Background. Defaults to `header_color`. Modifies the
  183. #' `.remark-slide-content h1` class. The value of this variable is also
  184. #' stored as a CSS variable that can be referenced with
  185. #' `var(--header-background-color)` in any argument of a style function or in
  186. #' custom CSS.
  187. #' @param header_background_text_color Text Color for h1 Header with
  188. #' Background. Defaults to `background_color`. Modifies the
  189. #' `.remark-slide-content h1` class. The value of this variable is also
  190. #' stored as a CSS variable that can be referenced with
  191. #' `var(--header-background-text-color)` in any argument of a style function
  192. #' or in custom CSS.
  193. #' @param header_background_padding Padding for h1 Header with Background.
  194. #' Defaults to `NULL`. Modifies the `.remark-slide-content h1` class. The
  195. #' value of this variable is also stored as a CSS variable that can be
  196. #' referenced with `var(NA)` in any argument of a style function or in custom
  197. #' CSS.
  198. #' @param header_background_content_padding_top Top Padding for Content in
  199. #' Slide with Header with Background. Defaults to 7rem. Modifies the
  200. #' `.remark-slide-content` class. The value of this variable is also stored
  201. #' as a CSS variable that can be referenced with `var(NA)` in any argument of
  202. #' a style function or in custom CSS.
  203. #' @param header_background_ignore_classes Slide Classes Where Header with
  204. #' Background will not be Applied. Defaults to
  205. #' `c('normal', 'inverse', 'title', 'middle', 'bottom')`. Modifies the
  206. #' `.remark-slide-content` class. The value of this variable is also stored
  207. #' as a CSS variable that can be referenced with `var(NA)` in any argument of
  208. #' a style function or in custom CSS.
  209. #' @param text_slide_number_font_size Slide Number Text Font Size. Defaults to
  210. #' 0.9em. Modifies the `.remark-slide-number` class. The value of this
  211. #' variable is also stored as a CSS variable that can be referenced with
  212. #' `var(NA)` in any argument of a style function or in custom CSS.
  213. #' @param text_font_google Use `google_font()` to specify body font. Defaults
  214. #' to `NULL`. Modifies the `body` element. The value of this variable is also
  215. #' stored as a CSS variable that can be referenced with `var(NA)` in any
  216. #' argument of a style function or in custom CSS.
  217. #' @param text_font_family Body Text Font Family (xaringan default is
  218. #' `'Droid Serif'`). Defaults to Noto Sans. Modifies the `body` element. The
  219. #' value of this variable is also stored as a CSS variable that can be
  220. #' referenced with `var(--text-font-family)` in any argument of a style
  221. #' function or in custom CSS.
  222. #' @param text_font_weight Body Text Font Weight. Defaults to normal. Modifies
  223. #' the `body` element. The value of this variable is also stored as a CSS
  224. #' variable that can be referenced with `var(NA)` in any argument of a style
  225. #' function or in custom CSS.
  226. #' @param text_font_url Body Text Font URL(s). Defaults to
  227. #' https://fonts.googleapis.com/css?family=Noto+Sans:400,400i,700,700i&display=swap.
  228. #' Modifies the `@import url()` elements. The value of this variable is also
  229. #' stored as a CSS variable that can be referenced with `var(NA)` in any
  230. #' argument of a style function or in custom CSS.
  231. #' @param text_font_family_fallback Body Text Font Fallbacks. Defaults to
  232. #' -apple-system, BlinkMacSystemFont, avenir next, avenir, helvetica neue,
  233. #' helvetica, Ubuntu, roboto, noto, segoe ui, arial. Modifies the `body`
  234. #' element. The value of this variable is also stored as a CSS variable that
  235. #' can be referenced with `var(--text-font-family-fallback)` in any argument
  236. #' of a style function or in custom CSS.
  237. #' @param text_font_base Body Text Base Font (Total Failure Fallback). Defaults
  238. #' to sans-serif. Modifies the `body` element. The value of this variable is
  239. #' also stored as a CSS variable that can be referenced with
  240. #' `var(--text-font-base)` in any argument of a style function or in custom
  241. #' CSS.
  242. #' @param header_font_google Use `google_font()` to specify header font.
  243. #' Defaults to `NULL`. Modifies the `body` element. The value of this
  244. #' variable is also stored as a CSS variable that can be referenced with
  245. #' `var(NA)` in any argument of a style function or in custom CSS.
  246. #' @param header_font_family Header Font Family (xaringan default is
  247. #' `'Yanone Kaffeesatz'`). Defaults to Cabin. Modifies the `h1, h2, h3`
  248. #' elements. The value of this variable is also stored as a CSS variable that
  249. #' can be referenced with `var(--header-font-family)` in any argument of a
  250. #' style function or in custom CSS.
  251. #' @param header_font_weight Header Font Weight. Defaults to 600. Modifies the
  252. #' `h1, h2, h3` elements. The value of this variable is also stored as a CSS
  253. #' variable that can be referenced with `var(NA)` in any argument of a style
  254. #' function or in custom CSS.
  255. #' @param header_font_url Header Font URL. Defaults to
  256. #' https://fonts.googleapis.com/css?family=Cabin:600,600i&display=swap.
  257. #' Modifies the `@import url` elements. The value of this variable is also
  258. #' stored as a CSS variable that can be referenced with `var(NA)` in any
  259. #' argument of a style function or in custom CSS.
  260. #' @param code_font_google Use `google_font()` to specify code font. Defaults
  261. #' to `NULL`. Modifies the `body` element. The value of this variable is also
  262. #' stored as a CSS variable that can be referenced with `var(NA)` in any
  263. #' argument of a style function or in custom CSS.
  264. #' @param code_font_family Code Font Family. Defaults to Source Code Pro.
  265. #' Modifies the `.remark-code, .remark-inline-code` classes. The value of
  266. #' this variable is also stored as a CSS variable that can be referenced with
  267. #' `var(--code-font-family)` in any argument of a style function or in custom
  268. #' CSS.
  269. #' @param code_font_size Code Text Font Size. Defaults to 0.9rem. Modifies the
  270. #' `.remark-inline` class. The value of this variable is also stored as a CSS
  271. #' variable that can be referenced with `var(--code-font-size)` in any
  272. #' argument of a style function or in custom CSS.
  273. #' @param code_font_url Code Font URL. Defaults to
  274. #' https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700&display=swap.
  275. #' Modifies the `@import url` elements. The value of this variable is also
  276. #' stored as a CSS variable that can be referenced with `var(NA)` in any
  277. #' argument of a style function or in custom CSS.
  278. #' @param code_font_family_fallback Code Font Fallback. Defaults to Menlo,
  279. #' Consolas, Monaco, Liberation Mono, Lucida Console. Modifies the
  280. #' `.remark-code, .remark-inline-code` classes. The value of this variable is
  281. #' also stored as a CSS variable that can be referenced with `var(NA)` in any
  282. #' argument of a style function or in custom CSS.
  283. #' @template theme_params
  284. #' @template style_xaringan
  285. #' @export
  286. style_xaringan <- function(
  287. text_color = "#000",
  288. header_color = "#000",
  289. background_color = "#FFF",
  290. link_color = "rgb(249, 38, 114)",
  291. text_bold_color = NULL,
  292. text_slide_number_color = inverse_background_color,
  293. padding = "16px 64px 16px 64px",
  294. background_image = NULL,
  295. background_size = NULL,
  296. background_position = NULL,
  297. code_highlight_color = "rgba(255,255,0,0.5)",
  298. code_inline_color = "#000",
  299. code_inline_background_color = NULL,
  300. code_inline_font_size = "1em",
  301. inverse_background_color = "#272822",
  302. inverse_text_color = "#d6d6d6",
  303. inverse_text_shadow = FALSE,
  304. inverse_header_color = "#f3f3f3",
  305. title_slide_text_color = inverse_text_color,
  306. title_slide_background_color = inverse_background_color,
  307. title_slide_background_image = NULL,
  308. title_slide_background_size = NULL,
  309. title_slide_background_position = NULL,
  310. footnote_color = NULL,
  311. footnote_font_size = "0.9em",
  312. footnote_position_bottom = "60px",
  313. left_column_subtle_color = "#777",
  314. left_column_selected_color = "#000",
  315. blockquote_left_border_color = "lightgray",
  316. table_border_color = "#666",
  317. table_row_border_color = "#ddd",
  318. table_row_even_background_color = "#eee",
  319. base_font_size = "20px",
  320. text_font_size = "1rem",
  321. header_h1_font_size = "2.75rem",
  322. header_h2_font_size = "2.25rem",
  323. header_h3_font_size = "1.75rem",
  324. header_background_auto = FALSE,
  325. header_background_color = header_color,
  326. header_background_text_color = background_color,
  327. header_background_padding = NULL,
  328. header_background_content_padding_top = "7rem",
  329. header_background_ignore_classes = c('normal', 'inverse', 'title', 'middle', 'bottom'),
  330. text_slide_number_font_size = "0.9em",
  331. text_font_google = NULL,
  332. text_font_family = "Noto Sans",
  333. text_font_weight = "normal",
  334. text_font_url = "https://fonts.googleapis.com/css?family=Noto+Sans:400,400i,700,700i&display=swap",
  335. text_font_family_fallback = "-apple-system, BlinkMacSystemFont, avenir next, avenir, helvetica neue, helvetica, Ubuntu, roboto, noto, segoe ui, arial",
  336. text_font_base = "sans-serif",
  337. header_font_google = NULL,
  338. header_font_family = "Cabin",
  339. header_font_weight = "600",
  340. header_font_url = "https://fonts.googleapis.com/css?family=Cabin:600,600i&display=swap",
  341. code_font_google = NULL,
  342. code_font_family = "Source Code Pro",
  343. code_font_size = "0.9rem",
  344. code_font_url = "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700&display=swap",
  345. code_font_family_fallback = "Menlo, Consolas, Monaco, Liberation Mono, Lucida Console",
  346. colors = NULL,
  347. extra_css = NULL,
  348. extra_fonts = NULL,
  349. outfile = "xaringan-themer.css"
  350. ) {
  351. # DO NOT EDIT - Generated from inst/scripts/generate_theme_functions.R
  352. # Make sure font names are wrapped in quotes if they have spaces
  353. f_args <- names(formals(sys.function()))
  354. for (var in f_args[grepl("font_family$", f_args)]) {
  355. var_value <- get(var, inherits = FALSE)
  356. if (!is.null(var_value)) {
  357. eval(parse(text = paste0(var, "<-quote_elements_w_spaces(", var, ")")))
  358. }
  359. # set an is_google flag default of FALSE that is possibly overwritten later
  360. eval(parse(text = paste0(sub("font_family$", "font_is_google", var), "<-0")))
  361. }
  362. # Warn if base_font_size isn't absolute
  363. css_abs_units <- c("cm", "mm", "Q", "in", "pc", "pt", "px")
  364. if (!grepl(paste(tolower(css_abs_units), collapse = "|"), tolower(base_font_size))) {
  365. warning(
  366. glue::glue(
  367. "Base font size '{base_font_size}' is not in absolute units. ",
  368. "For best results, specify the `base_font_size` using absolute CSS units: ",
  369. "{paste(css_abs_units, collapse = ', ')}"
  370. ),
  371. call. = FALSE,
  372. immediate. = TRUE
  373. )
  374. }
  375. # Use font_..._google args to overwrite font args
  376. for (var in f_args[grepl("font_google$", f_args)]) {
  377. gf <- eval(parse(text = var))
  378. if (is.null(gf)) next
  379. if (!inherits(gf, "google_font")) {
  380. stop("`", var, "` must be set using `google_font()`.")
  381. }
  382. group <- strsplit(var, "_")[[1]][1]
  383. if (group == "text") {
  384. text_font_family <- quote_elements_w_spaces(gf$family)
  385. text_font_weight <- gf$weights %||% "normal"
  386. text_font_weight <- substr(text_font_weight, 1, regexpr(",", text_font_weight)[1] - 1)
  387. text_font_url <- gf$url
  388. } else {
  389. eval(parse(text = paste0(group, "_font_family <- quote_elements_w_spaces(gf$family)")))
  390. eval(parse(text = paste0(group, "_font_url <- gf$url")))
  391. }
  392. eval(parse(text = paste0(group, "_font_is_google <- 1")))
  393. }
  394. is_default <- function(type, suffix, reference = style_xaringan) {
  395. var <- paste0(type, "_", suffix)
  396. default_value <- formals(reference)[[var]]
  397. if (suffix == "font_family") {
  398. default_value <- quote_elements_w_spaces(default_value)
  399. }
  400. get(var, envir = parent.frame(2), inherits = FALSE) == default_value
  401. }
  402. # the defaults are google fonts
  403. for (var in c("text", "header", "code")) {
  404. suffixes <- c("font_family", "font_weight", "font_url")
  405. if (var == "code") suffixes <- setdiff(suffixes, "font_weight")
  406. var_is_google <- all(vapply(suffixes, is_default, logical(1), type = var))
  407. if (var_is_google) {
  408. eval(parse(text = paste0(var, "_font_is_google <- 1")))
  409. }
  410. }
  411. extra_font_imports <- if (is.null(extra_fonts)) "" else list2fonts(extra_fonts)
  412. extra_font_imports <- paste(extra_font_imports, collapse = "\n")
  413. # convert NA arguments to NULL
  414. for (var in f_args) {
  415. val <- eval(parse(text = var))
  416. if (is.null(val)) next
  417. val <- val[!is.na(val)]
  418. is_na <- length(val) == 0
  419. if (is_na) assign(var, NULL)
  420. }
  421. # prepare variables for template
  422. body_font_family <- paste(c(text_font_family, text_font_family_fallback, text_font_base), collapse = ", ")
  423. background_size_fallback <- if (is.null(background_position)) "cover" else "100%"
  424. background_size <- background_image %??% (background_size %||% background_size_fallback)
  425. title_slide_background_size <- title_slide_background_size %||% (
  426. title_slide_background_image %??% "cover"
  427. )
  428. table_row_even_background_color <- table_row_even_background_color %||% background_color
  429. # stash theme settings in package env
  430. lapply(f_args, function(n) assign(n, get(n), envir = xaringanthemer_env))
  431. for (font_is_google in paste0(c("text", "code", "header"), "_font_is_google")) {
  432. assign(
  433. font_is_google,
  434. get(font_is_google, inherits = FALSE) == 1,
  435. envir = xaringanthemer_env
  436. )
  437. }
  438. xaringanthemer_version <- utils::packageVersion("xaringanthemer")
  439. # prepare header background object
  440. needs_leading_dot <- !grepl("^\\.", header_background_ignore_classes)
  441. header_background_ignore_classes[needs_leading_dot] <- paste0(
  442. ".",
  443. header_background_ignore_classes[needs_leading_dot]
  444. )
  445. header_background_ignore_classes <- purrr::map(
  446. header_background_ignore_classes,
  447. ~ list(class = .)
  448. )
  449. if (is.null(header_background_padding)) {
  450. slide_padding <- css_get_padding(padding)
  451. header_background_padding <- paste(
  452. "2rem", slide_padding$right, "1.5rem", slide_padding$left
  453. )
  454. }
  455. header_background <- list(
  456. auto = header_background_auto,
  457. background_color = header_background_color,
  458. text_color = header_background_text_color,
  459. padding = header_background_padding,
  460. content_padding_top = header_background_content_padding_top,
  461. ignore = header_background_ignore_classes
  462. )
  463. colors <- prepare_colors(colors)
  464. tf <- system.file("resources", "template.css", package = "xaringanthemer")
  465. template <- readLines(tf, warn = FALSE)
  466. template <- paste(template, collapse = "\n")
  467. x <- whisker::whisker.render(template)
  468. if (!is.null(extra_css)) {
  469. x <- c(x, style_extra_css(extra_css, outfile = NULL))
  470. }
  471. if (is.null(outfile)) {
  472. return(x)
  473. }
  474. writeLines(x, con = outfile)
  475. invisible(outfile)
  476. }