Method: Primer::Alpha::Dropdown::Menu#initialize

Defined in:
app/components/primer/alpha/dropdown/menu.rb

#initialize(as: AS_DEFAULT, direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments) ⇒ Menu

Returns a new instance of Menu.

Parameters:

  • as (Symbol) (defaults to: AS_DEFAULT)

    When ‘as` is `:list`, wraps the menu in a `<ul>` with a `<li>` for each item.

  • direction (Symbol) (defaults to: DIRECTION_DEFAULT)

    <%= one_of(Primer::Alpha::Dropdown::Menu::DIRECTION_OPTIONS) %>.

  • header (String) (defaults to: nil)

    Header to be displayed above the menu.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/components/primer/alpha/dropdown/menu.rb', line 34

def initialize(as: AS_DEFAULT, direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
  @header = header
  @direction = direction
  @as = fetch_or_fallback(AS_OPTIONS, as, AS_DEFAULT)

  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = "details-menu"
  @system_arguments[:role] = "menu"

  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "dropdown-menu",
    "dropdown-menu-#{fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT)}",
    SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, SCHEME_DEFAULT)]
  )
end