From 144ca5d65a726263d1dc1284859d74160e3fedde Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:00:18 +0000 Subject: [PATCH] BREAKING Use component wrapper on attachment link component --- .../components/_attachment_link.html.erb | 9 ++++++--- .../components/docs/attachment_link.yml | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/views/govuk_publishing_components/components/_attachment_link.html.erb b/app/views/govuk_publishing_components/components/_attachment_link.html.erb index c04c0dda53..78b450458a 100644 --- a/app/views/govuk_publishing_components/components/_attachment_link.html.erb +++ b/app/views/govuk_publishing_components/components/_attachment_link.html.erb @@ -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 @@ -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 %> diff --git a/app/views/govuk_publishing_components/components/docs/attachment_link.yml b/app/views/govuk_publishing_components/components/docs/attachment_link.yml index 342a7f2cfe..9e54110327 100644 --- a/app/views/govuk_publishing_components/components/docs/attachment_link.yml +++ b/app/views/govuk_publishing_components/components/docs/attachment_link.yml @@ -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: @@ -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"