Skip to content

Commit

Permalink
BREAKING Use component wrapper on attachment link component
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGDS committed Jan 14, 2025
1 parent 00d1d88 commit 144ca5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

attachment = GovukPublishingComponents::Presenters::AttachmentHelper.new(attachment)
target ||= nil
data_attributes ||= {}
url_data_attributes ||= {}
attributes = []
if attachment.content_type_name
content = if attachment.content_type_abbr
Expand All @@ -30,11 +30,14 @@
class: "gem-c-attachment-link__attribute",
)
end

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-attachment-link")
%>
<%= tag.span(class: "gem-c-attachment-link") do %>
<%= tag.span(**component_helper.all_attributes) do %>
<%= link_to(attachment.title, attachment.url,
class: "govuk-link",
target: target,
data: data_attributes) -%>
data: url_data_attributes) -%>
<%= raw("(#{attributes.join(', ')})") if attributes.any? -%>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ accessibility_criteria: |
Attachment links within paragraphs of text do not need to meet the 24 by 24 CSS pixels requirements.
shared_accessibility_criteria:
- link
uses_component_wrapper_helper: true
examples:
default:
data:
Expand Down Expand Up @@ -58,10 +59,10 @@ examples:
title: "Temporary snow ploughs: guidance note"
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
target: _blank
with_data_attributes:
with_data_attributes_on_url:
data:
attachment:
title: "Temporary snow ploughs: guidance note"
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/259634/temporary-snow-ploughs.pdf
data_attributes:
url_data_attributes:
gtm: "attachment-preview"

0 comments on commit 144ca5d

Please sign in to comment.