Class: Blacklight::System::FlashMessageComponent
- Inherits:
 - 
      Component
      
        
- Object
 - ViewComponent::Base
 - Component
 - Blacklight::System::FlashMessageComponent
 
 
- Defined in:
 - app/components/blacklight/system/flash_message_component.rb
 
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
- #alert_class(type) ⇒ Object
 - #before_render ⇒ Object
 - 
  
    
      #button_contents  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Bootstrap 4 requires the span, but Bootstrap 5 should not have it.
 - 
  
    
      #initialize(type:, message: nil)  ⇒ FlashMessageComponent 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of FlashMessageComponent.
 
Methods inherited from Component
Constructor Details
#initialize(type:, message: nil) ⇒ FlashMessageComponent
Returns a new instance of FlashMessageComponent.
      10 11 12 13  | 
    
      # File 'app/components/blacklight/system/flash_message_component.rb', line 10 def initialize(type:, message: nil) @message = @classes = alert_class(type) end  | 
  
Instance Method Details
#alert_class(type) ⇒ Object
      28 29 30 31 32 33 34 35 36  | 
    
      # File 'app/components/blacklight/system/flash_message_component.rb', line 28 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  | 
  
#before_render ⇒ Object
      15 16 17  | 
    
      # File 'app/components/blacklight/system/flash_message_component.rb', line 15 def before_render { @message } if @message end  | 
  
#button_contents ⇒ Object
Bootstrap 4 requires the span, but Bootstrap 5 should not have it. See getbootstrap.com/docs/4.6/components/alerts/#dismissing
https://getbootstrap.com/docs/5.1/components/alerts/#dismissing
  
      22 23 24 25 26  | 
    
      # File 'app/components/blacklight/system/flash_message_component.rb', line 22 def return if helpers.controller.blacklight_config.bootstrap_version == 5 tag.span '×'.html_safe, aria: { hidden: true } end  |