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 +4 -4
- data/README.md +2 -1
- data/app/components/govuk_component/pagination_component.rb +8 -3
- data/app/components/govuk_component/start_button_component.rb +15 -6
- data/app/helpers/govuk_link_helper.rb +1 -1
- data/lib/govuk/components/version.rb +1 -1
- data/lib/govuk/components.rb +1 -0
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d96973745655e46c089832c7bf7045995f5026ad65acacebba3b2eaaec72ba8
|
4
|
+
data.tar.gz: bdf4bd50011bf68cba44cd4df794ed59988154bd204461f0630433f55a23a55a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
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
|
-
|
7
|
+
LINK_ATTRIBUTES = BUTTON_ATTRIBUTES.merge({ role: 'button' }).freeze
|
9
8
|
|
10
|
-
|
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
|
-
|
19
|
-
|
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
|
-
|
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::
|
71
|
+
html_options = GovukComponent::StartButtonComponent::LINK_ATTRIBUTES
|
72
72
|
.merge build_html_options(extra_options, style: :button)
|
73
73
|
|
74
74
|
if block_given?
|
data/lib/govuk/components.rb
CHANGED
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.
|
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-
|
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: []
|