Class: Www::SectionNavComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Www::SectionNavComponent
- Defined in:
- app/components/www/section_nav_component.rb
Overview
Reusable sticky section navigation bar for www pages.
Renders a horizontally scrollable nav inside a sticky bar. Pair with
the scrollspy Stimulus controller on a parent wrapper to get active
section highlighting on scroll.
Usage:
<%= render Www::SectionNavComponent.new(
nav_id: "nav-product-sections",
items: presenter.sections.map { |id, opts| { id: id, label: opts[:title] } }
) %>
Instance Method Summary collapse
-
#initialize(nav_id:, items:) ⇒ SectionNavComponent
constructor
A new instance of SectionNavComponent.
- #render? ⇒ Boolean
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(nav_id:, items:) ⇒ SectionNavComponent
Returns a new instance of SectionNavComponent.
15 16 17 18 19 |
# File 'app/components/www/section_nav_component.rb', line 15 def initialize(nav_id:, items:) super() @nav_id = nav_id @items = items end |
Instance Method Details
#render? ⇒ Boolean
21 22 23 |
# File 'app/components/www/section_nav_component.rb', line 21 def render? @items.present? end |