woutdp / live_svelte

Svelte inside Phoenix LiveView with seamless end-to-end reactivity
https://hexdocs.pm/live_svelte
MIT License
1.01k stars 38 forks source link

Slot Support #52

Closed dev-guy closed 2 weeks ago

dev-guy commented 1 year ago

Slots are not supported by LiveSvelte because of issues in Svelte itself. I don't have the issue number but once it's resolved, this usage can be officially supported.

A working named slot example is in the following files. Timeline.svelte optionally accepts a slot named 'toast.' Other use cases might not work.

Note: The Svelte way to specify slot content is something like < span slot='slot_name'> . This doesn't work in Heex templates. Use the Phoenix <: slot_name> way instead.

Another downside is that Elixir warns when compiling:

warning: undefined slot "toast" for component LiveSvelte.svelte/1
  lib/kantan_web/controllers/page_html/timeline.html.heex:6

1) https://github.com/dev-guy/phoenix-ash-svelte-flowbite/blob/main/lib/kantan_web/controllers/page_html/timeline.html.heex

2) https://github.com/dev-guy/phoenix-ash-svelte-flowbite/blob/main/assets/svelte/Timeline.svelte

woutdp commented 1 year ago

This is the ticket that should help with this: https://github.com/sveltejs/svelte/issues/2588