Class: Primer::Alpha::ActionMenu::SubMenu

Inherits:
Menu
  • Object
show all
Defined in:
app/components/primer/alpha/action_menu/sub_menu.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_ANCHOR_ALIGN =
:start
DEFAULT_ANCHOR_SIDE =
:outside_right

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

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

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 Menu

#anchor_align, #anchor_side, #form_arguments, #list, #menu_id, #preload, #select_variant, #src

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from Primer::AttributesHelper

#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Methods included from ExperimentalSlotHelpers

included

Methods included from ExperimentalRenderHelpers

included

Constructor Details

#initialize(menu_id: self.class.generate_id, anchor_align: DEFAULT_ANCHOR_ALIGN, anchor_side: DEFAULT_ANCHOR_SIDE, overlay_arguments: {}, **system_arguments) ⇒ SubMenu



49
50
51
52
53
54
55
56
57
58
# File 'app/components/primer/alpha/action_menu/sub_menu.rb', line 49

def initialize(
  menu_id: self.class.generate_id,
  anchor_align: DEFAULT_ANCHOR_ALIGN,
  anchor_side: DEFAULT_ANCHOR_SIDE,
  overlay_arguments: {},
  **system_arguments
)
  overlay_arguments[:anchor] = "#{menu_id}-button"
  super
end

Instance Method Details

#itemsArray<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/sub_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/sub_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/sub_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/sub_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/sub_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.



63
64
65
66
67
68
69
70
# File 'app/components/primer/alpha/action_menu/sub_menu.rb', line 63

def with_sub_menu_item(**system_arguments, &block)
  super(
    anchor_align: anchor_align, # carry over to sub-menus
    anchor_side: anchor_side, # carry over to sub-menus
    **system_arguments,
    &block
  )
end