Class: UI::SheetTrigger
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::SheetTrigger
- Includes:
- SharedAsChildBehavior
- Defined in:
- app/components/ui/sheet_trigger.rb
Instance Method Summary collapse
-
#initialize(as_child: false, **attributes) ⇒ SheetTrigger
constructor
A new instance of SheetTrigger.
- #view_template(&block) ⇒ Object
Methods included from SharedAsChildBehavior
Constructor Details
#initialize(as_child: false, **attributes) ⇒ SheetTrigger
Returns a new instance of SheetTrigger.
8 9 10 11 |
# File 'app/components/ui/sheet_trigger.rb', line 8 def initialize(as_child: false, **attributes) @as_child = as_child @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/components/ui/sheet_trigger.rb', line 13 def view_template(&block) trigger_attrs = { data: {action: "click->ui--dialog#open"}, **@attributes } if @as_child # Yield attributes to block - child must accept and use them yield(trigger_attrs) if block_given? else # Default: render as button (**trigger_attrs, &block) end end |