Class: UI::ScrollAreaScrollbar
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::ScrollAreaScrollbar
- Includes:
- ScrollAreaScrollbarBehavior, SharedAsChildBehavior
- Defined in:
- app/components/ui/scroll_area_scrollbar.rb
Overview
Scrollbar - Phlex implementation
Custom scrollbar track that contains the draggable thumb.
Instance Method Summary collapse
-
#initialize(as_child: false, orientation: "vertical", classes: "", **attributes) ⇒ ScrollAreaScrollbar
constructor
A new instance of ScrollAreaScrollbar.
- #view_template(&block) ⇒ Object
Methods included from SharedAsChildBehavior
Methods included from ScrollAreaScrollbarBehavior
#scroll_area_scrollbar_classes, #scroll_area_scrollbar_html_attributes
Constructor Details
#initialize(as_child: false, orientation: "vertical", classes: "", **attributes) ⇒ ScrollAreaScrollbar
Returns a new instance of ScrollAreaScrollbar.
20 21 22 23 24 25 |
# File 'app/components/ui/scroll_area_scrollbar.rb', line 20 def initialize(as_child: false, orientation: "vertical", classes: "", **attributes) @as_child = as_child @orientation = orientation @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/components/ui/scroll_area_scrollbar.rb', line 27 def view_template(&block) = .deep_merge(@attributes) # Add Stimulus target [:data] ||= {} [:data][:"ui--scroll-area-target"] = "scrollbar" if @as_child && block_given? # asChild mode: yield attributes to block, but also render thumb if not provided yield() render UI::Thumb.new unless block_given? else # Default mode: render as div with thumb div(**) do render UI::Thumb.new end end end |