From 57797a530c00a2607077f5c710d91b42c7f0970c Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 17 Dec 2024 08:52:28 +0000 Subject: [PATCH] Allow component to receive parameters and remove redundant options The hardcoded text in the view can now be passed as parameters from the instance of the component. The `link_text` code is now removed as it was previously hardcoded to false (it's not required). --- .../components/_global_bar.html.erb | 39 ++++--------------- .../components/docs/global_bar.yml | 9 ++++- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/app/views/govuk_publishing_components/components/_global_bar.html.erb b/app/views/govuk_publishing_components/components/_global_bar.html.erb index 455fe2d8af..2222854756 100644 --- a/app/views/govuk_publishing_components/components/_global_bar.html.erb +++ b/app/views/govuk_publishing_components/components/_global_bar.html.erb @@ -3,23 +3,15 @@ if before_update_time?(year: 2024, month: 12, day: 30, hour: 22, minute: 0) show_global_bar ||= true # Toggles the appearance of the global bar - title = "Bring photo ID to vote" - title_href = "/how-to-vote/photo-id-youll-need" - link_text = "Check what photo ID you'll need to vote in person in the General Election on 4 July." - else - show_global_bar = false - title = nil - title_href = nil - link_text = nil + title || nil + title_href || nil + link_text || nil + always_visible || false + # 'always_visibe' Toggles banner being permanently visible + # If true, banner is always_visible & doesn't disappear after 3 pageviews + # Regardless of value, banner is always manually dismissable by users end - link_href = false - - # Toggles banner being permanently visible - # If true, banner is always_visible & does not disappear automatically after 3 pageviews - # Regardless of value, banner is always manually dismissable by users - always_visible = true - global_bar_classes = %w(gem-c-global-bar govuk-!-display-none-print) title_classes = %w(gem-c-global-bar-title) @@ -47,22 +39,7 @@ <% end %> <% if link_text %> - - <% if link_href %> - <%= link_to( - link_text, - link_href, - rel: "external noreferrer", - class: "govuk-link js-call-to-action", - data: { - module: "ga4-link-tracker", - ga4_link: ga4_data, - }, - ) %> - <% else %> - <%= link_text %> - <% end %> - + <%= link_text %> <% end %>

diff --git a/app/views/govuk_publishing_components/components/docs/global_bar.yml b/app/views/govuk_publishing_components/components/docs/global_bar.yml index 92712c7787..94c4f02ef0 100644 --- a/app/views/govuk_publishing_components/components/docs/global_bar.yml +++ b/app/views/govuk_publishing_components/components/docs/global_bar.yml @@ -5,4 +5,11 @@ body: | shared_accessibility_criteria: - link examples: - default: {} + default: + data: + title: Bring photo ID to vote + title_href: "/how-to-vote/photo-id-youll-need" + link_text: Check what photo ID you'll need to vote in person in the General Election on 4 July. + always_visible: true + +