Class: UI::SelectGroupComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
SelectGroupBehavior
Defined in:
app/view_components/ui/select_group_component.rb

Overview

GroupComponent - ViewComponent implementation

Container for grouping select items with a label.

Examples:

Basic usage

<%= render UI::GroupComponent.new do %>
  <%= render UI::LabelComponent.new { "North America" } %>
  <%= render UI::ItemComponent.new(value: "america/new_york") { "Eastern Time" } %>
  <%= render UI::ItemComponent.new(value: "america/chicago") { "Central Time" } %>
<% end %>

Instance Method Summary collapse

Methods included from SelectGroupBehavior

#select_group_classes, #select_group_html_attributes

Constructor Details

#initialize(classes: "", **attributes) ⇒ SelectGroupComponent

Returns a new instance of SelectGroupComponent.

Parameters:

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



18
19
20
21
# File 'app/view_components/ui/select_group_component.rb', line 18

def initialize(classes: "", **attributes)
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



23
24
25
# File 'app/view_components/ui/select_group_component.rb', line 23

def call
   :div, content, **select_group_html_attributes.deep_merge(@attributes)
end