[Enhancement] Render URL attributes as a link (#299)

* Render URLs as links when listing items from a map

* Applies suggestions from MR feedback
This commit is contained in:
Dan 2024-07-15 11:59:02 -04:00 committed by GitHub
parent 8f91c4e6a2
commit 0d5a41fd35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,6 +19,7 @@ defmodule PinchflatWeb.CoreComponents do
import PinchflatWeb.Gettext
alias Phoenix.LiveView.JS
alias PinchflatWeb.CustomComponents.TextComponents
@doc """
Renders a modal.
@ -644,7 +645,11 @@ defmodule PinchflatWeb.CoreComponents do
<li :for={{k, v} <- @iterable_attributes} class="mb-2 w-2/3">
<strong><%= k %>:</strong>
<code class="inline-block text-sm font-mono text-gray p-0.5 mx-0.5">
<%= v %>
<%= if is_binary(v) && URI.parse(v).scheme && URI.parse(v).scheme =~ "http" do %>
<TextComponents.inline_link href={v}><%= v %></TextComponents.inline_link>
<% else %>
<%= v %>
<% end %>
</code>
</li>
</ul>