Class: Railsboot::Modal::BodyComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/modal/body_component.rb

Overview

ViewComponent: renders the body block.

Instance Method Summary collapse

Constructor Details

#initialize(**html_attributes) ⇒ BodyComponent

Returns a new instance of BodyComponent.

Parameters:

  • html_attributes (Hash)

    additional HTML attributes applied to the rendered element

Options Hash (**html_attributes):

  • :class (String)

    additional CSS classes, merged with the component's own classes



6
7
8
9
10
11
12
13
# File 'app/components/railsboot/modal/body_component.rb', line 6

def initialize(**html_attributes)
  @html_attributes = html_attributes

  @html_attributes[:class] = class_names(
    "modal-body",
    html_attributes.delete(:class)
  )
end

Instance Method Details

#callString

Renders the modal body as a div containing the component content.

Returns:

  • (String)

    the rendered HTML



17
18
19
# File 'app/components/railsboot/modal/body_component.rb', line 17

def call
  render(Railsboot::BaseComponent.new(tag: "div", **@html_attributes)) { content }
end