Class: Panda::Core::Admin::DropdownButtonComponent::ItemComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/admin/dropdown_button_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.



30
31
32
33
34
35
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 30

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.



37
38
39
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 37

def href
  @href
end

#labelObject (readonly)

Returns the value of attribute label.



37
38
39
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 37

def label
  @label
end

#methodObject (readonly)

Returns the value of attribute method.



37
38
39
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 37

def method
  @method
end

Instance Method Details

#callObject



39
40
41
42
43
44
45
46
47
48
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 39

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

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