Class: Avo::AlertComponent

Inherits:
BaseComponent show all
Includes:
ApplicationHelper
Defined in:
app/components/avo/alert_component.rb

Constant Summary

Constants included from Concerns::FindAssociationField

Concerns::FindAssociationField::ASSOCIATIONS

Instance Method Summary collapse

Methods included from ApplicationHelper

#a_button, #a_link, #button_classes, #card_classes, #chart_color, #container_classes, #container_is_full_width?, #d, #decode_filter_params, #e, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #pagy_major_version, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table

Methods inherited from BaseComponent

#component_name, #has_with_trial

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#classesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/components/avo/alert_component.rb', line 19

def classes
  return "hidden" if is_empty?

  result = "max-w-lg w-full shadow-lg rounded px-4 py-3 rounded relative border text-white pointer-events-auto"

  result += if is_error?
    " bg-red-400 border-red-600"
  elsif is_success?
    " bg-green-500 border-green-600"
  elsif is_warning?
    " bg-orange-400 border-orange-600"
  else
    " bg-blue-400 border-blue-600"
  end

  result
end

#iconObject



10
11
12
13
14
15
16
17
# File 'app/components/avo/alert_component.rb', line 10

def icon
  return "heroicons/solid/exclamation-circle" if is_error?
  return "heroicons/solid/exclamation" if is_warning?
  return "heroicons/solid/exclamation-circle" if is_info?
  return "heroicons/solid/check-circle" if is_success?

  "check-circle"
end

#is_empty?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/components/avo/alert_component.rb', line 53

def is_empty?
  @message.nil?
end

#is_error?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/components/avo/alert_component.rb', line 37

def is_error?
  @type.to_sym == :error || @type.to_sym == :alert
end

#is_info?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'app/components/avo/alert_component.rb', line 45

def is_info?
  @type.to_sym == :notice || @type.to_sym == :info
end

#is_success?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/components/avo/alert_component.rb', line 41

def is_success?
  @type.to_sym == :success
end

#is_warning?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/components/avo/alert_component.rb', line 49

def is_warning?
  @type.to_sym == :warning
end

#keep_open?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/components/avo/alert_component.rb', line 62

def keep_open?
  @timeout.try(:to_sym) == :forever
end

#timeoutObject



57
58
59
60
# File 'app/components/avo/alert_component.rb', line 57

def timeout
  return @timeout if @timeout.is_a?(Numeric)
  Avo.configuration.alert_dismiss_time
end