Skip to content

Commit

Permalink
Make components pass fixed test
Browse files Browse the repository at this point in the history
- doesn't seem like important_metadata needed the html_safe on it
- updated YML example to show links rendered correctly
  • Loading branch information
andysellick committed Jun 7, 2024
1 parent 46a199d commit b6ca36b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
12 changes: 9 additions & 3 deletions app/views/components/_contents_list_with_body.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
<% unless block.empty? %>
<%
contents ||= []
sticky_attr = ' data-module="sticky-element-container"'.html_safe if contents.any?
sticky_attr = "sticky-element-container" if contents.any?
%>
<div id="contents" class="app-c-contents-list-with-body"<%= sticky_attr %>>
<%= tag.div(
id: "contents",
class: "app-c-contents-list-with-body",
data: {
module: sticky_attr,
},
) do %>
<% if contents.any? %>
<div class="responsive-bottom-margin">
<%= render 'govuk_publishing_components/components/contents_list', contents: contents %>
Expand All @@ -19,5 +25,5 @@
</div>
</div>
<% end %>
</div>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/components/_important_metadata.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
title = local_assigns[:title]
items = local_assigns[:items] || {}
items = items.reject { |k,v| v.nil? }
items = items.merge(items) { |k,v| Array(v).join(", ").html_safe }
items = items.merge(items) { |k,v| Array(v).join(", ") }
margin_bottom_class = " app-c-important-metadata--bottom-margin" unless local_assigns[:margin_bottom]
-%>
<% if items.any? %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/components/docs/contents_list_with_body.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ examples:
<h3 id="contact">Contact</h3>
<p>Please send written representations about any competition issues to:</p>
<div class="address"><div class="adr org fn"><p>
<br>Competition and Markets Authority
<br>Victoria House
<br>Southampton Row
<br>London
<br>Competition and Markets Authority
<br>Victoria House
<br>Southampton Row
<br>London
<br>WC1B 4AD
<br>
</p></div></div>
Expand Down
6 changes: 3 additions & 3 deletions app/views/components/docs/important_metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ examples:
data:
items:
Many things:
- First thing
- Second thing
- Third thing
- <a href="#">First thing</a>
- <a href="#">Second thing</a>
- <a href="#">Third thing</a>
with_title:
description: Used on statistics announcements to display release date changed information, [see example](https://gov.uk/government/statistics/announcements/museums-and-galleries-monthly-visits--8)
data:
Expand Down

0 comments on commit b6ca36b

Please sign in to comment.