Class: FoxTail::AlertComponent

Inherits:
DismissibleComponent show all
Defined in:
app/components/fox_tail/alert_component.rb

Constant Summary collapse

SEVERITY_ICONS =
{success: "check-circle", warning: "exclamation-triangle", danger: "exclamation-circle"}.freeze
DEFAULT_SEVERITY_ICON =
"information-circle"

Instance Attribute Summary

Attributes inherited from BaseComponent

#html_attributes

Instance Method Summary collapse

Methods inherited from DismissibleComponent

#call, stimulus_controller_name, #stimulus_controller_options

Methods inherited from BaseComponent

classname_merger, #initialize, stimulus_merger, use_stimulus?, #with_html_attributes, #with_html_class

Methods inherited from Base

fox_tail_config

Constructor Details

This class inherits a constructor from FoxTail::BaseComponent

Instance Method Details

#before_renderObject



83
84
85
86
87
88
89
90
# File 'app/components/fox_tail/alert_component.rb', line 83

def before_render
  super

  with_dismiss_icon unless !dismissible? || dismiss_icon

  html_attributes[:class] = root_classes
  html_attributes[:role] = :alert
end

#borderObject



69
70
71
72
73
74
75
76
77
# File 'app/components/fox_tail/alert_component.rb', line 69

def border
  if options[:border].is_a?(TrueClass)
    :basic
  elsif !options[:border]
    :none
  else
    (options[:border] || :none).to_sym
  end
end

#border?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'app/components/fox_tail/alert_component.rb', line 65

def border?
  border != :none
end

#use_stimulus?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'app/components/fox_tail/alert_component.rb', line 79

def use_stimulus?
  super && dismissible?
end