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, #decode_filter_params, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #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, #resource_grid, #resource_show_path, #resource_table

Methods inherited from BaseComponent

#has_with_trial

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#classesObject



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

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"
  elsif is_info?
    " bg-blue-400 border-blue-600"
  end

  result
end

#iconObject



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

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)


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

def is_empty?
  @message.nil?
end

#is_error?Boolean

Returns:

  • (Boolean)


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

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

#is_info?Boolean

Returns:

  • (Boolean)


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

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

#is_success?Boolean

Returns:

  • (Boolean)


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

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

#is_warning?Boolean

Returns:

  • (Boolean)


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

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