Class: ButtonToComponent
- Includes:
- Sizeable
- Defined in:
- app/components/button_to_component.rb
Overview
ButtonTo — a form-based button for non-GET actions (DELETE, PATCH, etc).
Wraps Rails button_to with Fomantic-UI button styling.
Usage:
ButtonTo(url: "/items/1", method: :delete, color: "red", confirm: "Sure?") {
Icon(name: "trash")
text " Delete"
}
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
Methods inherited from Component
default, #initialize, #render_in, slot
Constructor Details
This class inherits a constructor from Component
Instance Method Details
#to_s ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/components/button_to_component.rb', line 24 def to_s classes = class_names( "ui", color, size, variant, { "disabled" => disabled }, "button" ) html_opts = { method: method.to_sym } html_opts[:form] = { data: { turbo_confirm: confirm } } if confirm @view_context.( url, html_opts.merge(class: classes) ) { @content } end |