Class: UI::InputGroupButtonComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::InputGroupButtonComponent
- Includes:
- InputGroupButtonBehavior
- Defined in:
- app/view_components/ui/input_group_button_component.rb
Overview
InputGroupButtonComponent - ViewComponent implementation
A button component specifically styled for use within input groups. Uses InputGroupButtonBehavior concern for shared styling logic.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(size: "xs", variant: "ghost", type: "button", classes: "", **attributes) ⇒ InputGroupButtonComponent
constructor
A new instance of InputGroupButtonComponent.
Methods included from InputGroupButtonBehavior
#input_group_button_attributes, #input_group_button_classes, #input_group_button_html_attributes
Constructor Details
#initialize(size: "xs", variant: "ghost", type: "button", classes: "", **attributes) ⇒ InputGroupButtonComponent
Returns a new instance of InputGroupButtonComponent.
25 26 27 28 29 30 31 |
# File 'app/view_components/ui/input_group_button_component.rb', line 25 def initialize(size: "xs", variant: "ghost", type: "button", classes: "", **attributes) @size = size @variant = variant @type = type @classes = classes @attributes = attributes end |
Instance Method Details
#call ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/view_components/ui/input_group_button_component.rb', line 33 def call # Get base attributes from behavior (type, variant, classes) base_attrs = # Extract button-specific params that ui/button accepts as direct arguments = { type: base_attrs[:type], variant: base_attrs[:variant], classes: base_attrs[:classes], content: content } # Merge additional HTML attributes (data, role, aria, tabindex, etc.) into attributes hash html_attrs = base_attrs.except(:type, :variant, :classes, :"data-size") [:attributes] = html_attrs unless html_attrs.empty? render partial: "ui/button", locals: end |