-
-
Notifications
You must be signed in to change notification settings - Fork 112
Change default export to combined EditorControls + Plot component #384
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
Conversation
f8472af
to
91c9cef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note the new state in App
: just data and layout!
dev/App.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note the new update call: just data and layout!
src/PlotlyEditor.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this iteration, we mutate and pass along. In the next iteration, we'll finally use immutability-helper
to NOT mutate and pass along copies as per #212 :)
src/PlotlyEditorWithPlot.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new component only stores the graphDiv in state, which it gets from Plot.
So the lifecycle of a user edit is now:
data
/layout
fromPlotlyEditor
up toPlotlyEditorWithPlot
up toApp
setState
causesrender
forApp
data
/layout
fromApp
down toPlotlyEditorWithPlot
down toPlot
graphDiv
fromPlot
up toPlotlyEditorWithPlot
setState
causesrender
forPlotlyEditorWithPlot
graphDiv
fromPlotlyEditorWithPlot
down toPlotlyEditor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool lets try it out! Since you just built a great end-to-end testing machine lets get a couple tests in with this PR so we have some patterns to build off of.
Then we can start adding more tests with less friction!
here is the batch reporter end-to-end test https://github.com/plotly/plotly.js-batch-reporter/blob/master/example/src/index.test.js
There are a few accompanying helper functions. One of which https://github.com/plotly/plotly.js-batch-reporter/blob/master/example/src/index.test.js#L11 may be instructive.
also since things are async I use await
https://github.com/plotly/plotly.js-batch-reporter/blob/master/example/src/index.test.js#L77 plus an async type of "waits for" routine called stateChange
https://github.com/plotly/plotly.js-batch-reporter/blob/master/example/src/lib/testUtils.js#L78
This is what we suspected could make the editor really slow right? And it isn't really slow?
For names: Editor
, Plot
, PlotWithEditor
?
But this looks good to me!
@VeraZab Well, I didn't think it would make things "really slow" I said there might be a performance hit from extra renders. It doesn't feel bad to me at all though :)
Actually the bigger performance hit probably came from #381
41da20d
to
abb0746
Compare
@VeraZab @bpostlethwaite here's my more radical proposal: let's change the top-level export to be this new combined component that looks more React-idiomatic. I've renamed the top-level component to PlotlyEditor
and the old one to EditorControls
in this PR.
If we like it, I can fix all the other examples and write some tests against it. I'm pretty convinced that this is a better way forward but we can discuss in person when @VeraZab is back :)
I like it! I feel like API users should not have to think about those things (most of them). And for the ones who do want to handle this in a more individual way, that's still available to them.
OK so remaining to do on this PR:
- add an end to end testing framework stub
- fix the README
- fix the existing examples
8d735bb
to
8a5bac7
Compare
@VeraZab check out how nice the examples are now! simple
and redux
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeahhh!! I like it!! 🎉
package.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on ajoute le nouveau plotly.js aussi?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
b21456f
to
f29c2f6
Compare
src/PlotlyEditor.js
Outdated
@vdh
vdh
Mar 9, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should app
here be replaced with a BEM class instead? (Perhaps by adjusting/moving the one now in EditorControls
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I just copied stuff over but app
is a terrible class to bake in ;)
f29c2f6
to
34681a7
Compare
3b92cfc
to
9168d7c
Compare
@VeraZab @bpostlethwaite ready for review. The end-to-end test is a stub but it works and can be built upon in future PRs :)
partly addresses #321
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could these encoded styles go in the plotly_editor_plot className?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this too, can we not hard code here?
💃
1 similar comment
💃
Uh oh!
There was an error while loading. Please reload this page.
I'm happy to rename the new component but the idea here is to provide something that, though it keeps a gross DOM node in state, looks and behaves like a dumb component which bundles an editor and a plot area.