Class: Panda::Core::Admin::DropdownButtonComponent::ItemComponent
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- Panda::Core::Admin::DropdownButtonComponent::ItemComponent
- Defined in:
- app/components/panda/core/admin/dropdown_button_component.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(label:, href: "#", method: nil, **attrs) ⇒ ItemComponent
constructor
A new instance of ItemComponent.
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
#href ⇒ Object (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 |
#label ⇒ Object (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 |
#method ⇒ Object (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
#call ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'app/components/panda/core/admin/dropdown_button_component.rb', line 39 def call = { 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"} } [:data][:turbo_method] = method if method content_tag(:a, label, **.merge(href: href)) end |