Class: Yattho::Alpha::NavList::Section
- Inherits:
-
ActionList
- Object
- ViewComponent::Base
- Component
- ActionList
- Yattho::Alpha::NavList::Section
- Defined in:
- app/components/yattho/alpha/nav_list/section.rb
Overview
A logical grouping of navigation links with an optional heading.
See <%= link_to_component(Yattho::Alpha::NavList) %> for usage examples.
Constant Summary
Constants inherited from ActionList
ActionList::DEFAULT_ROLE, ActionList::DEFAULT_SCHEME, ActionList::SCHEME_MAPPINGS, ActionList::SCHEME_OPTIONS
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Class Method Summary collapse
Instance Method Summary collapse
- #build_item(component_klass: NavList::Item, **system_arguments) ⇒ Object
-
#expand! ⇒ Object
Cause this section to show its list of sub items when rendered.
-
#initialize(selected_item_id: nil, **system_arguments) ⇒ Section
constructor
A new instance of Section.
-
#items ⇒ Array<Yattho::Alpha::ActionList::Item>
The items contained within this section.
Methods inherited from ActionList
#before_render, #custom_element_name, #will_add_item
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Constructor Details
#initialize(selected_item_id: nil, **system_arguments) ⇒ Section
Returns a new instance of Section.
46 47 48 49 50 51 52 |
# File 'app/components/yattho/alpha/nav_list/section.rb', line 46 def initialize(selected_item_id: nil, **system_arguments) @system_arguments = system_arguments @selected_item_id = selected_item_id @system_arguments[:'data-target'] = "nav-list.list" super(**@system_arguments) end |
Class Method Details
.custom_element_name ⇒ Object
40 41 42 |
# File 'app/components/yattho/alpha/nav_list/section.rb', line 40 def self.custom_element_name "nav-list" end |
Instance Method Details
#build_item(component_klass: NavList::Item, **system_arguments) ⇒ Object
75 76 77 78 79 80 81 |
# File 'app/components/yattho/alpha/nav_list/section.rb', line 75 def build_item(component_klass: NavList::Item, **system_arguments) component_klass.new( **system_arguments, selected_item_id: @selected_item_id, list: self ) end |
#expand! ⇒ Object
Cause this section to show its list of sub items when rendered. :nocov:
56 57 58 |
# File 'app/components/yattho/alpha/nav_list/section.rb', line 56 def @expanded = true end |
#items ⇒ Array<Yattho::Alpha::ActionList::Item>
The items contained within this section.
64 65 66 |
# File 'app/components/yattho/alpha/nav_list/section.rb', line 64 def items [*super, show_more_item].tap(&:compact!) end |