Sha256: 3837ccc17cfdfcb9f7ca59d66050ebdc152d503b74bedf046e3d476517dff6de

Contents?: true

Size: 679 Bytes

Versions: 8

Compression:

Stored size: 679 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  module System
    class FlashMessageComponent < ViewComponent::Base
      renders_one :message

      with_collection_parameter :message

      def initialize(message: nil, type:)
        @message = message
        @classes = alert_class(type)
      end

      def before_render
        with_message { @message } if @message
      end

      def alert_class(type)
        case type.to_s
        when 'success' then "alert-success"
        when 'notice'  then "alert-info"
        when 'alert'   then "alert-warning"
        when 'error'   then "alert-danger"
        else "alert-#{type}"
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
blacklight-7.38.0 app/components/blacklight/system/flash_message_component.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/components/blacklight/system/flash_message_component.rb
blacklight-7.37.0 app/components/blacklight/system/flash_message_component.rb
blacklight-7.36.2 app/components/blacklight/system/flash_message_component.rb
blacklight-7.36.1 app/components/blacklight/system/flash_message_component.rb
blacklight-7.36.0 app/components/blacklight/system/flash_message_component.rb
blacklight-7.35.0 app/components/blacklight/system/flash_message_component.rb
blacklight-7.34.0 app/components/blacklight/system/flash_message_component.rb