Class: Panda::Core::Admin::FormFooterComponent
- Defined in:
- app/components/panda/core/admin/form_footer_component.rb
Overview
Standardized form footer component with submit button(s) and optional secondary actions.
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#cancel_path ⇒ Object
readonly
Returns the value of attribute cancel_path.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#submit_action ⇒ Object
readonly
Returns the value of attribute submit_action.
-
#submit_text ⇒ Object
readonly
Returns the value of attribute submit_text.
Instance Method Summary collapse
- #cancel_link_classes ⇒ Object
- #computed_icon ⇒ Object
- #default_attrs ⇒ Object
-
#initialize(submit_text: "Save", icon: nil, cancel_path: nil, submit_action: nil, **attrs) ⇒ FormFooterComponent
constructor
A new instance of FormFooterComponent.
- #submit_button_classes ⇒ Object
- #submit_data_attrs ⇒ Object
Constructor Details
#initialize(submit_text: "Save", icon: nil, cancel_path: nil, submit_action: nil, **attrs) ⇒ FormFooterComponent
Returns a new instance of FormFooterComponent.
29 30 31 32 33 34 35 |
# File 'app/components/panda/core/admin/form_footer_component.rb', line 29 def initialize(submit_text: "Save", icon: nil, cancel_path: nil, submit_action: nil, **attrs) @submit_text = submit_text @icon = icon @cancel_path = cancel_path @submit_action = submit_action super(**attrs) end |
Instance Attribute Details
#cancel_path ⇒ Object (readonly)
Returns the value of attribute cancel_path.
37 38 39 |
# File 'app/components/panda/core/admin/form_footer_component.rb', line 37 def cancel_path @cancel_path end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
37 38 39 |
# File 'app/components/panda/core/admin/form_footer_component.rb', line 37 def icon @icon end |
#submit_action ⇒ Object (readonly)
Returns the value of attribute submit_action.
37 38 39 |
# File 'app/components/panda/core/admin/form_footer_component.rb', line 37 def submit_action @submit_action end |
#submit_text ⇒ Object (readonly)
Returns the value of attribute submit_text.
37 38 39 |
# File 'app/components/panda/core/admin/form_footer_component.rb', line 37 def submit_text @submit_text end |
Instance Method Details
#cancel_link_classes ⇒ Object
49 50 51 |
# File 'app/components/panda/core/admin/form_footer_component.rb', line 49 def cancel_link_classes "inline-flex items-center justify-center rounded-xl px-3 py-2 text-sm font-medium text-gray-600 hover:text-gray-900" end |
#computed_icon ⇒ Object
53 54 55 |
# File 'app/components/panda/core/admin/form_footer_component.rb', line 53 def computed_icon @icon end |
#default_attrs ⇒ Object
39 40 41 42 43 |
# File 'app/components/panda/core/admin/form_footer_component.rb', line 39 def default_attrs { class: "flex justify-end gap-x-3 mt-2" } end |
#submit_button_classes ⇒ Object
45 46 47 |
# File 'app/components/panda/core/admin/form_footer_component.rb', line 45 def "inline-flex items-center gap-x-2 justify-center rounded-xl bg-primary-500 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-primary-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600 cursor-pointer" end |
#submit_data_attrs ⇒ Object
57 58 59 60 61 |
# File 'app/components/panda/core/admin/form_footer_component.rb', line 57 def submit_data_attrs attrs = {disable_with: "Saving..."} attrs[:action] = submit_action if submit_action attrs end |