Class: UI::HoverCardComponent

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

Overview

HoverCardComponent - ViewComponent implementation

Container for hover card trigger and content. Uses HoverCardBehavior for shared styling logic.

Examples:

Basic usage

<%= render UI::HoverCardComponent.new do %>
  <%= render UI::TriggerComponent.new { "Hover me" } %>
  <%= render UI::ContentComponent.new { "Content" } %>
<% end %>

Instance Method Summary collapse

Methods included from HoverCardBehavior

#hover_card_classes, #hover_card_data_attributes, #hover_card_html_attributes

Constructor Details

#initialize(classes: "", **attributes) ⇒ HoverCardComponent

Returns a new instance of HoverCardComponent.

Parameters:

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



18
19
20
21
# File 'app/view_components/ui/hover_card_component.rb', line 18

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

Instance Method Details

#callObject



23
24
25
26
27
28
29
# File 'app/view_components/ui/hover_card_component.rb', line 23

def call
  attrs = hover_card_html_attributes

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