Class: Primer::Dropdown::MenuComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/dropdown/menu_component.rb

Overview

This component is part of ‘Primer::DropdownComponent` and should not be used as a standalone component.

Constant Summary collapse

SCHEME_DEFAULT =
:default
SCHEME_MAPPINGS =
{
  SCHEME_DEFAULT => "",
  :dark => "dropdown-menu-dark"
}.freeze
DIRECTION_DEFAULT =
:se
DIRECTION_OPTIONS =
[DIRECTION_DEFAULT, :sw, :w, :e, :ne, :s].freeze

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

Instance Method Summary collapse

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

Constructor Details

#initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments) ⇒ MenuComponent

Returns a new instance of MenuComponent.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/components/primer/dropdown/menu_component.rb', line 29

def initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
  @header = header
  @direction = direction
  @system_arguments = 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