Class: BackButtonComponent
- Defined in:
- app/components/back_button_component.rb
Overview
BackButton - link that restores Turbo history when possible.
Usage:
BackButton(href: "/dashboard")
BackButton(href: "/notes", icon: "arrow left")
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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/components/back_button_component.rb', line 18 def to_s icon_el = icon ? tag.i(class: "#{icon} icon") : nil content = @content.presence || ERB::Util.html_escape(label) tag.a( **( href: href, class: css_class, data: { controller: controller, action: action, turbo_action: turbo_action } ) ) { safe_join([ icon_el, content ]) } end |