Class: LightningUiKit::CommandComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- LightningUiKit::CommandComponent
- Defined in:
- app/components/lightning_ui_kit/command_component.rb
Instance Attribute Summary collapse
-
#empty_text ⇒ Object
readonly
Returns the value of attribute empty_text.
-
#placeholder ⇒ Object
readonly
Returns the value of attribute placeholder.
Instance Method Summary collapse
- #classes ⇒ Object
- #data ⇒ Object
-
#initialize(placeholder: "Type a command or search...", empty_text: "No results found.", **options) ⇒ CommandComponent
constructor
A new instance of CommandComponent.
- #item_classes ⇒ Object
Constructor Details
#initialize(placeholder: "Type a command or search...", empty_text: "No results found.", **options) ⇒ CommandComponent
Returns a new instance of CommandComponent.
4 5 6 7 8 |
# File 'app/components/lightning_ui_kit/command_component.rb', line 4 def initialize(placeholder: "Type a command or search...", empty_text: "No results found.", **) @placeholder = placeholder @empty_text = empty_text @options = end |
Instance Attribute Details
#empty_text ⇒ Object (readonly)
Returns the value of attribute empty_text.
10 11 12 |
# File 'app/components/lightning_ui_kit/command_component.rb', line 10 def empty_text @empty_text end |
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
10 11 12 |
# File 'app/components/lightning_ui_kit/command_component.rb', line 10 def placeholder @placeholder end |
Instance Method Details
#classes ⇒ Object
12 13 14 15 16 17 |
# File 'app/components/lightning_ui_kit/command_component.rb', line 12 def classes merge_classes([ "lui:flex lui:w-full lui:flex-col lui:overflow-hidden lui:rounded-lg lui:border lui:border-border lui:bg-surface lui:text-foreground lui:shadow-md", @options[:class] ].compact.join(" ")) end |
#data ⇒ Object
23 24 25 |
# File 'app/components/lightning_ui_kit/command_component.rb', line 23 def data {controller: "lui-command"}.merge(@options[:data] || {}) end |
#item_classes ⇒ Object
19 20 21 |
# File 'app/components/lightning_ui_kit/command_component.rb', line 19 def item_classes "lui:flex lui:cursor-pointer lui:items-center lui:gap-2 lui:rounded-sm lui:px-2 lui:py-1.5 lui:text-sm lui:text-foreground lui:outline-none lui:data-[active]:bg-surface-hover lui:hover:bg-surface-hover" end |