Sha256: 48d2345b3c2f8305de7c0c740261193ad19adc55245ec01fafee0034671769a0

Contents?: true

Size: 1022 Bytes

Versions: 3

Compression:

Stored size: 1022 Bytes

Contents

# frozen_string_literal: true

module Panda
  module CMS
    module Admin
      class FlashMessageComponent < ::ViewComponent::Base
        attr_reader :kind, :message

        def initialize(message:, kind:, temporary: true)
          @kind = kind.to_sym
          @message = message
          @temporary = temporary
        end

        def text_colour_css
          case kind
          when :success
            "text-active"
          when :alert, :error
            "text-error"
          when :warning
            "text-warning"
          when :info, :notice
            "text-active"
          else
            "text-mid"
          end
        end

        def icon_css
          case kind
          when :success
            "fa-circle-check"
          when :alert
            "fa-circle-xmark"
          when :warning
            "fa-triangle-exclamation"
          when :info, :notice
            "fa-circle-info"
          else
            "fa-circle-info"
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
panda-cms-0.7.3 app/components/panda/cms/admin/flash_message_component.rb
panda-cms-0.7.2 app/components/panda/cms/admin/flash_message_component.rb
panda-cms-0.7.0 app/components/panda/cms/admin/flash_message_component.rb