Class: Primer::Alpha::ActionMenu::Menu
- Defined in:
- app/components/primer/alpha/action_menu/menu.rb
Overview
This component is part of <%= link_to_component(Primer::Alpha::ActionMenu) %> and should not be used as a standalone component.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_PRELOAD =
false- DEFAULT_SELECT_VARIANT =
:none- SELECT_VARIANT_OPTIONS =
[ :single, :multiple, DEFAULT_SELECT_VARIANT ].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
Constants included from Primer::AttributesHelper
Primer::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Primer::AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Attribute Summary collapse
-
#anchor_align ⇒ Object
readonly
Returns the value of attribute anchor_align.
-
#anchor_side ⇒ Object
readonly
Returns the value of attribute anchor_side.
-
#form_arguments ⇒ Object
readonly
Returns the value of attribute form_arguments.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#menu_id ⇒ Object
readonly
Returns the value of attribute menu_id.
-
#preload ⇒ Object
(also: #preload?)
readonly
Returns the value of attribute preload.
-
#select_variant ⇒ Object
readonly
Returns the value of attribute select_variant.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Instance Method Summary collapse
-
#initialize(anchor_align:, anchor_side:, menu_id: self.class.generate_id, size: Primer::Alpha::Overlay::DEFAULT_SIZE, src: nil, preload: DEFAULT_PRELOAD, select_variant: DEFAULT_SELECT_VARIANT, form_arguments: {}, overlay_arguments: {}, list_arguments: {}, **system_arguments) ⇒ Menu
constructor
A new instance of Menu.
-
#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_sub_menu_item(**system_arguments, &block) ⇒ Object
Adds a sub-menu to the 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:, anchor_side:, menu_id: self.class.generate_id, size: Primer::Alpha::Overlay::DEFAULT_SIZE, src: nil, preload: DEFAULT_PRELOAD, select_variant: DEFAULT_SELECT_VARIANT, form_arguments: {}, overlay_arguments: {}, list_arguments: {}, **system_arguments) ⇒ Menu
Returns a new instance of Menu.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'app/components/primer/alpha/action_menu/menu.rb', line 67 def initialize( anchor_align:, anchor_side:, menu_id: self.class.generate_id, size: Primer::Alpha::Overlay::DEFAULT_SIZE, src: nil, preload: DEFAULT_PRELOAD, select_variant: DEFAULT_SELECT_VARIANT, form_arguments: {}, overlay_arguments: {}, list_arguments: {}, **system_arguments ) = @src = src @preload = fetch_or_fallback_boolean(preload, DEFAULT_PRELOAD) @anchor_side = anchor_side @anchor_align = anchor_align @select_variant = fetch_or_fallback(SELECT_VARIANT_OPTIONS, select_variant, DEFAULT_SELECT_VARIANT) @form_arguments = form_arguments [:data] = merge_data( , data: { target: "action-menu.overlay" } ) = Primer::Alpha::Overlay.new( id: "#{@menu_id}-overlay", title: "Menu", visually_hide_title: true, anchor_align: anchor_align, anchor_side: anchor_side, size: size, ** ) @list = Primer::Alpha::ActionMenu::List.new( menu_id: , select_variant: select_variant, form_arguments: form_arguments, **list_arguments ) system_arguments # rubocop:disable Lint/Void end |
Instance Attribute Details
#anchor_align ⇒ Object (readonly)
Returns the value of attribute anchor_align.
19 20 21 |
# File 'app/components/primer/alpha/action_menu/menu.rb', line 19 def anchor_align @anchor_align end |
#anchor_side ⇒ Object (readonly)
Returns the value of attribute anchor_side.
19 20 21 |
# File 'app/components/primer/alpha/action_menu/menu.rb', line 19 def anchor_side @anchor_side end |
#form_arguments ⇒ Object (readonly)
Returns the value of attribute form_arguments.
19 20 21 |
# File 'app/components/primer/alpha/action_menu/menu.rb', line 19 def form_arguments @form_arguments end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
19 20 21 |
# File 'app/components/primer/alpha/action_menu/menu.rb', line 19 def list @list end |
#menu_id ⇒ Object (readonly)
Returns the value of attribute menu_id.
19 20 21 |
# File 'app/components/primer/alpha/action_menu/menu.rb', line 19 def end |
#preload ⇒ Object (readonly) Also known as: preload?
Returns the value of attribute preload.
19 20 21 |
# File 'app/components/primer/alpha/action_menu/menu.rb', line 19 def preload @preload end |
#select_variant ⇒ Object (readonly)
Returns the value of attribute select_variant.
19 20 21 |
# File 'app/components/primer/alpha/action_menu/menu.rb', line 19 def select_variant @select_variant end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
19 20 21 |
# File 'app/components/primer/alpha/action_menu/menu.rb', line 19 def src @src 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/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/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/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/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/menu.rb', line 4 def with_item(**system_arguments) end |
#with_sub_menu_item(**system_arguments, &block) ⇒ Object
Adds a sub-menu to the menu.
118 119 120 121 122 123 124 125 126 |
# File 'app/components/primer/alpha/action_menu/menu.rb', line 118 def (**system_arguments, &block) @list.with_item( component_klass: SubMenuItem, select_variant: select_variant, form_arguments: form_arguments, **system_arguments, &block ) end |