rstudio / distill

Distill for R Markdown
https://rstudio.github.io/distill/
Apache License 2.0
423 stars 57 forks source link

Using crosstalk filters disrupt Distill css theming? #275

Open mfherman opened 3 years ago

mfherman commented 3 years ago

I noticed this issue when trying to use crosstalk with Leaflet and DT in a distill article. I'm not savvy enough to figure out where in the HTML or CSS the problem is introduced, but it appears that when using a filter_* function from crosstalk, the formatting (font, text size, in particular) in the rest of distill article changes. I'm not sure if this issue belongs here or in crosstalk, but I haven't had the same issue when using crosstalk filters with other R Markdown templates.

Here are two sample Rmds that exhibit the behavior. The first is the default distill output:

---
title: "No Crosstalk Distill"
output: distill::distill_article
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)

Distill is a publication format for scientific and technical writing, native to the web.

Learn more about using Distill for R Markdown at https://rstudio.github.io/distill.

![image](https://user-images.githubusercontent.com/24945757/103363075-434c1780-4a88-11eb-95b9-73e916ff5831.png)

And the second adds a select filter from crosstalk:

title: "Crosstalk Distill" output: distill::distill_article

knitr::opts_chunk$set(echo = FALSE)
library(crosstalk)

shared_iris <- SharedData$new(iris)

filter_select(
  id = "species",
  label = "Species",
  sharedData = shared_iris,
  group = ~Species
)

Distill is a publication format for scientific and technical writing, native to the web.

Learn more about using Distill for R Markdown at https://rstudio.github.io/distill.



![image](https://user-images.githubusercontent.com/24945757/103363098-50690680-4a88-11eb-9eec-02fc70f22e35.png)

I've also noticed this behavior elsewhere, so I don't think it is limited to my configuration. For example, on @jthomasmock's distill blog, [his post using crosstalk](https://themockup.blog/posts/2020-05-29-client-side-interactivity-do-more-with-crosstalk/) has similar formatting issues that aren't present in his other blog posts.
apreshill commented 3 years ago

Hi there!

I have a hypothesis 😄 I believe filter_select() introduces bootstrap, since the docs state: https://rdrr.io/cran/crosstalk/man/filter_select.html

"Creates a select box or list of checkboxes"

I believe crosstalk will bring in bootstrap if you use:

But not:

mfherman commented 3 years ago

Yes, that makes sense! I'm not seeing the issue just using filter_slider():

---
title: "Crosstalk Distill"
output: distill::distill_article
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(crosstalk)

shared_iris <- SharedData$new(iris)

filter_slider(
  id = "sepal",
  label = "Sepal Lenth",
  sharedData = shared_iris,
  column = ~Sepal.Length
)

Distill is a publication format for scientific and technical writing, native to the web.

Learn more about using Distill for R Markdown at https://rstudio.github.io/distill.


![image](https://user-images.githubusercontent.com/24945757/103368508-ac865780-4a95-11eb-95cb-285e700641c4.png)

So given that bootstrap appears to be the culprit, is there a way to have it not interfere with the distill formatting or do bootstrap and distill just not play well together? 
apreshill commented 3 years ago

Bootstrap in general clobbers all site-level styling. It happens with every blogdown site (not based on bootstrap) as well. I suspect an immediate workaround involves iframes.

mfherman commented 3 years ago

Got it! I'll poke around and see what I can make work for now.

werkstattcodes commented 3 years ago

Got it! I'll poke around and see what I can make work for now.

I ran into a similar issue and this helped me: https://github.com/rstudio/crosstalk/issues/26

dzulfiqarfr commented 3 years ago

The unstrap() function from govdown can help. Worked for me. 👍🏽

More: https://rdrr.io/cran/govdown/man/unstrap.html

apreshill commented 3 years ago

Hii @mfherman and others in this thread: we have worked to remove the Bootstrap dependency of crosstalk - please give it a try again in distill!

https://github.com/rstudio/crosstalk/blob/master/NEWS.md#crosstalk-1119000

remotes::install_github("rstudio/crosstalk")
dzulfiqarfr commented 3 years ago

Hii @mfherman and others in this thread: we have worked to remove the Bootstrap dependency of crosstalk - please give it a try again in distill!

https://github.com/rstudio/crosstalk/blob/master/NEWS.md#crosstalk-1119000

remotes::install_github("rstudio/crosstalk")

I've tried it (locally) and it was very neat. Thanks!