class Primer::Alpha::ActionBar

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

def before_render

def before_render
  @system_arguments[:tag] = render_overflow_menu? ? :"action-bar" : :div
  @system_arguments[:classes] = class_names(
    @system_arguments[:classes],
    "overflow-visible": !render_overflow_menu?
  )
  content
end

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

Parameters:
  • system_arguments (Hash) -- <%= link_to_system_arguments_docs %>
  • overflow_menu (Boolean) -- Whether to render the overflow menu.
  • size (Symbol) -- <%= one_of(Primer::Alpha::ActionBar::SIZE_OPTIONS) %>
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

def render?

def render?
  items.any?
end

def render_overflow_menu?

def render_overflow_menu?
  @overflow_menu && items.count > 3
end

def with_menu_item(id:, **system_arguments, &block)

def with_menu_item(id:, **system_arguments, &block)
  return unless @overflow_menu
  system_arguments = {
    **system_arguments,
    hidden: true,
    "data-for": id,
    "data-action": "click:action-bar#menuItemClick"
  }
  @action_menu.with_item(
    value: "",
    **system_arguments,
    &block
  )
end