Class: Primer::Alpha::Dropdown

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

Overview

‘Dropdown` is a lightweight context menu for housing navigation and actions. They’re great for instances where you don’t need the full power (and code) of the SelectMenu.

Defined Under Namespace

Classes: Menu

Constant Summary

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 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, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initialize(overlay: :default, with_caret: false, **system_arguments) ⇒ Dropdown

Returns a new instance of Dropdown.

Parameters:

  • overlay (Symbol) (defaults to: :default)

    <%= one_of(Primer::Beta::Details::OVERLAY_MAPPINGS.keys) %>

  • with_caret (Boolean) (defaults to: false)

    Whether or not a caret should be rendered in the button.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



32
33
34
35
36
37
38
39
40
41
42
# File 'app/components/primer/alpha/dropdown.rb', line 32

def initialize(overlay: :default, with_caret: false, **system_arguments)
  @with_caret = with_caret

  @system_arguments = system_arguments
  @system_arguments[:overlay] = overlay
  @system_arguments[:reset] = true
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "dropdown"
  )
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/components/primer/alpha/dropdown.rb', line 44

def render?
  button? && menu?
end