iobio / bam.iobio

bam.iobio version 2.0
https://bam2.iobio.io
Other
1 stars 0 forks source link

Consider a new router architecture #5

Open anderspitman opened 1 month ago

anderspitman commented 1 month ago

The current router works well and is pretty simple, but it might be work refactoring it to be cleaner. I think we could create a <iobio-app> component that would work like this:

<iobio-app>
  <iobio-help-page class="route" id="help-page"></iobio-help-page>
  <iobio-home-page class="route" id="home-page"></iobio-home-page>
  <iobio-file-requirements-page class="route" id="file-requirements-page"></iobio-file-requirements-page>
  <iobio-license-page class="route" id="license-page"></iobio-license-page>
  <iobio-compatible-browsers-page class="route" id="compatible-browsers-page"></iobio-compatible-browsers-page>
</iobio-app>

That would be pretty much the entire index.html for bam.iobio. Most of the existing index.html code would move into main_page.js.

would live in app.js and be a web component that takes care of all the routing. It would probably work pretty similarly to the component, but with a nav bar instead of tabs. You might even be able to share code with the component. The individual pages would not know anything about how the router works. Again, since it's already working, this is not high priority. @YangQi007 thoughts?
YangQi007 commented 1 month ago

@anderspitman I like the app structure you proposed. It's worth thinking about it.

Could you give me more details? For example, are you saying that moving the main section in index.html to main_page.js, and make it a web component <iobio-main-page>? Then we put all the routing logic into the app.js(another web component)?

anderspitman commented 1 month ago

Yeah that's pretty much what I had in mind. I don't think we should do it now, but if we need to make changes to this code in the future, that might be a good opportunity to refactor it to be more like this.