Class: Primer::Alpha::ActionBar

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/alpha/action_bar.rb,
app/components/primer/alpha/action_bar/item.rb,
app/components/primer/alpha/action_bar/divider.rb

Overview

Add a general description of component here Add additional usage considerations or best practices that may aid the user to use the component correctly.

Defined Under Namespace

Classes: Divider, Item

Constant Summary collapse

DEFAULT_SIZE =
:medium
SIZE_MAPPINGS =
{
  DEFAULT_SIZE => nil,
  :small => "ActionBar--small",
  :large => "ActionBar--large"
}.freeze
SIZE_OPTIONS =
SIZE_MAPPINGS.keys.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 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(size: Primer::Alpha::ActionBar::DEFAULT_SIZE, overflow_menu: true, **system_arguments) ⇒ ActionBar

Returns a new instance of ActionBar.

Parameters:

  • size (Symbol) (defaults to: Primer::Alpha::ActionBar::DEFAULT_SIZE)

    <%= one_of(Primer::Alpha::ActionBar::SIZE_OPTIONS) %>

  • overflow_menu (Boolean) (defaults to: true)

    Whether to render the overflow menu.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/components/primer/alpha/action_bar.rb', line 37

def initialize(size: Primer::Alpha::ActionBar::DEFAULT_SIZE, overflow_menu: true, **system_arguments)
  @system_arguments = system_arguments
  @overflow_menu = overflow_menu

  @size = fetch_or_fallback(Primer::Alpha::ActionBar::SIZE_OPTIONS, size, Primer::Alpha::ActionBar::DEFAULT_SIZE)

  @system_arguments[:classes] = class_names(
    system_arguments[:classes],
    "ActionBar",
    SIZE_MAPPINGS[@size]
  )
  @system_arguments[:role] = "toolbar"

  return unless overflow_menu

  @action_menu = Primer::Alpha::ActionMenu.new(
    menu_id: self.class.generate_id,
    "data-target": "action-bar.moreMenu",
    hidden: true,
    classes: "ActionBar-more-menu",
    anchor_align: :end
  )
end