Class: UI::ScrollAreaThumb
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::ScrollAreaThumb
- Includes:
- ScrollAreaThumbBehavior, SharedAsChildBehavior
- Defined in:
- app/components/ui/scroll_area_thumb.rb
Overview
Thumb - Phlex implementation
Draggable scroll indicator inside the scrollbar.
Instance Method Summary collapse
-
#initialize(as_child: false, classes: "", **attributes) ⇒ ScrollAreaThumb
constructor
A new instance of ScrollAreaThumb.
- #view_template(&block) ⇒ Object
Methods included from SharedAsChildBehavior
Methods included from ScrollAreaThumbBehavior
#scroll_area_thumb_classes, #scroll_area_thumb_html_attributes
Constructor Details
#initialize(as_child: false, classes: "", **attributes) ⇒ ScrollAreaThumb
Returns a new instance of ScrollAreaThumb.
16 17 18 19 20 |
# File 'app/components/ui/scroll_area_thumb.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 33 34 35 36 37 |
# File 'app/components/ui/scroll_area_thumb.rb', line 22 def view_template(&block) thumb_attrs = scroll_area_thumb_html_attributes.deep_merge(@attributes) # Add Stimulus target and action for drag thumb_attrs[:data] ||= {} thumb_attrs[:data][:"ui--scroll-area-target"] = "thumb" thumb_attrs[:data][:action] = "pointerdown->ui--scroll-area#startDrag" if @as_child && block_given? # asChild mode: yield attributes to block yield(thumb_attrs) else # Default mode: render as empty div div(**thumb_attrs) end end |