govuk-components 3.1.2 → 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:
|
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
|
@@ -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?
|
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
|
@@ -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: []
|