Skip to content

Better slots and component composition. - #39

Closed
TheComputerM wants to merge 1 commit into
sveltejs:masterfrom
TheComputerM:thecomputerm/slots
Closed

Better slots and component composition.#39
TheComputerM wants to merge 1 commit into
sveltejs:masterfrom
TheComputerM:thecomputerm/slots

Conversation

@TheComputerM

Copy link
Copy Markdown

Rendered

This is my first RFC so please comment any helpful suggestions.

@TheComputerM

Copy link
Copy Markdown
Author

Somewhat like sveltejs/svelte#4556

@lukeed

lukeed commented Sep 30, 2020

Copy link
Copy Markdown
Member

I was just going to link that – what are the differences? It looks like this is implemented as described

@TheComputerM

Copy link
Copy Markdown
Author

This is still incomplete and I am brain storming on better syntax.
The goal of it is to provide a more svelte like syntax and some additional features also such as slot options:

<Component>
  <svelte:fragment dense={true}>
    This will do something in the component
  </svelte:fragment>
</Component>

@lukeed

lukeed commented Sep 30, 2020

Copy link
Copy Markdown
Member

Wouldn't slots just be a portal for where to render? The contents of what is rendered is determined by the content itself.

As far as I understand it, this RFC seems to be mostly about using svelte:fragment to render text nodes (non-component and non-element) with siblings.

I have an RFC open about inheriting <slot/> attributes (#15)
But (imo) if you're passing dense={true} so that the slot can react/alter its display, then I think that falls more into svelte:template territory (#34).

But, I might be misunderstanding you completely. I'm sorta guessing at the examples

@TheComputerM

Copy link
Copy Markdown
Author

Yeah, sorry for the short explanation. Was thinking more on the lines of something like this:
The syntax is just for better understanding.

<svelte:slot tag={ListItem} export:dense on:click={func}>
  Default
</svelte:slot>
<svelte:fragment dense={true}>
  Content
</svelte:fragment>
<ListItem dense={true} on:click={func}>
  Content
</ListItem>

@TheComputerM

Copy link
Copy Markdown
Author

This was mainly intended to solve sveltejs/svelte#2079 and add some new features.

@lukeed

lukeed commented Sep 30, 2020

Copy link
Copy Markdown
Member

No problem

Yeah, to me that's 100% an inline component, if not an external component. Either of which only get placed by a <slot>

@TheComputerM
TheComputerM marked this pull request as draft October 8, 2020 13:38
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 this pull request may close these issues.

2 participants