Class: PandaCms::Admin::FlashMessageComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/panda_cms/admin/flash_message_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message:, kind:) ⇒ FlashMessageComponent

Returns a new instance of FlashMessageComponent.



8
9
10
11
# File 'app/components/panda_cms/admin/flash_message_component.rb', line 8

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

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



6
7
8
# File 'app/components/panda_cms/admin/flash_message_component.rb', line 6

def kind
  @kind
end

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'app/components/panda_cms/admin/flash_message_component.rb', line 6

def message
  @message
end

Instance Method Details

#icon_cssObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/components/panda_cms/admin/flash_message_component.rb', line 28

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

#text_colour_cssObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/components/panda_cms/admin/flash_message_component.rb', line 13

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