-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add React via esbuild #1334
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
Add React via esbuild #1334
Conversation
Codecov ReportBase: 91.09% // Head: 91.09% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## main #1334 +/- ##
=======================================
Coverage 91.09% 91.09%
=======================================
Files 18 18
Lines 1348 1348
Branches 260 260
=======================================
Hits 1228 1228
Misses 85 85
Partials 35 35
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
<canvas width={canvas_width} height={canvas_height} style={{border: "1px dotted"}}></canvas>Yes, this is more readable. We could approximate it using vanilla JS's backticks, but it's not semantic. Regarding with using React, I assume that you want to use the SPA functionality of it as much as possible? My only concern with this is that then it becomes harder to run viz on a Jupyter notebook (#1263). We could have 2 separate ("parallel universes") viz libraries for the Tornado-based ( |
Interesting point. I think with Jupyter we have have two options:
But if we architecture this with this issue in mind the components based approach of react might actually help us. If we have a visualisation component (i.e. without controls and navbar, etc.), we might be able to display just that component inside a jupyter widget. I haven't evaluated how realistic that is, just putting out ideas here. |
This problem is documented in #1259. |
|
Authoring a Jupyter widget with React: https://blog.jupyter.org/build-a-jupyter-widget-with-react-and-typescript-d83e07340fa3. |
| $("#" + domID).html(value + " " + span); | ||
| onSubmitCallback(param, value); | ||
| }); | ||
| const domID = param + "_id"; |
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 Choice implementation has been made much simpler in 7b3b072.
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.
Huh, thanks. I was actually waiting for this commit to be merged, but I must have made a mistake while updating my files with your changes.
Anyhow I will evolve this pr more to be more idiomatic react code and not the current mixture of declarative and Imperative code. So this is all temporary
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.
It's more of with the change from HTML dropdown to HTML select. The latter is much simpler. Dropdown should be used only when each dropdown items has different event listener.
|
Is this PR obsolete, given that Solara is based on React principles? |
|
Not so much because of its react principles, but yes, solara suits mesa much better. This was meant to replace ModularServer, but a solara based approach makes more sense. |
What is this?
This is the start of a journey to modernize and enhance the mesa frontend. The basic premise is that I added a lot of cool functionality with my mesa-viz package, but I ended up with rewriting large parts of the server and writing very unexperienced frontend react code. While I guess the package still works I think it is outdated beyond repair. But to salvage some of the functionality (like time traveling model steps and parallel simulation runs) I want to pursue a more gentle approach for updating the stack.
Over the last couple days I have been experimenting on how to best add react to our frontend stack. Most frameworks rely on hosting there own dev server, but this makes it quite hard to fit to our current ´modular_tempate.html´. That was also the main reason why mesa-viz required a new server and did not make use of tornados templating.
In this approach I only use esbuild to create a single
main.tsfile that is script-included in the template. Currently that means only a single invisible div is added at the front-end, but this allows us to gradually adopt react code.The immediate goals are to move the existing html code and our
runcontrol.jslogic into react. The other modules can stay and should work independently like before.The long term goals would be to move everything over to react so that we will only have a single ´js´ file that bundles all our dependencies and js modules together. That means we can have a small package footprint, while at the same time improve the development experience of the front end stack (which really is the point of all this).
While the actual need for react is discussable, it just enables to write more functional, descriptive code. Just as an example instead of writing
in react you only write (via JSX)
Things like a ChartJS chart can become concise as
<Chart type='line' data={chartData} />Any thoughts and opinions are very welcomed! Especially @rht since you are currently doing a lot of frontend development