govuk-components 6.4.1 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 448eb2b3c765475aa5e67b693d52628aa70ce9759ef9eaedf0b71ad6e5905db4
4
- data.tar.gz: dc7af5109db0372dc9baa102cc09b77f96a645a2dd22389b8ea75fab4870f983
3
+ metadata.gz: f54ed28b71fcc66df0f020e4760ffc756ab559fc71ae04b6754ff9b124d2364e
4
+ data.tar.gz: 01f758424641f2c494e0764d706ffc1c1ea079fbb36b90e9dd0751e330e6eedb
5
5
  SHA512:
6
- metadata.gz: 7aec79f3e89135ecd180a28c2485f47d4b7f4ee99d9ad0f6f44396fb3962b60b58616469ffc72865e8a5fd6d19ea7064b4874b088cf98f033dc725153b881c64
7
- data.tar.gz: de4de0cf2251398725639e7209fe48db79893da6e1b4da9f18bba682313b6796b1447000c182c08811cce684a22474e27f34f5b72e2f5996b77933446fb58535
6
+ metadata.gz: c016303e309e6a59c33982fafe8983a4a15190847c46bc7ecac2e0967f76f2a60e07b008e9ab9efea6132d34d82163fd312ff990b53ec46557a748e48f977f78
7
+ data.tar.gz: 30d7b1cd9fb766513bafc9aa0bdc8f362409d2628b31bfc950e06dc6bf10ee3258a3d3a249d5dab89e07612631da05eba175890c2ea4946603cfdd26b6261c0e
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Gem version](https://badge.fury.io/rb/govuk-components.svg)](https://badge.fury.io/rb/govuk-components)
5
5
  [![Gem](https://img.shields.io/gem/dt/govuk-components?logo=rubygems)](https://rubygems.org/gems/govuk-components)
6
6
  [![Licence](https://img.shields.io/github/license/x-govuk/govuk-components)](https://github.com/x-govuk/govuk-components/blob/main/LICENSE.txt)
7
- [![GOV.UK Design System version](https://img.shields.io/badge/GOV.UK%20Design%20System-6.4.0-brightgreen)](https://design-system.service.gov.uk)
7
+ [![GOV.UK Design System version](https://img.shields.io/badge/GOV.UK%20Design%20System-6.5.0-brightgreen)](https://design-system.service.gov.uk)
8
8
  [![ViewComponent](https://img.shields.io/badge/ViewComponent-4.6.0-brightgreen)](https://viewcomponent.org/)
9
9
  [![Rails](https://img.shields.io/badge/Rails-7.2.2%20%E2%95%B1%208.0.2%20%E2%95%B1%208.1.0-E16D6D)](https://weblog.rubyonrails.org/releases/)
10
10
  [![Ruby](https://img.shields.io/badge/Ruby-3.3.11%20%20%E2%95%B1%204.0.2-E16D6D)](https://www.ruby-lang.org/en/downloads/)
@@ -31,6 +31,7 @@ The provided components are:
31
31
  * [Cookie banner](https://govuk-components.x-govuk.org/components/cookie-banner)
32
32
  * [Details](https://govuk-components.x-govuk.org/components/details)
33
33
  * [Exit this page](https://govuk-components.x-govuk.org/components/exit-this-page)
34
+ * [Generic header](https://govuk-components.x-govuk.org/components/generic-header)
34
35
  * [GOV.UK footer](https://govuk-components.x-govuk.org/components/footer)
35
36
  * [GOV.UK header](https://govuk-components.x-govuk.org/components/header)
36
37
  * [Inset text](https://govuk-components.x-govuk.org/components/inset-text)
@@ -39,6 +40,7 @@ The provided components are:
39
40
  * [Pagination](https://govuk-components.x-govuk.org/components/pagination)
40
41
  * [Phase banner](https://govuk-components.x-govuk.org/components/phase-banner)
41
42
  * [Section break](https://govuk-components.x-govuk.org/components/section-break)
43
+ * [Service navigation](https://govuk-components.x-govuk.org/components/service-navigation)
42
44
  * [Start button](https://govuk-components.x-govuk.org/components/start-button)
43
45
  * [Summary list](https://govuk-components.x-govuk.org/components/summary-list)
44
46
  * [Tabs](https://govuk-components.x-govuk.org/components/tabs)
@@ -0,0 +1,48 @@
1
+ class GovukComponent::FeedbackComponent < GovukComponent::Base
2
+ attr_reader :title_text, :text, :heading_level
3
+
4
+ renders_one :header
5
+ renders_one :body
6
+
7
+ def initialize(title_text: nil, text: nil, heading_level: 2, classes: [], html_attributes: {})
8
+ @title_text = title_text
9
+ @text = text
10
+ @heading_level = %(h#{heading_level})
11
+
12
+ super(classes:, html_attributes:)
13
+ end
14
+
15
+ def call
16
+ tag.div(**html_attributes) do
17
+ tag.div(class: "#{brand}-grid-row") do
18
+ tag.div(class: "#{brand}-grid-column-two-thirds") do
19
+ safe_join([title_content, text_content])
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def title_content
28
+ content = header || title_text
29
+
30
+ fail(ArgumentError, 'title_text or header is missing') if content.blank?
31
+
32
+ content_tag(heading_level, content, class: "#{brand}-feedback__title")
33
+ end
34
+
35
+ def text_content
36
+ content = body || text
37
+
38
+ fail(ArgumentError, 'text or body is missing') if content.blank?
39
+
40
+ tag.div(class: "#{brand}-feedback__body") do
41
+ tag.p(content, class: "#{brand}-body")
42
+ end
43
+ end
44
+
45
+ def default_attributes
46
+ { class: ["#{brand}-feedback", "#{brand}-width-container"] }
47
+ end
48
+ end
@@ -1,4 +1,4 @@
1
- <%= tag.footer(**footer_attributes) do %>
1
+ <%= tag.footer(**footer_html_attributes) do %>
2
2
  <%= content %>
3
3
  <%= tag.div(**html_attributes) do %>
4
4
  <%= tag.div(**container_html_attributes) do %>
@@ -10,7 +10,7 @@ class GovukComponent::FooterComponent < GovukComponent::Base
10
10
  renders_one :content_after_meta_items
11
11
  renders_one :meta_licence_html
12
12
 
13
- attr_reader :meta_items, :meta_text, :meta_items_title, :meta_licence, :copyright_text, :copyright_url, :custom_container_classes, :footer_attributes
13
+ attr_reader :meta_items, :meta_text, :meta_items_title, :meta_licence, :copyright_text, :copyright_url, :custom_container_classes, :footer_html_attributes
14
14
 
15
15
  def initialize(
16
16
  classes: [],
@@ -18,7 +18,7 @@ class GovukComponent::FooterComponent < GovukComponent::Base
18
18
  container_html_attributes: {},
19
19
  copyright_text: config.default_footer_copyright_text,
20
20
  copyright_url: config.default_footer_copyright_url,
21
- footer_attributes: {},
21
+ footer_html_attributes: {},
22
22
  html_attributes: {},
23
23
  meta_items: {},
24
24
  meta_items_title: "Support links",
@@ -37,7 +37,7 @@ class GovukComponent::FooterComponent < GovukComponent::Base
37
37
  @copyright_url = copyright_url
38
38
  @custom_container_classes = container_classes
39
39
  @custom_container_html_attributes = container_html_attributes
40
- @footer_attributes = footer_attributes
40
+ @footer_html_attributes = footer_html_attributes
41
41
 
42
42
  super(classes:, html_attributes:)
43
43
  end
@@ -0,0 +1,95 @@
1
+ class GovukComponent::LanguageNavigationComponent < GovukComponent::Base
2
+ attr_reader :inverse, :any_rtl
3
+
4
+ renders_many :items, "GovukComponent::LanguageNavigationComponent::Item"
5
+
6
+ def initialize(items: [], inverse: false, classes: [], html_attributes: {})
7
+ @items = items
8
+ @any_rtl = items.any? { |item| item.symbolize_keys[:dir] == 'rtl' }
9
+ @inverse = inverse
10
+
11
+ super(classes:, html_attributes:)
12
+ end
13
+
14
+ def before_render
15
+ @items.each { |item| with_item(**item, any_rtl:) }
16
+ end
17
+
18
+ def call
19
+ tag.nav(**html_attributes) do
20
+ tag.ul(class: "#{brand}-language-navigation__list") do
21
+ safe_join(items)
22
+ end
23
+ end
24
+ end
25
+
26
+ def render?
27
+ items.any?
28
+ end
29
+
30
+ def default_attributes
31
+ {
32
+ class: class_names(
33
+ "#{brand}-language-navigation",
34
+ "#{brand}-language-navigation--inverse" => inverse
35
+ ),
36
+ aria: { label: 'language' }
37
+ }
38
+ end
39
+
40
+ class GovukComponent::LanguageNavigationComponent::Item < GovukComponent::Base
41
+ include GovukVisuallyHiddenHelper
42
+
43
+ attr_reader :text, :lang, :current, :href, :href_lang, :language_description_text, :any_rtl, :dir
44
+
45
+ def initialize(text:, lang:, href: nil, language_description_text: nil, current: false, href_lang: nil, dir: 'ltr', any_rtl: false, classes: [], html_attributes: {})
46
+ @text = text
47
+ @lang = lang
48
+ @href = href
49
+ @href_lang = href_lang || lang
50
+ @current = current
51
+ @language_description_text = language_description_text
52
+ @dir = dir if any_rtl
53
+
54
+ super(classes:, html_attributes:)
55
+ end
56
+
57
+ def call
58
+ tag.li(content, **default_attributes)
59
+ end
60
+
61
+ private
62
+
63
+ def content
64
+ common = { dir: dir, lang: lang }
65
+
66
+ if current
67
+ tag.span(
68
+ text,
69
+ class: "#{brand}-language-navigation__text",
70
+ aria: { current: true },
71
+ **common
72
+ )
73
+ else
74
+ link_text = if language_description_text.present?
75
+ text + govuk_visually_hidden(' ' + language_description_text)
76
+ else
77
+ text
78
+ end
79
+ tag.a(
80
+ link_text,
81
+ class: "#{brand}-language-navigation__link",
82
+ href:,
83
+ lang: lang,
84
+ hreflang: href_lang,
85
+ rel: 'alternate',
86
+ **common
87
+ )
88
+ end
89
+ end
90
+
91
+ def default_attributes
92
+ { class: "#{brand}-language-navigation__list-item" }
93
+ end
94
+ end
95
+ end
@@ -1,6 +1,8 @@
1
1
  class GovukComponent::ServiceNavigationComponent < GovukComponent::Base
2
- renders_one :start_slot
3
- renders_one :end_slot
2
+ renders_one :navigation_start
3
+ renders_one :navigation_end
4
+ renders_one :content_before
5
+ renders_one :content_after
4
6
 
5
7
  renders_one :service_name, "GovukComponent::ServiceNavigationComponent::ServiceNameComponent"
6
8
  renders_many :navigation_items, ->(text:, href: nil, current_path: nil, active_when: nil, current: false, active: false, classes: [], html_attributes: {}) do
@@ -16,15 +18,16 @@ class GovukComponent::ServiceNavigationComponent < GovukComponent::Base
16
18
  )
17
19
  end
18
20
 
19
- attr_reader :aria_label_text, :navigation_id, :inverse
21
+ attr_reader :aria_label_text, :navigation_id, :inverse, :inline
20
22
 
21
- def initialize(service_name: nil, service_url: nil, navigation_items: [], current_path: nil, aria_label: "Service information", navigation_id: 'navigation', inverse: false, classes: [], html_attributes: {})
23
+ def initialize(service_name: nil, service_url: nil, navigation_items: [], current_path: nil, aria_label: "Service information", navigation_id: 'navigation', inverse: false, inline: false, classes: [], html_attributes: {})
22
24
  @service_name_text = service_name
23
25
  @service_url = service_url
24
26
  @current_path = current_path
25
27
  @aria_label_text = aria_label
26
28
  @navigation_id = navigation_id
27
29
  @inverse = inverse
30
+ @inline = inline
28
31
 
29
32
  if @service_name_text.present?
30
33
  with_service_name(service_name: @service_name_text, service_url:)
@@ -37,17 +40,21 @@ class GovukComponent::ServiceNavigationComponent < GovukComponent::Base
37
40
 
38
41
  def call
39
42
  outer_element do
40
- tag.div(class: "#{brand}-width-container") do
41
- safe_join(
42
- [
43
- start_slot,
44
- tag.div(class: "#{brand}-service-navigation__container") do
45
- safe_join([service_name, navigation].compact)
46
- end,
47
- end_slot
48
- ]
49
- )
50
- end
43
+ safe_join(
44
+ [
45
+ tag.div(class: class_names("#{brand}-width-container", "#{brand}-service-navigation__inlining-container" => inline)) do
46
+ safe_join(
47
+ [
48
+ content_before,
49
+ tag.div(class: "#{brand}-service-navigation__container") do
50
+ safe_join([service_name, navigation].compact)
51
+ end,
52
+ content_after
53
+ ]
54
+ )
55
+ end
56
+ ]
57
+ )
51
58
  end
52
59
  end
53
60
 
@@ -60,7 +67,7 @@ class GovukComponent::ServiceNavigationComponent < GovukComponent::Base
60
67
  end
61
68
 
62
69
  def navigation_list
63
- tag.ul(safe_join(navigation_items), id: navigation_id, class: "#{brand}-service-navigation__list")
70
+ tag.ul(safe_join([navigation_start, *navigation_items, navigation_end]), id: navigation_id, class: "#{brand}-service-navigation__list")
64
71
  end
65
72
 
66
73
  private
@@ -6,10 +6,12 @@ module GovukComponentsHelper
6
6
  govuk_cookie_banner: 'GovukComponent::CookieBannerComponent',
7
7
  govuk_details: 'GovukComponent::DetailsComponent',
8
8
  govuk_exit_this_page: 'GovukComponent::ExitThisPageComponent',
9
+ govuk_feedback: 'GovukComponent::FeedbackComponent',
9
10
  govuk_footer: 'GovukComponent::FooterComponent',
10
11
  govuk_generic_header: 'GovukComponent::GenericHeaderComponent',
11
12
  govuk_header: 'GovukComponent::HeaderComponent',
12
13
  govuk_inset_text: 'GovukComponent::InsetTextComponent',
14
+ govuk_language_navigation: 'GovukComponent::LanguageNavigationComponent',
13
15
  govuk_notification_banner: 'GovukComponent::NotificationBannerComponent',
14
16
  govuk_pagination: 'GovukComponent::PaginationComponent',
15
17
  govuk_panel: 'GovukComponent::PanelComponent',
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '6.4.1'.freeze
3
+ VERSION = '6.5.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.1
4
+ version: 6.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DfE developers
@@ -58,7 +58,7 @@ dependencies:
58
58
  version: '4.9'
59
59
  - - "<"
60
60
  - !ruby/object:Gem::Version
61
- version: '4.13'
61
+ version: '4.16'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
@@ -68,9 +68,9 @@ dependencies:
68
68
  version: '4.9'
69
69
  - - "<"
70
70
  - !ruby/object:Gem::Version
71
- version: '4.13'
71
+ version: '4.16'
72
72
  - !ruby/object:Gem::Dependency
73
- name: deep_merge
73
+ name: debug
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - ">="
@@ -84,7 +84,7 @@ dependencies:
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  - !ruby/object:Gem::Dependency
87
- name: ostruct
87
+ name: deep_merge
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - ">="
@@ -98,7 +98,7 @@ dependencies:
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  - !ruby/object:Gem::Dependency
101
- name: pry-byebug
101
+ name: ostruct
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
104
  - - ">="
@@ -173,14 +173,14 @@ dependencies:
173
173
  requirements:
174
174
  - - "~>"
175
175
  - !ruby/object:Gem::Version
176
- version: '0.20'
176
+ version: '1.1'
177
177
  type: :development
178
178
  prerelease: false
179
179
  version_requirements: !ruby/object:Gem::Requirement
180
180
  requirements:
181
181
  - - "~>"
182
182
  - !ruby/object:Gem::Version
183
- version: '0.20'
183
+ version: '1.1'
184
184
  - !ruby/object:Gem::Dependency
185
185
  name: sqlite3
186
186
  requirement: !ruby/object:Gem::Requirement
@@ -243,14 +243,14 @@ dependencies:
243
243
  requirements:
244
244
  - - "~>"
245
245
  - !ruby/object:Gem::Version
246
- version: 5.0.0
246
+ version: 5.1.0
247
247
  type: :development
248
248
  prerelease: false
249
249
  version_requirements: !ruby/object:Gem::Requirement
250
250
  requirements:
251
251
  - - "~>"
252
252
  - !ruby/object:Gem::Version
253
- version: 5.0.0
253
+ version: 5.1.0
254
254
  - !ruby/object:Gem::Dependency
255
255
  name: rubypants
256
256
  requirement: !ruby/object:Gem::Requirement
@@ -313,14 +313,14 @@ dependencies:
313
313
  requirements:
314
314
  - - "~>"
315
315
  - !ruby/object:Gem::Version
316
- version: 0.34.0
316
+ version: 0.37.0
317
317
  type: :development
318
318
  prerelease: false
319
319
  version_requirements: !ruby/object:Gem::Requirement
320
320
  requirements:
321
321
  - - "~>"
322
322
  - !ruby/object:Gem::Version
323
- version: 0.34.0
323
+ version: 0.37.0
324
324
  - !ruby/object:Gem::Dependency
325
325
  name: webrick
326
326
  requirement: !ruby/object:Gem::Requirement
@@ -357,6 +357,7 @@ files:
357
357
  - app/components/govuk_component/cookie_banner_component/message_component.rb
358
358
  - app/components/govuk_component/details_component.rb
359
359
  - app/components/govuk_component/exit_this_page_component.rb
360
+ - app/components/govuk_component/feedback_component.rb
360
361
  - app/components/govuk_component/footer_component.html.erb
361
362
  - app/components/govuk_component/footer_component.rb
362
363
  - app/components/govuk_component/generic_header_component.html.erb
@@ -364,6 +365,7 @@ files:
364
365
  - app/components/govuk_component/header_component.html.erb
365
366
  - app/components/govuk_component/header_component.rb
366
367
  - app/components/govuk_component/inset_text_component.rb
368
+ - app/components/govuk_component/language_navigation_component.rb
367
369
  - app/components/govuk_component/notification_banner_component.html.erb
368
370
  - app/components/govuk_component/notification_banner_component.rb
369
371
  - app/components/govuk_component/pagination_component.rb