Skip to content
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

Resetting layouts only up to a certain level #4133

Closed
gtm-nayan opened this issue Feb 26, 2022 · 1 comment · Fixed by #4388
Closed

Resetting layouts only up to a certain level #4133

gtm-nayan opened this issue Feb 26, 2022 · 1 comment · Fixed by #4388

Comments

@gtm-nayan
Copy link
Contributor

gtm-nayan commented Feb 26, 2022

Describe the problem

Currently __layout.reset.svelte files undo all the layouts that have been applied from the root level. This behaviour is undesirable when we only want to reset the immediate parent layout and leave the remaining ones.

Another thing that makes it undesirable, importing global stylesheets in the root layout is a common pattern from what I've seen and undoing the root layout means having to do those imports all over again in the reset file.

Describe the proposed solution

My first thought was something in the filename of the resets like __layout.reset.1.svelte.

Seeing #4103 and #2694 makes me wonder what if we ditch the __layout.reset.svelte file altogether and instead allow page level components (incl __layout.svelte files) to do export const reset like with prerender and router except that reset would be number instead of a boolean.

Say we have a file structure like this.

routes/
├─ index.svelte
├─ __layout.svelte
├─ nested/
│  ├─ __layout.svelte
│  ├─ page1.svelte
│  ├─ deeper-nested/
│  │  ├─ page2.svelte

Example 1

If page2 exports reset = 1, then it'd only reset nested/__layout.svelte
If it exports reset = 2, then it'd reset both nested/__layout.svelte and routes/__layout.svelte

Example 2

If nested/__layout.svelte exports reset = 1, then it'd reset its parent layout, routes/__layout.svelte
And if it didn't export reset at all, then it'd just stack like it currently does.

Example 3?

If the current behavior of resetting all the way to the top is desired in some cases, then exporting reset = 0 could be treated as a special value to make that easier (this can be scrapped if it's thought to be ambiguous/confusing)

Alternatives considered

N/A

Importance

would make my life easier

Additional Information

No response

@rgossiaux
Copy link

I don't agree with the proposed solution, but I agree with the general problem: layouts are a little too strongly coupled with the directory structure right now, which is in turn strongly coupled with routing. It's great that layouts just work in a simple way out of the box, but I don't think there's enough flexibility right now. Ideally I should be able to easily configure an arbitrary route to use an arbitrary layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants