Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-use use_logo for multiple logos/multiple rules templates #132

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rsimonmd
Copy link

Disclaimer: This is my first ever pull request so please feel free to dunk me for all the things I have certainly missed and the etiquette I am not following: I am very eager to learn! Also, I love your package so much 😄

Hello,

I work for a french public health/government organisation and we have a very strict ppt template to follow. I am allowed to pursue the use of html slides but only if I use the official template (example here, although you shouldn't look it will make your eyes bleed).

Up until today and diving into the use_logo() function from your package, I was stuck on a simple problem: our template has different background images/logos depending on the slide ... And if I made CSS rules for slide classes using background-image property, then I couldn't use background-image when I needed it for presentation purposes (at least my users wouldn't understand why the logos suddenly disapeared).

I tried your package but using the function twice resulted in the last call erasing the first so I went ahead and slightly changed some arguments to allow for the naming of the added image and thus adding as many divs as needed !

PS: if you took a look at the example ppt format (again, I advise against it for your eyes safety), the images that I need to change are vertical colored bars. I figured I also could use a variation of what you did there (before use_logo existed I guess?) to add spans with a colored background but I don't know if thats a better way of doing things in HTML ...

Have a great day

Raphaël

@gadenbuie
Copy link
Owner

Hi @rsimonmd, thanks for the PR! The idea of having multiple logos has certainly come up before and your approach seems like a good place to start. I took a look at your official template (with sunglasses on to protect my eyes [ouch!]), but it would be helpful if you could share a small example that demonstrates how the updated version works. You could copy/paste an example Rmd source into a code block in a comment in this PR, rather than having to commit the file to the PR branch.

@rsimonmd
Copy link
Author

rsimonmd commented Aug 11, 2021

Of course ! Here it is :

---
title: "A clever title"
subtitle: "Demoing xaringanExtra's expanded use_logo()"
author: "Raphael Simon"
institute: "Myself"
date: "`r Sys.Date()`"
output:
  xaringan::moon_reader:
    lib_dir: libs
    seal: false
    nature:
      ratio: 16:10
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---
class: middle center someclass

```{r setup, echo = FALSE, warning=FALSE}
library(xaringanExtra)

use_logo(
  image_url = "logo1", 
  width = "150px",
  height = "150px",
  position = css_position(top = "1em", left = "1em"),
  logo_class = "my-xaringan-logo1",
  exclude_class = c("hide_logo", "someotherclass")
)

use_logo(
  image_url = "logo2", 
  width = "150px",
  height = "150px",
  position = css_position(top = "1em", right = "1em"),
  logo_class = "my-xaringan-logo2",
  exclude_class = c("hide_logo", "someclass")
)
```

# A slide

### With only the left-side logo

---
class: middle center someotherclass

# A slide

### With only the right-side logo

---
class: middle center

# Or both !

Notice how they both appear on the title slide as well!  
You can change that by excluding `"title-slide"` from `use_logo(exclude_class = c(...))` as well

I hope that answers your query, thanks for allowing me to contribute 😄

EDIT : added some punctuation so that this Rmd actually knits withotu errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants