Class: Shadcn::CommandInputComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Shadcn::CommandInputComponent
- Defined in:
- app/components/shadcn/command_input_component.rb
Overview
Command Input component - search input for command palette
Constant Summary collapse
- WRAPPER_CLASSES =
"flex items-center border-b px-3"- INPUT_CLASSES =
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50"- ICON_CLASSES =
"mr-2 h-4 w-4 shrink-0 opacity-50"
Instance Attribute Summary
Attributes inherited from BaseComponent
#class_name, #data, #html_options
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(placeholder: "Type a command or search...", autofocus: false, **options) ⇒ CommandInputComponent
constructor
A new instance of CommandInputComponent.
Methods inherited from BaseComponent
Methods included from Rails::Helpers::ClassNameHelper
Constructor Details
#initialize(placeholder: "Type a command or search...", autofocus: false, **options) ⇒ CommandInputComponent
Returns a new instance of CommandInputComponent.
12 13 14 15 16 |
# File 'app/components/shadcn/command_input_component.rb', line 12 def initialize(placeholder: "Type a command or search...", autofocus: false, **) super(**) @placeholder = placeholder @autofocus = autofocus end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/shadcn/command_input_component.rb', line 18 def call content_tag(:div, class: WRAPPER_CLASSES) do safe_join([ search_icon, tag.input( type: "text", placeholder: @placeholder, autofocus: @autofocus || nil, class: merge_classes(INPUT_CLASSES), data: { "shadcn--command-target": "input", action: "input->shadcn--command#filter" }, **.except(:class) ) ]) end end |