plotly / documentation

Issue tracker for Plotly's open-source documentation.
423 stars 547 forks source link

Inline JS example charts and add edit on codepen button #1616

Closed jdamiba closed 4 years ago

jdamiba commented 4 years ago

The purpose of this PR is to inline the example charts in the Plotly.js documentation while preserving the edit on codepen functionality. This will allow contributors to write docs without having to worry about maintaining a separate codepen, while users still get the benefit of being able to use/edit live code snippets.

In order to accomplish this, I

Before:

Screen Shot 2019-12-09 at 3 35 21 PM

After: Screen Shot 2019-12-09 at 3 36 30 PM

closes https://github.com/plotly/documentation/issues/1587

jdamiba commented 4 years ago

FYI @nicolas this PR incorporates all the QA from and supersedes https://github.com/plotly/documentation/pull/1605

jdamiba commented 4 years ago

@nicolas I have updated the styling of inline charts (removed border) and moved the try it on codepen button into the code area.

Screen Shot 2019-12-12 at 4 27 56 PM

nicolaskruchten commented 4 years ago

Could we trim the whitespace above the button a bit and change the font on it to be open sans plz?

nicolaskruchten commented 4 years ago

The React page is a bit wonky, because there is the "try it on codepen" link on all the examples, even the ones that don't have an embed and don't run, like the npm install block, and the ones that do. We should not show the "try it" button in these cases

nicolaskruchten commented 4 years ago

Some of these examples don't work because they try to write to an non-myDiv div: http://localhost:4000/javascript/hover-events/

nicolaskruchten commented 4 years ago

The top one here needs the myDiv conversion: http://localhost:4000/javascript/disable-zoom/

nicolaskruchten commented 4 years ago

Actually there are quite a few places where we need to suppress the "try it" button, e.g. at the top of http://localhost:4000/javascript/tick-formatting/

Maybe we can just show it if there is myDiv in the string (and there is no actual embedded pen)? that's probably a decent heuristic

nicolaskruchten commented 4 years ago

This one doesn't work because it uses require http://localhost:4000/javascript/colorway/ ... we should ensure that anything that uses require either gets a workaround or goes back to being embedded in a pen.

nicolaskruchten commented 4 years ago

This is getting super, super close! Let's clear up the last few comments I made here and we can merge this this week :)

nicolaskruchten commented 4 years ago

Even if we rely on a bunch of CodePens for now, the mere possibility of creating new docs without them is great, and the fact that most of our examples are not using CodePen directly any more is a huge win.