Class: Cmdk::List

Inherits:
Base
  • Object
show all
Defined in:
lib/cmdk/list.rb

Overview

Contains items, groups and separators. Port of ‘<Command.List>` from cmdk. The JS runtime keeps the `–cmdk-list-height` CSS variable updated on this element so the list height can be animated.

Constant Summary

Constants inherited from Base

Base::SR_ONLY_STYLE

Instance Method Summary collapse

Constructor Details

#initialize(label: 'Suggestions', **attributes) ⇒ List

Returns a new instance of List.



6
7
8
9
# File 'lib/cmdk/list.rb', line 6

def initialize(label: 'Suggestions', **attributes)
  @label = label
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



11
12
13
14
15
# File 'lib/cmdk/list.rb', line 11

def view_template(&block)
  div(**merged({ 'cmdk-list' => '', role: 'listbox', tabindex: '-1', aria_label: @label }, @attributes)) do
    div('cmdk-list-sizer' => '', &block)
  end
end