Class: IronAdmin::Ui::DropdownComponent::ItemComponent Private
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Ui::DropdownComponent::ItemComponent
- Defined in:
- app/components/iron_admin/ui/dropdown_component.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Individual dropdown menu item.
Instance Attribute Summary collapse
-
#destructive ⇒ Boolean
readonly
private
Whether item is destructive (red styling).
-
#href ⇒ String?
readonly
private
Link URL.
-
#icon ⇒ String?
readonly
private
Heroicon name.
-
#method ⇒ Symbol?
readonly
private
HTTP method.
Instance Method Summary collapse
-
#call ⇒ String
private
Renders the menu item.
-
#initialize(href: nil, method: nil, icon: nil, destructive: false) ⇒ ItemComponent
constructor
private
A new instance of ItemComponent.
-
#item_classes ⇒ String
private
CSS classes for menu item.
Constructor Details
#initialize(href: nil, method: nil, icon: nil, destructive: false) ⇒ ItemComponent
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ItemComponent.
64 65 66 67 68 69 |
# File 'app/components/iron_admin/ui/dropdown_component.rb', line 64 def initialize(href: nil, method: nil, icon: nil, destructive: false) @href = href @method = method @icon = icon @destructive = destructive end |
Instance Attribute Details
#destructive ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Whether item is destructive (red styling).
58 59 60 |
# File 'app/components/iron_admin/ui/dropdown_component.rb', line 58 def destructive @destructive end |
#href ⇒ String? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Link URL.
49 50 51 |
# File 'app/components/iron_admin/ui/dropdown_component.rb', line 49 def href @href end |
#icon ⇒ String? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Heroicon name.
55 56 57 |
# File 'app/components/iron_admin/ui/dropdown_component.rb', line 55 def icon @icon end |
#method ⇒ Symbol? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns HTTP method.
52 53 54 |
# File 'app/components/iron_admin/ui/dropdown_component.rb', line 52 def method @method end |
Instance Method Details
#call ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Renders the menu item.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/components/iron_admin/ui/dropdown_component.rb', line 84 def call if href link_to(href, class: item_classes, data: method ? { turbo_method: method } : {}) do item_content end else tag.(type: "button", class: item_classes) do item_content end end end |
#item_classes ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns CSS classes for menu item.
73 74 75 76 77 78 79 80 |
# File 'app/components/iron_admin/ui/dropdown_component.rb', line 73 def item_classes base = "flex items-center gap-2 w-full px-4 py-2 text-sm text-left transition-colors duration-150" if destructive "#{base} text-red-600 hover:bg-red-50" else "#{base} text-gray-700 hover:bg-gray-50" end end |