Sha256: 56ed0bc53a7efae08c076527dd4a428018c593e77112a7868bd8d431e4f1062c

Contents?: true

Size: 1.07 KB

Versions: 24

Compression:

Stored size: 1.07 KB

Contents

module AmaLayout
  class NotificationDecorator
    include AmaLayout::DraperReplacement

    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

24 entries across 24 versions & 1 rubygems

Version Path
ama_layout-11.5.1 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-11.5.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-11.4.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-11.3.1 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-11.3.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-11.2.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-11.1.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-10.2.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-10.1.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-10.0.1 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-9.5.3 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-9.5.2 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-9.5.1 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-9.5.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-9.4.1 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-9.4.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-9.3.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-9.2.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-9.1.0 lib/ama_layout/decorators/notification_decorator.rb
ama_layout-9.0.0 lib/ama_layout/decorators/notification_decorator.rb