Class: Panda::Core::Admin::DropdownComponent::ItemComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/admin/dropdown_component.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, href: "#", method: nil, **attrs) ⇒ ItemComponent

Returns a new instance of ItemComponent.



32
33
34
35
36
37
# File 'app/components/panda/core/admin/dropdown_component.rb', line 32

def initialize(label:, href: "#", method: nil, **attrs)
  @label = label
  @href = href
  @method = method
  super(**attrs)
end

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href.



39
40
41
# File 'app/components/panda/core/admin/dropdown_component.rb', line 39

def href
  @href
end

#labelObject (readonly)

Returns the value of attribute label.



39
40
41
# File 'app/components/panda/core/admin/dropdown_component.rb', line 39

def label
  @label
end

#methodObject (readonly)

Returns the value of attribute method.



39
40
41
# File 'app/components/panda/core/admin/dropdown_component.rb', line 39

def method
  @method
end

Instance Method Details

#callObject



41
42
43
44
45
46
47
48
49
50
# File 'app/components/panda/core/admin/dropdown_component.rb', line 41

def call
  options = {
    class: "block w-full text-left px-4 py-2 text-xs text-gray-500 hover:bg-gray-50 hover:text-gray-700",
    role: "menuitem",
    data: {dropdown_target: "menuItem"}
  }
  options[:data][:turbo_method] = method if method

  (:a, label, **options.merge(href: href))
end