Class: UI::ContextMenuItemComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::ContextMenuItemComponent
- Includes:
- ContextMenuItemBehavior
- Defined in:
- app/view_components/ui/context_menu_item_component.rb
Overview
ItemComponent - ViewComponent implementation
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(href: nil, inset: false, variant: "default", classes: "", **attributes) ⇒ ContextMenuItemComponent
constructor
A new instance of ContextMenuItemComponent.
Methods included from ContextMenuItemBehavior
#context_menu_item_classes, #context_menu_item_data_attributes, #context_menu_item_html_attributes
Constructor Details
#initialize(href: nil, inset: false, variant: "default", classes: "", **attributes) ⇒ ContextMenuItemComponent
Returns a new instance of ContextMenuItemComponent.
7 8 9 10 11 12 13 |
# File 'app/view_components/ui/context_menu_item_component.rb', line 7 def initialize(href: nil, inset: false, variant: "default", classes: "", **attributes) @href = href @inset = inset @variant = variant @classes = classes @attributes = attributes end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/view_components/ui/context_menu_item_component.rb', line 15 def call attrs = attrs[:data] = attrs[:data].merge(@attributes.fetch(:data, {})) if @href content_tag :a, **attrs.merge(@attributes.except(:data)) do content end else content_tag :div, **attrs.merge(@attributes.except(:data)) do content end end end |