Class: Railsboot::CopyToClipboardComponent
- Inherits:
-
Component
- Object
- Component
- Railsboot::CopyToClipboardComponent
- Defined in:
- app/components/railsboot/copy_to_clipboard_component.rb
Overview
ViewComponent: renders the copy to clipboard block.
Instance Method Summary collapse
- #default_button ⇒ Object
-
#initialize(**html_attributes) ⇒ CopyToClipboardComponent
constructor
A new instance of CopyToClipboardComponent.
- #render? ⇒ Boolean
Constructor Details
#initialize(**html_attributes) ⇒ CopyToClipboardComponent
Returns a new instance of CopyToClipboardComponent.
4 5 6 7 8 9 10 11 12 13 |
# File 'app/components/railsboot/copy_to_clipboard_component.rb', line 4 def initialize(**html_attributes) @html_attributes = html_attributes # Set default class and merge with provided classes default_class = 'd-inline-block' provided_class = @html_attributes.delete(:class) @html_attributes[:class] = provided_class ? "#{default_class} #{provided_class}" : default_class @html_attributes['data-controller'] = 'copy-to-clipboard' end |
Instance Method Details
#default_button ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/components/railsboot/copy_to_clipboard_component.rb', line 19 def content_tag :button, type: 'button', class: 'btn btn-sm btn-outline-secondary', data: { action: 'copy-to-clipboard#copy' }, title: 'Copy URL to clipboard' do content_tag :i, nil, class: 'fas fa-copy' end end |
#render? ⇒ Boolean
15 16 17 |
# File 'app/components/railsboot/copy_to_clipboard_component.rb', line 15 def render? block_given? ? content.present? : true end |