Class: Primer::Alpha::ActionMenu::PrimaryMenu
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_ANCHOR_ALIGN =
:start- DEFAULT_ANCHOR_SIDE =
:outside_bottom
Constants inherited from Menu
Menu::DEFAULT_PRELOAD, Menu::DEFAULT_SELECT_VARIANT, Menu::SELECT_VARIANT_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 collapse
-
#dynamic_label ⇒ Object
readonly
Returns the value of attribute dynamic_label.
-
#dynamic_label_prefix ⇒ Object
readonly
Returns the value of attribute dynamic_label_prefix.
Attributes inherited from Menu
#anchor_align, #anchor_side, #form_arguments, #list, #menu_id, #preload, #select_variant, #src
Instance Method Summary collapse
-
#initialize(anchor_align: DEFAULT_ANCHOR_ALIGN, anchor_side: DEFAULT_ANCHOR_SIDE, dynamic_label: false, dynamic_label_prefix: nil, **system_arguments) ⇒ PrimaryMenu
constructor
A new instance of PrimaryMenu.
-
#items ⇒ Array<ViewComponent::Slot>
Gets the list of configured menu items, which includes regular items, avatar items, groups, and dividers.
-
#with_avatar_item(**system_arguments) ⇒ Object
Adds an avatar item to the menu.
-
#with_divider(**system_arguments) ⇒ Object
Adds a divider to the list.
-
#with_group(**system_arguments) ⇒ Object
Adds a group to the menu.
-
#with_item(**system_arguments) ⇒ Object
Adds an item to the menu.
-
#with_show_button(**system_arguments, &block) ⇒ Object
Button to activate the menu.
Methods inherited from Menu
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(anchor_align: DEFAULT_ANCHOR_ALIGN, anchor_side: DEFAULT_ANCHOR_SIDE, dynamic_label: false, dynamic_label_prefix: nil, **system_arguments) ⇒ PrimaryMenu
Returns a new instance of PrimaryMenu.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/components/primer/alpha/action_menu/primary_menu.rb', line 51 def initialize( anchor_align: DEFAULT_ANCHOR_ALIGN, anchor_side: DEFAULT_ANCHOR_SIDE, dynamic_label: false, dynamic_label_prefix: nil, **system_arguments ) @dynamic_label = dynamic_label @dynamic_label_prefix = dynamic_label_prefix system_arguments[:list_arguments] ||= {} system_arguments[:list_arguments][:data] = merge_data( system_arguments[:list_arguments], { data: { target: "action-menu.list" } } ) super( anchor_align: anchor_align, anchor_side: anchor_side, **system_arguments ) end |
Instance Attribute Details
#dynamic_label ⇒ Object (readonly)
Returns the value of attribute dynamic_label.
13 14 15 |
# File 'app/components/primer/alpha/action_menu/primary_menu.rb', line 13 def dynamic_label @dynamic_label end |
#dynamic_label_prefix ⇒ Object (readonly)
Returns the value of attribute dynamic_label_prefix.
13 14 15 |
# File 'app/components/primer/alpha/action_menu/primary_menu.rb', line 13 def dynamic_label_prefix @dynamic_label_prefix end |
Instance Method Details
#items ⇒ Array<ViewComponent::Slot>
Gets the list of configured menu items, which includes regular items, avatar items, groups, and dividers.
28 29 |
# File 'app/components/primer/alpha/action_menu/primary_menu.rb', line 28 def items end |
#with_avatar_item(**system_arguments) ⇒ Object
Adds an avatar item to the menu.
10 11 |
# File 'app/components/primer/alpha/action_menu/primary_menu.rb', line 10 def with_avatar_item(**system_arguments) end |
#with_divider(**system_arguments) ⇒ Object
Adds a divider to the list. Dividers visually separate items.
16 17 |
# File 'app/components/primer/alpha/action_menu/primary_menu.rb', line 16 def with_divider(**system_arguments) end |
#with_group(**system_arguments) ⇒ Object
Adds a group to the menu. Groups are a logical set of items with a header.
22 23 |
# File 'app/components/primer/alpha/action_menu/primary_menu.rb', line 22 def with_group(**system_arguments) end |
#with_item(**system_arguments) ⇒ Object
Adds an item to the menu.
4 5 |
# File 'app/components/primer/alpha/action_menu/primary_menu.rb', line 4 def with_item(**system_arguments) end |
#with_show_button(**system_arguments, &block) ⇒ Object
Button to activate the menu.
78 79 80 81 82 |
# File 'app/components/primer/alpha/action_menu/primary_menu.rb', line 78 def (**system_arguments, &block) .(**system_arguments, id: "#{@menu_id}-button", controls: "#{@menu_id}-list") do || evaluate_block(, &block) end end |