Class: Primer::Alpha::ActionMenu::SubMenuItem
- Inherits:
-
Primer::Alpha::ActionList::Item
- Object
- ViewComponent::Base
- Component
- Primer::Alpha::ActionList::Item
- Primer::Alpha::ActionMenu::SubMenuItem
- Defined in:
- app/components/primer/alpha/action_menu/sub_menu_item.rb
Overview
This component is part of <%= link_to_component(Primer::Alpha::ActionMenu) %> and should not be used as a standalone component.
Constant Summary
Constants inherited from Primer::Alpha::ActionList::Item
Primer::Alpha::ActionList::Item::DEFAULT_DESCRIPTION_SCHEME, Primer::Alpha::ActionList::Item::DEFAULT_SCHEME, Primer::Alpha::ActionList::Item::DEFAULT_SIZE, Primer::Alpha::ActionList::Item::DEFAULT_TRUNCATION_BEHAVIOR, Primer::Alpha::ActionList::Item::DESCRIPTION_SCHEME_MAPPINGS, Primer::Alpha::ActionList::Item::DESCRIPTION_SCHEME_OPTIONS, Primer::Alpha::ActionList::Item::SCHEME_MAPPINGS, Primer::Alpha::ActionList::Item::SCHEME_OPTIONS, Primer::Alpha::ActionList::Item::SIZE_MAPPINGS, Primer::Alpha::ActionList::Item::SIZE_OPTIONS, Primer::Alpha::ActionList::Item::TRUNCATION_BEHAVIOR_MAPPINGS, Primer::Alpha::ActionList::Item::TRUNCATION_BEHAVIOR_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
Constants included from Primer::AttributesHelper
Primer::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Primer::AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Attribute Summary
Attributes inherited from Primer::Alpha::ActionList::Item
#active, #disabled, #href, #id, #item_id, #list, #parent
Instance Method Summary collapse
-
#initialize(content_arguments: {}, form_arguments: {}, **system_arguments) ⇒ SubMenuItem
constructor
A new instance of SubMenuItem.
- #with_avatar_item(**system_arguments, &block) ⇒ Object
- #with_divider(**system_arguments, &block) ⇒ Object
- #with_group(**system_arguments, &block) ⇒ Object
- #with_item(**system_arguments, &block) ⇒ Object
- #with_sub_menu_item(**system_arguments, &block) ⇒ 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
Methods included from Primer::AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(content_arguments: {}, form_arguments: {}, **system_arguments) ⇒ SubMenuItem
Returns a new instance of SubMenuItem.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/primer/alpha/action_menu/sub_menu_item.rb', line 11 def initialize(content_arguments: {}, form_arguments: {}, **system_arguments) # We extract form_arguments from system_arguments here to avoid passing them to the # ActionList::Item base class or to the SubMenu instance. Doing so prevents a form # input from being emitted for sub-menu items, which prevents an extra empty value # from being sent to the server on form submit. @sub_menu = SubMenu.allocate system_arguments = @sub_menu.send(:initialize, **system_arguments) system_arguments[:id] = "#{@sub_menu.}-button" @form_arguments = form_arguments content_arguments[:tag] = :button content_arguments[:popovertarget] = "#{@sub_menu.}-overlay" content_arguments[:aria] = merge_aria( content_arguments, { aria: { controls: "#{@sub_menu.}-list", haspopup: true } } ) super end |
Instance Method Details
#with_avatar_item(**system_arguments, &block) ⇒ Object
45 46 47 |
# File 'app/components/primer/alpha/action_menu/sub_menu_item.rb', line 45 def with_avatar_item(**system_arguments, &block) @sub_menu.with_avatar_item(form_arguments: @form_arguments, **system_arguments, &block) end |
#with_divider(**system_arguments, &block) ⇒ Object
41 42 43 |
# File 'app/components/primer/alpha/action_menu/sub_menu_item.rb', line 41 def with_divider(**system_arguments, &block) @sub_menu.with_divider(form_arguments: @form_arguments, **system_arguments, &block) end |
#with_group(**system_arguments, &block) ⇒ Object
53 54 55 |
# File 'app/components/primer/alpha/action_menu/sub_menu_item.rb', line 53 def with_group(**system_arguments, &block) @sub_menu.with_group(form_arguments: @form_arguments, **system_arguments, &block) end |
#with_item(**system_arguments, &block) ⇒ Object
37 38 39 |
# File 'app/components/primer/alpha/action_menu/sub_menu_item.rb', line 37 def with_item(**system_arguments, &block) @sub_menu.with_item(form_arguments: @form_arguments, **system_arguments, &block) end |
#with_sub_menu_item(**system_arguments, &block) ⇒ Object
49 50 51 |
# File 'app/components/primer/alpha/action_menu/sub_menu_item.rb', line 49 def (**system_arguments, &block) @sub_menu.(form_arguments: @form_arguments, **system_arguments, &block) end |