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: 97cb13bbf94f21942d186a15574ab81753e4c14b26382775ab5dcc748043ce68
4
- data.tar.gz: b10e0c6b31295930c300d84f51501fedb36de8e33bfb4de528bfd1ae237b5729
3
+ metadata.gz: 448eb2b3c765475aa5e67b693d52628aa70ce9759ef9eaedf0b71ad6e5905db4
4
+ data.tar.gz: dc7af5109db0372dc9baa102cc09b77f96a645a2dd22389b8ea75fab4870f983
5
5
  SHA512:
6
- metadata.gz: 3b5077e7da99cd661503e8625735a2b13d322f772f2b83b65da20caf697ba24818b454d35a6dcd7ef48a4477e2d0710c7e3eeb976167a66f6acd4e75922504c5
7
- data.tar.gz: d80c55dca5308bb77e4158274d47e93a5ce22fa98aef05441c314951232696304ce1ee083bf851e2abe1ee97c3b0edd67a18dfc2195fb512bacb64a76a9b4bf0
6
+ metadata.gz: 7aec79f3e89135ecd180a28c2485f47d4b7f4ee99d9ad0f6f44396fb3962b60b58616469ffc72865e8a5fd6d19ea7064b4874b088cf98f033dc725153b881c64
7
+ data.tar.gz: de4de0cf2251398725639e7209fe48db79893da6e1b4da9f18bba682313b6796b1447000c182c08811cce684a22474e27f34f5b72e2f5996b77933446fb58535
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.3.0-brightgreen)](https://design-system.service.gov.uk)
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)
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/)
@@ -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
- { class: "#{brand}-panel #{brand}-panel--confirmation" }
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
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '6.4.0'.freeze
3
+ VERSION = '6.4.1'.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.0
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