From d27aa14e7e9f52fe65b65927ce142f141157b6e1 Mon Sep 17 00:00:00 2001 From: Chris McCord Date: Tue, 19 Sep 2023 16:58:59 -0400 Subject: [PATCH] Touchup --- lib/phoenix_component.ex | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/phoenix_component.ex b/lib/phoenix_component.ex index bc9f6ebc38..aaf3d28969 100644 --- a/lib/phoenix_component.ex +++ b/lib/phoenix_component.ex @@ -2805,7 +2805,7 @@ defmodule Phoenix.Component do defp join_refs(entries), do: Enum.join(entries, ",") - @doc """ + @doc ~S""" Generates an image preview on the client for a selected file. [INSERT LVATTRDOCS] @@ -2817,15 +2817,14 @@ defmodule Phoenix.Component do <.live_img_preview entry={entry} width="75" /> <% end %> ``` - + When you need to use it multiple times, make sure that they have distinct ids - + ```heex <%= for entry <- @uploads.avatar.entries do %> <.live_img_preview entry={entry} width="75" /> <% end %> - - + <%= for entry <- @uploads.avatar.entries do %> <.live_img_preview id={"modal-#{entry.ref}"} entry={entry} width="500" /> <% end %> @@ -2837,7 +2836,13 @@ defmodule Phoenix.Component do required: true, doc: "The `Phoenix.LiveView.UploadEntry` struct" ) - attr.(:id, :string, default: nil, doc: "Override the id if using live_img_preview more than once in the template") + + attr.(:id, :string, + default: nil, + doc: + "the id of the img tag. Derived by default from the entry ref, but can be overridden as needed if you need to render a preview of the same entry multiple times on the same page" + ) + attr.(:rest, :global, []) def live_img_preview(assigns) do