Class: Essence::NotificationComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/essence/notification_component.rb

Constant Summary collapse

DEFAULT_VARIANT =
:info
VARIANT_MAPPINGS =
{
  :success => 'notification-success',
  DEFAULT_VARIANT => 'notification-info',
  :warning => 'notification-warning',
  :danger => 'notification-danger'
}.freeze
VARIANT_OPTIONS =
VARIANT_MAPPINGS.keys.freeze
ICON_MAPPINGS =
{
  :success => 'circle_check',
  DEFAULT_VARIANT => 'circle_info',
  :warning => 'circle_exclamation',
  :danger => 'circle_xmark'
}.freeze

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationComponent

#assets_path, assets_path, images_directory

Methods included from Utils

#get_directory_file_names

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #integer_or_fallback

Constructor Details

#initialize(variant: DEFAULT_VARIANT, **html_options) ⇒ NotificationComponent

Returns a new instance of NotificationComponent.



25
26
27
28
29
# File 'app/components/essence/notification_component.rb', line 25

def initialize(variant: DEFAULT_VARIANT,
               **html_options)
  @variant      = fetch_or_fallback(VARIANT_OPTIONS, variant.to_sym, DEFAULT_VARIANT)
  @html_options = html_options
end

Instance Attribute Details

#html_optionsObject (readonly)

Returns the value of attribute html_options.



5
6
7
# File 'app/components/essence/notification_component.rb', line 5

def html_options
  @html_options
end

#iconObject (readonly)

Returns the value of attribute icon.



5
6
7
# File 'app/components/essence/notification_component.rb', line 5

def icon
  @icon
end