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>
|
||||||
<div class="py-2 px-3">
|
<div class="py-2 px-3">
|
||||||
<.input
|
<.form phx-change="change_alt_text">
|
||||||
type="textarea"
|
<.input type="textarea" name="alt" placeholder="alt text" value={@attachment["name"]} />
|
||||||
placeholder="alt text"
|
<.input type="hidden" name="url" value={@attachment["url"]} />
|
||||||
name={@attachment["url"]}
|
</.form>
|
||||||
phx-change="change_alt_text"
|
|
||||||
phx-value-url={@attachment["url"]}
|
|
||||||
value={@attachment["name"]}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
phx-click="remove_attachment"
|
phx-click="remove_attachment"
|
||||||
|
|
@ -214,10 +210,12 @@ defmodule PostlandWeb.CoreComponents do
|
||||||
style={"background-image: url('#{attachment["url"]}')"}
|
style={"background-image: url('#{attachment["url"]}')"}
|
||||||
phx-click={show_modal("modal-#{Base.url_encode64(attachment["url"], padding: false)}")}
|
phx-click={show_modal("modal-#{Base.url_encode64(attachment["url"], padding: false)}")}
|
||||||
phx-value-attachment={attachment["url"]}
|
phx-value-attachment={attachment["url"]}
|
||||||
|
alt={attachment["name"]}
|
||||||
|
title={attachment["name"]}
|
||||||
/>
|
/>
|
||||||
<.modal id={"modal-#{Base.url_encode64(attachment["url"], padding: false)}"}>
|
<.modal id={"modal-#{Base.url_encode64(attachment["url"], padding: false)}"}>
|
||||||
<div class="w-full flex justify-center">
|
<div class="w-full flex justify-center" title={attachment["name"]}>
|
||||||
<img src={attachment["url"]} />
|
<img src={attachment["url"]} alt={attachment["name"]} />
|
||||||
</div>
|
</div>
|
||||||
</.modal>
|
</.modal>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,12 @@ defmodule PostlandWeb.TimelineLive do
|
||||||
|
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<.post_form post_content={@post} attachments={@attachments} upload={@uploads.files} />
|
<div id="timeline">
|
||||||
<div id="timeline-posts" phx-update="stream">
|
<.post_form post_content={@post} attachments={@attachments} upload={@uploads.files} />
|
||||||
<div :for={{id, post} <- @streams.posts} id={id} class="mt-10">
|
<div id="timeline-posts" phx-update="stream">
|
||||||
<.post_card post={post} post_dom_id={id} />
|
<div :for={{id, post} <- @streams.posts} id={id} class="mt-10">
|
||||||
|
<.post_card post={post} post_dom_id={id} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
|
@ -77,7 +79,17 @@ defmodule PostlandWeb.TimelineLive do
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_event("change_alt_text", %{"alt" => value, "url" => url}, socket) do
|
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
|
end
|
||||||
|
|
||||||
def handle_progress(:files, entry, socket) do
|
def handle_progress(:files, entry, socket) do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue