My space on the web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
734 B

defmodule MirageWeb.LiveHelpers do
import Phoenix.LiveView.Helpers
@doc """
Renders a component inside the `MirageWeb.ModalComponent` component.
The rendered modal receives a `:return_to` option to properly update
the URL when the modal is closed.
## Examples
<%= live_modal @socket, MirageWeb.LinkLive.FormComponent,
id: || :new,
action: @live_action,
link: @link,
return_to: Routes.link_index_path(@socket, :index) %>
def live_modal(socket, component, opts) do
path = Keyword.fetch!(opts, :return_to)
modal_opts = [id: :modal, return_to: path, component: component, opts: opts]
live_component(socket, MirageWeb.ModalComponent, modal_opts)