Class: UI::CommandGroupComponent

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

Instance Method Summary collapse

Methods included from CommandGroupBehavior

#command_group_classes, #command_group_data_attributes, #command_group_heading_classes, #command_group_html_attributes

Constructor Details

#initialize(heading: nil, classes: "", **attributes) ⇒ CommandGroupComponent

Returns a new instance of CommandGroupComponent.



6
7
8
9
10
11
# File 'app/view_components/ui/command_group_component.rb', line 6

def initialize(heading: nil, classes: "", **attributes)
  @heading = heading
  @heading_id = "command-group-#{SecureRandom.hex(4)}" if heading
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
# File 'app/view_components/ui/command_group_component.rb', line 13

def call
  (:div, **command_group_html_attributes.deep_merge(@attributes)) do
    safe_join([
      (@heading ? (:div, @heading, class: command_group_heading_classes, id: @heading_id) : nil),
      content
    ].compact)
  end
end