fix: Handle alt text
This commit is contained in:
parent
cf364a11c6
commit
2685a8dfb8
2 changed files with 25 additions and 15 deletions
|
|
@ -145,14 +145,10 @@ defmodule PostlandWeb.CoreComponents do
|
|||
>
|
||||
</div>
|
||||
<div class="py-2 px-3">
|
||||
<.input
|
||||
type="textarea"
|
||||
placeholder="alt text"
|
||||
name={@attachment["url"]}
|
||||
phx-change="change_alt_text"
|
||||
phx-value-url={@attachment["url"]}
|
||||
value={@attachment["name"]}
|
||||
/>
|
||||
<.form phx-change="change_alt_text">
|
||||
<.input type="textarea" name="alt" placeholder="alt text" value={@attachment["name"]} />
|
||||
<.input type="hidden" name="url" value={@attachment["url"]} />
|
||||
</.form>
|
||||
</div>
|
||||
<div
|
||||
phx-click="remove_attachment"
|
||||
|
|
@ -214,10 +210,12 @@ defmodule PostlandWeb.CoreComponents do
|
|||
style={"background-image: url('#{attachment["url"]}')"}
|
||||
phx-click={show_modal("modal-#{Base.url_encode64(attachment["url"], padding: false)}")}
|
||||
phx-value-attachment={attachment["url"]}
|
||||
alt={attachment["name"]}
|
||||
title={attachment["name"]}
|
||||
/>
|
||||
<.modal id={"modal-#{Base.url_encode64(attachment["url"], padding: false)}"}>
|
||||
<div class="w-full flex justify-center">
|
||||
<img src={attachment["url"]} />
|
||||
<div class="w-full flex justify-center" title={attachment["name"]}>
|
||||
<img src={attachment["url"]} alt={attachment["name"]} />
|
||||
</div>
|
||||
</.modal>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ defmodule PostlandWeb.TimelineLive do
|
|||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<.post_form post_content={@post} attachments={@attachments} upload={@uploads.files} />
|
||||
<div id="timeline-posts" phx-update="stream">
|
||||
<div :for={{id, post} <- @streams.posts} id={id} class="mt-10">
|
||||
<.post_card post={post} post_dom_id={id} />
|
||||
<div id="timeline">
|
||||
<.post_form post_content={@post} attachments={@attachments} upload={@uploads.files} />
|
||||
<div id="timeline-posts" phx-update="stream">
|
||||
<div :for={{id, post} <- @streams.posts} id={id} class="mt-10">
|
||||
<.post_card post={post} post_dom_id={id} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
|
|
@ -77,7 +79,17 @@ defmodule PostlandWeb.TimelineLive do
|
|||
end
|
||||
|
||||
def handle_event("change_alt_text", %{"alt" => value, "url" => url}, socket) do
|
||||
{:noreply, socket}
|
||||
attachments =
|
||||
socket.assigns.attachments
|
||||
|> Enum.map(fn
|
||||
%{"url" => ^url} = attachment ->
|
||||
Map.put(attachment, "name", value)
|
||||
|
||||
other ->
|
||||
other
|
||||
end)
|
||||
|
||||
{:noreply, assign(socket, attachments: attachments)}
|
||||
end
|
||||
|
||||
def handle_progress(:files, entry, socket) do
|
||||
|
|
|
|||
Loading…
Reference in a new issue