sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.75k stars 1.96k forks source link

Send snippets (that are not children) to +layout.svelte #12722

Open feuersteiner opened 1 month ago

feuersteiner commented 1 month ago

Describe the problem

I am creating a base page layout, that has different "slots", say a sidebar, a "main" content container, maybe a righthand sidebar ...

Content in these elements change frequently, hence the need to make sure that the layout is uniform for all of them.

one other reason that might be not relevant to everywhere, is that I need to initialize a canvas component in the layout and send some manager and some store downstream using the context API.

Describe the proposed solution

the ability for the layout page to receive multiple snippets:


<script>
    let {snippetA, snippetB} = $props();
</script>

<div>
{@render snippetA()}
</div>
<div>
the stuff I want to do
</div>
<div>
{@render snippetB()}
</div>

Alternatives considered

Currently the 2 things possible are:

  1. reverting back to using named slots
  2. only using children() snippet with layout.

Importance

would make my life easier

Additional Information

discord : https://discord.com/channels/457912077277855764/1288862792887308410

feuersteiner commented 1 month ago

answering myself: a simpler way to fix this, IF the concern is simply a UI (i.e. layout) issue, my case fixes it by the use of the css grid, one has to do a little of gymnastics, but yeah, gets done (see @Rich-Harris ? I convinced myself that I don't need it lol)