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

Automatically import <style> cells ? #28

Open
juba opened this issue Jul 29, 2020 · 4 comments
Open

Automatically import <style> cells ? #28

juba opened this issue Jul 29, 2020 · 4 comments

Comments

@juba
Copy link
Owner

juba commented Jul 29, 2020

When CSS styles are defined with a html`<style>...</style>` cell, they don't seem to be taken into account when the notebook is imported into Observable.

I'll do a reprex soon.

@juba
Copy link
Owner Author

juba commented Jul 29, 2020

For example, here :

https://observablehq.com/@danburzo/color-vision-deficiency-simulation

For the plot to render we have to include both the chart cell and the <style> cell.

robservable(
  "https://observablehq.com/@danburzo/color-vision-deficiency-simulation",
  include = c(5, 6)
)

This is normal behavior but as <style> cells are generally not named, could there be a possibility to automatically detect and import them ?

@juba juba changed the title Styles don't seem to be taken into account Automatically import <style> cells ? Jul 29, 2020
@juba
Copy link
Owner Author

juba commented Jul 29, 2020

I'm not sure this would be possible, as the only way I can think of would be to get access to the cell code to check if it begins with html`<style>`.

@thomasballinger
Copy link

From my perspective, doing this might be helpful in common cases but would be inconsistent with other Observable embed tools, so might confuse users familiar with choosing Observable cells in other contexts. I agree it's a good bet that any CSS on the page should be applied, but this isn't always the case; especially when CSS from one embed might conflict with other HTML.

@juba
Copy link
Owner Author

juba commented Jul 30, 2020

Yes, you're certainly right, but if there is a way to automatically include <style> cells, I still wonder if it wouldn't be better to turn it on by default (with a possibility to disable it), as, as you say, in a vast majority of notebooks these styles are directly related to the main visualisation. So making visualisations more often work "out of the box" would be more beneficial that avoiding possible CSS conflicts, which could be solved by disabling automatic import if needed.

But I still don't see how to automatically import these cells, yet.

Anyway, thanks for taking the time to give your feedback here, it is really valuable and appreciated !

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

No branches or pull requests

2 participants