Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reintroduce the loading spinner (#107)
## Context / before - The loading spinner (and loading text) were removed in d12c19d - If `WebRunner::start` fails nothing is shown in HTML, the user has to open the console to see if something happened (a.k.a. halting problem) ## What changed / now - before the canvas is loaded a CSS loading spinner with "Loading..." text is displayed - if the loading fails, "the app has crashed" text is shown instead - still `panic!` in this case (as it did) - the corresponding div is removed after loading successfully completes ## How does it look   ## What exactly changed - introduce dependency to `web-sys` - add the `loading_text` div that shows the spinner text during loading, or error if loading fails - access the DOM (in `main.rs`) after the app has been loaded, and remove the spinner, or show an error - if we fail to locate `loading_text` (like when someone removes the div from `index.html`) - nothing happens ## Discussion - I wanted to avoid dependency on `web-sys`, but, I don't see any other simple way to access the spinner - Another idea I had was to do it straight from the `js` side (like it was before), however, I don't see a way to receive events from `WebRunner` - If this solution is undesired, I think the CSS remnants of the spinner [should be removed](master...sedsedus:eframe_template:remove-left-over-css) (like `lds-dual-ring`) ## Alternative solution A more thorough solution (in `main.rs`) is master...sedsedus:eframe_template:fix-css-spinner-install-hook, where all panics are caught to show HTML error. I encountered this myself, where I would mistype the canvas id and wait a few seconds wondering why the app doesn't load, only to discover in the console that something failed. This is more thorough (but at the same time a little more complex / less clean due to hook insertion) because this "invalid canvas id error" wouldn't get caught by the proposal in this PR --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
- Loading branch information