Class: UI::PopoverTrigger
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::PopoverTrigger
- Includes:
- PopoverTriggerBehavior
- Defined in:
- app/components/ui/popover_trigger.rb
Overview
Trigger - Phlex implementation
Button or element that triggers the popover. Uses PopoverTriggerBehavior concern for shared styling logic.
Instance Method Summary collapse
-
#initialize(as_child: false, classes: "", **attributes) ⇒ PopoverTrigger
constructor
A new instance of PopoverTrigger.
- #view_template(&block) ⇒ Object
Methods included from PopoverTriggerBehavior
#popover_trigger_classes, #popover_trigger_html_attributes
Constructor Details
#initialize(as_child: false, classes: "", **attributes) ⇒ PopoverTrigger
Returns a new instance of PopoverTrigger.
18 19 20 21 22 |
# File 'app/components/ui/popover_trigger.rb', line 18 def initialize(as_child: false, classes: "", **attributes) @as_child = as_child @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/ui/popover_trigger.rb', line 24 def view_template(&block) trigger_attrs = popover_trigger_html_attributes.deep_merge(@attributes) if @as_child # asChild mode: yield attributes to block # The caller is responsible for rendering an element with these attributes yield(trigger_attrs) if block_given? else # Default mode: render as div div(**trigger_attrs, &block) end end |