Class: UI::ScrollAreaCorner

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

Overview

Corner - Phlex implementation

Intersection element between vertical and horizontal scrollbars.

Examples:

Default usage (automatically used by ScrollArea)

render UI::Corner.new

Instance Method Summary collapse

Methods included from SharedAsChildBehavior

#merge_attributes

Methods included from ScrollAreaCornerBehavior

#scroll_area_corner_classes, #scroll_area_corner_html_attributes

Constructor Details

#initialize(as_child: false, classes: "", **attributes) ⇒ ScrollAreaCorner

Returns a new instance of ScrollAreaCorner.

Parameters:

  • as_child (Boolean) (defaults to: false)

    When true, yields attributes to block instead of rendering div

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



16
17
18
19
20
# File 'app/components/ui/scroll_area_corner.rb', line 16

def initialize(as_child: false, classes: "", **attributes)
  @as_child = as_child
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



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

def view_template(&block)
  corner_attrs = scroll_area_corner_html_attributes.deep_merge(@attributes)

  if @as_child && block_given?
    # asChild mode: yield attributes to block
    yield(corner_attrs)
  else
    # Default mode: render as empty div
    div(**corner_attrs)
  end
end