From 004cb2afc53b254ce9908aeb4da25538bdff27b7 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Wed, 4 Dec 2024 18:38:05 +0000 Subject: [PATCH] Only render Link-content when visuals exist --- app/components/primer/beta/link.html.erb | 16 ++++++++++------ static/classes.json | 3 +++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/components/primer/beta/link.html.erb b/app/components/primer/beta/link.html.erb index 9d95eb0da2..25093f52b2 100644 --- a/app/components/primer/beta/link.html.erb +++ b/app/components/primer/beta/link.html.erb @@ -1,13 +1,17 @@ <%= render Primer::ConditionalWrapper.new(condition: tooltip?, trim: true, tag: :span, position: :relative) do %> <%= render(Primer::BaseComponent.new(trim: true, **@system_arguments)) do %> - <%= render(Primer::BaseComponent.new(tag: :span, classes: "Link-content", trim: true)) do %> - <% if leading_visual %> - <%= leading_visual %> + <% if leading_visual || trailing_visual %> + <%= render(Primer::BaseComponent.new(tag: :span, classes: "Link-content", trim: true)) do %> + <% if leading_visual %> + <%= leading_visual %> + <% end %> + <%= content %> + <% if trailing_visual %> + <%= trailing_visual %> + <% end %> <% end %> + <% else %> <%= content %> - <% if trailing_visual %> - <%= trailing_visual %> - <% end %> <% end %> <% end %> <%= tooltip if tooltip? %> diff --git a/static/classes.json b/static/classes.json index bcd8c93cc9..4e46c9161d 100644 --- a/static/classes.json +++ b/static/classes.json @@ -404,6 +404,9 @@ "Link--underline": [ "Primer::Beta::Link" ], + "Link-content": [ + "Primer::Beta::Link" + ], "Overlay": [ "Primer::Alpha::Dialog", "Primer::Alpha::Overlay"