From e139a75b693c010e9b47535a81feacd5017e28c1 Mon Sep 17 00:00:00 2001 From: jamey Date: Wed, 4 Mar 2026 07:12:25 +0000 Subject: [PATCH] consolidate all external links through external_link component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- lib/berrypod_web/components/core_components.ex | 14 ++++++++------ .../components/shop_components/content.ex | 16 +++++++--------- lib/berrypod_web/live/admin/email_settings.ex | 9 ++++----- lib/berrypod_web/live/admin/product_show.ex | 8 +++----- lib/berrypod_web/page_renderer.ex | 13 +++++-------- 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/lib/berrypod_web/components/core_components.ex b/lib/berrypod_web/components/core_components.ex index 9125aeb..27d2539 100644 --- a/lib/berrypod_web/components/core_components.ex +++ b/lib/berrypod_web/components/core_components.ex @@ -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""" {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" /> (opens in new tab) """ @@ -623,17 +626,16 @@ defmodule BerrypodWeb.CoreComponents do {@option.description} {@option.badge} - " (opens in new tab)"} + aria-label={@option.name} > {@option.name} ↗ - + """ end diff --git a/lib/berrypod_web/components/shop_components/content.ex b/lib/berrypod_web/components/shop_components/content.ex index b696e2c..0b163fd 100644 --- a/lib/berrypod_web/components/shop_components/content.ex +++ b/lib/berrypod_web/components/shop_components/content.ex @@ -3,6 +3,7 @@ defmodule BerrypodWeb.ShopComponents.Content do use Phoenix.Component + import BerrypodWeb.CoreComponents, only: [external_link: 1] import BerrypodWeb.ShopComponents.Base @default_social_links [ @@ -421,18 +422,16 @@ defmodule BerrypodWeb.ShopComponents.Content do

{@title}

@@ -458,15 +457,14 @@ defmodule BerrypodWeb.ShopComponents.Content do ~H""" """ diff --git a/lib/berrypod_web/live/admin/email_settings.ex b/lib/berrypod_web/live/admin/email_settings.ex index ffd27ce..20faa1f 100644 --- a/lib/berrypod_web/live/admin/email_settings.ex +++ b/lib/berrypod_web/live/admin/email_settings.ex @@ -268,16 +268,15 @@ defmodule BerrypodWeb.Admin.EmailSettings do

{adapter.name} - " website (opens in new tab)"} + aria-label={adapter.name <> " website"} > ↗ - +

{adapter.description}

diff --git a/lib/berrypod_web/live/admin/product_show.ex b/lib/berrypod_web/live/admin/product_show.ex index 1d82f76..b1bd22b 100644 --- a/lib/berrypod_web/live/admin/product_show.ex +++ b/lib/berrypod_web/live/admin/product_show.ex @@ -98,17 +98,15 @@ defmodule BerrypodWeb.Admin.ProductShow do <.status_badge status={@product.status} /> <:actions> - <.link + <.external_link :if={provider_edit_url(@product)} href={provider_edit_url(@product)} - target="_blank" - rel="noopener noreferrer" + icon={false} class="admin-btn admin-btn-ghost admin-btn-sm" > Edit on {provider_label(@product)} <.icon name="hero-arrow-top-right-on-square-mini" class="size-4" /> - (opens in new tab) - + <.link navigate={~p"/products/#{@product.slug}"} class="admin-btn admin-btn-ghost admin-btn-sm" diff --git a/lib/berrypod_web/page_renderer.ex b/lib/berrypod_web/page_renderer.ex index 07a70dd..9608776 100644 --- a/lib/berrypod_web/page_renderer.ex +++ b/lib/berrypod_web/page_renderer.ex @@ -16,7 +16,7 @@ defmodule BerrypodWeb.PageRenderer do statics: BerrypodWeb.static_paths() import BerrypodWeb.BlockEditorComponents - import BerrypodWeb.CoreComponents, only: [icon: 1] + import BerrypodWeb.CoreComponents, only: [icon: 1, external_link: 1] alias Berrypod.Cart @@ -883,15 +883,12 @@ defmodule BerrypodWeb.PageRenderer do <% end %> <%= if assigns[:order].tracking_url do %> - Track parcel - + <% end %> @@ -1078,9 +1075,9 @@ defmodule BerrypodWeb.PageRenderer do

- + <.external_link href={@raw_url}> {if @caption != "", do: @caption, else: "Watch video"} - +

{@caption}