Class: BulmaPhlex::Message
- Inherits:
-
Base
- Object
- Base
- BulmaPhlex::Message
- 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
-
#initialize(header_text = nil, delete: nil, color: nil, size: nil, **html_attributes) ⇒ Message
constructor
A new instance of Message.
- #view_template ⇒ Object
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 skippeddelete— Iftrue, includes a delete button to dismiss the message. Can also be a hash of HTML attributes for the buttoncolor— 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_template ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/bulma_phlex/message.rb', line 31 def view_template(&) vanish(&) article(**mix({ class: }, **@html_attributes)) do unless @header_text.nil? (&) end end |