Skip to content

Commit

Permalink
Contents list tidying
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
andysellick committed Oct 24, 2024
1 parent 164a9d7 commit 3ee8225
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,15 +22,17 @@
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
component_helper.add_class("gem-c-contents-list--custom-title") if title
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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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: |
Expand Down

0 comments on commit 3ee8225

Please sign in to comment.