module Shipyard::AlertHelper
Public Instance Methods
flash_alert(*args, &block)
click to toggle source
# 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 content_tag :div, options do concat content_tag(:p, raw(alert_txt), class: 'alert-txt') if dismissible concat content_tag(:button, icon(:x, class: 'alert-close-icon icon-outline-inverse center'), class: 'alert-close center-v', shipyard: 'alert-close' ) end end end
Private Instance Methods
alert_type(type)
click to toggle source
# File lib/shipyard-framework/helpers/alert_helper.rb, line 46 def alert_type(type) case type.to_sym when :notice then :success when :alert then :error else type.to_s.tr('_', '-') end end