Skip to content

Commit

Permalink
Version 5.0.0 (#456)
Browse files Browse the repository at this point in the history
Following the release of [GOV.UK Design System
v5.0](https://github.com/alphagov/govuk-design-system/milestone/16),
govuk-components v5.0.0 will be released. The headline features are:

* support for GOV.UK Design System v5.0
* inclusion of [the task list
component](alphagov/govuk-frontend#2261) #425
* all new link helpers #419
* update header to use new SVG which combines the crown and the GOV.UK
test #466

Release notes will be drafted in #469.
  • Loading branch information
peteryates authored Dec 8, 2023
2 parents aed6a5e + a70be3e commit 00d582f
Show file tree
Hide file tree
Showing 63 changed files with 1,055 additions and 244 deletions.
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-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.9zM66 92.8c16.9 0 32.8 1.1 47.1 3.2 4-16.9 8.9-26.7 14-33.5l-9.6-3.4c1 4.9 1.1 7.2 0 10.2-1.5-1.4-3-4.3-4.2-8.7L108.6 76c2.8-2 5-3.2 7.5-3.3-4.4 9.4-10 11.9-13.6 11.2-4.3-.8-6.3-4.6-5.6-7.9 1-4.7 5.7-5.9 8-.5 4.3-8.7-3-11.4-7.6-8.8 7.1-7.2 7.9-13.5 2.1-21.1-8 6.1-8.1 12.3-4.5 20.8-4.7-5.4-12.1-2.5-9.5 6.2 3.4-5.2 7.9-2 7.2 3.1-.6 4.3-6.4 7.8-13.5 7.2-10.3-.9-10.9-8-11.2-13.8 2.5-.5 7.1 1.8 11 7.3L80.2 60c-4.1 4.4-8 5.3-12.3 5.4 1.4-4.4 8-11.6 8-11.6H55.5s6.4 7.2 7.9 11.6c-4.2-.1-8-1-12.3-5.4l1.4 16.4c3.9-5.5 8.5-7.7 10.9-7.3-.3 5.8-.9 12.8-11.1 13.8-7.2.6-12.9-2.9-13.5-7.2-.7-5 3.8-8.3 7.1-3.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.5m1.3 4.8c-1 .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.5m-10.4-5.8c-1 .4-2.1-.1-2.5-1s.1-2.1 1-2.5c1-.4 2.1.1 2.5 1s0 2.1-1 2.5m-5.3-4.9 2.4 1.3V6.5l-2.4.8c-.1-.1-.1-.2-.2-.2s1-3 1-3h-3.4l1 3c-.1.1-.2.1-.2.2-.1.1-2.4-.7-2.4-.7v3.5L17 8.8c-.1.1 0 .2.1.3l-1.4 4.2c-.1.2-.1.4-.1.7 0 1.1.8 2.1 1.9 2.2h.6C19.2 16 20 15.1 20 14c0-.2 0-.4-.1-.7l-1.4-4.2c.2-.1.3-.2.3-.3m-1 20.3c4.6 0 8.9.3 12.8.9 1.1-4.6 2.4-7.2 3.8-9.1l-2.6-.9c.3 1.3.3 1.9 0 2.8-.4-.4-.8-1.2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.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

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

0 comments on commit 00d582f

Please sign in to comment.