govuk-components 1.1.4 → 1.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bb78c96c1c9197b5fb35aaecd9f5d92a642db0ce1918ff3cb582698ae8cd8a2
4
- data.tar.gz: ff373974b83e3aaf04c79becc91fe25527311f3b9d8a0212fca0acac44e8ce31
3
+ metadata.gz: 58f95bba6b6806470b1963b8e9d62aa69eb0b09c98c0d6ec0e8416ac9412d14e
4
+ data.tar.gz: 053dab8628ad0849dd16c01649c6cef559b277612f0766d25061e691bcc574b5
5
5
  SHA512:
6
- metadata.gz: 4b6c857eb90195678cb4c2c14c7842d690416e3b95b398d991a72eb5ea81d34670c7cf43a7e0c77005f9f3c33c20224dfe4f9d40741027f7789e294e886dcf5d
7
- data.tar.gz: 28d99eaea4e9047ceddd7e03f2213c48d1d768a748d22cd438b4c2e02f09dddf3f2782948358dffce554c4e9aea3dfd13f191f82c366c5348ad4852951c2c2a5
6
+ metadata.gz: 21f9795a2058a029949d179df03227f05c10cf7d41c2e0645566aff872886ec2c5293b1d91c7472a61c9496fad12174d15f2985568b06427942261db4912084d
7
+ data.tar.gz: 883d695f40a82e58ed96fd1ee78a9426fe62e5772cf10a182165f31fc6781b8ecccdd606388ee5725aad9f02077e2940f969c05271766ab9cf7e64b46aa79254
@@ -1,15 +1,20 @@
1
1
  class GovukComponent::Breadcrumbs < GovukComponent::Base
2
2
  attr_accessor :breadcrumbs
3
3
 
4
- def initialize(breadcrumbs:, classes: [], html_attributes: {})
4
+ def initialize(breadcrumbs:, hide_in_print: false, collapse_on_mobile: false, classes: [], html_attributes: {})
5
5
  super(classes: classes, html_attributes: html_attributes)
6
6
 
7
- @breadcrumbs = breadcrumbs
7
+ @breadcrumbs = breadcrumbs
8
+ @hide_in_print = hide_in_print
9
+ @collapse_on_mobile = collapse_on_mobile
8
10
  end
9
11
 
10
12
  private
11
13
 
12
14
  def default_classes
13
- %w(govuk-breadcrumbs)
15
+ %w(govuk-breadcrumbs).tap do |classes|
16
+ classes << "govuk-!-display-none-print" if @hide_in_print
17
+ classes << "govuk-breadcrumbs--collapse-on-mobile" if @collapse_on_mobile
18
+ end
14
19
  end
15
20
  end
@@ -1,5 +1,6 @@
1
1
  class GovukComponent::CookieBanner < GovukComponent::Base
2
- with_content_areas :body, :actions
2
+ renders_one :body
3
+ renders_one :actions
3
4
 
4
5
  attr_accessor :title, :aria_label
5
6
 
@@ -5,6 +5,6 @@
5
5
  </span>
6
6
  </summary>
7
7
  <div class="govuk-details__text">
8
- <%= @description || content %>
8
+ <%= content.presence || @description %>
9
9
  </div>
10
10
  <% end %>
@@ -11,6 +11,15 @@
11
11
  <%= @logo %>
12
12
  </span>
13
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 %>
14
23
  </a>
15
24
  </div>
16
25
  <div class="govuk-header__content">
@@ -21,16 +30,21 @@
21
30
  <% end %>
22
31
 
23
32
  <% if items.any? %>
33
+ <button type="button" class="govuk-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="Show or hide navigation menu">
34
+ <%= menu_button_label %>
35
+ </button>
24
36
  <nav>
25
- <ul class="govuk-header__navigation " aria-label="Top Level Navigation">
37
+ <%= tag.ul(class: navigation_classes, aria: { label: "Top Level Navigation" }) do %>
26
38
  <% items.each do |item| %>
27
39
  <%= tag.li(class: item.classes.append(item.active_class), **item.html_attributes) do %>
28
- <a class="govuk-header__link" href="<%= item.href %>">
40
+ <% if item.link? %>
41
+ <%= link_to(item.title, item.href, class: "govuk-header__link") %>
42
+ <% else %>
29
43
  <%= item.title %>
30
- </a>
44
+ <% end %>
31
45
  <% end %>
32
46
  <% end %>
33
- </ul>
47
+ <% end %>
34
48
  </nav>
35
49
  <% end %>
36
50
  </div>
@@ -1,18 +1,24 @@
1
1
  class GovukComponent::Header < GovukComponent::Base
2
2
  include ViewComponent::Slotable
3
3
 
4
- attr_accessor :logo, :logo_href, :service_name, :service_name_href
4
+ attr_accessor :logo, :logo_href, :service_name, :service_name_href, :product_name, :menu_button_label
5
5
 
6
6
  with_slot :item, collection: true, class_name: 'Item'
7
7
  wrap_slot :item
8
8
 
9
- def initialize(logo: 'GOV.UK', logo_href: '/', service_name: nil, service_name_href: '/', classes: [], html_attributes: {})
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: 'Menu', classes: [], navigation_classes: [], html_attributes: {})
10
13
  super(classes: classes, html_attributes: html_attributes)
11
14
 
12
- @logo = logo
13
- @logo_href = logo_href
14
- @service_name = service_name
15
- @service_name_href = service_name_href
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
16
22
  end
17
23
 
18
24
  private
@@ -21,10 +27,16 @@ private
21
27
  %w(govuk-header)
22
28
  end
23
29
 
30
+ def navigation_classes
31
+ %w(govuk-header__navigation).tap { |nc|
32
+ nc.concat(@navigation_classes.is_a?(String) ? @navigation_classes.split : @navigation_classes)
33
+ }.uniq
34
+ end
35
+
24
36
  class Item < GovukComponent::Slot
25
37
  attr_accessor :title, :href, :active
26
38
 
27
- def initialize(title:, href:, active: false, classes: [], html_attributes: {})
39
+ def initialize(title:, href: nil, active: false, classes: [], html_attributes: {})
28
40
  super(classes: classes, html_attributes: html_attributes)
29
41
 
30
42
  self.title = title
@@ -40,6 +52,10 @@ private
40
52
  %w(govuk-header__navigation-item--active) if active?
41
53
  end
42
54
 
55
+ def link?
56
+ href.present?
57
+ end
58
+
43
59
  private
44
60
 
45
61
  def default_classes
@@ -1,14 +1,18 @@
1
1
  class GovukComponent::InsetText < GovukComponent::Base
2
2
  attr_accessor :text
3
3
 
4
- def initialize(text:, classes: [], html_attributes: {})
4
+ def initialize(text: nil, classes: [], html_attributes: {})
5
5
  super(classes: classes, html_attributes: html_attributes)
6
6
 
7
7
  @text = text
8
8
  end
9
9
 
10
10
  def call
11
- tag.div(class: classes, **html_attributes) { @text }
11
+ tag.div(class: classes, **html_attributes) { content.presence || @text }
12
+ end
13
+
14
+ def render?
15
+ @text.present? || content.present?
12
16
  end
13
17
 
14
18
  private
@@ -1,9 +1,13 @@
1
1
  <%= tag.div(class: classes, **html_attributes) do %>
2
- <h1 class="govuk-panel__title">
3
- <%= @title %>
4
- </h1>
2
+ <% if display_title? %>
3
+ <h1 class="govuk-panel__title">
4
+ <%= @title %>
5
+ </h1>
6
+ <% end %>
5
7
 
6
- <div class="govuk-panel__body">
7
- <%= @body %>
8
- </div>
8
+ <% if display_body? %>
9
+ <div class="govuk-panel__body">
10
+ <%= content.presence || @body %>
11
+ </div>
12
+ <% end %>
9
13
  <% end %>
@@ -1,7 +1,7 @@
1
1
  class GovukComponent::Panel < GovukComponent::Base
2
2
  attr_accessor :title, :body
3
3
 
4
- def initialize(title:, body:, classes: [], html_attributes: {})
4
+ def initialize(title: nil, body: nil, classes: [], html_attributes: {})
5
5
  super(classes: classes, html_attributes: html_attributes)
6
6
 
7
7
  @title = title
@@ -13,4 +13,16 @@ private
13
13
  def default_classes
14
14
  %w(govuk-panel govuk-panel--confirmation)
15
15
  end
16
+
17
+ def display_title?
18
+ @title.present?
19
+ end
20
+
21
+ def display_body?
22
+ [@body, content].any?(&:present?)
23
+ end
24
+
25
+ def render?
26
+ display_title? || display_body?
27
+ end
16
28
  end
@@ -1,10 +1,8 @@
1
1
  <%= tag.div(class: classes, **html_attributes) do %>
2
2
  <p class="govuk-phase-banner__content">
3
- <strong class="govuk-tag govuk-phase-banner__content__tag">
4
- <%= @phase %>
5
- </strong>
3
+ <%= render(phase_tag) %>
6
4
  <span class="govuk-phase-banner__text">
7
- <%= @text || content %>
5
+ <%= content.presence || @text %>
8
6
  </span>
9
7
  </p>
10
8
  <% end %>
@@ -1,11 +1,11 @@
1
1
  class GovukComponent::PhaseBanner < GovukComponent::Base
2
- attr_accessor :phase, :text
2
+ attr_accessor :phase_tag, :text
3
3
 
4
- def initialize(phase:, text: nil, classes: [], html_attributes: {})
4
+ def initialize(phase_tag: nil, text: nil, classes: [], html_attributes: {})
5
5
  super(classes: classes, html_attributes: html_attributes)
6
6
 
7
- @phase = phase
8
- @text = text
7
+ @phase_tag = GovukComponent::Tag.new(classes: "govuk-phase-banner__content__tag", **phase_tag)
8
+ @text = text
9
9
  end
10
10
 
11
11
  private
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '1.1.4'.freeze
3
+ VERSION = '1.1.9'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,17 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - DfE developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-23 00:00:00.000000000 Z
11
+ date: 2021-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '6.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="