Class: Primer::Alpha::ActionMenu::List

Inherits:
Component
  • Object
show all
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 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 collapse

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(**system_arguments) ⇒ List

Returns a new instance of List.

Parameters:

  • system_arguments (Hash)

    The arguments accepted by <%= link_to_component(Primer::Alpha::ActionList) %>



15
16
17
18
19
20
# File 'app/components/primer/alpha/action_menu/list.rb', line 15

def initialize(**system_arguments)
  @items = []
  @has_group = false

  @list = Primer::Alpha::ActionMenu::ListWrapper.new(**system_arguments)
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



12
13
14
# File 'app/components/primer/alpha/action_menu/list.rb', line 12

def items
  @items
end

Instance Method Details

#with_avatar_item(**system_arguments, &block) ⇒ Object



40
41
42
43
44
45
46
# File 'app/components/primer/alpha/action_menu/list.rb', line 40

def with_avatar_item(**system_arguments, &block)
  @items << {
    type: :avatar_item,
    kwargs: organize_arguments(**system_arguments),
    block: block
  }
end

#with_divider(**system_arguments, &block) ⇒ Object



48
49
50
51
52
53
54
# File 'app/components/primer/alpha/action_menu/list.rb', line 48

def with_divider(**system_arguments, &block)
  @items << {
    type: :divider,
    kwargs: system_arguments,
    block: block
  }
end

#with_group(**system_arguments, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'app/components/primer/alpha/action_menu/list.rb', line 22

def with_group(**system_arguments, &block)
  @has_group = true

  @items << {
    type: :group,
    kwargs: system_arguments,
    block: block
  }
end

#with_item(**system_arguments, &block) ⇒ Object



32
33
34
35
36
37
38
# File 'app/components/primer/alpha/action_menu/list.rb', line 32

def with_item(**system_arguments, &block)
  @items << {
    type: :item,
    kwargs: organize_arguments(**system_arguments),
    block: block
  }
end