Class: BulmaPhlex::Message

Inherits:
Base
  • Object
show all
Defined in:
lib/bulma_phlex/message.rb

Overview

Renders a Bulma message component with a header, optional delete button, and body.

The component generates an article element and supports color and size options, as well as any additional html attributes.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header_text = nil, delete: nil, color: nil, size: nil, **html_attributes) ⇒ Message

Returns a new instance of Message.



22
23
24
25
26
27
28
29
# File 'lib/bulma_phlex/message.rb', line 22

def initialize(header_text = nil, delete: nil, color: nil, size: nil, **html_attributes)
  @header_text = header_text
  @delete = delete
  @color = color
  @size = size
  @html_attributes = html_attributes
  after_initialize
end

Class Method Details

.new(header_text = nil, delete: nil, color: nil, size: nil, **html_attributes) ⇒ Object

Parameters

  • header_text (positional, optional) — If not provided, the header will be skipped
  • delete — If true, includes a delete button to dismiss the message. Can also be a hash of HTML attributes for the button
  • color — Color of the notification (e.g. "primary", "info", "danger")
  • size"small", "normal" (the default), "medium" or "large"
  • **html_attributes — Additional HTML attributes for the notification element


18
19
20
# File 'lib/bulma_phlex/message.rb', line 18

def self.new(header_text = nil, delete: nil, color: nil, size: nil, **html_attributes)
  super
end

Instance Method Details

#view_templateObject



31
32
33
34
35
36
37
38
# File 'lib/bulma_phlex/message.rb', line 31

def view_template(&)
  vanish(&)

  article(**mix({ class: message_classes }, **@html_attributes)) do
    message_header unless @header_text.nil?
    message_body(&)
  end
end