Class: Www::FullWidthLandingPageHeaderComponent

Inherits:
ApplicationComponent show all
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

Methods included from ImagesHelper

#image_asset_tag, #image_asset_url, #picture_asset_tag

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, 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.

Parameters:

  • lazy (Boolean) (defaults to: false)

    Whether to lazy load the background image. Default false (hero images should load immediately)

  • mobile_poster_id (Integer, nil) (defaults to: nil)

    Image asset to show on mobile instead of video.
    Defaults to video_thumb_asset_id. Rendered with ImageKit focus:auto for smart crop.

  • content_width (Symbol) (defaults to: :standard)

    Width of the text content column over the hero image.
    :standard (default) → col-lg-8 — fits most titles
    :wide → col-lg-9 col-xl-9 — use when the H1 is long enough to wrap unnecessarily at lg+

  • title (Object)
  • introduction (Object)
  • image_asset_id (Object, nil) (defaults to: nil)
  • fallback_image_asset_id (Object, nil) (defaults to: nil)
  • video_source (Object, nil) (defaults to: nil)
  • video_thumb_asset_id (Object, nil) (defaults to: nil)
  • links (Array<Object>) (defaults to: [])
  • sub_title (Object, nil) (defaults to: nil)
  • hide_cta (Boolean) (defaults to: false)
  • image_asset_options (Object, nil) (defaults to: nil)
  • button_columns (Integer) (defaults to: 4)
  • review_avg_stars (Object, nil) (defaults to: nil)
  • review_count (Object, nil) (defaults to: nil)
  • color_mode (Symbol) (defaults to: :full)
  • content_align (Symbol) (defaults to: :left)
  • banner_badges (Object, nil) (defaults to: nil)
  • image_object_position (Symbol) (defaults to: :center)

    Vertical anchor for the hero image crop (:center, :top, :bottom)



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/components/www/full_width_landing_page_header_component.rb', line 30

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, 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
  @hide_cta = hide_cta
  @image_asset_options = image_asset_options
  @button_columns = 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(banner_badges).compact.presence
  @image_object_position = (image_object_position || :center).to_sym
end

Instance Method Details

#before_rendervoid

This method returns an undefined value.

Resolve the effective banner image and set og:image.
Banner resolution order:

  1. Explicit image_asset_id passed to the component
  2. Tagged banner image (banner-for-xxx-page)
    og:image resolution order:
  3. Dedicated og-image-for-xxx-page tagged Image
  4. The resolved banner image
  5. Template-level page_og_image call (handled by MetaHelper guard)


63
64
65
66
67
68
# File 'app/components/www/full_width_landing_page_header_component.rb', line 63

def before_render
  super
  @image_asset_id = @provided_image_asset_id || resolve_banner_image
  og_image = resolve_og_image || @image_asset_id
  helpers.page_og_image(og_image) if og_image.present?
end

Returns the built CTA link component.

Parameters:

  • options (Hash)

    CTA link attributes forwarded to Www::LandingPageCtaLinkComponent

Options Hash (options):

  • :url (String, nil)

    link target URL

  • :title (String, nil)

    link text, defaults to 'Learn More'

  • :fa_icon (String, nil)

    Font Awesome icon name

  • :svg_icon (String, nil)

    SVG icon name

  • :icon_url (String, nil)

    custom icon image URL

  • :style (Symbol, nil)

    button style, defaults to :solid

  • :data (Hash, nil)

    HTML data attributes

  • :panel (Symbol, nil)

    offcanvas panel to open (e.g. :contact)

Returns:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'app/components/www/full_width_landing_page_header_component.rb', line 95

def cta_link_for(options)
  # Extract and normalize options for the CTA component
  cta_options = {
    url: options[:url],
    title: options[:title] || 'Learn More',
    fa_icon: options[:fa_icon],
    svg_icon: options[:svg_icon],
    icon_url: options[:icon_url],
    style: options[:style] || :solid,
    data: options[:data],
    panel: options[:panel]
  }.compact

  Www::LandingPageCtaLinkComponent.new(**cta_options)
end

CTA links rendered in the header. Defaults to the contact modal when
no explicit links are configured.

Returns:

  • (Array<Hash>)

    normalized link option hashes



73
74
75
76
77
78
79
80
81
82
83
# File 'app/components/www/full_width_landing_page_header_component.rb', line 73

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