From 3ee822566bf0379b14e697711a65be4feb4201f1 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Thu, 24 Oct 2024 09:32:36 +0100 Subject: [PATCH] Contents list tidying - clean up the template file, reorder and separate the options at the top to make it more readable and remove an unused line - adjust the wording of the documentation intro --- .../components/_contents_list.html.erb | 15 +++++++++------ .../components/docs/contents_list.yml | 5 ++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/views/govuk_publishing_components/components/_contents_list.html.erb b/app/views/govuk_publishing_components/components/_contents_list.html.erb index dbb984da5e..2bb56de704 100644 --- a/app/views/govuk_publishing_components/components/_contents_list.html.erb +++ b/app/views/govuk_publishing_components/components/_contents_list.html.erb @@ -1,15 +1,16 @@ -<%- +<% add_gem_component_stylesheet("contents-list") - cl_helper = GovukPublishingComponents::Presenters::ContentsListHelper.new(local_assigns) underline_links ||= false format_numbers ||= false alternative_line_style ||= false title ||= nil brand ||= false + local_assigns[:aria] ||= {} + + cl_helper = GovukPublishingComponents::Presenters::ContentsListHelper.new(local_assigns) brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand) - title_fallback = t("components.contents_list.contents", locale: I18n.locale, fallback: false, default: "en") - classes = %w[gem-c-contents-list] + link_classes = %w[gem-c-contents-list__link govuk-link gem-print-link] link_classes << brand_helper.color_class link_classes << "govuk-link--no-underline" unless underline_links @@ -21,7 +22,7 @@ type: "contents list", index_total: cl_helper.get_index_total, } unless disable_ga4 - local_assigns[:aria] ||= {} + component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns) component_helper.add_class("gem-c-contents-list #{brand_helper.brand_class}") component_helper.add_class("gem-c-contents-list--alternative-line-style") if alternative_line_style @@ -29,7 +30,9 @@ component_helper.add_data_attribute({ module: "ga4-link-tracker" }) unless disable_ga4 component_helper.add_aria_attribute({ label: t("components.contents_list.contents") }) unless local_assigns[:aria][:label] component_helper.add_role("navigation") --%> + + title_fallback = t("components.contents_list.contents", locale: I18n.locale, fallback: false, default: "en") +%> <% if cl_helper.contents.any? %> <%= tag.nav(**component_helper.all_attributes) do %> <%= content_tag( diff --git a/app/views/govuk_publishing_components/components/docs/contents_list.yml b/app/views/govuk_publishing_components/components/docs/contents_list.yml index 4930f895de..7ffa6aedcb 100644 --- a/app/views/govuk_publishing_components/components/docs/contents_list.yml +++ b/app/views/govuk_publishing_components/components/docs/contents_list.yml @@ -1,12 +1,11 @@ name: Contents list description: Provides a list of links with options for dashes or numbering. body: | - Commonly used to lists a page’s contents with links pointing to headings within the document, but can also be used for a list of links to other pages. + Commonly used to list the contents of a page with links pointing to headings within the document, but can also be used for a list of links to other pages. Pass a list of contents each with an `href` and `text`. The `href` can point at the ID of a heading within the page. - Supports nesting contents one level deep, currently only used by specialist documents. When nesting the top level list items - display in bold. + Supports nesting contents one level deep, currently only used by specialist documents. When nesting the top level list items display in bold. `format_numbers` option will pull out numbers in the link text to render them as though they were the list style type. Applies to numbers at the start of text, with or without a decimal. See the [format complex numbers fixture](/component-guide/contents-list/formats_complex_numbers) for details. accessibility_criteria: |