Class: Railsboot::Offcanvas::BodyComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/offcanvas/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

  • :tag (String)

    HTML tag to render for the element



7
8
9
10
11
12
13
14
15
# File 'app/components/railsboot/offcanvas/body_component.rb', line 7

def initialize(**html_attributes)
  @html_attributes = html_attributes

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

Instance Method Details

#callString

Renders the offcanvas body wrapper around the provided content.

Returns:

  • (String)

    the rendered HTML for the offcanvas body



19
20
21
# File 'app/components/railsboot/offcanvas/body_component.rb', line 19

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