Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add component wrapper to more components #7048

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/views/components/_result_card.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
if !title || !url || !url_text
raise ArgumentError, "The result card component requires a title, url, and url_text"
end

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("app-c-result-card")
%>
<div class="app-c-result-card">
<%= tag.div(**component_helper.all_attributes) do %>
<%= render "govuk_publishing_components/components/heading", {
text: title,
heading_level: 2,
Expand All @@ -27,4 +30,4 @@
data: {
"ga4-ecommerce-path": url.delete_prefix("https://www.gov.uk"),
} %>
</div>
<% end %>
8 changes: 5 additions & 3 deletions app/views/components/_result_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
highlighted ||= false
group_index ||= 1
result_index ||= 1
css_classes = %w(app-c-result-item)
css_classes << "app-c-result-item--highlighted" if highlighted

if !title || !url || !description
raise ArgumentError, "The result item component requires a title, url and description"
end

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("app-c-result-item")
component_helper.add_class("app-c-result-item--highlighted") if highlighted
%>
<%= tag.div class: css_classes do %>
<%= tag.div(**component_helper.all_attributes) do %>
<h4 class="govuk-heading-s govuk-!-margin-bottom-2">
<%= link_to url, class: "govuk-link", target: "_blank", rel: "noreferrer noopener" do %>
<%= title || url %> <span class="govuk-!-display-none-print">(opens in new tab)</span>
Expand Down
7 changes: 5 additions & 2 deletions app/views/components/_result_sections.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
if !topics.any?
raise ArgumentError, "The result section component requires topics data"
end

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("app-c-result-sections")
%>
<div class="app-c-result-sections">
<%= tag.div(**component_helper.all_attributes) do %>
<% topics.each do |topic, results| %>
<section class="app-c-result-sections__section">
<h3 class="govuk-heading-m"><%= topic %></h3>
Expand All @@ -22,4 +25,4 @@
<% end %>
</section>
<% end %>
</div>
<% end %>
7 changes: 5 additions & 2 deletions app/views/components/check_uk_visa/_result_card.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
if !type || !title || !url || !attributes.any? || !calculator
raise ArgumentError, "The result card component requires a type, title, url, attributes data and calculator"
end

component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("app-c-result-card")
%>

<div class="app-c-result-card">
<%= tag.div(**component_helper.all_attributes) do %>
<h2 class="govuk-heading-m">
<span class="govuk-caption-m"><%= type %></span>
<%= title %>
Expand Down Expand Up @@ -56,4 +59,4 @@
<%= link_to "Find out more about the #{type}", url,
class: "govuk-link app-c-result-card__link" %>
</p>
</div>
<% end %>
1 change: 1 addition & 0 deletions app/views/components/docs/result_card.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Result card
description: Presents a card style component with a title, description and link
shared_accessibility_criteria:
- link
uses_component_wrapper_helper: true
examples:
default:
data:
Expand Down
1 change: 1 addition & 0 deletions app/views/components/docs/result_item.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Result item
description: Presents a link with label and description
shared_accessibility_criteria:
- link
uses_component_wrapper_helper: true
examples:
default:
data:
Expand Down
40 changes: 21 additions & 19 deletions app/views/components/docs/result_sections.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,34 @@ name: Result section
description: Groups a set of results items under a common title
shared_accessibility_criteria:
- link
uses_component_wrapper_helper: true
examples:
default:
data:
title: Business tax
results:
topics:
business_tax:
- title: "Register for Corporation Tax"
url: "/corporation-tax"
description: "You need to register for corporation tax within 3 months of starting to do business, if you haven’t done so already."
with-multiple-items:
data:
title: Business tax
results:
- title: "Register for Corporation Tax"
url: "/corporation-tax"
description: "You need to register for corporation tax within 3 months of starting to do business, if you haven’t done so already."
- title: "Register for VAT"
url: "/vat-registration"
description: "You need to register your business for VAT if your VAT taxable turnover is more than £85,000."
topics:
business_tax:
- title: "Register for Corporation Tax"
url: "/corporation-tax"
description: "You need to register for corporation tax within 3 months of starting to do business, if you haven’t done so already."
- title: "Register for VAT"
url: "/vat-registration"
description: "You need to register your business for VAT if your VAT taxable turnover is more than £85,000."
with-multiple-highlighted-items:
data:
title: Business tax
highlighted: true
results:
- title: "Register for Corporation Tax"
url: "/corporation-tax"
description: "You need to register for corporation tax within 3 months of starting to do business, if you haven’t done so already."
- title: "Register for VAT"
url: "/vat-registration"
description: "You need to register your business for VAT if your VAT taxable turnover is more than £85,000."
topics:
business_tax:
- title: "Register for Corporation Tax"
url: "/corporation-tax"
description: "You need to register for corporation tax within 3 months of starting to do business, if you haven’t done so already."
highlighted: true
- title: "Register for VAT"
url: "/vat-registration"
description: "You need to register your business for VAT if your VAT taxable turnover is more than £85,000."
highlighted: true
Loading