😎 Give your xaringan slides some style
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

312 linhas
18KB

  1. template_variables <- tibble::tribble(
  2. ~ variable, ~ default, ~ element, ~ description
  3. , "text_color", "#000", "body", "Text Color"
  4. , "header_color", "#000", "h1, h2, h3", "Header Color"
  5. , "background_color", "#FFF", ".remark-slide-content", "Slide Background Color"
  6. , "link_color", "rgb(249, 38, 114)", "a, a > code", "Link Color"
  7. , "text_bold_color", NA_character_, "strong", "Bold Text Color"
  8. , "text_slide_number_color", "{inverse_background_color}", ".remark-slide-number", "Slide Number Color"
  9. , "code_highlight_color", "rgba(255,255,0,0.5)", ".remark-code-line-highlighted", "Code Line Highlight"
  10. , "code_inline_color", "#000", ".remark-inline-code", "Inline Code Color"
  11. , "code_inline_background_color", NA_character_, ".remark-inline-code", "Inline Code Background Color"
  12. , "inverse_background_color", "#272822", ".inverse", "Inverse Background Color"
  13. , "inverse_text_color", "#d6d6d6", ".inverse", "Inverse Text Color"
  14. , "inverse_text_shadow", "{FALSE}", ".inverse", "Enables Shadow on text of inverse slides"
  15. , "inverse_header_color", "#f3f3f3", ".inverse h1, .inverse h2, .inverse h3", "Inverse Header Color"
  16. , "title_slide_text_color", "{inverse_text_color}", ".title-slide", "Title Slide Text Color"
  17. , "title_slide_background_color", "{inverse_background_color}", ".title-slide", "Title Slide Background Color"
  18. , "title_slide_background_image", NA_character_, ".title-slide", "Title Slide Background Image URL"
  19. , "left_column_subtle_color", "#777", ".left-column", "Left Column Text (not last)"
  20. , "left_column_selected_color", "#000", ".left-column h2:last-of-type, .left-column h3:last-child", "Left Column Current Selection"
  21. , "blockquote_left_color", "lightgray", "blockquote", "Blockquote Left Border Color"
  22. , "table_border_color", "#666", "table: border-top, border-bottom", "Table top/bottom border"
  23. , "table_row_border_color", "#ddd", "table thead th: border-bottom", "Table row inner bottom border"
  24. , "table_row_even_background_color", "#eee", "thead, tfoot, tr:nth-child(even)", "Table Even Row Background Color"
  25. , "text_size", "20px", ".remark-slide-content", "Slide Body Text Size"
  26. , "text_size_h1", "55px", ".remark-slide-content h1", "h1 Header Text Size"
  27. , "text_size_h2", "45px", ".remark-slide-content h2", "h2 Header Text Size"
  28. , "text_size_h3", "35px", ".remark-slide-content h3", "h3 Header Text Size"
  29. , "text_size_slide_number", "20px", ".remark-slide-number", "Slide Number Text Size"
  30. , "text_size_code_inline", "20px", ".remark-inline-code", "Inline Code Text Size"
  31. , "text_size_code", "18px", ".remark-inline", "Code Text Size"
  32. , "text_font_google", NULL, "body", "Use `google_font()` to specify body font"
  33. , "text_font_family", "'Droid Serif'", "body", "Body Text Font Family"
  34. , "text_font_weight", "normal", "body", "Body Text Font Weight"
  35. , "text_font_url", "https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic", "@import url()", "Body Text Font URL(s)"
  36. , "text_font_family_fallback", "'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC'", "body", "Body Text Font Fallbacks"
  37. , "text_font_base", "serif", "body", "Body Text Base Font (Total Failure Fallback)"
  38. , "header_font_google", NULL, "body", "Use `google_font()` to specify header font"
  39. , "header_font_family", "'Yanone Kaffeesatz'", "h1, h2, h3", "Header Font Family"
  40. , "header_font_weight", "normal", "h1, h2, h3", "Header Font Weight"
  41. , "header_font_url", "https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz", "@import url", "Header Font URL"
  42. , "code_font_google", NULL, "body", "Use `google_font()` to specify code font"
  43. , "code_font_family", "'Source Code Pro'", ".remark-code, .remark-inline-code", "Code Font Family"
  44. , "code_font_url", "https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700", "@import url", "Code Font URL"
  45. , "code_font_family_fallback", "'Lucida Console', Monaco", ".remark-code, .remark-inline-code", "Code Font Fallback"
  46. )
  47. set_default <- function(tv, ...) {
  48. vars <- c(...)
  49. for (var in names(vars)) {
  50. tv[tv$variable == var, 'default'] <- vars[var]
  51. }
  52. tv
  53. }
  54. template_mono_light <- tibble::tribble(
  55. ~ variable, ~ default, ~ element, ~ description
  56. , "base_color", "#23395b", "multiple", "Monotone base color, works best with a strong color"
  57. , "white_color", "{lighten_color(base_color, 0.9)}", "multiple", "Brightest color used, default is a very light version of `base_color`"
  58. , "black_color", "{darken_color(base_color, 0.3)}", "multiple", "Darkest color used, default is a very dark, version of `base_color`"
  59. )
  60. template_mono_light <- do.call('rbind', list(template_mono_light, template_variables))
  61. template_mono_light <- set_default(
  62. template_mono_light,
  63. text_color = "{black_color}",
  64. header_color = "{base_color}",
  65. background_color = "{white_color}",
  66. link_color = "{base_color}",
  67. text_bold_color = "{base_color}",
  68. text_slide_number_color = "{base_color}",
  69. code_inline_color = "{base_color}",
  70. inverse_background_color = "{base_color}",
  71. inverse_text_color = "{white_color}",
  72. inverse_header_color = "{white_color}",
  73. left_column_subtle_color = "{apply_alpha(base_color, 0.6)}",
  74. left_column_selected_color = "{base_color}",
  75. blockquote_left_color = "{apply_alpha(base_color, 0.5)}",
  76. table_row_even_background_color = "{lighten_color(base_color, 0.8)}")
  77. template_mono_dark <- tibble::tribble(
  78. ~ variable, ~ default, ~ element, ~ description
  79. , "base_color", "#cbf7ed", "multiple", "Monotone Base Color, works best with a light color."
  80. , "white_color", "{lighten_color(base_color, 0.8)}", "multiple", "Brightest color used, default is a very light version of `base_color`"
  81. , "black_color", "{darken_color(base_color, 0.85)}", "multiple", "Darkest color used, default is a very dark, version of `base_color`"
  82. )
  83. template_mono_dark <- do.call('rbind', list(template_mono_dark, template_variables))
  84. template_mono_dark <- set_default(
  85. template_mono_dark,
  86. text_color = "{white_color}",
  87. header_color = "{base_color}",
  88. background_color = "{black_color}",
  89. link_color = "{base_color}",
  90. text_bold_color = "{base_color}",
  91. text_slide_number_color = "{base_color}",
  92. code_inline_color = "{base_color}",
  93. inverse_background_color = "{base_color}",
  94. inverse_text_color = "{black_color}",
  95. inverse_header_color = "{black_color}",
  96. left_column_subtle_color = "{apply_alpha(base_color, 0.6)}",
  97. left_column_selected_color = "{base_color}",
  98. blockquote_left_color = "{apply_alpha(base_color, 0.5)}",
  99. table_row_even_background_color = "{darken_color(base_color, 0.7)}")
  100. template_mono_accent <- tibble::tribble(
  101. ~ variable, ~ default, ~ element, ~ description
  102. , "base_color", "#43418A", "multiple", "Monotone Base Color, works best with a strong color."
  103. , "white_color", "#FFFFFF", "multiple", "Brightest color used"
  104. , "black_color", "#272822", "multiple", "Darkest color used"
  105. )
  106. template_mono_accent <- do.call('rbind', list(template_mono_accent, template_variables))
  107. template_mono_accent <- set_default(
  108. template_mono_accent,
  109. text_color = "{black_color}",
  110. header_color = "{base_color}",
  111. background_color = "{white_color}",
  112. link_color = "{base_color}",
  113. text_bold_color = "{base_color}",
  114. text_slide_number_color = "{base_color}",
  115. code_inline_color = "{base_color}",
  116. inverse_background_color = "{base_color}",
  117. inverse_text_color = "{white_color}",
  118. inverse_header_color = "{white_color}",
  119. left_column_subtle_color = "{apply_alpha(base_color, 0.6)}",
  120. left_column_selected_color = "{base_color}",
  121. blockquote_left_color = "{apply_alpha(base_color, 0.5)}",
  122. table_row_even_background_color = "{lighten_color(base_color, 0.7)}")
  123. template_mono_accent_inverse <- tibble::tribble(
  124. ~ variable, ~ default, ~ element, ~ description
  125. , "base_color", "#3C989E", "multiple", "Monotone Base Color, works best with a light color."
  126. , "white_color", "#FFFFFF", "multiple", "Brightest color used, default is a very light version of `base_color`"
  127. , "black_color", "{darken_color(base_color, 0.9)}", "multiple", "Darkest color used, default is a very dark, version of `base_color`"
  128. )
  129. template_mono_accent_inverse <- do.call('rbind', list(template_mono_accent_inverse, template_variables))
  130. template_mono_accent_inverse <- set_default(
  131. template_mono_accent_inverse,
  132. text_color = "{white_color}",
  133. header_color = "{base_color}",
  134. background_color = "{black_color}",
  135. link_color = "{base_color}",
  136. text_bold_color = "{base_color}",
  137. text_slide_number_color = "{base_color}",
  138. code_inline_color = "{base_color}",
  139. inverse_background_color = "{base_color}",
  140. inverse_text_color = "{black_color}",
  141. inverse_header_color = "{black_color}",
  142. left_column_subtle_color = "{apply_alpha(base_color, 0.6)}",
  143. left_column_selected_color = "{base_color}",
  144. blockquote_left_color = "{apply_alpha(base_color, 0.5)}",
  145. table_row_even_background_color = "{darken_color(base_color, 0.7)}")
  146. template_duo_light <- tibble::tribble(
  147. ~ variable, ~ default, ~ element, ~ description
  148. , "primary_color", "#1F4257", "mutliple", "Duotone Secondary Color"
  149. , "secondary_color", "#F97B64", "multiple", "Duotone Primary Color"
  150. , "white_color", "{lighten_color(primary_color, 0.99)}", "multiple", "Brightest color used, default is a very light version of `primary_color`"
  151. , "black_color", "{darken_color(secondary_color, 0.9)}", "multiple", "Darkest color used, default is a very dark version of `secondary_color`"
  152. )
  153. template_duo_light <- do.call('rbind', list(template_duo_light, template_variables))
  154. template_duo_light <- set_default(
  155. template_duo_light,
  156. text_color = "{black_color}",
  157. header_color = "{primary_color}",
  158. background_color = "{white_color}",
  159. link_color = "{secondary_color}",
  160. text_bold_color = "{secondary_color}",
  161. text_slide_number_color = "{primary_color}",
  162. code_inline_color = "{secondary_color}",
  163. inverse_background_color = "{primary_color}",
  164. inverse_text_color = "{secondary_color}",
  165. inverse_header_color = "{secondary_color}",
  166. left_column_subtle_color = "{apply_alpha(secondary_color, 0.6)}",
  167. left_column_selected_color = "{secondary_color}",
  168. blockquote_left_color = "{apply_alpha(secondary_color, 0.5)}",
  169. table_row_even_background_color = "{lighten_color(secondary_color, 0.7)}")
  170. template_duo <- tibble::tribble(
  171. ~ variable, ~ default, ~ element, ~ description
  172. , "primary_color", "#1F4257", "mutliple", "Duotone Primary Color"
  173. , "secondary_color", "#F97B64", "multiple", "Duotone Secondary Color"
  174. )
  175. template_duo <- do.call('rbind', list(template_duo, template_variables))
  176. template_duo <- set_default(
  177. template_duo,
  178. text_color = "{choose_dark_or_light(primary_color, darken_color(primary_color, 0.9), lighten_color(secondary_color, 0.99))}",
  179. header_color = "{secondary_color}",
  180. background_color = "{primary_color}",
  181. link_color = "{secondary_color}",
  182. text_bold_color = "{secondary_color}",
  183. text_slide_number_color = "{text_color}",
  184. code_inline_color = "{secondary_color}",
  185. inverse_background_color = "{secondary_color}",
  186. inverse_text_color = "{primary_color}",
  187. inverse_header_color = "{primary_color}",
  188. title_slide_text_color = "{secondary_color}",
  189. title_slide_background_color = "{primary_color}",
  190. left_column_subtle_color = "{apply_alpha(secondary_color, 0.6)}",
  191. left_column_selected_color = "{secondary_color}",
  192. blockquote_left_color = "{apply_alpha(secondary_color, 0.5)}",
  193. table_row_even_background_color = "{lighten_color(primary_color, 0.3)}")
  194. template_duo_accent <- tibble::tribble(
  195. ~ variable, ~ default, ~ element, ~ description
  196. , "primary_color", "#006747", "mutliple", "Duotone Primary Color"
  197. , "secondary_color", "#CFC493", "multiple", "Duotone Secondary Color"
  198. , "white_color", "#FFFFFF", "multiple", "Brightest color used"
  199. , "black_color", "#000000", "multiple", "Darkest color used"
  200. )
  201. template_duo_accent <- do.call('rbind', list(template_duo_accent, template_variables))
  202. template_duo_accent <- set_default(
  203. template_duo_accent,
  204. text_color = "{black_color}",
  205. header_color = "{primary_color}",
  206. background_color = "{white_color}",
  207. link_color = "{choose_dark_or_light(secondary_color, primary_color, secondary_color)}",
  208. text_bold_color = "{choose_dark_or_light(secondary_color, primary_color, secondary_color)}",
  209. text_slide_number_color = "{primary_color}",
  210. code_inline_color = "{choose_dark_or_light(secondary_color, primary_color, secondary_color)}",
  211. inverse_background_color = "{secondary_color}",
  212. inverse_text_color = "{choose_dark_or_light(secondary_color, black_color, white_color)}",
  213. inverse_header_color = "{choose_dark_or_light(secondary_color, black_color, white_color)}",
  214. title_slide_background_color = "{primary_color}",
  215. title_slide_text_color = "{choose_dark_or_light(primary_color, black_color, white_color)}",
  216. left_column_subtle_color = "{apply_alpha(primary_color, 0.6)}",
  217. left_column_selected_color = "{primary_color}",
  218. blockquote_left_color = "{apply_alpha(secondary_color, 0.5)}",
  219. table_row_even_background_color = "{lighten_color(secondary_color, 0.3)}")
  220. template_duo_accent_inverse <- set_default(
  221. template_duo_accent,
  222. text_color = "{white_color}",
  223. header_color = "{primary_color}",
  224. background_color = "{black_color}",
  225. link_color = "{choose_dark_or_light(secondary_color, secondary_color, primary_color)}",
  226. text_bold_color = "{choose_dark_or_light(secondary_color, secondary_color, primary_color)}",
  227. text_slide_number_color = "{primary_color}",
  228. code_inline_color = "{choose_dark_or_light(secondary_color, secondary_color, primary_color)}",
  229. inverse_background_color = "{secondary_color}",
  230. inverse_text_color = "{choose_dark_or_light(secondary_color, black_color, white_color)}",
  231. inverse_header_color = "{choose_dark_or_light(secondary_color, black_color, white_color)}",
  232. title_slide_background_color = "{primary_color}",
  233. title_slide_text_color = "{choose_dark_or_light(primary_color, black_color, white_color)}",
  234. left_column_subtle_color = "{apply_alpha(primary_color, 0.6)}",
  235. left_column_selected_color = "{primary_color}",
  236. blockquote_left_color = "{apply_alpha(secondary_color, 0.5)}",
  237. table_row_even_background_color = "{darken_color(choose_dark_or_light(primary_color, secondary_color, primary_color), 0.3)}")
  238. solarized <- list(
  239. "base03" = "#002b36",
  240. "base02" = "#073642",
  241. "base01" = "#586e75",
  242. "base00" = "#657b83",
  243. "base0" = "#839496",
  244. "base1" = "#93a1a1",
  245. "base2" = "#eee8d5",
  246. "base3" = "#fdf6e3",
  247. "yellow" = "#b58900",
  248. "orange" = "#cb4b16",
  249. "red" = "#dc322f",
  250. "magenta" = "#d33682",
  251. "violet" = "#6c71c4",
  252. "blue" = "#268bd2",
  253. "cyan" = "#2aa198",
  254. "green" = "#859900")
  255. template_solarized_light <- set_default(
  256. template_variables,
  257. text_color = solarized$base00,
  258. header_color = solarized$red,
  259. background_color = solarized$base3,
  260. link_color = solarized$yellow,
  261. text_bold_color = solarized$magenta,
  262. text_slide_number_color = solarized$base1,
  263. code_highlight_color = "#268bd240", #xaringanthemer:::apply_alpha(solarized$blue, 0.25)
  264. code_inline_color = solarized$violet,
  265. inverse_background_color = solarized$base03,
  266. inverse_text_color = solarized$base3,
  267. inverse_header_color = "{inverse_text_color}",
  268. title_slide_text_color = "{inverse_text_color}",
  269. title_slide_background_color = "{inverse_background_color}",
  270. left_column_subtle_color = solarized$base1,
  271. left_column_selected_color = solarized$base01,
  272. blockquote_left_color = solarized$orange,
  273. table_border_color = solarized$base0,
  274. table_row_border_color = solarized$base0,
  275. table_row_even_background_color = solarized$base2
  276. )
  277. template_solarized_dark <- set_default(
  278. template_variables,
  279. text_color = solarized$base0,
  280. header_color = solarized$red,
  281. background_color = solarized$base03,
  282. link_color = solarized$yellow,
  283. text_bold_color = solarized$magenta,
  284. text_slide_number_color = solarized$base01,
  285. code_highlight_color = "#268bd240", #xaringanthemer:::apply_alpha(solarized$blue, 0.25)
  286. code_inline_color = solarized$violet,
  287. inverse_background_color = solarized$base3,
  288. inverse_text_color = solarized$base03,
  289. inverse_header_color = "{inverse_text_color}",
  290. title_slide_text_color = "{inverse_text_color}",
  291. title_slide_background_color = "{inverse_background_color}",
  292. left_column_subtle_color = solarized$base01,
  293. left_column_selected_color = solarized$base1,
  294. blockquote_left_color = solarized$orange,
  295. table_border_color = solarized$base00,
  296. table_row_border_color = solarized$base00,
  297. table_row_even_background_color = solarized$base02
  298. )