Class: Www::FullWidthLandingPageHeaderComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Www::FullWidthLandingPageHeaderComponent
- Includes:
- ImagesHelper
- Defined in:
- app/components/www/full_width_landing_page_header_component.rb
Overview
ViewComponent: renders the full width landing page header block.
Instance Method Summary collapse
-
#before_render ⇒ Object
Resolve the effective banner image and set og:image.
- #compare_component ⇒ Object
- #cta_link_for(options) ⇒ Object
- #header_links ⇒ Object
-
#initialize(title:, introduction:, image_asset_id: nil, fallback_image_asset_id: nil, video_source: nil, video_thumb_asset_id: nil, mobile_poster_id: nil, links: [], sub_title: nil, show_compare: false, hide_cta: false, image_asset_options: nil, button_columns: 4, review_avg_stars: nil, review_count: nil, color_mode: :full, lazy: false, content_align: :left, content_width: :standard, banner_badges: nil, image_object_position: :center) ⇒ FullWidthLandingPageHeaderComponent
constructor
A new instance of FullWidthLandingPageHeaderComponent.
- #show_compare? ⇒ Boolean
Methods included from ImagesHelper
#image_asset_tag, #image_asset_url
Methods inherited from ApplicationComponent
#cms_link, #fetch_or_fallback, #image_asset_tag, #image_tag, #number_to_currency, #number_with_delimiter, #post_path, #post_url, #strip_tags
Constructor Details
#initialize(title:, introduction:, image_asset_id: nil, fallback_image_asset_id: nil, video_source: nil, video_thumb_asset_id: nil, mobile_poster_id: nil, links: [], sub_title: nil, show_compare: false, hide_cta: false, image_asset_options: nil, button_columns: 4, review_avg_stars: nil, review_count: nil, color_mode: :full, lazy: false, content_align: :left, content_width: :standard, banner_badges: nil, image_object_position: :center) ⇒ FullWidthLandingPageHeaderComponent
Returns a new instance of FullWidthLandingPageHeaderComponent.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/components/www/full_width_landing_page_header_component.rb', line 31 def initialize(title:, introduction:, image_asset_id: nil, fallback_image_asset_id: nil, video_source: nil, video_thumb_asset_id: nil, mobile_poster_id: nil, links: [], sub_title: nil, show_compare: false, hide_cta: false, image_asset_options: nil, button_columns: 4, review_avg_stars: nil, review_count: nil, color_mode: :full, lazy: false, content_align: :left, content_width: :standard, banner_badges: nil, image_object_position: :center) super() @title = title @sub_title = sub_title @introduction = introduction @provided_image_asset_id = image_asset_id || fallback_image_asset_id @video_source = video_source @video_thumb_asset_id = video_thumb_asset_id @mobile_poster_id = mobile_poster_id @links = links @show_compare = show_compare @hide_cta = hide_cta @image_asset_options = @button_columns = @review_avg_stars = review_avg_stars @review_count = review_count @color_mode = (color_mode || :full).to_sym @lazy = lazy @content_align = (content_align || :left).to_sym @content_width = (content_width || :standard).to_sym @banner_badges = Array().compact.presence @image_object_position = (image_object_position || :center).to_sym end |
Instance Method Details
#before_render ⇒ Object
Resolve the effective banner image and set og:image.
Banner resolution order:
- Explicit image_asset_id passed to the component
- Tagged banner image (banner-for-xxx-page)
og:image resolution order: - Dedicated og-image-for-xxx-page tagged Image
- The resolved banner image
- Template-level page_og_image call (handled by MetaHelper guard)
64 65 66 67 68 69 |
# File 'app/components/www/full_width_landing_page_header_component.rb', line 64 def before_render super @image_asset_id = @provided_image_asset_id || og_image = resolve_og_image || @image_asset_id helpers.page_og_image(og_image) if og_image.present? end |
#compare_component ⇒ Object
106 107 108 |
# File 'app/components/www/full_width_landing_page_header_component.rb', line 106 def compare_component Www::LandingPageCompareComponent.new end |
#cta_link_for(options) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/components/www/full_width_landing_page_header_component.rb', line 90 def cta_link_for() # Extract and normalize options for the CTA component = { url: [:url], title: [:title] || 'Learn More', fa_icon: [:fa_icon], svg_icon: [:svg_icon], icon_url: [:icon_url], style: [:style] || :solid, data: [:data], panel: [:panel] }.compact Www::LandingPageCtaLinkComponent.new(**) end |
#header_links ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/components/www/full_width_landing_page_header_component.rb', line 71 def header_links return [] if @hide_cta return Array(@links).filter_map { |entry| normalize_link_entry(entry) } if @links.present? links = [] return links if links.present? # Default: only Contact Modal [preset_link(:contact_modal)] end |
#show_compare? ⇒ Boolean
83 84 85 86 87 88 |
# File 'app/components/www/full_width_landing_page_header_component.rb', line 83 def show_compare? return false unless @show_compare request_path = helpers.request&.path.to_s request_path.include?('/floor-heating') end |