Class: Primer::Alpha::ActionMenu::List
- Inherits:
-
Primer::Alpha::ActionList
- Object
- ViewComponent::Base
- Component
- Primer::Alpha::ActionList
- Primer::Alpha::ActionMenu::List
- Defined in:
- app/components/primer/alpha/action_menu/list.rb
Overview
This component is part of <%= link_to_component(Primer::Alpha::ActionMenu) %> and should not be used as a standalone component.
Constant Summary collapse
- DEFAULT_ITEM_TAG =
:button
- ITEM_TAG_OPTIONS =
[:a, :"clipboard-copy", DEFAULT_ITEM_TAG].freeze
Constants inherited from Primer::Alpha::ActionList
Primer::Alpha::ActionList::DEFAULT_MENU_ITEM_ROLE, Primer::Alpha::ActionList::DEFAULT_ROLE, Primer::Alpha::ActionList::DEFAULT_SCHEME, Primer::Alpha::ActionList::DEFAULT_SELECT_VARIANT, Primer::Alpha::ActionList::MENU_ROLE, Primer::Alpha::ActionList::SCHEME_MAPPINGS, Primer::Alpha::ActionList::SCHEME_OPTIONS, Primer::Alpha::ActionList::SELECT_VARIANT_OPTIONS, Primer::Alpha::ActionList::SELECT_VARIANT_ROLE_MAP
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
Instance Method Summary collapse
-
#initialize(menu_id:, **system_arguments, &block) ⇒ List
constructor
A new instance of List.
-
#with_avatar_item(src:, username:, full_name: nil, full_name_scheme: Primer::Alpha::ActionList::Item::DEFAULT_DESCRIPTION_SCHEME, data: {}, avatar_arguments: {}, **system_arguments, &block) ⇒ Object
Adds an avatar item to the list.
-
#with_item(data: {}, **system_arguments, &block) ⇒ Object
Adds a new item to the list.
Methods inherited from Primer::Alpha::ActionList
#acts_as_form_input?, #acts_as_menu?, #allows_selection?, #before_render, #build_avatar_item, #build_item, custom_element_name, #custom_element_name, #multi_select?, #required_form_arguments_given?, #single_select?, #will_add_item, #with_divider
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, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Constructor Details
#initialize(menu_id:, **system_arguments, &block) ⇒ List
Returns a new instance of List.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/components/primer/alpha/action_menu/list.rb', line 44 def initialize(menu_id:, **system_arguments, &block) @menu_id = system_arguments[:aria] = merge_aria( system_arguments, { aria: { labelledby: "#{@menu_id}-button" } } ) system_arguments[:role] = :menu system_arguments[:scheme] = :inset system_arguments[:id] = "#{@menu_id}-list" super(**system_arguments, &block) end |
Instance Method Details
#with_avatar_item(src:, username:, full_name: nil, full_name_scheme: Primer::Alpha::ActionList::Item::DEFAULT_DESCRIPTION_SCHEME, data: {}, avatar_arguments: {}, **system_arguments, &block) ⇒ Object
Adds an avatar item to the list. Avatar items are a convenient way to accessibly add an item with a leading avatar image.
34 35 36 37 38 39 40 |
# File 'app/components/primer/alpha/action_menu/list.rb', line 34 def with_avatar_item(src:, username:, full_name: nil, full_name_scheme: Primer::Alpha::ActionList::Item::DEFAULT_DESCRIPTION_SCHEME, data: {}, avatar_arguments: {}, **system_arguments, &block) system_arguments = organize_arguments(data: data, **system_arguments) super(src: src, username: username, full_name: full_name, full_name_scheme: full_name_scheme, avatar_arguments: avatar_arguments, **system_arguments) do |item| evaluate_block(item, &block) end end |
#with_item(data: {}, **system_arguments, &block) ⇒ Object
Adds a new item to the list.
17 18 19 20 21 22 23 |
# File 'app/components/primer/alpha/action_menu/list.rb', line 17 def with_item(data: {}, **system_arguments, &block) system_arguments = organize_arguments(data: data, **system_arguments) super(**system_arguments) do |item| evaluate_block(item, &block) end end |