Sha256: 0bf8c8e874f2da1ef4157f289c04a098e8260808c1ddca807d8eb50b62f4fdc3
Contents?: true
Size: 1.07 KB
Versions: 6
Compression:
Stored size: 1.07 KB
Contents
module AmaLayout class NotificationDecorator < Draper::Decorator delegate_all ICONS = { notice: { icon_class: 'fa-info', colour_class: 'right-sidebar__content-icon--blue' # currently not in use }, warning: { icon_class: 'fa-exclamation', colour_class: 'right-sidebar__content-icon--orange' }, alert: { icon_class: 'fa-exclamation-triangle', colour_class: 'right-sidebar__content-icon--red' } }.freeze def created_at "#{time_elapsed} ago".humanize end def icon h.content_tag :div, class: icon_data.fetch(:colour_class) do klass = icon_data.fetch(:icon_class) h.content_tag :i, nil, class: "fa #{klass} right-sidebar__notice-icon" end end def active_class active? ? 'right-sidebar__content--active' : 'right-sidebar__content--inactive' end private def icon_data @icon_data ||= ICONS.fetch(type) end def time_elapsed h.time_ago_in_words(object.created_at, include_seconds: true) end end end
Version data entries
6 entries across 6 versions & 1 rubygems