feddelegrand7 / fabricerin

Create Easily Canvas in Shiny and RMarkdown Documents
https://ihaddadenfodil.com/post/fabricerin-a-tutorial/
Other
54 stars 5 forks source link

How to include in Xaringan slides #3

Closed Robinlovelace closed 4 years ago

Robinlovelace commented 4 years ago

The readme states that

you can also use it within your xaringan slides

Awesome, but how? I looked at the original tweet and an associated issue: https://github.com/yihui/xaringan/issues/204

Thanks for a fantastic package. FYI, it works great with a Wacom drawing tablet and pen :pen: :tada:

Robinlovelace commented 4 years ago

Reproducible example, create a file called test.Rmd and paste the following, then run:

---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
institute: "RStudio, PBC"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
# runtime: shiny
---

background-image: url(https://upload.wikimedia.org/wikipedia/commons/b/be/Sharingan_triple.svg)

```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)

???

Image credit: Wikimedia Commons


Illustration

library(shiny)
library(fabricerin)

ui <- fluidPage(

  fabric_drawing(cid = "canvas123")

)

server <- function(input, output){}

shinyApp(ui, server)
feddelegrand7 commented 4 years ago

Hi Robin,

You can use the fabricerin package in xaringan slides just as you use it with Rmd documents (see here : https://ihaddadenfodil.com/post/fabricering-a-tutorial/). Don't use the Shiny functions with Rmd documents.

Best.

feddelegrand7 commented 4 years ago

Example ###################################### .pull-left[

library(ggplot2)
ggplot(mpg, aes(hwy, cty)) + 
geom_point()
```]

.pull-right[
```{r echo = FALSE}
library(fabricerin)
fabric_drawing("canvaId")
Robinlovelace commented 4 years ago

Confirmed, it works, no shiny needed (all examples in the readme use shiny which is what confused me):

Peek 2020-08-05 14-38

feddelegrand7 commented 4 years ago

Indeed, it's a bit confusing, I've separated Shiny docs (in the README) and Rmd docs (within my website). Maybe I'll modify that structure.