Class: Yattho::Alpha::ActionList
- Defined in:
- app/components/yattho/alpha/action_list.rb,
app/components/yattho/alpha/action_list/item.rb,
app/components/yattho/alpha/action_list/divider.rb,
app/components/yattho/alpha/action_list/heading.rb
Overview
An ActionList is a styled list of links. It acts as the base component for many other menu-type components, including ‘ActionMenu` and `SelectPanel`, as well as the navigational component `NavList`.
Each item in an action list can be augmented by specifying corresponding leading and/or trailing visuals.
Direct Known Subclasses
Defined Under Namespace
Classes: Divider, Heading, Item
Constant Summary collapse
- DEFAULT_ROLE =
:list
- DEFAULT_SCHEME =
:full
- SCHEME_MAPPINGS =
{ DEFAULT_SCHEME => nil, :inset => "ActionListWrap--inset" }.freeze
- SCHEME_OPTIONS =
SCHEME_MAPPINGS.keys.freeze
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
-
.custom_element_name ⇒ Object
:nocov:.
Instance Method Summary collapse
- #before_render ⇒ Object
- #build_item(**system_arguments) ⇒ Object
- #custom_element_name ⇒ Object
-
#initialize(role: DEFAULT_ROLE, item_classes: nil, scheme: DEFAULT_SCHEME, show_dividers: false, **system_arguments) ⇒ ActionList
constructor
A new instance of ActionList.
- #will_add_item(_item) ⇒ Object
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(role: DEFAULT_ROLE, item_classes: nil, scheme: DEFAULT_SCHEME, show_dividers: false, **system_arguments) ⇒ ActionList
Returns a new instance of ActionList.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/components/yattho/alpha/action_list.rb', line 56 def initialize( role: DEFAULT_ROLE, item_classes: nil, scheme: DEFAULT_SCHEME, show_dividers: false, **system_arguments ) @id = self.class.generate_id @role = role @system_arguments = system_arguments @system_arguments[:tag] = :ul @item_classes = item_classes @scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME) @show_dividers = show_dividers @system_arguments[:classes] = class_names( SCHEME_MAPPINGS[@scheme], system_arguments[:classes], "ActionListWrap", "ActionListWrap--subGroup", "ActionListWrap--divided" => @show_dividers ) @list_wrapper_arguments = {} end |
Class Method Details
.custom_element_name ⇒ Object
:nocov:
25 26 27 |
# File 'app/components/yattho/alpha/action_list.rb', line 25 def self.custom_element_name @custom_element_name ||= name.split("::").last.underscore.dasherize end |
Instance Method Details
#before_render ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/components/yattho/alpha/action_list.rb', line 83 def before_render if heading.present? @system_arguments[:'aria-labelledby'] = @id elsif aria(:label, @system_arguments).blank? raise ArgumentError, "An aria-label or heading must be provided" end return if items.blank? @list_wrapper_arguments[:classes] = class_names( @list_wrapper_arguments[:classes], "ActionListItem--hasSubItem" ) end |
#build_item(**system_arguments) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'app/components/yattho/alpha/action_list.rb', line 99 def build_item(**system_arguments) system_arguments[:classes] = class_names( @item_classes, system_arguments[:classes] ) ActionList::Item.new(list: self, **system_arguments) end |
#custom_element_name ⇒ Object
30 31 32 |
# File 'app/components/yattho/alpha/action_list.rb', line 30 def custom_element_name self.class.custom_element_name end |
#will_add_item(_item) ⇒ Object
109 |
# File 'app/components/yattho/alpha/action_list.rb', line 109 def will_add_item(_item); end |