Class: Primer::Beta::ButtonGroup::MenuButton
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Primer::Beta::ButtonGroup::MenuButton
- Defined in:
- app/components/primer/beta/button_group.rb
Overview
Renders a button in a <%= link_to_component(Primer::Beta::ButtonGroup) %> that displays an <%= link_to_component(Primer::Alpha::ActionMenu) %> when clicked. This component should not be used outside of a ‘ButtonGroup` context.
This component yields both the button and the list to the block when rendered.
“‘erb <%= render(Primer::Beta::ButtonGroup.new) do |group| %>
<% group.with_menu_button do |menu, button| %>
<% menu.with_item(label: "Item 1") %>
<% button.with_trailing_visual_icon(icon: "triangle-down") %>
<% end %>
<% end %> “‘
Constant Summary
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
- #before_render ⇒ Object
- #call ⇒ Object
-
#initialize(menu_arguments: {}, button_arguments: {}) ⇒ MenuButton
constructor
A new instance of MenuButton.
- #render_in(view_context, &block) ⇒ Object
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(menu_arguments: {}, button_arguments: {}) ⇒ MenuButton
Returns a new instance of MenuButton.
105 106 107 108 |
# File 'app/components/primer/beta/button_group.rb', line 105 def initialize(menu_arguments: {}, button_arguments: {}) @menu = Primer::Alpha::ActionMenu.new(**) @button = @menu.(icon: "triangle-down", **) end |
Instance Method Details
#before_render ⇒ Object
116 117 118 |
# File 'app/components/primer/beta/button_group.rb', line 116 def before_render content end |
#call ⇒ Object
120 121 122 |
# File 'app/components/primer/beta/button_group.rb', line 120 def call render(@menu) end |
#render_in(view_context, &block) ⇒ Object
110 111 112 113 114 |
# File 'app/components/primer/beta/button_group.rb', line 110 def render_in(view_context, &block) super(view_context) do block.call(@menu, @button) end end |