Class: Www::SectionHeaderComponent

Inherits:
ApplicationComponent show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
app/components/www/section_header_component.rb

Overview

SectionHeaderComponent - Renders a consistent section header with optional icon and description

Used by various components to provide a consistent header style.
The border (hr) is optional and defaults to false since PageSectionComponent now handles section borders.

Usage:

<%# Basic usage %>
<%= render Www::SectionHeaderComponent.new(title: 'Featured Products') %>

<%# With icon and description %>
<%= render Www::SectionHeaderComponent.new(
title: 'Heating Solutions',
icon: 'box',
description: 'Browse our product line'
) %>

<%# With border (for components not wrapped in PageSectionComponent) %>
<%= render Www::SectionHeaderComponent.new(title: 'Products', border: true) %>

Instance Method Summary collapse

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:, icon: nil, svg_icon: nil, description: nil, border: false, hr_classes: 'mt-2 mb-4') ⇒ SectionHeaderComponent

Returns a new instance of SectionHeaderComponent.

Parameters:

  • title (String)

    Section title text

  • icon (String, nil) (defaults to: nil)

    Font Awesome icon name (e.g., 'box', 'shower')

  • svg_icon (String, nil) (defaults to: nil)

    Path to custom SVG in app/assets/images/svgs/custom/ (e.g., 'floor-heating-shower.svg')

  • description (String, nil) (defaults to: nil)

    Optional description text below title

  • border (Boolean) (defaults to: false)

    Whether to render an below the header (default: false)

  • hr_classes (String) (defaults to: 'mt-2 mb-4')

    CSS classes for the horizontal rule (only used when border: true)



31
32
33
34
35
36
37
38
39
# File 'app/components/www/section_header_component.rb', line 31

def initialize(title:, icon: nil, svg_icon: nil, description: nil, border: false, hr_classes: 'mt-2 mb-4')
  super()
  @title = title
  @icon = icon
  @svg_icon = svg_icon
  @description = description
  @border = border
  @hr_classes = hr_classes
end

Instance Method Details

#render_border?Boolean

Returns true if an should be rendered below the header

Returns:

  • (Boolean)


52
53
54
# File 'app/components/www/section_header_component.rb', line 52

def render_border?
  @border
end

#svg_icon?Boolean

Returns true if using custom SVG icon

Returns:

  • (Boolean)


42
43
44
# File 'app/components/www/section_header_component.rb', line 42

def svg_icon?
  @svg_icon.present?
end

#svg_icon_pathObject

Full path for inline_svg_tag



47
48
49
# File 'app/components/www/section_header_component.rb', line 47

def svg_icon_path
  "svgs/custom/#{@svg_icon}"
end