govuk-components 1.2.0 → 2.0.0b5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/components/govuk_component/{accordion.html.erb → accordion_component.html.erb} +1 -1
  3. data/app/components/govuk_component/{accordion.rb → accordion_component.rb} +13 -14
  4. data/app/components/govuk_component/{back_link.rb → back_link_component.rb} +6 -2
  5. data/app/components/govuk_component/base.rb +9 -7
  6. data/app/components/govuk_component/{breadcrumbs.html.erb → breadcrumbs_component.html.erb} +3 -6
  7. data/app/components/govuk_component/{breadcrumbs.rb → breadcrumbs_component.rb} +4 -4
  8. data/app/components/govuk_component/{cookie_banner.html.erb → cookie_banner_component.html.erb} +2 -6
  9. data/app/components/govuk_component/{cookie_banner.rb → cookie_banner_component.rb} +1 -1
  10. data/app/components/govuk_component/details_component.rb +40 -0
  11. data/app/components/govuk_component/{footer.html.erb → footer_component.html.erb} +3 -5
  12. data/app/components/govuk_component/{footer.rb → footer_component.rb} +4 -9
  13. data/app/components/govuk_component/header_component.html.erb +49 -0
  14. data/app/components/govuk_component/header_component.rb +112 -0
  15. data/app/components/govuk_component/{inset_text.rb → inset_text_component.rb} +4 -4
  16. data/app/components/govuk_component/notification_banner_component.html.erb +14 -0
  17. data/app/components/govuk_component/{notification_banner.rb → notification_banner_component.rb} +30 -16
  18. data/app/components/govuk_component/panel_component.rb +46 -0
  19. data/app/components/govuk_component/phase_banner_component.html.erb +6 -0
  20. data/app/components/govuk_component/phase_banner_component.rb +20 -0
  21. data/app/components/govuk_component/start_button_component.rb +47 -0
  22. data/app/components/govuk_component/summary_list_component.html.erb +11 -0
  23. data/app/components/govuk_component/summary_list_component.rb +64 -0
  24. data/app/components/govuk_component/tab_component.html.erb +11 -0
  25. data/app/components/govuk_component/{tabs.rb → tab_component.rb} +23 -12
  26. data/app/components/govuk_component/tag_component.rb +48 -0
  27. data/app/components/govuk_component/warning_text_component.rb +38 -0
  28. data/app/helpers/govuk_components_helper.rb +16 -16
  29. data/app/helpers/govuk_link_helper.rb +39 -4
  30. data/lib/govuk/components.rb +1 -0
  31. data/lib/govuk/components/helpers/css_utilities.rb +22 -0
  32. data/lib/govuk/components/version.rb +1 -1
  33. metadata +48 -53
  34. data/app/components/govuk_component/back_link.html.erb +0 -1
  35. data/app/components/govuk_component/details.html.erb +0 -10
  36. data/app/components/govuk_component/details.rb +0 -16
  37. data/app/components/govuk_component/header.html.erb +0 -50
  38. data/app/components/govuk_component/header.rb +0 -66
  39. data/app/components/govuk_component/notification_banner.html.erb +0 -23
  40. data/app/components/govuk_component/panel.html.erb +0 -13
  41. data/app/components/govuk_component/panel.rb +0 -28
  42. data/app/components/govuk_component/phase_banner.html.erb +0 -8
  43. data/app/components/govuk_component/phase_banner.rb +0 -16
  44. data/app/components/govuk_component/slot.rb +0 -9
  45. data/app/components/govuk_component/start_now_button.html.erb +0 -6
  46. data/app/components/govuk_component/start_now_button.rb +0 -16
  47. data/app/components/govuk_component/summary_list.html.erb +0 -19
  48. data/app/components/govuk_component/summary_list.rb +0 -34
  49. data/app/components/govuk_component/tabs.html.erb +0 -19
  50. data/app/components/govuk_component/tag.rb +0 -30
  51. data/app/components/govuk_component/warning.html.erb +0 -7
  52. data/app/components/govuk_component/warning.rb +0 -14
@@ -1,21 +1,21 @@
1
1
  module GovukComponentsHelper
2
2
  {
3
- govuk_accordion: 'GovukComponent::Accordion',
4
- govuk_back_link: 'GovukComponent::BackLink',
5
- govuk_breadcrumbs: 'GovukComponent::Breadcrumbs',
6
- govuk_cookie_banner: 'GovukComponent::CookieBanner',
7
- govuk_details: 'GovukComponent::Details',
8
- govuk_footer: 'GovukComponent::Footer',
9
- govuk_header: 'GovukComponent::Header',
10
- govuk_inset_text: 'GovukComponent::InsetText',
11
- govuk_notification_banner: 'GovukComponent::NotificationBanner',
12
- govuk_panel: 'GovukComponent::Panel',
13
- govuk_phase_banner: 'GovukComponent::PhaseBanner',
14
- govuk_start_now_button: 'GovukComponent::StartNowButton',
15
- govuk_summary_list: 'GovukComponent::SummaryList',
16
- govuk_tabs: 'GovukComponent::Tabs',
17
- govuk_tag: 'GovukComponent::Tag',
18
- govuk_warning: 'GovukComponent::Warning',
3
+ govuk_accordion: 'GovukComponent::AccordionComponent',
4
+ govuk_back_link: 'GovukComponent::BackLinkComponent',
5
+ govuk_breadcrumbs: 'GovukComponent::BreadcrumbsComponent',
6
+ govuk_cookie_banner: 'GovukComponent::CookieBannerComponent',
7
+ govuk_details: 'GovukComponent::DetailsComponent',
8
+ govuk_footer: 'GovukComponent::FooterComponent',
9
+ govuk_header: 'GovukComponent::HeaderComponent',
10
+ govuk_inset_text: 'GovukComponent::InsetTextComponent',
11
+ govuk_notification_banner: 'GovukComponent::NotificationBannerComponent',
12
+ govuk_panel: 'GovukComponent::PanelComponent',
13
+ govuk_phase_banner: 'GovukComponent::PhaseBannerComponent',
14
+ govuk_start_button: 'GovukComponent::StartButtonComponent',
15
+ govuk_summary_list: 'GovukComponent::SummaryListComponent',
16
+ govuk_tabs: 'GovukComponent::TabComponent',
17
+ govuk_tag: 'GovukComponent::TagComponent',
18
+ govuk_warning_text: 'GovukComponent::WarningTextComponent',
19
19
  }.each do |name, klass|
20
20
  define_method(name) do |*args, **kwargs, &block|
21
21
  capture do
@@ -1,10 +1,14 @@
1
1
  module GovukLinkHelper
2
- def govuk_link_to(*args, button: false, **kwargs, &block)
3
- link_to(*args, **inject_class(kwargs, class_name: link_class(button)), &block)
2
+ def govuk_link_to(*args, button: false, no_visited_state: false, muted: false, text_colour: false, inverse: false, no_underline: false, **kwargs, &block)
3
+ classes = build_classes(button, no_visited_state, muted, text_colour, inverse, no_underline)
4
+
5
+ link_to(*args, **inject_class(kwargs, class_name: classes), &block)
4
6
  end
5
7
 
6
- def govuk_mail_to(*args, button: false, **kwargs, &block)
7
- mail_to(*args, **inject_class(kwargs, class_name: link_class(button)), &block)
8
+ def govuk_mail_to(*args, button: false, no_visited_state: false, muted: false, text_colour: false, inverse: false, no_underline: false, **kwargs, &block)
9
+ classes = build_classes(button, no_visited_state, muted, text_colour, inverse, no_underline)
10
+
11
+ mail_to(*args, **inject_class(kwargs, class_name: classes), &block)
8
12
  end
9
13
 
10
14
  def govuk_button_to(*args, **kwargs)
@@ -13,6 +17,17 @@ module GovukLinkHelper
13
17
 
14
18
  private
15
19
 
20
+ def build_classes(button, no_visited_state, muted, text_colour, inverse, no_underline)
21
+ [
22
+ link_class(button),
23
+ no_visited_state_class(no_visited_state),
24
+ muted_class(muted),
25
+ text_colour_class(text_colour),
26
+ inverse_class(inverse),
27
+ no_underline_class(no_underline),
28
+ ]
29
+ end
30
+
16
31
  def inject_class(attributes, class_name:)
17
32
  attributes.with_indifferent_access.tap do |attrs|
18
33
  attrs[:class] = Array.wrap(attrs[:class]).prepend(class_name)
@@ -22,6 +37,26 @@ private
22
37
  def link_class(button)
23
38
  button ? 'govuk-button' : 'govuk-link'
24
39
  end
40
+
41
+ def no_visited_state_class(no_visited_state)
42
+ 'govuk-link--no-visited-state' if no_visited_state
43
+ end
44
+
45
+ def muted_class(muted)
46
+ 'govuk-link--muted' if muted
47
+ end
48
+
49
+ def text_colour_class(colour)
50
+ 'govuk-link--text-colour' if colour
51
+ end
52
+
53
+ def inverse_class(inverse)
54
+ 'govuk-link--inverse' if inverse
55
+ end
56
+
57
+ def no_underline_class(no_underline)
58
+ 'govuk-link--no-underline' if no_underline
59
+ end
25
60
  end
26
61
 
27
62
  ActiveSupport.on_load(:action_view) { include GovukLinkHelper }
@@ -1,2 +1,3 @@
1
1
  require "view_component/engine"
2
+ require "govuk/components/helpers/css_utilities"
2
3
  require "govuk/components/engine"
@@ -0,0 +1,22 @@
1
+ module Govuk
2
+ module Components
3
+ module Helpers
4
+ module CssUtilities
5
+ def combine_classes(default_classes, custom_classes)
6
+ converted_custom_classes = case custom_classes
7
+ when Array
8
+ custom_classes
9
+ when String
10
+ custom_classes.split
11
+ when NilClass
12
+ []
13
+ else
14
+ fail(ArgumentError, "custom classes must be a String, Array or NilClass")
15
+ end
16
+
17
+ default_classes.concat(converted_custom_classes).uniq
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '1.2.0'.freeze
3
+ VERSION = '2.0.0b5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0b5
5
5
  platform: ruby
6
6
  authors:
7
7
  - DfE developers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-09 00:00:00.000000000 Z
11
+ date: 2021-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: railties
14
+ name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activemodel
28
+ name: railties
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -44,16 +44,16 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.20'
47
+ version: 2.31.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.20'
54
+ version: 2.31.1
55
55
  - !ruby/object:Gem::Dependency
56
- name: capybara
56
+ name: pry-byebug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,19 +67,19 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry-byebug
70
+ name: rspec-html-matchers
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '0.9'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '0.9'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-rails
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: rubocop-govuk
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 4.0.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 4.0.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sassc-rails
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -161,40 +161,34 @@ files:
161
161
  - MIT-LICENSE
162
162
  - README.md
163
163
  - Rakefile
164
- - app/components/govuk_component/accordion.html.erb
165
- - app/components/govuk_component/accordion.rb
166
- - app/components/govuk_component/back_link.html.erb
167
- - app/components/govuk_component/back_link.rb
164
+ - app/components/govuk_component/accordion_component.html.erb
165
+ - app/components/govuk_component/accordion_component.rb
166
+ - app/components/govuk_component/back_link_component.rb
168
167
  - app/components/govuk_component/base.rb
169
- - app/components/govuk_component/breadcrumbs.html.erb
170
- - app/components/govuk_component/breadcrumbs.rb
171
- - app/components/govuk_component/cookie_banner.html.erb
172
- - app/components/govuk_component/cookie_banner.rb
173
- - app/components/govuk_component/details.html.erb
174
- - app/components/govuk_component/details.rb
175
- - app/components/govuk_component/footer.html.erb
176
- - app/components/govuk_component/footer.rb
177
- - app/components/govuk_component/header.html.erb
178
- - app/components/govuk_component/header.rb
179
- - app/components/govuk_component/inset_text.rb
180
- - app/components/govuk_component/notification_banner.html.erb
181
- - app/components/govuk_component/notification_banner.rb
182
- - app/components/govuk_component/panel.html.erb
183
- - app/components/govuk_component/panel.rb
184
- - app/components/govuk_component/phase_banner.html.erb
185
- - app/components/govuk_component/phase_banner.rb
186
- - app/components/govuk_component/slot.rb
187
- - app/components/govuk_component/start_now_button.html.erb
188
- - app/components/govuk_component/start_now_button.rb
189
- - app/components/govuk_component/summary_list.html.erb
190
- - app/components/govuk_component/summary_list.rb
191
- - app/components/govuk_component/tabs.html.erb
192
- - app/components/govuk_component/tabs.rb
193
- - app/components/govuk_component/tag.rb
168
+ - app/components/govuk_component/breadcrumbs_component.html.erb
169
+ - app/components/govuk_component/breadcrumbs_component.rb
170
+ - app/components/govuk_component/cookie_banner_component.html.erb
171
+ - app/components/govuk_component/cookie_banner_component.rb
172
+ - app/components/govuk_component/details_component.rb
173
+ - app/components/govuk_component/footer_component.html.erb
174
+ - app/components/govuk_component/footer_component.rb
175
+ - app/components/govuk_component/header_component.html.erb
176
+ - app/components/govuk_component/header_component.rb
177
+ - app/components/govuk_component/inset_text_component.rb
178
+ - app/components/govuk_component/notification_banner_component.html.erb
179
+ - app/components/govuk_component/notification_banner_component.rb
180
+ - app/components/govuk_component/panel_component.rb
181
+ - app/components/govuk_component/phase_banner_component.html.erb
182
+ - app/components/govuk_component/phase_banner_component.rb
183
+ - app/components/govuk_component/start_button_component.rb
184
+ - app/components/govuk_component/summary_list_component.html.erb
185
+ - app/components/govuk_component/summary_list_component.rb
186
+ - app/components/govuk_component/tab_component.html.erb
187
+ - app/components/govuk_component/tab_component.rb
188
+ - app/components/govuk_component/tag_component.rb
194
189
  - app/components/govuk_component/traits/custom_classes.rb
195
190
  - app/components/govuk_component/traits/custom_html_attributes.rb
196
- - app/components/govuk_component/warning.html.erb
197
- - app/components/govuk_component/warning.rb
191
+ - app/components/govuk_component/warning_text_component.rb
198
192
  - app/helpers/govuk_back_to_top_link_helper.rb
199
193
  - app/helpers/govuk_components_helper.rb
200
194
  - app/helpers/govuk_link_helper.rb
@@ -202,13 +196,14 @@ files:
202
196
  - config/routes.rb
203
197
  - lib/govuk/components.rb
204
198
  - lib/govuk/components/engine.rb
199
+ - lib/govuk/components/helpers/css_utilities.rb
205
200
  - lib/govuk/components/version.rb
206
201
  - lib/tasks/govuk/components_tasks.rake
207
202
  homepage: https://github.com/DFE-Digital/govuk-components
208
203
  licenses:
209
204
  - MIT
210
205
  metadata: {}
211
- post_install_message:
206
+ post_install_message:
212
207
  rdoc_options: []
213
208
  require_paths:
214
209
  - lib
@@ -219,12 +214,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
214
  version: '0'
220
215
  required_rubygems_version: !ruby/object:Gem::Requirement
221
216
  requirements:
222
- - - ">="
217
+ - - ">"
223
218
  - !ruby/object:Gem::Version
224
- version: '0'
219
+ version: 1.3.1
225
220
  requirements: []
226
- rubygems_version: 3.1.4
227
- signing_key:
221
+ rubygems_version: 3.1.6
222
+ signing_key:
228
223
  specification_version: 4
229
224
  summary: Lightweight set of reusable GOV.UK Design System components
230
225
  test_files: []
@@ -1 +0,0 @@
1
- <%= link_to @text, @href, class: classes, **html_attributes %>
@@ -1,10 +0,0 @@
1
- <%= tag.details(class: classes, data: { module: 'govuk-details' }, **html_attributes) do %>
2
- <summary class="govuk-details__summary">
3
- <span class="govuk-details__summary-text">
4
- <%= @summary %>
5
- </span>
6
- </summary>
7
- <div class="govuk-details__text">
8
- <%= content.presence || @description %>
9
- </div>
10
- <% end %>
@@ -1,16 +0,0 @@
1
- class GovukComponent::Details < GovukComponent::Base
2
- attr_accessor :summary, :description
3
-
4
- def initialize(summary:, description: nil, classes: [], html_attributes: {})
5
- super(classes: classes, html_attributes: html_attributes)
6
-
7
- @summary = summary
8
- @description = description
9
- end
10
-
11
- private
12
-
13
- def default_classes
14
- %w(govuk-details)
15
- end
16
- end
@@ -1,50 +0,0 @@
1
- <%= tag.header(class: classes, role: 'banner', data: { module: 'govuk-header' }, **html_attributes) do %>
2
- <div class="govuk-header__container govuk-width-container">
3
- <div class="govuk-header__logo">
4
- <a href=<%= @logo_href %> class="govuk-header__link govuk-header__link--homepage">
5
- <span class="govuk-header__logotype">
6
- <svg aria-hidden="true" focusable="false" class="govuk-header__logotype-crown" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 132 97" height="30" width="36">
7
- <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 9zm4.7 17.7c-3.6 1.5-7.8-.2-9.2-3.8-1.5-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.3 3.5-.4 7.6-3.9 9.1zM89.3 35.8c-3.6 1.5-7.8-.2-9.2-3.8-1.4-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.4 3.6-.3 7.7-3.9 9.1zM69.7 17.7l8.9 4.7V9.3l-8.9 2.8c-.2-.3-.5-.6-.9-.9L72.4 0H59.6l3.5 11.2c-.3.3-.6.5-.9.9l-8.8-2.8v13.1l8.8-4.7c.3.3.6.7.9.9l-5 15.4v.1c-.2.8-.4 1.6-.4 2.4 0 4.1 3.1 7.5 7 8.1h.2c.3 0 .7.1 1 .1.4 0 .7 0 1-.1h.2c4-.6 7.1-4.1 7.1-8.1 0-.8-.1-1.7-.4-2.4V34l-5.1-15.4c.4-.2.7-.6 1-.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>
8
- <image src="/assets/images/govuk-logotype-crown.png" xlink:href="" class="govuk-header__logotype-crown-fallback-image" width="36" height="32"></image>
9
- </svg>
10
- <span class="govuk-header__logotype-text">
11
- <%= @logo %>
12
- </span>
13
- </span>
14
- <% if @product_name.present? %>
15
- <span class="govuk-header__product-name">
16
- <%= @product_name %>
17
- </span>
18
- <% end %>
19
-
20
- <% if product_description.present? %>
21
- <%= product_description.content %>
22
- <% end %>
23
- </a>
24
- </div>
25
- <div class="govuk-header__content">
26
- <% if @service_name.present? %>
27
- <a href="<%= @service_name_href %>" class="govuk-header__link govuk-header__link--service-name">
28
- <%= @service_name %>
29
- </a>
30
- <% end %>
31
-
32
- <% if items.any? %>
33
- <button type="button" class="govuk-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="<%= menu_button_label %>">Menu</button>
34
- <nav>
35
- <%= tag.ul(class: navigation_classes, id: "navigation", aria: { label: navigation_label }) do %>
36
- <% items.each do |item| %>
37
- <%= tag.li(class: item.classes.append(item.active_class), **item.html_attributes) do %>
38
- <% if item.link? %>
39
- <%= link_to(item.title, item.href, class: "govuk-header__link") %>
40
- <% else %>
41
- <%= item.title %>
42
- <% end %>
43
- <% end %>
44
- <% end %>
45
- <% end %>
46
- </nav>
47
- <% end %>
48
- </div>
49
- </div>
50
- <% end %>
@@ -1,66 +0,0 @@
1
- class GovukComponent::Header < GovukComponent::Base
2
- include ViewComponent::Slotable
3
-
4
- attr_accessor :logo, :logo_href, :service_name, :service_name_href, :product_name, :menu_button_label, :navigation_label
5
-
6
- with_slot :item, collection: true, class_name: 'Item'
7
- wrap_slot :item
8
-
9
- with_slot :product_description
10
- wrap_slot :product_description
11
-
12
- def initialize(logo: 'GOV.UK', logo_href: '/', service_name: nil, service_name_href: '/', product_name: nil, menu_button_label: 'Show or hide navigation menu', classes: [], navigation_classes: [], navigation_label: 'Navigation menu', html_attributes: {})
13
- super(classes: classes, html_attributes: html_attributes)
14
-
15
- @logo = logo
16
- @logo_href = logo_href
17
- @service_name = service_name
18
- @service_name_href = service_name_href
19
- @product_name = product_name
20
- @menu_button_label = menu_button_label
21
- @navigation_classes = navigation_classes
22
- @navigation_label = navigation_label
23
- end
24
-
25
- private
26
-
27
- def default_classes
28
- %w(govuk-header)
29
- end
30
-
31
- def navigation_classes
32
- %w(govuk-header__navigation).tap { |nc|
33
- nc.concat(@navigation_classes.is_a?(String) ? @navigation_classes.split : @navigation_classes)
34
- }.uniq
35
- end
36
-
37
- class Item < GovukComponent::Slot
38
- attr_accessor :title, :href, :active
39
-
40
- def initialize(title:, href: nil, active: false, classes: [], html_attributes: {})
41
- super(classes: classes, html_attributes: html_attributes)
42
-
43
- self.title = title
44
- self.href = href
45
- self.active = active
46
- end
47
-
48
- def active?
49
- active
50
- end
51
-
52
- def active_class
53
- %w(govuk-header__navigation-item--active) if active?
54
- end
55
-
56
- def link?
57
- href.present?
58
- end
59
-
60
- private
61
-
62
- def default_classes
63
- %w(govuk-header__navigation-item)
64
- end
65
- end
66
- end