govuk-components 6.3.1 → 6.4.1
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 +4 -4
- data/README.md +1 -1
- data/app/components/govuk_component/generic_header_component.html.erb +18 -0
- data/app/components/govuk_component/generic_header_component.rb +36 -0
- data/app/components/govuk_component/header_component.html.erb +2 -2
- data/app/components/govuk_component/header_component.rb +5 -8
- data/app/components/govuk_component/panel_component.html.erb +14 -0
- data/app/components/govuk_component/panel_component.rb +46 -9
- data/app/helpers/govuk_components_helper.rb +1 -0
- data/lib/govuk/components/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 448eb2b3c765475aa5e67b693d52628aa70ce9759ef9eaedf0b71ad6e5905db4
|
|
4
|
+
data.tar.gz: dc7af5109db0372dc9baa102cc09b77f96a645a2dd22389b8ea75fab4870f983
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7aec79f3e89135ecd180a28c2485f47d4b7f4ee99d9ad0f6f44396fb3962b60b58616469ffc72865e8a5fd6d19ea7064b4874b088cf98f033dc725153b881c64
|
|
7
|
+
data.tar.gz: de4de0cf2251398725639e7209fe48db79893da6e1b4da9f18bba682313b6796b1447000c182c08811cce684a22474e27f34f5b72e2f5996b77933446fb58535
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://badge.fury.io/rb/govuk-components)
|
|
5
5
|
[](https://rubygems.org/gems/govuk-components)
|
|
6
6
|
[](https://github.com/x-govuk/govuk-components/blob/main/LICENSE.txt)
|
|
7
|
-
[](https://design-system.service.gov.uk)
|
|
8
8
|
[](https://viewcomponent.org/)
|
|
9
9
|
[](https://weblog.rubyonrails.org/releases/)
|
|
10
10
|
[](https://www.ruby-lang.org/en/downloads/)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<%= tag.header(**header_html_attributes) do %>
|
|
2
|
+
<%= tag.div(class: "#{brand}-generic-header", **html_attributes) do %>
|
|
3
|
+
<%= tag.div(class: ["#{brand}-generic-header__container", "#{brand}-width-container"]) do %>
|
|
4
|
+
<%= tag.div(class: "#{brand}-generic-header__logo") do %>
|
|
5
|
+
<%=
|
|
6
|
+
case
|
|
7
|
+
when logo.present? then logo
|
|
8
|
+
when url.present? then link_to(logo_text, url, class: "#{brand}-generic-header__homepage-link")
|
|
9
|
+
else logo_text
|
|
10
|
+
end
|
|
11
|
+
%>
|
|
12
|
+
<% end %>
|
|
13
|
+
<%= content %>
|
|
14
|
+
<% end %>
|
|
15
|
+
<% end %>
|
|
16
|
+
<%= service_navigation %>
|
|
17
|
+
<%= phase_banner %>
|
|
18
|
+
<% end %>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
class GovukComponent::GenericHeaderComponent < GovukComponent::Base
|
|
2
|
+
renders_one :logo
|
|
3
|
+
renders_one :service_navigation, "GovukComponent::ServiceNavigationComponent"
|
|
4
|
+
renders_one :phase_banner, "GovukComponent::PhaseBannerComponent"
|
|
5
|
+
|
|
6
|
+
attr_reader :url,
|
|
7
|
+
:logo_text,
|
|
8
|
+
:menu_button_label,
|
|
9
|
+
:header_html_attributes
|
|
10
|
+
|
|
11
|
+
def initialize(url: nil,
|
|
12
|
+
logo_text: nil,
|
|
13
|
+
classes: [],
|
|
14
|
+
html_attributes: {},
|
|
15
|
+
header_html_attributes: {})
|
|
16
|
+
|
|
17
|
+
@url = url
|
|
18
|
+
@logo_text = logo_text
|
|
19
|
+
@header_html_attributes = header_html_attributes
|
|
20
|
+
|
|
21
|
+
super(classes:, html_attributes:)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def before_render
|
|
25
|
+
if logo.blank?
|
|
26
|
+
fail(ArgumentError, 'logo_text missing') if logo_text.blank?
|
|
27
|
+
fail(ArgumentError, 'url missing') if url.blank?
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def default_attributes
|
|
34
|
+
{ class: class_names("#{brand}-generic-header") }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
<%= tag.header(**header_html_attributes) do %>
|
|
2
2
|
<%= tag.div(data: { module: "#{brand}-header" }, **html_attributes) do %>
|
|
3
3
|
<%= tag.div(**container_html_attributes) do %>
|
|
4
4
|
<div class="<%= brand %>-header__logo">
|
|
@@ -41,4 +41,4 @@
|
|
|
41
41
|
<% end %>
|
|
42
42
|
<%= service_navigation %>
|
|
43
43
|
<%= phase_banner %>
|
|
44
|
-
|
|
44
|
+
<% end %>
|
|
@@ -5,25 +5,22 @@ class GovukComponent::HeaderComponent < GovukComponent::Base
|
|
|
5
5
|
renders_one :phase_banner, "GovukComponent::PhaseBannerComponent"
|
|
6
6
|
|
|
7
7
|
attr_reader :homepage_url,
|
|
8
|
-
:service_name,
|
|
9
8
|
:service_url,
|
|
10
|
-
:menu_button_label,
|
|
11
9
|
:custom_container_classes,
|
|
12
|
-
:full_width_border
|
|
10
|
+
:full_width_border,
|
|
11
|
+
:header_html_attributes
|
|
13
12
|
|
|
14
13
|
def initialize(classes: [],
|
|
15
14
|
html_attributes: {},
|
|
16
15
|
homepage_url: config.default_header_homepage_url,
|
|
17
|
-
menu_button_label: config.default_header_menu_button_label,
|
|
18
16
|
container_classes: nil,
|
|
19
|
-
full_width_border: false
|
|
17
|
+
full_width_border: false,
|
|
18
|
+
header_html_attributes: {})
|
|
20
19
|
|
|
21
20
|
@homepage_url = homepage_url
|
|
22
|
-
@service_name = service_name
|
|
23
|
-
@service_url = service_url
|
|
24
|
-
@menu_button_label = menu_button_label
|
|
25
21
|
@custom_container_classes = container_classes
|
|
26
22
|
@full_width_border = full_width_border
|
|
23
|
+
@header_html_attributes = header_html_attributes
|
|
27
24
|
|
|
28
25
|
super(classes:, html_attributes:)
|
|
29
26
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%= tag.div(id:, **html_attributes) do %>
|
|
2
|
+
<%= panel_title %>
|
|
3
|
+
<%= panel_body %>
|
|
4
|
+
|
|
5
|
+
<% if show_actions? %>
|
|
6
|
+
<%= tag.div(class: "#{brand}-panel__actions") do %>
|
|
7
|
+
<%= tag.div(class: "#{brand}-button-group") do %>
|
|
8
|
+
<% actions.each do |action| %>
|
|
9
|
+
<%= action %>
|
|
10
|
+
<% end %>
|
|
11
|
+
<% end %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %>
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
class GovukComponent::PanelComponent < GovukComponent::Base
|
|
2
|
-
attr_reader :id, :title_text, :text, :heading_level
|
|
2
|
+
attr_reader :id, :title_text, :text, :heading_level, :interruption
|
|
3
3
|
|
|
4
4
|
renders_one :title_html
|
|
5
|
+
renders_many :actions, "Action"
|
|
5
6
|
|
|
6
|
-
def initialize(title_text: nil, text: nil, heading_level: 1, id: nil, classes: [], html_attributes: {})
|
|
7
|
+
def initialize(title_text: nil, text: nil, interruption: false, heading_level: 1, id: nil, classes: [], html_attributes: {})
|
|
7
8
|
@heading_level = heading_level
|
|
8
9
|
@title_text = title_text
|
|
9
10
|
@text = text
|
|
10
11
|
@id = id
|
|
12
|
+
@interruption = interruption
|
|
11
13
|
|
|
12
14
|
super(classes:, html_attributes:)
|
|
13
15
|
end
|
|
14
16
|
|
|
15
|
-
def call
|
|
16
|
-
tag.div(id:, **html_attributes) do
|
|
17
|
-
safe_join([panel_title, panel_body].compact)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
17
|
private
|
|
22
18
|
|
|
23
19
|
def default_attributes
|
|
24
|
-
{
|
|
20
|
+
{
|
|
21
|
+
class: "#{brand}-panel #{brand}-panel--#{mode}",
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def mode
|
|
26
|
+
interruption ? 'interruption' : 'confirmation'
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
def heading_tag
|
|
@@ -53,4 +55,39 @@ private
|
|
|
53
55
|
def render?
|
|
54
56
|
title.present? || panel_content.present?
|
|
55
57
|
end
|
|
58
|
+
|
|
59
|
+
def show_actions?
|
|
60
|
+
if !interruption && actions?
|
|
61
|
+
Rails.logger.warn(%(Actions will not be rendered unless the panel is in interruption mode))
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
interruption && actions?
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class Action < GovukComponent::Base
|
|
68
|
+
include GovukLinkHelper
|
|
69
|
+
include GovukVisuallyHiddenHelper
|
|
70
|
+
|
|
71
|
+
attr_reader :text, :href, :type
|
|
72
|
+
|
|
73
|
+
def initialize(text:, href:, type: :button, classes: [], html_attributes: {})
|
|
74
|
+
@text = text
|
|
75
|
+
@href = href
|
|
76
|
+
@type = type
|
|
77
|
+
|
|
78
|
+
super(classes:, html_attributes:)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def default_attributes
|
|
82
|
+
{}
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def call
|
|
86
|
+
case type.to_sym
|
|
87
|
+
when :button then govuk_button_link_to(text, href, inverse: true, **html_attributes)
|
|
88
|
+
when :link then govuk_link_to(text, href, inverse: true, **html_attributes)
|
|
89
|
+
else fail ArgumentError, "unrecognised type (must be :link or :button)"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
56
93
|
end
|
|
@@ -7,6 +7,7 @@ module GovukComponentsHelper
|
|
|
7
7
|
govuk_details: 'GovukComponent::DetailsComponent',
|
|
8
8
|
govuk_exit_this_page: 'GovukComponent::ExitThisPageComponent',
|
|
9
9
|
govuk_footer: 'GovukComponent::FooterComponent',
|
|
10
|
+
govuk_generic_header: 'GovukComponent::GenericHeaderComponent',
|
|
10
11
|
govuk_header: 'GovukComponent::HeaderComponent',
|
|
11
12
|
govuk_inset_text: 'GovukComponent::InsetTextComponent',
|
|
12
13
|
govuk_notification_banner: 'GovukComponent::NotificationBannerComponent',
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: govuk-components
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- DfE developers
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: html-attributes-utils
|
|
@@ -360,6 +359,8 @@ files:
|
|
|
360
359
|
- app/components/govuk_component/exit_this_page_component.rb
|
|
361
360
|
- app/components/govuk_component/footer_component.html.erb
|
|
362
361
|
- app/components/govuk_component/footer_component.rb
|
|
362
|
+
- app/components/govuk_component/generic_header_component.html.erb
|
|
363
|
+
- app/components/govuk_component/generic_header_component.rb
|
|
363
364
|
- app/components/govuk_component/header_component.html.erb
|
|
364
365
|
- app/components/govuk_component/header_component.rb
|
|
365
366
|
- app/components/govuk_component/inset_text_component.rb
|
|
@@ -370,6 +371,7 @@ files:
|
|
|
370
371
|
- app/components/govuk_component/pagination_component/item.rb
|
|
371
372
|
- app/components/govuk_component/pagination_component/next_page.rb
|
|
372
373
|
- app/components/govuk_component/pagination_component/previous_page.rb
|
|
374
|
+
- app/components/govuk_component/panel_component.html.erb
|
|
373
375
|
- app/components/govuk_component/panel_component.rb
|
|
374
376
|
- app/components/govuk_component/phase_banner_component.html.erb
|
|
375
377
|
- app/components/govuk_component/phase_banner_component.rb
|
|
@@ -422,7 +424,6 @@ homepage: https://github.com/x-govuk/govuk-components
|
|
|
422
424
|
licenses:
|
|
423
425
|
- MIT
|
|
424
426
|
metadata: {}
|
|
425
|
-
post_install_message:
|
|
426
427
|
rdoc_options: []
|
|
427
428
|
require_paths:
|
|
428
429
|
- lib
|
|
@@ -430,15 +431,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
430
431
|
requirements:
|
|
431
432
|
- - ">="
|
|
432
433
|
- !ruby/object:Gem::Version
|
|
433
|
-
version: '
|
|
434
|
+
version: '3.3'
|
|
434
435
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
435
436
|
requirements:
|
|
436
437
|
- - ">="
|
|
437
438
|
- !ruby/object:Gem::Version
|
|
438
439
|
version: '0'
|
|
439
440
|
requirements: []
|
|
440
|
-
rubygems_version:
|
|
441
|
-
signing_key:
|
|
441
|
+
rubygems_version: 4.0.10
|
|
442
442
|
specification_version: 4
|
|
443
443
|
summary: GOV.UK Components for Ruby on Rails
|
|
444
444
|
test_files: []
|