govuk_publishing_components 34.8.1 → 34.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +5 -1
- data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +6 -0
- data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +18 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6da9ed1af8922136300b056ca61432de28330b478e25e23334917d0fdec9041
|
|
4
|
+
data.tar.gz: 2efcf7e5c91aaca82158059670b6b5ea7d4f52cb998b49a23e13deb32276958e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c5b8de64f9ba866ce83e1ef48be8d42f3f57b74891f446cba362c83e1a4be599d67039fc9f4cd9ee2e3b77345a4fb2955310a2aefb45b9bfcdf59e69bc06fdd3
|
|
7
|
+
data.tar.gz: 75251f6417ec2c5e3e542eab3f2a914b93c9a5153f6b3be40848640d1e4944d2186e169a26198760cac76f482667e1d73e743105504c465b31974c583b4a0f3f
|
data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb
CHANGED
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
<svg class="gem-c-single-page-notification-button__icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" height="18" width="18" viewBox="0 0 459.334 459.334"><path fill="currentColor" d="M177.216 404.514c-.001.12-.009.239-.009.359 0 30.078 24.383 54.461 54.461 54.461s54.461-24.383 54.461-54.461c0-.12-.008-.239-.009-.359H175.216zM403.549 336.438l-49.015-72.002v-89.83c0-60.581-43.144-111.079-100.381-122.459V24.485C254.152 10.963 243.19 0 229.667 0s-24.485 10.963-24.485 24.485v27.663c-57.237 11.381-100.381 61.879-100.381 122.459v89.83l-49.015 72.002a24.76 24.76 0 0 0 20.468 38.693H383.08a24.761 24.761 0 0 0 20.469-38.694z"/></svg><span class="gem-c-single-page-notication-button__text"><%= component_helper.button_text %></span>
|
|
10
10
|
<% end %>
|
|
11
11
|
<%= tag.div class: wrapper_classes, data: { module: "gem-track-click"} do %>
|
|
12
|
-
<%= tag.form class: component_helper.classes, action:
|
|
12
|
+
<%= tag.form class: component_helper.classes, action: component_helper.form_action, method: "POST", data: component_helper.data do %>
|
|
13
13
|
<input type="hidden" name="base_path" value="<%= component_helper.base_path %>">
|
|
14
|
+
<% if component_helper.skip_account %>
|
|
15
|
+
<input type="hidden" name="<%= component_helper.skip_account_param %>" value="true">
|
|
16
|
+
<input type="hidden" name="link" value="<%= component_helper.base_path %>">
|
|
17
|
+
<% end %>
|
|
14
18
|
<%= content_tag(:button, button_text, {
|
|
15
19
|
class: "govuk-body-s gem-c-single-page-notification-button__submit",
|
|
16
20
|
type: "submit",
|
data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml
CHANGED
|
@@ -57,3 +57,9 @@ examples:
|
|
|
57
57
|
button_text:
|
|
58
58
|
subscribe: 'Subscribe to this page of things'
|
|
59
59
|
unsubscribe: 'Unsubscribe to this page of things'
|
|
60
|
+
with_skip_account:
|
|
61
|
+
description: If the skip_account flag is present, the button action will be set to the non GOV.UK account signup endpoint of /email-signup.
|
|
62
|
+
data:
|
|
63
|
+
base_path: '/current-page-path'
|
|
64
|
+
js_enhancement: true
|
|
65
|
+
skip_account: true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module GovukPublishingComponents
|
|
2
2
|
module Presenters
|
|
3
3
|
class SinglePageNotificationButtonHelper
|
|
4
|
-
attr_reader :already_subscribed, :data_attributes, :base_path, :js_enhancement, :button_type, :button_location, :classes
|
|
4
|
+
attr_reader :already_subscribed, :data_attributes, :base_path, :js_enhancement, :button_type, :button_location, :classes, :skip_account
|
|
5
5
|
|
|
6
6
|
def initialize(local_assigns)
|
|
7
7
|
@local_assigns = local_assigns
|
|
@@ -15,6 +15,7 @@ module GovukPublishingComponents
|
|
|
15
15
|
@classes << "js-personalisation-enhancement" if js_enhancement
|
|
16
16
|
@button_text_subscribe = custom_button_text_is_valid? ? custom_subscribe_text : default_subscribe_text
|
|
17
17
|
@button_text_unsubscribe = custom_button_text_is_valid? ? custom_unsubscribe_text : default_unsubscribe_text
|
|
18
|
+
@skip_account = @local_assigns[:skip_account] || nil
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
def data
|
|
@@ -58,6 +59,22 @@ module GovukPublishingComponents
|
|
|
58
59
|
def default_unsubscribe_text
|
|
59
60
|
I18n.t("components.single_page_notification_button.unsubscribe_text")
|
|
60
61
|
end
|
|
62
|
+
|
|
63
|
+
def form_action
|
|
64
|
+
@skip_account ? email_alert_frontend_endpoint_no_account : email_alert_frontend_endpoint_enforce_account
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def email_alert_frontend_endpoint_enforce_account
|
|
68
|
+
"/email/subscriptions/single-page/new"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def email_alert_frontend_endpoint_no_account
|
|
72
|
+
"/email-signup"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def skip_account_param
|
|
76
|
+
"single_page_subscription"
|
|
77
|
+
end
|
|
61
78
|
end
|
|
62
79
|
end
|
|
63
80
|
end
|