Class: UI::SheetClose
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::SheetClose
- Includes:
- SharedAsChildBehavior
- Defined in:
- app/components/ui/sheet_close.rb
Instance Method Summary collapse
-
#initialize(as_child: false, variant: :outline, size: :default, classes: nil, **attributes) ⇒ SheetClose
constructor
A new instance of SheetClose.
- #view_template(&block) ⇒ Object
Methods included from SharedAsChildBehavior
Constructor Details
#initialize(as_child: false, variant: :outline, size: :default, classes: nil, **attributes) ⇒ SheetClose
Returns a new instance of SheetClose.
10 11 12 13 14 15 16 |
# File 'app/components/ui/sheet_close.rb', line 10 def initialize(as_child: false, variant: :outline, size: :default, classes: nil, **attributes) @as_child = as_child @variant = variant @size = size @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/components/ui/sheet_close.rb', line 18 def view_template(&block) close_attrs = { data: {action: "click->ui--dialog#close"}, **@attributes } if @as_child # Yield attributes to block - child must accept and use them yield(close_attrs) if block_given? else # Default: render as Button component render UI::Button.new( variant: @variant, size: @size, classes: @classes, **close_attrs ) do yield if block_given? end end end |