Comments (6)
Can you describe what problem you’re trying to solve?
from abstract-state-router.
I have one main component App.svelte
, which has two components that are always available but routed pretty much independently;
Nav
, which changes between landing page / legal pages / workspace pagesMain
, whichchanges on every pagebasically holds all pages and their subpages.
I'd like to not rerender the whole App
component (e.g. change out for a different App
component for different routes) since it hosts some peripheral components like a modal wrapper, and the styles between nav and main stay pretty much the same.
from abstract-state-router.
I guess it would be possible with more wrapping of basically holding components that are empty except for a nav and the next <uiView>
, and then having an extra layer in the route tree:
My idea:
const routes = [
{
name: 'app',
route: '/',
template: App, // hosts `<uiView />` and `<uiView name="nav" />`
defaultChild: 'landing-area',
},
{
name: 'app.landing-area',
route: '/',
templates: {
default: LandingArea, // Hosts one `<uiView />`
nav: LandingAreaNav,
},
defaultChild: 'landing-page',
},
{
name: 'app.landing-area.landing-page',
route: '/',
template: LandingPage,
},
{
name: 'app.landing-area.login',
route: '/login',
template: Login
},
{
name: 'app.auth-area',
route: '/auth',
templates: {
default: AuthArea, // Hosts one `<uiView />` for further child routes
nav: AuthAreaNav,
},
},
];
While, if I understand correct, this would have to be the current solution:
const routes = [
{
name: 'app',
route: '/',
template: App,
defaultChild: 'landing-area',
},
{
name: 'app.landing-area',
route: '/',
templates: LandingArea, // hosts `<uiView />` and `<LandingAreaNav />`
defaultChild: 'landing-page',
},
{
name: 'app.landing-area.landing-page',
route: '/',
template: LandingPage,
},
{
name: 'app.landing-area.login',
route: '/login',
template: Login
},
{
name: 'app.auth-area',
route: '/auth',
template: AuthArea, // hosts `<uiView />` and `<AuthAreaNav />`
},
];
This makes nav transitions harder, and it prevents parts of nav to be kept between pages, since the whole thing has to be thrown out for the next nav to come in. You cannot do this:
<nav>
<some-stuff-that-i-want-to-keep />
<uiView name="nav" transition-this-nicely />
<account-menu show-if-logged-in />
</nav>
<uiView />
from abstract-state-router.
I do currently use the make-a-state-for-just-the-nav method, and it works well. Example: https://github.com/KayserCommentaryOrg/revelation-project/blob/master/client/view/Main.html#L1-L9
since the whole thing has to be thrown out for the next nav to come in
I don't think that's true with the nesting method – if you navigate from app.landing-area.landing-page
to app.landing-area.login
, the app.landing-area
state doesn't change, and the LandingAreaNav
component doesn't get reloaded.
If your idea was implemented and there was a <uiView name="nav" />
, it would naturally reload/re-render at exactly the same times as when it does now.
from abstract-state-router.
Well my gripe is that there's other stuff in the nav that could just stay there and not be rerendered, especially cause it ties in to nice transitions of the part of the nav that's stateful. Like in the HTML example, you'd need to rerender the account menu even though it's the same across all pages. Not only is it less performant, but you'd have to copy paste the code into all Nav components.
Edit: Ok I get the idea of an extra state for the nav. Might take a look at that and just wrap my current route array into a handler that tears them apart into the two states.
from abstract-state-router.
Thanks for the discussion!
from abstract-state-router.
Related Issues (20)
- Ignore parameters that are not used by any state HOT 3
- No way for children to depend on route parameters of ancestors HOT 2
- Eliminate references to node modules HOT 2
- Need to allow for adding custom hash fragments HOT 1
- When using root path '/' the page doesn't render on refresh HOT 9
- Why doesn't it scroll to the top when you navigate between states HOT 1
- Proposal to implement empty state HOT 4
- When using pushState routing, encodeURI should be used instead of encodeURIComponent
- Reloading current route HOT 22
- A dot/period(.) in url for a named parameter returns an error HOT 3
- Possible to send actual objects via callback.redirect? HOT 10
- Push state routing not working with "defaultChild state with an empty route string" HOT 1
- It is possible for `makePath` to return a url that will not be matched by the router
- Non-async resolve results in confusing behavior HOT 1
- Lazy-loading states HOT 3
- State name should be optional to `state.go` HOT 4
- Get browserstack tests passing again HOT 1
- Modern JS features HOT 5
- Default values for route parameters HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abstract-state-router.