gadenbuie / xaringanExtra

:ferris_wheel: A playground of enhancements and extensions for xaringan slides.
https://pkg.garrickadenbuie.com/xaringanExtra
Other
448 stars 36 forks source link

use_logo: issue with the quotes around the url of the background-image #25

Closed chainsawriot closed 4 years ago

chainsawriot commented 4 years ago

I found that the added logo may not display sometimes. For some unknown reasons, the quotes around the added css may corrupt sometimes. Actually, the quotes are not required. I have patched the logo_css function like so:

logo_css <- function(url, width, height, position) {
  if (!is_css_position(position)) {
    stop("Please use `css_position()` to specify the position of your logo", call. = FALSE)
  }
  dirs <- c("top", "right", "left", "bottom")
  names(dirs) <- dirs
  p <- lapply(dirs, function(pos) {
    if (!is.null(position[[pos]])) sprintf("%s:%s;", pos, position[[pos]]) else ""
  })
  width <- htmltools::validateCssUnit(width)
  height <- htmltools::validateCssUnit(height)
  sprintf("
.xaringan-extra-logo {
  width: %s;
  height: %s;
  z-index: 0;
  background-image: url(%s);
  background-size: contain;
  background-repeat: no-repeat;
  position: absolute;
  %s%s%s%s
}
", width, height, url, p$top, p$right, p$bottom, p$left)
} 

If you agree with that, I can make a PR.