govuk_publishing_components 21.47.0 → 21.48.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +2 -2
- data/app/views/govuk_publishing_components/components/_action_link.html.erb +6 -1
- data/app/views/govuk_publishing_components/components/_button.html.erb +5 -1
- data/app/views/govuk_publishing_components/components/docs/action_link.yml +6 -0
- data/lib/govuk_publishing_components/presenters/button_helper.rb +1 -6
- data/lib/govuk_publishing_components/presenters/shared_helper.rb +8 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41bce645d4da9c9c6fd2b1ab5e91fb4ecea8d1b76060fde43f56141fa3101570
|
4
|
+
data.tar.gz: 3ae1030faab5c0cd05487dda793de110743831147d5fe145c9cc69b8d92231b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2402cf261528736c5326f7687e70af627469ce970dd74800825a2a0cd7f3fdb97a0a4b56178a331579733ca98a3ee03987fafd192159f1ece14c29a4a9848076
|
7
|
+
data.tar.gz: a84744cc1ae7d7805aab08a6144b277f3e304ef23ad40b05396f47ed68fe04ebf103b9f51234cb223e9e3ecbf5215d7aa58d9ef86748a701f13cd44b8e1d9cc9
|
@@ -10,17 +10,22 @@
|
|
10
10
|
simple ||= false
|
11
11
|
dark_icon ||= false
|
12
12
|
data ||= nil
|
13
|
+
classes ||= nil
|
14
|
+
|
13
15
|
css_classes = %w(gem-c-action-link)
|
14
16
|
css_classes << "gem-c-action-link--light-text" if light_text
|
15
17
|
css_classes << "gem-c-action-link--dark-icon" if dark_icon
|
16
18
|
css_classes << "gem-c-action-link--simple" if simple
|
17
19
|
css_classes << "gem-c-action-link--with-subtext" if subtext
|
18
20
|
css_classes << (shared_helper.get_margin_bottom)
|
21
|
+
|
22
|
+
link_classes = %w(govuk-link gem-c-action-link__link)
|
23
|
+
link_classes << shared_helper.classes if classes
|
19
24
|
%>
|
20
25
|
<% if href.present? && text.present? %>
|
21
26
|
<div class="<%= css_classes.join(' ') %>">
|
22
27
|
<span class="gem-c-action-link__link-wrapper">
|
23
|
-
<%= link_to href, :class =>
|
28
|
+
<%= link_to href, :class => link_classes, :data => data do %>
|
24
29
|
<%= text %>
|
25
30
|
<%= content_tag(:span, nowrap_text, class: "gem-c-action-link__nowrap-text") if nowrap_text %>
|
26
31
|
<% end %>
|
@@ -1,4 +1,8 @@
|
|
1
|
-
<%
|
1
|
+
<%
|
2
|
+
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
3
|
+
local_assigns[:classes] = shared_helper.classes
|
4
|
+
button = GovukPublishingComponents::Presenters::ButtonHelper.new(local_assigns)
|
5
|
+
%>
|
2
6
|
|
3
7
|
<% start_button_text = capture do %>
|
4
8
|
<%= button.text %>
|
@@ -18,6 +18,12 @@ examples:
|
|
18
18
|
href: '/my-test-page'
|
19
19
|
data:
|
20
20
|
attr_test: "hasDataAttribute"
|
21
|
+
with_js_classes:
|
22
|
+
description: Use `js-` prefixed classes only as interaction hooks – to query and operate on elements via JavaScript. Classes are added to the link itself.
|
23
|
+
data:
|
24
|
+
text: "Coronavirus (COVID-19)"
|
25
|
+
href: '/my-test-page'
|
26
|
+
classes: 'js-hook'
|
21
27
|
with_no_wrapping_text:
|
22
28
|
data:
|
23
29
|
text: "Coronavirus (COVID-19):"
|
@@ -44,12 +44,7 @@ module GovukPublishingComponents
|
|
44
44
|
@destructive = local_assigns[:destructive]
|
45
45
|
@name = local_assigns[:name]
|
46
46
|
@value = local_assigns[:value]
|
47
|
-
|
48
|
-
@classes = local_assigns[:classes].split(" ")
|
49
|
-
unless @classes.all? { |c| c.start_with?("js-") }
|
50
|
-
raise(ArgumentError, "The button component expects classes to be prefixed with `js-`")
|
51
|
-
end
|
52
|
-
end
|
47
|
+
@classes = local_assigns[:classes]
|
53
48
|
@aria_label = local_assigns[:aria_label]
|
54
49
|
end
|
55
50
|
|
@@ -1,13 +1,20 @@
|
|
1
1
|
module GovukPublishingComponents
|
2
2
|
module Presenters
|
3
3
|
class SharedHelper
|
4
|
-
attr_reader :options, :margin_top, :margin_bottom, :heading_level
|
4
|
+
attr_reader :options, :margin_top, :margin_bottom, :heading_level, :classes
|
5
5
|
|
6
6
|
def initialize(local_assigns)
|
7
7
|
@options = local_assigns
|
8
8
|
@margin_top = @options[:margin_top] || nil
|
9
9
|
@margin_bottom = @options[:margin_bottom] || 3
|
10
10
|
@heading_level = @options[:heading_level] || 2
|
11
|
+
|
12
|
+
if local_assigns.include?(:classes)
|
13
|
+
@classes = local_assigns[:classes].split(" ")
|
14
|
+
unless @classes.all? { |c| c.start_with?("js-") }
|
15
|
+
raise(ArgumentError, "Passed classes must be prefixed with `js-`")
|
16
|
+
end
|
17
|
+
end
|
11
18
|
end
|
12
19
|
|
13
20
|
def get_margin_top
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_publishing_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 21.
|
4
|
+
version: 21.48.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gds-api-adapters
|