Class: Satis::FlashMessages::Message

Inherits:
ApplicationComponent show all
Defined in:
app/components/satis/flash_messages/component.rb

Instance Attribute Summary collapse

Attributes inherited from ApplicationComponent

#original_view_context

Instance Method Summary collapse

Methods inherited from ApplicationComponent

add_helper, #component_name

Constructor Details

#initialize(message:, level: :alert, icon: nil) ⇒ Message

Returns a new instance of Message.



8
9
10
11
12
13
# File 'app/components/satis/flash_messages/component.rb', line 8

def initialize(message:, level: :alert, icon: nil)
  super
  @message = message
  @level = level
  @icon = icon
end

Instance Attribute Details

#iconObject (readonly)

Returns the value of attribute icon.



6
7
8
# File 'app/components/satis/flash_messages/component.rb', line 6

def icon
  @icon
end

#levelObject (readonly)

Returns the value of attribute level.



6
7
8
# File 'app/components/satis/flash_messages/component.rb', line 6

def level
  @level
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'app/components/satis/flash_messages/component.rb', line 6

def message
  @message
end

Instance Method Details

#color_classObject



15
16
17
18
19
20
21
22
23
24
# File 'app/components/satis/flash_messages/component.rb', line 15

def color_class
  case level.to_sym
  when :alert
    :'bg-red-500'
  when :notice
    :'bg-green-500'
  else
    :'bg-yellow-500'
  end
end