From da064f076cd221388dccf91ea08db9e3ef8075db Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:48:45 +0000 Subject: [PATCH 1/2] Use component wrapper on share links component --- .../components/_share_links.html.erb | 21 +++++++++---------- .../components/docs/share_links.yml | 2 ++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/views/govuk_publishing_components/components/_share_links.html.erb b/app/views/govuk_publishing_components/components/_share_links.html.erb index 82ef8929e2..6299362399 100644 --- a/app/views/govuk_publishing_components/components/_share_links.html.erb +++ b/app/views/govuk_publishing_components/components/_share_links.html.erb @@ -14,19 +14,18 @@ black_icons ||= false black_links ||= false - classes = %w(gem-c-share-links govuk-!-display-none-print) - classes << "gem-c-share-links--stacked" if stacked - classes << "gem-c-share-links--columns" if columns - classes << "gem-c-share-links--flexbox" if flexbox - classes << "gem-c-share-links--square-icons" if square_icons - classes << "gem-c-share-links--black-icons" if black_icons - classes << "gem-c-share-links--black-links" if black_links - - data_attributes ||= {} - ((data_attributes[:module] ||= "") << " " << "ga4-link-tracker").strip! if track_as_sharing || track_as_follow + component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns) + component_helper.add_class("gem-c-share-links govuk-!-display-none-print") + component_helper.add_class("gem-c-share-links--stacked") if stacked + component_helper.add_class("gem-c-share-links--columns") if columns + component_helper.add_class("gem-c-share-links--flexbox") if flexbox + component_helper.add_class("gem-c-share-links--square-icons") if square_icons + component_helper.add_class("gem-c-share-links--black-icons") if black_icons + component_helper.add_class("gem-c-share-links--black-links") if black_links + component_helper.add_data_attribute({ module: "ga4-link-tracker" }) if track_as_sharing || track_as_follow %> <% if links.any? %> - <%= tag.div(class: classes, data: data_attributes) do %> + <%= tag.div(**component_helper.all_attributes) do %> <% if title %>

<%= title %>

<% end %> diff --git a/app/views/govuk_publishing_components/components/docs/share_links.yml b/app/views/govuk_publishing_components/components/docs/share_links.yml index 7d52624e43..d0b5a1ca43 100644 --- a/app/views/govuk_publishing_components/components/docs/share_links.yml +++ b/app/views/govuk_publishing_components/components/docs/share_links.yml @@ -13,6 +13,8 @@ body: | accessibility_criteria: | The share link icons must be presentational and ignored by screen readers. + +uses_component_wrapper_helper: true shared_accessibility_criteria: - link examples: From 2f627560947b9d2ed2182e27fc74ebf4b18bb16f Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:37:38 +0000 Subject: [PATCH 2/2] Use component wrapper on reorderable list component --- CHANGELOG.md | 2 ++ .../components/_reorderable_list.html.erb | 8 +++++--- .../components/docs/reorderable_list.yml | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b588cbc1d..e3e2066c26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ ## Unreleased +* Use component wrapper on reorderable list component ([PR #4474](https://github.com/alphagov/govuk_publishing_components/pull/4474)) + ## 46.2.0 * Support Welsh devolved nations component ([PR #4440](https://github.com/alphagov/govuk_publishing_components/pull/4440)) diff --git a/app/views/govuk_publishing_components/components/_reorderable_list.html.erb b/app/views/govuk_publishing_components/components/_reorderable_list.html.erb index 5e9932aa1c..ab31d417c3 100644 --- a/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +++ b/app/views/govuk_publishing_components/components/_reorderable_list.html.erb @@ -3,11 +3,13 @@ items ||= [] input_name ||= "ordering" - data_attributes ||= {} - data_attributes[:module] = "reorderable-list" + + component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns) + component_helper.add_class("gem-c-reorderable-list") + component_helper.add_data_attribute({ module: "reorderable-list" }) %> -<%= tag.ol class: "gem-c-reorderable-list", data: data_attributes do %> +<%= tag.ol(**component_helper.all_attributes) do %> <% items.each_with_index do |item, index| %> <%= tag.li class: "gem-c-reorderable-list__item" do %> <%= tag.div class: "gem-c-reorderable-list__wrapper" do %> diff --git a/app/views/govuk_publishing_components/components/docs/reorderable_list.yml b/app/views/govuk_publishing_components/components/docs/reorderable_list.yml index e6457bcee7..1282a30150 100644 --- a/app/views/govuk_publishing_components/components/docs/reorderable_list.yml +++ b/app/views/govuk_publishing_components/components/docs/reorderable_list.yml @@ -17,6 +17,7 @@ body: | you'd receive a submission of `ordering[a]=1&ordering[b]=2`, which Rails can translate to `"ordering" => { "a" => "1", "b" => "2" }`. +uses_component_wrapper_helper: true accessibility_criteria: | Buttons in this component must: