gadenbuie / xaringanExtra

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

Add `use_banner()` #161

Closed gadenbuie closed 2 years ago

gadenbuie commented 2 years ago

Fixes #130

Adds use_banner() to add text into the left, center, or right column of a top or bottom banner. Each position is associated with an argument, e.g. bottom_left or top_right, and plain text, raw HTML, or htmltools mediated HTML can be used.

You can also exclude slides of a particular class from having the banner with the exclude argument.

use_banner(bottom_left = "bit.ly/my-awesome-slides")

use_banner(
  bottom_left = "bit.ly/my-awesome-slides",
  top_center = "My Presentation",
  exclude = c("title-slide", "inverse")
)

(use_banner() should only be called once per slide deck, though.)

There are CSS variables for all of the important bits and I'll probably add a style_banner() function.

image

# example in previous screenshot
use_banner(
  bottom_left = htmltools::tags$a(href = "https://bit.ly/my-fancy-slides", "bit.ly/my-fancy-slides"),
  top_right = "Thomas J. Mock",
  top_left = "My Presentation",
  exclude = "title-slide"
)

I also added style_banner(), for something crazy try this

# note this should be in a separate chunk from `use_banner()`
style_banner("white", "red")
style_banner("red", "white", selector = ".inverse")

given the little comment above, maybe I should figure out how to make

use_banner()
style_banner()

work as expected in xaringan's weird markdown parsing environment

codecov-commenter commented 2 years ago

Codecov Report

Merging #161 (2ea2103) into main (ce8be69) will increase coverage by 5.14%. The diff coverage is 98.70%.

@@            Coverage Diff             @@
##             main     #161      +/-   ##
==========================================
+ Coverage   43.81%   48.96%   +5.14%     
==========================================
  Files          20       21       +1     
  Lines         744      821      +77     
==========================================
+ Hits          326      402      +76     
- Misses        418      419       +1     
Impacted Files Coverage Δ
R/xaringanExtra-package.R 0.00% <ø> (ø)
R/banner.R 98.64% <98.64%> (ø)
R/utils.R 44.44% <100.00%> (+27.77%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ce8be69...2ea2103. Read the comment docs.

gadenbuie commented 2 years ago

@mattwarkentin would you like to give this a spin and see what you think? Am I missing anything? And thank you for the code sketch and name idea!

gadenbuie commented 2 years ago

Maybe I should add hooks (CSS variables) to set the width of each of the columns. Currently I think things will start to overlap with long text in any of the columns so it would be necessary to set the width if you wanted it to wrap or not overflow into other columns.

gadenbuie commented 2 years ago

I think this is in a good spot, so I'm going to merge. Still would love feedback if any one has any!

mattwarkentin commented 2 years ago

@gadenbuie Thanks for the tag. Just took it for a test drive and everything seems to be working/playing nicely with my current slide deck. Cool new feature!