Class: UI::DialogContentComponent

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

Overview

Dialog content component (ViewComponent) Main content area for the dialog

Examples:

<%= render UI::ContentComponent.new do %>
  <!-- Content -->
<% end %>

Instance Method Summary collapse

Methods included from DialogContentBehavior

#dialog_content_base_classes, #dialog_content_classes, #dialog_content_data_attributes, #dialog_content_html_attributes, #merged_dialog_content_data_attributes

Constructor Details

#initialize(open: false, classes: "", **attributes) ⇒ DialogContentComponent

Returns a new instance of DialogContentComponent.

Parameters:

  • open (Boolean) (defaults to: false)

    whether the dialog is open

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

    additional CSS classes

  • attributes (Hash)

    additional HTML attributes



16
17
18
19
20
# File 'app/view_components/ui/dialog_content_component.rb', line 16

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

Instance Method Details

#callObject



22
23
24
25
26
27
# File 'app/view_components/ui/dialog_content_component.rb', line 22

def call
  attrs = dialog_content_html_attributes
  attrs[:data] = attrs[:data].merge(@attributes.fetch(:data, {}))

   :div, content, **attrs.merge(@attributes.except(:data))
end