govuk-components 6.4.0 → 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
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,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
|
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.
|
|
4
|
+
version: 6.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- DfE developers
|
|
@@ -371,6 +371,7 @@ files:
|
|
|
371
371
|
- app/components/govuk_component/pagination_component/item.rb
|
|
372
372
|
- app/components/govuk_component/pagination_component/next_page.rb
|
|
373
373
|
- app/components/govuk_component/pagination_component/previous_page.rb
|
|
374
|
+
- app/components/govuk_component/panel_component.html.erb
|
|
374
375
|
- app/components/govuk_component/panel_component.rb
|
|
375
376
|
- app/components/govuk_component/phase_banner_component.html.erb
|
|
376
377
|
- app/components/govuk_component/phase_banner_component.rb
|