Class: BulmaPhlex::Notification

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

Overview

Renders a [Bulma notification](bulma.io/documentation/elements/notification/) component.

A styled alert box for displaying messages to the user. Supports color and **style mode** (light/dark) options, and optionally includes a **dismiss button** whose HTML attributes can be customized. Content is provided via a block.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delete: nil, color: nil, mode: nil, **html_attributes) ⇒ Notification

Returns a new instance of Notification.



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

def initialize(delete: nil, color: nil, mode: nil, **html_attributes)
  @delete = delete
  @color = color
  @mode = mode
  @html_attributes = html_attributes

  after_initialize
end

Class Method Details

.new(delete: nil, color: nil, mode: nil, **html_attributes) ⇒ Object

Parameters

  • ‘delete` — If `true`, includes a delete button to dismiss the notification. Can also be a hash of HTML

attributes for the button
  • ‘color` — Color of the notification (e.g. `“primary”`, `“info”`, `“danger”`)

  • ‘mode` — Style mode: `“light”` or `“dark”`

  • ‘**html_attributes` — Additional HTML attributes for the notification element



17
18
19
# File 'lib/bulma_phlex/notification.rb', line 17

def self.new(delete: nil, color: nil, mode: nil, **html_attributes)
  super
end

Instance Method Details

#view_templateObject



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

def view_template(&)
  vanish(&)

  div(**mix({ class: notification_classes }, **@html_attributes)) do
    delete_button if @delete
    yield
  end
end