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

Version 5.0.0 #456

Merged
merged 75 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
983acfc
Add the new task list component
peteryates Aug 23, 2023
985cd70
Register the govuk_task_list helper
peteryates Aug 23, 2023
5872342
Add sample task list styles
peteryates Aug 23, 2023
98982db
Add guide page for the task list
peteryates Aug 23, 2023
44af816
Merge branch 'main' into add-task-list-component
frankieroberto Oct 26, 2023
509dc64
Update to use govuk-frontend v5
frankieroberto Oct 26, 2023
f50bab1
Update script
frankieroberto Oct 26, 2023
983a54b
Fix path
frankieroberto Oct 26, 2023
8193e01
Update script tag
frankieroberto Oct 26, 2023
5535296
Remove extra line break
frankieroberto Oct 26, 2023
8f8ae18
Update tags: capitalisation and new colour (light-blue)
frankieroberto Oct 26, 2023
7091dd5
Update class name of visually hidden text in warning component
frankieroberto Oct 26, 2023
1923443
Remove data-module from details
frankieroberto Oct 26, 2023
266d106
Remove crown fallback image
frankieroberto Oct 26, 2023
d156652
Remove disabled option from govuk_button_to
frankieroberto Oct 26, 2023
89bd24f
Update default aria label for pagination
frankieroberto Oct 26, 2023
4b77b60
Set supported Rails versions to 7.0.8 and 7.1.0
peteryates Oct 8, 2023
08f2cc5
Merge branch 'govuk-frontend-v5' into add-task-list-component
frankieroberto Oct 27, 2023
aac8008
Remove temporary css
frankieroberto Oct 27, 2023
627ae80
Simplify task list to not assume a tag in status
frankieroberto Oct 27, 2023
1e37f31
Use tag helper within tests
frankieroberto Oct 27, 2023
3ae6c35
Fix test
frankieroberto Oct 27, 2023
3efc941
Allow plain text statuses in the task list
peteryates Oct 27, 2023
257b497
Make task list statuses more flexible
peteryates Oct 27, 2023
a55bd88
Simplify class names
peteryates Oct 28, 2023
9386dc7
Add a hints example to the guide
peteryates Oct 28, 2023
2b699a6
Improve task list when hints/links missing
peteryates Oct 29, 2023
2bf5a18
Add aria-describedby links on title, status and hint
peteryates Oct 29, 2023
3ec2330
Remove aria attribute from div
frankieroberto Oct 30, 2023
7e6b039
Set the item id numbers sequentially
peteryates Oct 30, 2023
fa72072
Set a default id prefix for task lists
frankieroberto Oct 31, 2023
1169bcb
Update the docs a bit
frankieroberto Oct 31, 2023
fbf5ef8
Update docs
frankieroberto Oct 31, 2023
7fed473
Use slim syntax
frankieroberto Oct 31, 2023
f6cf2a7
Add example using custom classes and attributes
frankieroberto Oct 31, 2023
262f8c0
Trim multiple trailing lines
frankieroberto Oct 31, 2023
342eb42
Add task list component to the list in the README
peteryates Nov 2, 2023
b95a714
Update to second prerelease
frankieroberto Nov 3, 2023
40b2745
Add task list component (#445)
peteryates Nov 3, 2023
5287df1
Set supported Rails versions to 7.0.8 and 7.1.0 (#454)
frankieroberto Nov 24, 2023
09f5f7d
Merge branch 'main' into govuk-frontend-v5
peteryates Nov 26, 2023
8823090
Split out extract_button_link_args
peteryates Nov 26, 2023
04d38d6
Rework and simplify the link and button helpers
peteryates Nov 26, 2023
b71c4da
Update to use new combined logo svg
frankieroberto Nov 27, 2023
4ac9253
Remove the X-UA-Compatible meta tag
frankieroberto Nov 27, 2023
1e4f717
remove whitespace
frankieroberto Nov 27, 2023
5317863
Update to use new combined logo svg (#466)
frankieroberto Nov 27, 2023
f2de10d
Add GovukVisuallyHiddenHelper
peteryates Nov 27, 2023
ae8e273
Support inserting visually hidden text into links
peteryates Nov 27, 2023
5722bb0
Move the spaces inside the visually hidden span
peteryates Nov 27, 2023
c96c555
Add ARIA label to SVG title
frankieroberto Nov 28, 2023
5beb68a
Add docs on adding visually hidden text to links
peteryates Nov 28, 2023
e8a11a7
Move aria label
frankieroberto Nov 28, 2023
aa77c40
Add docs covering visually hidden helper standalone
peteryates Nov 28, 2023
f01217d
Add visually hidden prefix and suffix text to links and buttons (#465)
peteryates Nov 28, 2023
fd18679
Release version 5.0.0b1
peteryates Nov 28, 2023
67d716a
Fix module name in include
frankieroberto Nov 28, 2023
ad9521d
Add a basic test for govuk_visually_hidden
frankieroberto Nov 28, 2023
7d3bdb9
Drop focusable option from govuk_visually_hidden
frankieroberto Nov 29, 2023
475443d
Remove example from guide
frankieroberto Nov 29, 2023
94808a1
Remove argument from method definition
frankieroberto Nov 29, 2023
7f4965f
Drop focusable option from govuk_visually_hidden (#473)
frankieroberto Nov 29, 2023
a1bd5ee
Delete govuk-mask-icon.svg
frankieroberto Nov 29, 2023
5fa597d
Delete govuk-mask-icon.svg (#474)
frankieroberto Nov 29, 2023
85eeb17
Release version 5.0.0b2
peteryates Nov 29, 2023
98c0e6e
Refactor to allow blocks to be used in ERb
frankieroberto Nov 29, 2023
80c9528
Code style fix: add line break after guard clause
frankieroberto Nov 29, 2023
e4a6ab1
Refactor to allow blocks to be used in ERb (#475)
frankieroberto Nov 29, 2023
3151c54
Release version 5.0.0b3
peteryates Nov 29, 2023
b1a98c2
Fix block syntax for buttons
frankieroberto Nov 29, 2023
b29f7a9
Bump version
frankieroberto Nov 29, 2023
3bcf531
code style fix
frankieroberto Nov 29, 2023
1691036
Fix spelling of compatible
peteryates Nov 29, 2023
ab2d258
Fix spelling of compatible (#476)
peteryates Nov 29, 2023
a70be3e
Use released version
frankieroberto Dec 8, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Install gems
env:
RAILS_VERSION: '6.1.7.4'
RAILS_VERSION: '7.0.8'
run: |
gem install bundler
bundle install --jobs 4 --retry 3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
ruby: ['3.0.6', '3.1.4', '3.2.2']
rails: ['6.1.7', '7.0.6']
rails: ['7.0.8', '7.1.0']
runs-on: ubuntu-20.04
name: Testing with Ruby ${{ matrix.ruby }} and Rails ${{ matrix.rails }}
steps:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Licence](https://img.shields.io/github/license/x-govuk/govuk-components)](https://github.com/x-govuk/govuk-components/blob/main/LICENSE.txt)
[![GOV.UK Design System version](https://img.shields.io/badge/GOV.UK%20Design%20System-4.7.0-brightgreen)](https://design-system.service.gov.uk)
[![ViewComponent](https://img.shields.io/badge/ViewComponent-3.3.0-brightgreen)](https://viewcomponent.org/)
[![Rails](https://img.shields.io/badge/Rails-6.1.7%20%E2%95%B1%207.0.6-E16D6D)](https://weblog.rubyonrails.org/releases/)
[![Rails](https://img.shields.io/badge/Rails-7.0.8%20%E2%95%B1%207.1.0-E16D6D)](https://weblog.rubyonrails.org/releases/)
[![Ruby](https://img.shields.io/badge/Ruby-3.0.6%20%20%E2%95%B1%203.1.4%20%20%E2%95%B1%203.2.2-E16D6D)](https://www.ruby-lang.org/en/downloads/)

This gem provides a suite of reusable components for the [GOV.UK Design System](https://design-system.service.gov.uk/). It is intended to provide a lightweight alternative to the [GOV.UK Publishing Components](https://github.com/alphagov/govuk_publishing_components) library and is built with GitHub’s [ViewComponent](https://github.com/github/view_component) framework.
Expand Down Expand Up @@ -46,6 +46,7 @@ The provided components are:
* [Tabs](https://govuk-components.netlify.app/components/tabs)
* [Tables](https://govuk-components.netlify.app/components/table)
* [Tags](https://govuk-components.netlify.app/components/tag)
* [Task list](https://govuk-components.netlify.app/components/task-list)
* [Warning text](https://govuk-components.netlify.app/components/warning-text)

This library also provides helpers for creating [links](https://govuk-components.netlify.app/helpers/link),
Expand Down
2 changes: 1 addition & 1 deletion app/components/govuk_component/details_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(summary_text: nil, text: nil, classes: [], id: nil, open: nil, ht
end

def call
tag.details(data: { module: "#{brand}-details" }, id: id, open: open, **html_attributes) do
tag.details(id: id, open: open, **html_attributes) do
safe_join([summary, description])
end
end
Expand Down
38 changes: 17 additions & 21 deletions app/components/govuk_component/header_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@
<%= tag.div(**container_html_attributes) do %>
<div class="<%= brand %>-header__logo">
<%= link_to(homepage_url, class: ["#{brand}-header__link", "#{brand}-header__link--homepage"]) do %>
<span class="<%= brand %>-header__logotype">
<% if custom_logo.present? %>
<%= custom_logo %>
<% else %>
<% if crown %>
<!--[if gt IE 8]><!-->
<svg aria-hidden="true" focusable="false" class="<%= brand %>-header__logotype-crown" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 132 97" height="30" width="36">
<path fill="currentColor" fill-rule="evenodd" d="M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.6-1.5-7.6.3-9.1 3.8-1.3 3.6.4 7.7 3.9 9.1zm64.4-5.6c-3.6 1.5-7.8-.2-9.1-3.7-1.5-3.6.2-7.8 3.8-9.2 3.6-1.4 7.7.3 9.2 3.9 1.3 3.5-.4 7.5-3.9 9zm15.9 9.3c-3.6 1.5-7.7-.2-9.1-3.7-1.5-3.6.2-7.8 3.7-9.1 3.6-1.5 7.7.2 9.2 3.8 1.5 3.5-.3 7.5-3.8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.1 2.7-8.7-4.6-11.6-9.4-6.2 3.7-8.5 3.6-14.7-4.6-20.8-5.8 7.6-5 13.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z"></path>
</svg>
<!--<![endif]-->
<% end %>

<% if crown_fallback_image_path.present? %>
<!--[if IE 8]>
<%= image_tag(crown_fallback_image_path, **crown_fallback_image_attributes) %>
<![endif]-->
<% end %>

<%= tag.span(logotype, class: "#{brand}-header__logotype-text") %>
<% end %>
</span>
<% if custom_logo.present? %>
<%= custom_logo %>
<% else %>
<svg
focusable="false"
role="img"
class="<%= brand %>-header__logotype"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 152 30"
height="30"
width="152"
aria-label="GOV.UK"
>
<title>GOV.UK</title>
<path d="M6.7 12.2c1 .4 2.1-.1 2.5-1s-.1-2.1-1-2.5c-1-.4-2.1.1-2.5 1-.4 1 0 2.1 1 2.5m-4.3 2.5c1 .4 2.1-.1 2.5-1s-.1-2.1-1-2.5c-1-.4-2.1.1-2.5 1-.5 1 0 2.1 1 2.5m-1.3 4.8c1 .4 2.1-.1 2.5-1 .4-1-.1-2.1-1-2.5-1-.4-2.1.1-2.5 1-.4 1 0 2.1 1 2.5m10.4-5.8c1 .4 2.1-.1 2.5-1s-.1-2.1-1-2.5c-1-.4-2.1.1-2.5 1s0 2.1 1 2.5m17.4-1.5c-1 .4-2.1-.1-2.5-1s.1-2.1 1-2.5c1-.4 2.1.1 2.5 1 .5 1 0 2.1-1 2.5m4.3 2.5c-1 .4-2.1-.1-2.5-1s.1-2.1 1-2.5c1-.4 2.1.1 2.5 1 .5 1 0 2.1-1 2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 2-3.4.4-1.3.7-2.7.7-4.2-.1-1.5-.3-2.9-.8-4.2zM81 17.6c0 1-.1 1.9-.4 2.7-.2.8-.6 1.6-1.1 2.2-.5.6-1.1 1.1-1.7 1.4-.7.3-1.5.5-2.4.5-.9 0-1.7-.2-2.4-.5s-1.3-.8-1.7-1.4c-.5-.6-.8-1.3-1.1-2.2-.2-.8-.4-1.7-.4-2.7v-.1c0-1 .1-1.9.4-2.7.2-.8.6-1.6 1.1-2.2.5-.6 1.1-1.1 1.7-1.4.7-.3 1.5-.5 2.4-.5.9 0 1.7.2 2.4.5s1.3.8 1.7 1.4c.5.6.8 1.3 1.1 2.2.2.8.4 1.7.4 2.7v.1zM92.9 28 87 7h4.7l4 15.7h.1l4-15.7h4.7l-5.9 21h-5.7zm28.8-3.6c.6 0 1.2-.1 1.7-.3.5-.2 1-.4 1.4-.8.4-.4.7-.8.9-1.4.2-.6.3-1.2.3-2v-13h4.1v13.6c0 1.2-.2 2.2-.6 3.1s-1 1.7-1.8 2.4c-.7.7-1.6 1.2-2.7 1.5-1 .4-2.2.5-3.4.5-1.2 0-2.4-.2-3.4-.5-1-.4-1.9-.9-2.7-1.5-.8-.7-1.3-1.5-1.8-2.4-.4-.9-.6-2-.6-3.1V6.9h4.2v13c0 .8.1 1.4.3 2 .2.6.5 1 .9 1.4.4.4.8.6 1.4.8.6.2 1.1.3 1.8.3zm13-17.4h4.2v9.1l7.4-9.1h5.2l-7.2 8.4L152 28h-4.9l-5.5-9.4-2.7 3V28h-4.2V7zm-27.6 16.1c-1.5 0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z"></path>
</svg>
<% end %>
<% if product_name.present? %>
<%= product_name %>
<% end %>
Expand Down
19 changes: 1 addition & 18 deletions app/components/govuk_component/header_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ class GovukComponent::HeaderComponent < GovukComponent::Base
renders_one :custom_logo
renders_one :product_name, "ProductName"

attr_reader :logotype,
:crown,
:crown_fallback_image_path,
:homepage_url,
attr_reader :homepage_url,
:service_name,
:service_url,
:menu_button_label,
Expand All @@ -16,9 +13,6 @@ class GovukComponent::HeaderComponent < GovukComponent::Base

def initialize(classes: [],
html_attributes: {},
logotype: config.default_header_logotype,
crown: true,
crown_fallback_image_path: nil,
homepage_url: config.default_header_homepage_url,
menu_button_label: config.default_header_menu_button_label,
navigation_classes: [],
Expand All @@ -27,9 +21,6 @@ def initialize(classes: [],
service_url: config.default_header_service_url,
container_classes: nil)

@logotype = logotype
@crown = crown
@crown_fallback_image_path = crown_fallback_image_path
@homepage_url = homepage_url
@service_name = service_name
@service_url = service_url
Expand Down Expand Up @@ -57,14 +48,6 @@ def container_html_attributes
{ class: ["#{brand}-header__container", "#{brand}-width-container"].append(custom_container_classes).compact }
end

def crown_fallback_image_attributes
{
class: "#{brand}-header__logotype-crown-fallback-image",
width: "36",
height: "32",
}
end

class NavigationItem < GovukComponent::Base
attr_reader :text, :href, :options, :active

Expand Down
2 changes: 1 addition & 1 deletion app/components/govuk_component/tag_component.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class GovukComponent::TagComponent < GovukComponent::Base
attr_reader :text, :colour

COLOURS = %w(grey green turquoise blue red purple pink orange yellow).freeze
COLOURS = %w(grey green turquoise blue light-blue red purple pink orange yellow).freeze
frankieroberto marked this conversation as resolved.
Show resolved Hide resolved

def initialize(text: nil, colour: config.default_tag_colour, classes: [], html_attributes: {})
@text = text
Expand Down
37 changes: 37 additions & 0 deletions app/components/govuk_component/task_list_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module GovukComponent
class TaskListComponent < GovukComponent::Base
renders_many :items, ->(title: nil, href: nil, hint: nil, status: {}, classes: [], html_attributes: {}) do
GovukComponent::TaskListComponent::ItemComponent.new(
title: title,
href: href,
hint: hint,
id_prefix: @id_prefix,
count: @count,
status: status,
classes: classes,
html_attributes: html_attributes
)
end

def initialize(id_prefix: "task-list", classes: [], html_attributes: {})
@id_prefix = id_prefix
@count = 0

super(classes: classes, html_attributes: html_attributes)
end

def call
numbered_items = items.each.with_index(1) { |item, count| item.count = count }

tag.ul(**html_attributes) do
safe_join(numbered_items)
end
end

private

def default_attributes
{ class: 'govuk-task-list' }
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
module GovukComponent
class TaskListComponent::ItemComponent < GovukComponent::Base
renders_one :status, ->(text: nil, classes: [], html_attributes: {}, &block) do
GovukComponent::TaskListComponent::StatusComponent.new(
id_prefix: @id_prefix,
count: @count,
text: text,
classes: classes,
html_attributes: html_attributes,
&block
)
end

renders_one :title, ->(text: nil, href: nil, hint: nil, classes: [], html_attributes: {}, &block) do
GovukComponent::TaskListComponent::TitleComponent.new(
id_prefix: @id_prefix,
count: @count,
text: text,
href: href,
hint: hint,
classes: classes,
html_attributes: html_attributes,
&block
)
end

attr_reader :raw_title, :hint, :href, :raw_status
attr_writer :count

def initialize(title: nil, href: nil, hint: nil, count: nil, id_prefix: nil, status: {}, classes: [], html_attributes: {})
@raw_title = title
@href = href
@hint = hint
@raw_status = status
@id_prefix = id_prefix
@count = count

super(classes: classes, html_attributes: html_attributes)
end

def call
adjusted_html_attributes = if href.present? || title&.href.present?
html_attributes_with_link_class
else
html_attributes
end

tag.li(safe_join([title_content, status_content].compact), **adjusted_html_attributes)
end

private

def title_content
title || with_title(**title_attributes)
end

def status_content
status || with_status(**status_attributes)
end

def default_attributes
{ class: 'govuk-task-list__item' }
end

def title_attributes
{ text: raw_title, href: href, hint: hint }
end

def html_attributes_with_link_class
html_attributes.tap { |h| h[:class].append("govuk-task-list__item--with-link") }
end

def status_attributes
raw_status.is_a?(String) ? { text: raw_status } : raw_status
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module GovukComponent
class TaskListComponent::StatusComponent < GovukComponent::Base
attr_reader :id_prefix, :text, :count

def initialize(text: nil, id_prefix: nil, count: nil, classes: [], html_attributes: {})
@text = text
@count = count
@id_prefix = id_prefix

super(classes: classes, html_attributes: html_attributes)
end

def call
tag.div(status_text, **html_attributes)
end

def render?
status_text.present?
end

private

def default_attributes
{ class: %w(govuk-task-list__status), id: [id_prefix, count, "status"].compact.join("-") }
end

def status_text
text || content
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module GovukComponent
class TaskListComponent::TitleComponent < GovukComponent::Base
using HTMLAttributesUtils

attr_reader :id_prefix, :text, :href, :hint, :count

def initialize(text: nil, href: nil, hint: nil, id_prefix: nil, count: nil, classes: [], html_attributes: {})
@text = text
@href = href
@hint = hint
@id_prefix = id_prefix
@count = count

super(classes: classes, html_attributes: html_attributes)
end

def call
tag.div(**html_attributes) { safe_join([title_content, hint_content]) }
end

private

def title_content
(href.present?) ? govuk_link_to(text, href, **link_attributes) : text
end

def hint_content
return if hint.blank?

tag.div(hint, class: "govuk-task-list__hint", id: hint_id)
end

def default_attributes
{ class: "govuk-task-list__name-and-hint" }
end

def link_attributes
{ class: "govuk-task-list__link", **aria_described_by_attributes }
end

def aria_described_by_attributes
{ aria: { describedby: [*status_id, *hint_id] } }
end

def hint_id
[id_prefix, count, "hint"].compact.join("-") if hint.present?
end

def status_id
[id_prefix, count, "status"].compact.join("-")
end
end
end
6 changes: 3 additions & 3 deletions app/components/govuk_component/warning_text_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def icon_element

def warning_text
tag.strong(class: "#{brand}-warning-text__text") do
safe_join([assistive, (content || text)])
safe_join([visually_hidden_text, (content || text)])
end
end

def assistive
tag.span(icon_fallback_text, class: "#{brand}-warning-text__assistive")
def visually_hidden_text
tag.span(icon_fallback_text, class: "#{brand}-visually-hidden")
end

def default_attributes
Expand Down
1 change: 1 addition & 0 deletions app/helpers/govuk_components_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module GovukComponentsHelper
govuk_table: 'GovukComponent::TableComponent',
govuk_tabs: 'GovukComponent::TabComponent',
govuk_tag: 'GovukComponent::TagComponent',
govuk_task_list: 'GovukComponent::TaskListComponent',
govuk_warning_text: 'GovukComponent::WarningTextComponent',
}.each do |name, klass|
define_method(name) do |*args, **kwargs, &block|
Expand Down
Loading