Class: UI::Popover
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::Popover
- Includes:
- PopoverBehavior
- Defined in:
- app/components/ui/popover.rb
Overview
Popover - Phlex implementation
Container for popover trigger and content. Uses PopoverBehavior concern for shared styling logic.
Supports asChild pattern for composition without wrapper elements.
Instance Method Summary collapse
-
#initialize(as_child: false, placement: "bottom", offset: 4, trigger: "click", hover_delay: 200, classes: "", align: nil, side_offset: nil, **attributes) ⇒ Popover
constructor
A new instance of Popover.
- #view_template(&block) ⇒ Object
Methods included from PopoverBehavior
#popover_classes, #popover_data_attributes, #popover_html_attributes
Constructor Details
#initialize(as_child: false, placement: "bottom", offset: 4, trigger: "click", hover_delay: 200, classes: "", align: nil, side_offset: nil, **attributes) ⇒ Popover
Returns a new instance of Popover.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/components/ui/popover.rb', line 39 def initialize( as_child: false, placement: "bottom", offset: 4, trigger: "click", hover_delay: 200, classes: "", align: nil, side_offset: nil, **attributes ) @as_child = as_child @placement = placement @offset = side_offset || offset @trigger = trigger @hover_delay = hover_delay @classes = classes @align = align @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/components/ui/popover.rb', line 60 def view_template(&block) popover_attrs = popover_html_attributes.deep_merge(@attributes) if @as_child # Yield data attributes to block - child receives controller setup yield(popover_attrs) if block_given? else # Default: render wrapper div with controller div(**popover_attrs) do yield if block_given? end end end |