Class: Panda::Core::Admin::DropdownComponent::ItemComponent
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- Panda::Core::Admin::DropdownComponent::ItemComponent
- Defined in:
- app/components/panda/core/admin/dropdown_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.
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
#href ⇒ Object (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 |
#label ⇒ Object (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 |
#method ⇒ Object (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
#call ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'app/components/panda/core/admin/dropdown_component.rb', line 41 def call = { 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"} } [:data][:turbo_method] = method if method content_tag(:a, label, **.merge(href: href)) end |