Class: GovukPublishingComponents::Presenters::PublicLayoutHelper
- Inherits:
-
Object
- Object
- GovukPublishingComponents::Presenters::PublicLayoutHelper
- Defined in:
- lib/govuk_publishing_components/presenters/public_layout_helper.rb
Constant Summary collapse
- BLUE_BAR_BACKGROUND_COLOURS =
%w[browse].freeze
- FOOTER_NAVIGATION_COLUMNS =
[2, 1].freeze
- FOOTER_TRACK_ACTIONS =
%w[topicsLink governmentactivityLink].freeze
- FOOTER_META =
{ items: [ { href: "/help", text: "Help", }, { href: "/help/privacy-notice", text: "Privacy", }, { href: "/help/cookies", text: "Cookies", }, { href: "/help/accessibility-statement", text: "Accessibility statement", }, { href: "/contact", text: "Contact", }, { href: "/help/terms-conditions", text: "Terms and conditions", }, { href: "/cymraeg", text: "Rhestr o Wasanaethau Cymraeg", attributes: { lang: "cy", }, }, { href: "/government/organisations/government-digital-service", text: "Government Digital Service", }, ], }.freeze
Instance Attribute Summary collapse
-
#cookie_banner_data ⇒ Object
readonly
Returns the value of attribute cookie_banner_data.
-
#footer_meta ⇒ Object
readonly
Returns the value of attribute footer_meta.
-
#footer_navigation ⇒ Object
readonly
Returns the value of attribute footer_navigation.
Instance Method Summary collapse
- #add_data_attributes_to_links(items, track_action) ⇒ Object
- #blue_bar_background_colours ⇒ Object
- #footer_navigation_columns ⇒ Object
- #footer_track_actions ⇒ Object
- #generate_data_attribute(link, track_action) ⇒ Object
-
#initialize(local_assigns) ⇒ PublicLayoutHelper
constructor
A new instance of PublicLayoutHelper.
- #navigation_link_generation_from_locale(links) ⇒ Object
Constructor Details
#initialize(local_assigns) ⇒ PublicLayoutHelper
Returns a new instance of PublicLayoutHelper.
49 50 51 52 53 |
# File 'lib/govuk_publishing_components/presenters/public_layout_helper.rb', line 49 def initialize(local_assigns) @footer_navigation = local_assigns[:footer_navigation] || (I18n.t("components.layout_footer.navigation_links")) @footer_meta = local_assigns[:footer_meta] || { items: add_data_attributes_to_links(FOOTER_META[:items], "supportLink") } @cookie_banner_data = local_assigns[:cookie_banner_data] || {} end |
Instance Attribute Details
#cookie_banner_data ⇒ Object (readonly)
Returns the value of attribute cookie_banner_data.
47 48 49 |
# File 'lib/govuk_publishing_components/presenters/public_layout_helper.rb', line 47 def @cookie_banner_data end |
#footer_meta ⇒ Object (readonly)
Returns the value of attribute footer_meta.
47 48 49 |
# File 'lib/govuk_publishing_components/presenters/public_layout_helper.rb', line 47 def @footer_meta end |
#footer_navigation ⇒ Object (readonly)
Returns the value of attribute footer_navigation.
47 48 49 |
# File 'lib/govuk_publishing_components/presenters/public_layout_helper.rb', line 47 def @footer_navigation end |
Instance Method Details
#add_data_attributes_to_links(items, track_action) ⇒ Object
88 89 90 91 92 |
# File 'lib/govuk_publishing_components/presenters/public_layout_helper.rb', line 88 def add_data_attributes_to_links(items, track_action) items.map do |item| item.deep_merge({ attributes: { data: generate_data_attribute(item, track_action) } }) end end |
#blue_bar_background_colours ⇒ Object
73 74 75 |
# File 'lib/govuk_publishing_components/presenters/public_layout_helper.rb', line 73 def BLUE_BAR_BACKGROUND_COLOURS end |
#footer_navigation_columns ⇒ Object
65 66 67 |
# File 'lib/govuk_publishing_components/presenters/public_layout_helper.rb', line 65 def FOOTER_NAVIGATION_COLUMNS end |
#footer_track_actions ⇒ Object
69 70 71 |
# File 'lib/govuk_publishing_components/presenters/public_layout_helper.rb', line 69 def FOOTER_TRACK_ACTIONS end |
#generate_data_attribute(link, track_action) ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/govuk_publishing_components/presenters/public_layout_helper.rb', line 77 def generate_data_attribute(link, track_action) { track_category: "footerClicked", track_action:, track_label: link[:href], track_options: { dimension29: link[:text], }, } end |
#navigation_link_generation_from_locale(links) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/govuk_publishing_components/presenters/public_layout_helper.rb', line 55 def (links) links.each_with_index.map do |, i| { title: [:title], columns: [i], items: add_data_attributes_to_links([:menu_contents], [i]), } end end |