Class: UI::ScrollAreaViewport
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::ScrollAreaViewport
- Includes:
- ScrollAreaViewportBehavior, SharedAsChildBehavior
- Defined in:
- app/components/ui/scroll_area_viewport.rb
Overview
Viewport - Phlex implementation
Scrollable content container with hidden native scrollbar.
Instance Method Summary collapse
-
#initialize(as_child: false, classes: "", **attributes) ⇒ ScrollAreaViewport
constructor
A new instance of ScrollAreaViewport.
- #view_template(&block) ⇒ Object
Methods included from SharedAsChildBehavior
Methods included from ScrollAreaViewportBehavior
#scroll_area_viewport_classes, #scroll_area_viewport_html_attributes
Constructor Details
#initialize(as_child: false, classes: "", **attributes) ⇒ ScrollAreaViewport
Returns a new instance of ScrollAreaViewport.
18 19 20 21 22 |
# File 'app/components/ui/scroll_area_viewport.rb', line 18 def initialize(as_child: false, classes: "", **attributes) @as_child = as_child @classes = classes @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/components/ui/scroll_area_viewport.rb', line 24 def view_template(&block) = .deep_merge(@attributes) # Add Stimulus target [:data] ||= {} [:data][:"ui--scroll-area-target"] = "viewport" if @as_child && block_given? # asChild mode: yield attributes to block yield() else # Default mode: render as div with inner table div div(**) do div(style: "min-width: 100%; display: table;", &block) end end end |