Class: Avo::AlertComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Avo::AlertComponent
show all
- Includes:
- ApplicationHelper
- Defined in:
- app/components/avo/alert_component.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#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, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes
#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_select_all_input, #item_selector_init, #item_selector_input, #resource_grid, #resource_table
Constructor Details
#initialize(type, message) ⇒ AlertComponent
Returns a new instance of AlertComponent.
9
10
11
12
|
# File 'app/components/avo/alert_component.rb', line 9
def initialize(type, message)
@type = type
@message = message
end
|
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
7
8
9
|
# File 'app/components/avo/alert_component.rb', line 7
def message
@message
end
|
#type ⇒ Object
Returns the value of attribute type.
6
7
8
|
# File 'app/components/avo/alert_component.rb', line 6
def type
@type
end
|
Instance Method Details
#classes ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/components/avo/alert_component.rb', line 23
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
|
#icon ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'app/components/avo/alert_component.rb', line 14
def icon
return "heroicons/solid/x-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
57
58
59
|
# File 'app/components/avo/alert_component.rb', line 57
def is_empty?
message.nil?
end
|
#is_error? ⇒ Boolean
41
42
43
|
# File 'app/components/avo/alert_component.rb', line 41
def is_error?
type.to_sym == :error || type.to_sym == :alert
end
|
#is_info? ⇒ Boolean
49
50
51
|
# File 'app/components/avo/alert_component.rb', line 49
def is_info?
type.to_sym == :notice || type.to_sym == :info
end
|
#is_success? ⇒ Boolean
45
46
47
|
# File 'app/components/avo/alert_component.rb', line 45
def is_success?
type.to_sym == :success
end
|
#is_warning? ⇒ Boolean
53
54
55
|
# File 'app/components/avo/alert_component.rb', line 53
def is_warning?
type.to_sym == :warning
end
|