😎 Give your xaringan slides some style
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
821B

  1. # Xaringan Theme from Coolors URL
  2. # ex: https://coolors.co/fcf7f8-06d6a0-fcb0b3-f93943-7eb2dd
  3. # ex: https://coolors.co/e06c53-ffba49-a3d9ff-d6efff-7e6b8f
  4. # ex: https://coolors.co/ff5e5b-b9d8c2-ffffea-00cecb-ffed66
  5. xaringan_coolors_accent <- function(coolors_url, order = "12345", ...) {
  6. stopifnot(length(coolors_url) == 1)
  7. colors <- coolors2colors(coolors_url)
  8. order <- stringr::str_split(order, "")[1]
  9. order <- unlist(purrr::map(order, as.integer))
  10. colors <- colors[order]
  11. colors <- list(
  12. primary = colors[1],
  13. secondary = colors[2]
  14. )
  15. return(colors)
  16. }
  17. coolors2colors <- function(url) {
  18. colors <- stringr::str_extract(url, "([a-f0-9]{6}-?){5}")
  19. colors <- stringr::str_split(colors, "-")
  20. colors <- purrr::map(colors, ~ paste0("#", .))
  21. if (length(colors) == 1) colors[[1]]
  22. else colors
  23. }