Class: UI::ScrollAreaComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::ScrollAreaComponent
- Includes:
- ScrollAreaBehavior
- Defined in:
- app/view_components/ui/scroll_area_component.rb
Overview
ScrollAreaComponent - ViewComponent implementation
Augments native scroll functionality for custom, cross-browser styling. Root container with Stimulus controller.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(type: "hover", scroll_hide_delay: 600, classes: "", **attributes) ⇒ ScrollAreaComponent
constructor
A new instance of ScrollAreaComponent.
Methods included from ScrollAreaBehavior
#scroll_area_classes, #scroll_area_html_attributes
Constructor Details
#initialize(type: "hover", scroll_hide_delay: 600, classes: "", **attributes) ⇒ ScrollAreaComponent
Returns a new instance of ScrollAreaComponent.
22 23 24 25 26 27 |
# File 'app/view_components/ui/scroll_area_component.rb', line 22 def initialize(type: "hover", scroll_hide_delay: 600, classes: "", **attributes) @type = type @scroll_hide_delay = scroll_hide_delay @classes = classes @attributes = attributes end |
Instance Method Details
#call ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/view_components/ui/scroll_area_component.rb', line 29 def call root_attrs = scroll_area_html_attributes.deep_merge(@attributes) # Add Stimulus controller and values root_attrs[:data] ||= {} root_attrs[:data][:controller] = "ui--scroll-area" root_attrs[:data][:ui__scroll_area_type_value] = @type root_attrs[:data][:ui__scroll_area_scroll_hide_delay_value] = @scroll_hide_delay content_tag :div, **root_attrs do safe_join([ render(UI::ViewportComponent.new) { content }, render(UI::ScrollbarComponent.new(orientation: "vertical")), render(UI::CornerComponent.new) ]) end end |