Class: Railsboot::Toast::HeaderComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/toast/header_component.rb

Overview

ViewComponent: renders the header block.

Instance Method Summary collapse

Constructor Details

#initialize(**html_attributes) ⇒ HeaderComponent

Returns a new instance of HeaderComponent.



4
5
6
7
8
9
10
11
12
# File 'app/components/railsboot/toast/header_component.rb', line 4

def initialize(**html_attributes)
  @html_attributes = html_attributes

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

Instance Method Details

#callObject



14
15
16
17
18
# File 'app/components/railsboot/toast/header_component.rb', line 14

def call
  render(Railsboot::BaseComponent.new(**@html_attributes)) do
    content.to_s + render(Railsboot::CloseButtonComponent.new(data: { bs_dismiss: "toast" }))
  end
end