Class: UI::DrawerTrigger

Inherits:
Phlex::HTML
  • Object
show all
Includes:
DrawerTriggerBehavior, SharedAsChildBehavior
Defined in:
app/components/ui/drawer_trigger.rb

Instance Method Summary collapse

Methods included from DrawerTriggerBehavior

#drawer_trigger_data_attributes, #drawer_trigger_html_attributes

Methods included from SharedAsChildBehavior

#merge_attributes

Constructor Details

#initialize(as_child: false, variant: :outline, size: :default, classes: nil, **attributes) ⇒ DrawerTrigger

Returns a new instance of DrawerTrigger.

Parameters:

  • as_child (Boolean) (defaults to: false) —

    When true, yields attributes to block instead of rendering button

  • variant (Symbol) (defaults to: :outline) —

    Button variant (when not using as_child)

  • size (Symbol) (defaults to: :default) —

    Button size (when not using as_child)

  • classes (String) (defaults to: nil) —

    Additional CSS classes

  • attributes (Hash) —

    Additional HTML attributes



12
13
14
15
16
17
18
# File 'app/components/ui/drawer_trigger.rb', line 12

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



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/components/ui/drawer_trigger.rb', line 20

def view_template(&block)
  if @as_child
    # Yield attributes to block - child must accept and use them
    yield(drawer_trigger_html_attributes) if block_given?
  else
    # Default: render as Button component
    render UI::Button.new(
      variant: @variant,
      size: @size,
      classes: @classes,
      **drawer_trigger_html_attributes
    ), &block
  end
end