consolidate all external links through external_link component
All checks were successful
deploy / deploy (push) Successful in 1m32s

Add icon={false} option to external_link for links with their own
visual indicator. Migrate remaining manual target="_blank" links:
email settings adapter links, product show provider edit, card radio
links, social link cards/icons, page renderer tracking and video
fallback. Every external link in the codebase now goes through the
single component — one place to change rel, target, or sr-only text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-03-04 07:12:25 +00:00
parent 156a23da16
commit e139a75b69
5 changed files with 27 additions and 33 deletions

View File

@@ -426,9 +426,12 @@ defmodule BerrypodWeb.CoreComponents do
@doc """
Renders a link to an external site with proper security attributes,
an external-link icon, and screen reader context.
Set `icon={false}` when the link already contains its own visual indicator.
"""
attr :href, :string, required: true
attr :class, :string, default: nil
attr :icon, :boolean, default: true
attr :rest, :global
slot :inner_block, required: true
@@ -436,7 +439,7 @@ defmodule BerrypodWeb.CoreComponents do
~H"""
<a href={@href} target="_blank" rel="noopener noreferrer" class={@class} {@rest}>
{render_slot(@inner_block)}
<.icon name="hero-arrow-top-right-on-square" class="external-link-icon" />
<.icon :if={@icon} name="hero-arrow-top-right-on-square" class="external-link-icon" />
<span class="sr-only">(opens in new tab)</span>
</a>
"""
@@ -623,17 +626,16 @@ defmodule BerrypodWeb.CoreComponents do
{@option.description}
</span>
<span :if={@option[:badge]} class="card-radio-badge">{@option.badge}</span>
<a
<.external_link
:if={@option[:url]}
href={@option.url}
target="_blank"
rel="noopener noreferrer"
icon={false}
class="card-radio-link"
onclick="event.stopPropagation();"
aria-label={@option.name <> " (opens in new tab)"}
aria-label={@option.name}
>
{@option.name} &nearr;
</a>
</.external_link>
"""
end