Class: Shadcn::CommandGroupComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/command_group_component.rb

Overview

Command Group component - groups related command items

Constant Summary collapse

BASE_CLASSES =
"overflow-hidden p-1 text-foreground"
HEADING_CLASSES =
"px-2 py-1.5 text-xs font-medium text-muted-foreground"

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Instance Method Summary collapse

Methods inherited from BaseComponent

#content

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

#initialize(heading: nil, **options) ⇒ CommandGroupComponent

Returns a new instance of CommandGroupComponent.

Parameters:

  • heading (String, nil) (defaults to: nil)

    Optional heading for the group



15
16
17
18
# File 'app/components/shadcn/command_group_component.rb', line 15

def initialize(heading: nil, **options)
  super(**options)
  @heading = heading
end

Instance Method Details

#callObject



20
21
22
# File 'app/components/shadcn/command_group_component.rb', line 20

def call
  (:div, group_content, class: merge_classes(BASE_CLASSES), role: "group", data: { "shadcn--command-target": "group" }, **html_options.merge(build_data))
end