feat(contact): link grid squares to gridmap.org

This commit is contained in:
Graham McIntire 2026-04-27 09:31:59 -05:00
parent 0cf044be30
commit 610892e77e
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -1064,7 +1064,8 @@ defmodule MicrowavepropWeb.ContactLive.Show do
<div class="text-sm font-mono mb-2 text-center">
{format_band(@contact.band)} &middot; {@contact.mode} &middot; {format_dist(
@elevation_profile.dist_km
)} &middot; {@contact.grid1 || ""} &rarr; {@contact.grid2 || ""}
)} &middot; <.grid_link grid={@contact.grid1} /> &rarr;
<.grid_link grid={@contact.grid2} />
</div>
<table class="text-sm font-mono mb-2 mx-auto">
<tr>
@ -2467,4 +2468,23 @@ defmodule MicrowavepropWeb.ContactLive.Show do
defp maybe_put_band(params, band) when is_integer(band), do: Map.put(params, "band", Integer.to_string(band))
defp maybe_put_band(params, band) when is_binary(band), do: Map.put(params, "band", band)
defp maybe_put_band(params, _), do: params
attr :grid, :string, default: nil
defp grid_link(assigns) do
~H"""
<%= if @grid && @grid != "" do %>
<a
href={"https://gridmap.org/#{@grid}"}
target="_blank"
rel="noopener noreferrer"
class="link link-hover"
>
{@grid}
</a>
<% else %>
<% end %>
"""
end
end