Skip to content

Commit

Permalink
Allow component to receive parameters and remove redundant options
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
matthillco committed Dec 17, 2024
1 parent f1736be commit 24fe024
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -47,22 +39,7 @@
<% end %>

<% if link_text %>
<span class="gem-c-global-bar-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 %>
</span>
<span class="gem-c-global-bar-text"><%= link_text %></span>
<% end %>
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


0 comments on commit 24fe024

Please sign in to comment.