Class: Avo::ButtonComponent
Overview
A button/link can have the following settings: style: primary/outline/text size: :sm, :md, :lg padding: nil (default), :sm or :xs for tighter, equal padding rounded: nil (default, uses the standard radius), :full for a pill shape color: nil, :primary, :accent, :gray, :red, :green, :blue, or any other tailwind color icon: “tabler/outline/paperclip” as specified in the docs (docs.avohq.io/3.0/icons.html)
Constant Summary
Concerns::FindAssociationField::ASSOCIATIONS
Instance Method Summary
collapse
#component_name, #hotkey_badge
#a_button, #a_link, #body_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #manual_frame_cookie_name, #manual_frame_remembered?, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_header_menu_items, #render_license_warning, #root_path_without_url, #rtl?, #safe_blob_path, #safe_blob_representation_url, #safe_blob_url, #text_direction, #ui, #wrap_in_modal
#summary_chart_params_for
#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
#find_association_field
Instance Method Details
#args ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/components/avo/button_component.rb', line 29
def args
if @args[:loading]
@args[:"data-controller"] = "loading-button"
@args[:"data-action"] = "click->loading-button#attemptSubmit"
end
@args[:class] = button_classes
@args[:aria] = @aria
@args
end
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/components/avo/button_component.rb', line 41
def button_classes
base_classes = [
"button",
"button--size-#{@size}",
"button--style-#{@style}",
@class,
"button--color-#{@color}": @color.present?,
"button--padding-#{@padding}": @padding.present?,
"button--rounded-#{@rounded}": @rounded.present?
]
base_classes << "button--loading" if @args[:loading]
class_names(*base_classes.compact)
end
|
#call ⇒ Object
60
61
62
63
64
65
66
|
# File 'app/components/avo/button_component.rb', line 60
def call
if is_link?
output_link
else
output_button
end
end
|
#is_link? ⇒ Boolean
56
57
58
|
# File 'app/components/avo/button_component.rb', line 56
def is_link?
@is_link
end
|
74
75
76
77
78
79
80
81
82
83
84
|
# File 'app/components/avo/button_component.rb', line 74
def output_button
if args.dig(:method).present? || args.dig(:data, :turbo_method).present?
button_to args[:url], **args do
render_content
end
else
button_tag(**args) do
render_content
end
end
end
|
#output_link ⇒ Object
68
69
70
71
72
|
# File 'app/components/avo/button_component.rb', line 68
def output_link
link_to @path, **args do
render_content
end
end
|