Class: Components::CopyButton
- Inherits:
-
Base
- Object
- Base
- Components::CopyButton
- Defined in:
- app/components/copy_button.rb
Instance Method Summary collapse
- #before_template ⇒ Object
-
#initialize(text:, label: nil) ⇒ CopyButton
constructor
A new instance of CopyButton.
- #view_template ⇒ Object
Constructor Details
#initialize(text:, label: nil) ⇒ CopyButton
Returns a new instance of CopyButton.
2 3 4 5 |
# File 'app/components/copy_button.rb', line 2 def initialize(text:, label: nil) @text = text @label = label end |
Instance Method Details
#before_template ⇒ Object
7 8 9 |
# File 'app/components/copy_button.rb', line 7 def before_template @label ||= t("components.copy_button.copy") end |
#view_template ⇒ Object
11 12 13 14 15 |
# File 'app/components/copy_button.rb', line 11 def view_template class: "btn btn-secondary", data: {controller: "copy-text", action: "click->copy-text#copy:prevent", copy_text_text_value: @text} do Icon icon: "clipboard-plus", label: @label end end |