Class: UI::SelectScrollDownButton

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

Overview

Select Scroll Down Button - Phlex implementation

Button that appears when content is scrollable downward. Automatically hidden when at bottom of list.

Examples:

Default usage (no customization needed)

render UI::ScrollDownButton.new

Instance Method Summary collapse

Methods included from SharedAsChildBehavior

#merge_attributes

Methods included from SelectScrollDownButtonBehavior

#select_scroll_down_button_classes, #select_scroll_down_button_data_attributes, #select_scroll_down_button_html_attributes

Constructor Details

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

Returns a new instance of SelectScrollDownButton.

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



17
18
19
20
21
# File 'app/components/ui/select_scroll_down_button.rb', line 17

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

Instance Method Details

#view_template(&block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/components/ui/select_scroll_down_button.rb', line 23

def view_template(&block)
  button_attrs = select_scroll_down_button_html_attributes.deep_merge(@attributes)

  if @as_child && block_given?
    # asChild mode: yield attributes to block
    yield(button_attrs)
  else
    # Default mode: render as div with chevron down icon
    div(**button_attrs) do
      svg(
        class: "size-4",
        xmlns: "http://www.w3.org/2000/svg",
        viewBox: "0 0 24 24",
        fill: "none",
        stroke: "currentColor",
        stroke_width: "2",
        stroke_linecap: "round",
        stroke_linejoin: "round"
      ) do |s|
        s.path(d: "m6 9 6 6 6-6")
      end
    end
  end
end