diff --git a/example_project/assets/svelte/CompositionParent.svelte b/example_project/assets/svelte/CompositionParent.svelte new file mode 100644 index 0000000..35ce7e6 --- /dev/null +++ b/example_project/assets/svelte/CompositionParent.svelte @@ -0,0 +1,17 @@ + + +
+ + + + diff --git a/example_project/assets/svelte/TextInput.svelte b/example_project/assets/svelte/TextInput.svelte new file mode 100644 index 0000000..92bad39 --- /dev/null +++ b/example_project/assets/svelte/TextInput.svelte @@ -0,0 +1,17 @@ + + +
+ +
diff --git a/example_project/lib/example_web/live/live_composition.ex b/example_project/lib/example_web/live/live_composition.ex new file mode 100644 index 0000000..f429135 --- /dev/null +++ b/example_project/lib/example_web/live/live_composition.ex @@ -0,0 +1,14 @@ +defmodule ExampleWeb.LiveComposition do + use ExampleWeb, :live_view + + def render(assigns) do + ~H""" + <.svelte name="CompositionParent" socket={@socket} /> + """ + end + + def handle_event("validate-item", %{"name" => name}, socket) do + IO.puts(name) + {:noreply, socket} + end +end diff --git a/example_project/lib/example_web/router.ex b/example_project/lib/example_web/router.ex index 7ff4cee..8a3df1a 100644 --- a/example_project/lib/example_web/router.ex +++ b/example_project/lib/example_web/router.ex @@ -33,6 +33,7 @@ defmodule ExampleWeb.Router do live "/svelvet", LiveSvelvet live "/live-json", LiveJson live "/slots-experiment", LiveSlotsExperiment + live "/composition", LiveComposition end # Other scopes may use custom stacks.