Class: UI::ContextMenuLabelComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ContextMenuLabelBehavior
Defined in:
app/view_components/ui/context_menu_label_component.rb

Overview

LabelComponent - ViewComponent implementation

Instance Method Summary collapse

Methods included from ContextMenuLabelBehavior

#context_menu_label_classes, #context_menu_label_data_attributes, #context_menu_label_html_attributes

Constructor Details

#initialize(inset: false, classes: "", **attributes) ⇒ ContextMenuLabelComponent

Returns a new instance of ContextMenuLabelComponent.



7
8
9
10
11
# File 'app/view_components/ui/context_menu_label_component.rb', line 7

def initialize(inset: false, classes: "", **attributes)
  @inset = inset
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
# File 'app/view_components/ui/context_menu_label_component.rb', line 13

def call
  attrs = context_menu_label_html_attributes
  data_attrs = attrs.delete(:data) || {}
  data_attrs = data_attrs.merge(@attributes.fetch(:data, {}))

   :div, **attrs.merge(@attributes.except(:data)).merge(data: data_attrs) do
    content
  end
end