Skip to content

Commit

Permalink
[Enhancement] Render URL attributes as a link (#299)
Browse files Browse the repository at this point in the history
* Render URLs as links when listing items from a map

* Applies suggestions from MR feedback
  • Loading branch information
breakid authored Jul 15, 2024
1 parent 8f91c4e commit 0d5a41f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pinchflat_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ defmodule PinchflatWeb.CoreComponents do
import PinchflatWeb.Gettext

alias Phoenix.LiveView.JS
alias PinchflatWeb.CustomComponents.TextComponents

@doc """
Renders a modal.
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 0d5a41f

Please sign in to comment.