Module: Shipyard::AlertHelper

Includes:
ActionView::Context, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, IconHelper
Included in:
Jekyll::Alert
Defined in:
lib/shipyard-framework/helpers/alert_helper.rb

Instance Method Summary collapse

Methods included from IconHelper

#icon

Instance Method Details

#flash_alert(*args, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/shipyard-framework/helpers/alert_helper.rb', line 10

def flash_alert(*args, &block)
  alert_txt = capture(&block) if block_given?
  options = {}
  options[:role] ||= 'alert'
  class_list = ['alert']
  dismissible = false

  args.each do |arg|
    if arg == :dismissible
      dismissible = true
      options[:shipyard] = 'alert'
    elsif arg.is_a? Symbol
      class_list << "alert-#{alert_type(arg)}"
    elsif arg.is_a? Hash
      options = options.merge(arg) if arg.is_a?(Hash)
    else
      alert_txt = arg
    end
  end

  options[:class] = "#{class_list.join(' ')} #{options[:class]}".strip

   :div, options do
    concat (:p, raw(alert_txt), class: 'alert-txt')
    if dismissible
      concat (:button,
               icon(:x, class: 'alert-close-icon icon-outline-inverse center'),
               class: 'alert-close center-v',
               shipyard: 'alert-close'
             )
    end
  end
end