Class: Keystone::Ui::CopyButtonComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Keystone::Ui::CopyButtonComponent
- Defined in:
- app/components/keystone/ui/copy_button_component.rb
Constant Summary collapse
- BUTTON_CLASSES =
"inline-flex items-center gap-1.5 rounded-md border border-gray-300 bg-white px-3 py-1.5 text-sm font-medium text-gray-700 transition hover:bg-gray-50 dark:border-zinc-600 dark:bg-zinc-800 dark:text-gray-300 dark:hover:bg-zinc-700"- COPY_ICON =
<<~SVG.freeze <svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg> SVG
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#success_message ⇒ Object
readonly
Returns the value of attribute success_message.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #classes ⇒ Object
- #copy_icon ⇒ Object
-
#initialize(text:, label: "Copy", success_message: "Copied!", error_message: "Failed!") ⇒ CopyButtonComponent
constructor
A new instance of CopyButtonComponent.
- #wrapper_data ⇒ Object
Constructor Details
#initialize(text:, label: "Copy", success_message: "Copied!", error_message: "Failed!") ⇒ CopyButtonComponent
Returns a new instance of CopyButtonComponent.
14 15 16 17 18 19 |
# File 'app/components/keystone/ui/copy_button_component.rb', line 14 def initialize(text:, label: "Copy", success_message: "Copied!", error_message: "Failed!") @text = text @label = label @success_message = @error_message = end |
Instance Attribute Details
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
12 13 14 |
# File 'app/components/keystone/ui/copy_button_component.rb', line 12 def @error_message end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
12 13 14 |
# File 'app/components/keystone/ui/copy_button_component.rb', line 12 def label @label end |
#success_message ⇒ Object (readonly)
Returns the value of attribute success_message.
12 13 14 |
# File 'app/components/keystone/ui/copy_button_component.rb', line 12 def @success_message end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
12 13 14 |
# File 'app/components/keystone/ui/copy_button_component.rb', line 12 def text @text end |
Instance Method Details
#classes ⇒ Object
21 22 23 |
# File 'app/components/keystone/ui/copy_button_component.rb', line 21 def classes BUTTON_CLASSES end |
#copy_icon ⇒ Object
25 26 27 |
# File 'app/components/keystone/ui/copy_button_component.rb', line 25 def copy_icon COPY_ICON end |
#wrapper_data ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/components/keystone/ui/copy_button_component.rb', line 29 def wrapper_data { controller: "clipboard", "clipboard-text": @text, "clipboard-success-message-value": @success_message, "clipboard-error-message-value": @error_message } end |