Class: LightningUiKit::CopyInputComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- LightningUiKit::CopyInputComponent
- Defined in:
- app/components/lightning_ui_kit/copy_input_component.rb
Instance Method Summary collapse
- #action_button_classes ⇒ Object
- #classes ⇒ Object
- #control_classes ⇒ Object
- #copy_button_classes ⇒ Object
- #data ⇒ Object
-
#initialize(value:, label: nil, description: nil, secret: false, **options) ⇒ CopyInputComponent
constructor
A new instance of CopyInputComponent.
- #input_classes ⇒ Object
- #input_type ⇒ Object
- #label_data ⇒ Object
- #label_html_options ⇒ Object
- #render_label ⇒ Object
- #toggle_button_classes ⇒ Object
Constructor Details
#initialize(value:, label: nil, description: nil, secret: false, **options) ⇒ CopyInputComponent
Returns a new instance of CopyInputComponent.
2 3 4 5 6 7 8 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 2 def initialize(value:, label: nil, description: nil, secret: false, **) @value = value @label = label @description = description @secret = secret @options = end |
Instance Method Details
#action_button_classes ⇒ Object
47 48 49 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 47 def "lui:flex lui:items-center lui:justify-center lui:px-3 lui:border-l lui:border-border lui:text-foreground-muted lui:hover:text-foreground lui:hover:bg-surface-hover lui:transition-colors lui:cursor-pointer lui:focus:outline-hidden" end |
#classes ⇒ Object
10 11 12 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 10 def classes merge_classes(["lui:[&>[data-slot=label]+[data-slot=description]]:mt-1 lui:[&>[data-slot=label]+[data-slot=control]]:mt-3 lui:[&>[data-slot=description]+[data-slot=control]]:mt-3 lui:*:data-[slot=label]:font-medium", @options[:class]].compact.join(" ")) end |
#control_classes ⇒ Object
35 36 37 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 35 def control_classes "lui:relative lui:flex lui:w-full lui:rounded-lg lui:border lui:border-border lui:bg-surface-input lui:shadow-sm lui:focus-within:ring-2 lui:focus-within:ring-focus" end |
#copy_button_classes ⇒ Object
51 52 53 54 55 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 51 def classes = [] classes << "lui:rounded-r-lg" unless @secret classes.join(" ") end |
#data ⇒ Object
14 15 16 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 14 def data {controller: "lui-clipboard"}.merge(@options[:data] || {}) end |
#input_classes ⇒ Object
39 40 41 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 39 def input_classes "lui:block lui:w-full lui:min-w-0 lui:flex-1 lui:appearance-none lui:bg-transparent lui:px-[calc(--spacing(3.5)-1px)] lui:py-[calc(--spacing(2.5)-1px)] lui:sm:px-[calc(--spacing(3)-1px)] lui:sm:py-[calc(--spacing(1.5)-1px)] lui:text-base/6 lui:text-foreground lui:sm:text-sm/6 lui:border-0 lui:focus:outline-hidden lui:select-all" end |
#input_type ⇒ Object
43 44 45 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 43 def input_type @secret ? "password" : "text" end |
#label_data ⇒ Object
18 19 20 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 18 def label_data {slot: "label"} end |
#label_html_options ⇒ Object
22 23 24 25 26 27 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 22 def { class: "lui:text-base/6 lui:text-foreground lui:select-none lui:sm:text-sm/6", data: label_data } end |
#render_label ⇒ Object
29 30 31 32 33 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 29 def render_label return unless @label helpers.label_tag(nil, @label, **) end |
#toggle_button_classes ⇒ Object
57 58 59 |
# File 'app/components/lightning_ui_kit/copy_input_component.rb', line 57 def "#{} lui:rounded-r-lg" end |