class UiBibz::Ui::Core::Notifications::Alert

Create an alert

This element is an extend of UiBibz::Ui::Core::Component.

Attributes

Options

You can add HTML attributes using the html_options. You can pass arguments in options attribute:

Signatures

UiBibz::Ui::Core::Alert.new(content, options = nil, html_options = nil)

UiBibz::Ui::Core::Alert.new(options = nil, html_options = nil) do
  content
end

Examples

UiBibz::Ui::Core::Alert.new(content, { status: :success, glyph: 'eye' },{ class: 'test' }).render

UiBibz::Ui::Core::Alert.new({glyph: { name: 'eye', size: 3}, { class: 'test' }) do
  content
end.render

Helper

notify(content, options = {}, html_options = {})

notify(options = {}, html_options = {}) do
  content
end

Public Class Methods

new(content = nil, options = nil, html_options = nil, &block) click to toggle source

See UiBibz::Ui::Core::Component.initialize

Calls superclass method UiBibz::Ui::Core::Component::new
# File lib/ui_bibz/ui/core/notifications/alert.rb, line 52
def initialize(content = nil, options = nil, html_options = nil, &block)
  super
  header(@content, tap: false) unless @tapped
end

Public Instance Methods

body(content = nil, options = nil, html_options = nil, &block) click to toggle source

Add Body which is a component

# File lib/ui_bibz/ui/core/notifications/alert.rb, line 77
def body(content = nil, options = nil, html_options = nil, &block)
  @body = UiBibz::Ui::Core::Notifications::Components::AlertBody.new(content, options, html_options, &block).render
end
header(content = nil, options = nil, html_options = nil, &block) click to toggle source

Add Header which is a component

# File lib/ui_bibz/ui/core/notifications/alert.rb, line 66
def header(content = nil, options = nil, html_options = nil, &block)
  if block.nil?
    options = @options.merge(options || {})
  else
    content = @options.merge(content || {})
  end

  @header = UiBibz::Ui::Core::Notifications::Components::AlertHeader.new(content, options, html_options, &block).render
end
pre_render() click to toggle source

Render html tag

# File lib/ui_bibz/ui/core/notifications/alert.rb, line 58
def pre_render
  content_tag :div, html_options do
    concat @header
    concat @body unless @body.nil?
  end
end

Private Instance Methods

component_html_classes() click to toggle source
# File lib/ui_bibz/ui/core/notifications/alert.rb, line 88
def component_html_classes
  %w[alert alert-dismissible]
end
component_html_data() click to toggle source
# File lib/ui_bibz/ui/core/notifications/alert.rb, line 83
def component_html_data
  super
  add_html_data 'timeout', value: options[:timeout] if options[:timeout]
end
component_html_options() click to toggle source
# File lib/ui_bibz/ui/core/notifications/alert.rb, line 92
def component_html_options
  { role: 'alert' }
end
status() click to toggle source
# File lib/ui_bibz/ui/core/notifications/alert.rb, line 96
def status
  "alert-#{options[:status] || :info}"
end