govuk-components 3.1.0 → 3.1.3

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: e7d91723138110b84d128cc377b0c458ee7dca3714b77708581ffc2ce7c55e8e
4
- data.tar.gz: 784446ce4999d80eefe5c176ce17d4e4952163cd460996b9530a01e6a51d17e1
3
+ metadata.gz: 5d96973745655e46c089832c7bf7045995f5026ad65acacebba3b2eaaec72ba8
4
+ data.tar.gz: bdf4bd50011bf68cba44cd4df794ed59988154bd204461f0630433f55a23a55a
5
5
  SHA512:
6
- metadata.gz: 106c70d02e199030904967f1a814baa564d6c4397978d99b1afdbcbe80f8414d94589a83c39317c80a0fa75fa0841d835090f49b76b2597956f0838ec763824f
7
- data.tar.gz: 5aa69c78b7879be82256aac6d6e7ba967de6179ae4ba9386501d4f31179a5b0b07cd2d16648e0c135d2cf32b5462725a2a7931433a4af08bb2133f9889dbef4d
6
+ metadata.gz: 977b348a414cf49fb9e7fd59022ff60698175a50da1489e44b0c84db0d5bf1dff5b8e6035bade8e1a3d3cc7089c98c52fcae4bda995c1a912460efa9f6c3f6dd
7
+ data.tar.gz: 05fb69a77e3441634eb377d15a7a271ce945e0f27701f1fb8d1073acf8af678ab9fcacc479e328cf2ad171b2b2fcea06294048a218e03d47281de543d164d2be
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  [![GitHub license](https://img.shields.io/github/license/DFE-Digital/govuk-components)](https://github.com/DFE-Digital/govuk-components/blob/main/LICENSE)
9
9
  [![GOV.UK Design System Version](https://img.shields.io/badge/GOV.UK%20Design%20System-4.2.0-brightgreen)](https://design-system.service.gov.uk)
10
10
  [![Rails](https://img.shields.io/badge/Rails-6.1.5%20%E2%95%B1%207.0.3-E16D6D)](https://weblog.rubyonrails.org/releases/)
11
- [![Ruby](https://img.shields.io/badge/Ruby-2.7.5%20%20%E2%95%B1%203.0.3%20%20%E2%95%B1%203.1.0-E16D6D)](https://www.ruby-lang.org/en/downloads/)
11
+ [![Ruby](https://img.shields.io/badge/Ruby-2.7.5%20%20%E2%95%B1%203.0.3%20%20%E2%95%B1%203.1.2-E16D6D)](https://www.ruby-lang.org/en/downloads/)
12
12
 
13
13
  This gem provides a suite of reusable components for the [GOV.UK Design System](https://design-system.service.gov.uk/). It is intended to provide a lightweight alternative to the [GOV.UK Publishing Components](https://github.com/alphagov/govuk_publishing_components) library and is built with GitHub’s [ViewComponent](https://github.com/github/view_component) framework.
14
14
 
@@ -30,6 +30,7 @@ The provided components are:
30
30
  * [Inset text](https://govuk-components.netlify.app/components/inset-text)
31
31
  * [Notification banner](https://govuk-components.netlify.app/components/notification-banner)
32
32
  * [Panel](https://govuk-components.netlify.app/components/panel)
33
+ * [Pagination](https://govuk-components.netlify.app/components/pagination)
33
34
  * [Phase banner](https://govuk-components.netlify.app/components/phase-banner)
34
35
  * [Section break](https://govuk-components.netlify.app/components/section-break)
35
36
  * [Start button](https://govuk-components.netlify.app/components/start-button)
@@ -49,13 +49,18 @@ class GovukComponent::PaginationComponent < GovukComponent::Base
49
49
  @block_mode = block_mode
50
50
  @landmark_label = landmark_label
51
51
 
52
- build_items if pagy.present?
53
-
54
52
  super(classes: classes, html_attributes: html_attributes)
55
53
  end
56
54
 
57
55
  def before_render
58
- @page_items = items || build_items
56
+ @page_items = if pagy.present?
57
+ build_items
58
+ elsif items.any?
59
+ items
60
+ else
61
+ []
62
+ end
63
+
59
64
  @previous_content = previous_page || build_previous
60
65
  @next_content = next_page || build_next
61
66
  end
@@ -1,29 +1,38 @@
1
1
  class GovukComponent::StartButtonComponent < GovukComponent::Base
2
2
  BUTTON_ATTRIBUTES = {
3
- role: 'button',
4
3
  draggable: 'false',
5
4
  data: { module: 'govuk-button' }
6
5
  }.freeze
7
6
 
8
- attr_reader :text, :href
7
+ LINK_ATTRIBUTES = BUTTON_ATTRIBUTES.merge({ role: 'button' }).freeze
9
8
 
10
- def initialize(text:, href:, classes: [], html_attributes: {})
9
+ attr_reader :text, :href, :as_button
10
+
11
+ def initialize(text:, href:, as_button: false, classes: [], html_attributes: {})
11
12
  @text = text
12
13
  @href = href
14
+ @as_button = as_button
13
15
 
14
16
  super(classes: classes, html_attributes: html_attributes)
15
17
  end
16
18
 
17
19
  def call
18
- link_to(href, **html_attributes) do
19
- safe_join([text, icon])
20
+ if as_button
21
+ button_to(href, **html_attributes) do
22
+ safe_join([text, icon])
23
+ end
24
+ else
25
+ link_to(href, **html_attributes) do
26
+ safe_join([text, icon])
27
+ end
20
28
  end
21
29
  end
22
30
 
23
31
  private
24
32
 
25
33
  def default_attributes
26
- BUTTON_ATTRIBUTES.merge({ class: %w(govuk-button govuk-button--start) })
34
+ (as_button ? BUTTON_ATTRIBUTES : LINK_ATTRIBUTES)
35
+ .merge({ class: %w(govuk-button govuk-button--start) })
27
36
  end
28
37
 
29
38
  def icon
@@ -68,7 +68,7 @@ module GovukLinkHelper
68
68
 
69
69
  def govuk_button_link_to(name = nil, options = nil, extra_options = {}, &block)
70
70
  extra_options = options if block_given?
71
- html_options = GovukComponent::StartButtonComponent::BUTTON_ATTRIBUTES
71
+ html_options = GovukComponent::StartButtonComponent::LINK_ATTRIBUTES
72
72
  .merge build_html_options(extra_options, style: :button)
73
73
 
74
74
  if block_given?
@@ -1,5 +1,5 @@
1
1
  module Govuk
2
2
  module Components
3
- VERSION = '3.1.0'.freeze
3
+ VERSION = '3.1.3'.freeze
4
4
  end
5
5
  end
@@ -3,3 +3,4 @@ require "view_component"
3
3
  require "govuk/components/helpers/css_utilities"
4
4
  require "govuk/components/engine"
5
5
  require "html_attributes_utils"
6
+ require "pagy"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.3
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: 2022-06-27 00:00:00.000000000 Z
11
+ date: 2022-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: 0.9.2
75
+ - !ruby/object:Gem::Dependency
76
+ name: pagy
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 5.10.1
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 5.10.1
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: view_component
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -226,20 +240,6 @@ dependencies:
226
240
  - - "~>"
227
241
  - !ruby/object:Gem::Version
228
242
  version: '4.11'
229
- - !ruby/object:Gem::Dependency
230
- name: pagy
231
- requirement: !ruby/object:Gem::Requirement
232
- requirements:
233
- - - "~>"
234
- - !ruby/object:Gem::Version
235
- version: 5.10.1
236
- type: :development
237
- prerelease: false
238
- version_requirements: !ruby/object:Gem::Requirement
239
- requirements:
240
- - - "~>"
241
- - !ruby/object:Gem::Version
242
- version: 5.10.1
243
243
  - !ruby/object:Gem::Dependency
244
244
  name: redcarpet
245
245
  requirement: !ruby/object:Gem::Requirement
@@ -428,7 +428,7 @@ homepage: https://github.com/DFE-Digital/govuk-components
428
428
  licenses:
429
429
  - MIT
430
430
  metadata: {}
431
- post_install_message:
431
+ post_install_message:
432
432
  rdoc_options: []
433
433
  require_paths:
434
434
  - lib
@@ -444,7 +444,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
444
444
  version: '0'
445
445
  requirements: []
446
446
  rubygems_version: 3.1.6
447
- signing_key:
447
+ signing_key:
448
448
  specification_version: 4
449
449
  summary: Lightweight set of reusable GOV.UK Design System components
450
450
  test_files: []