Class: UI::ResizablePanelGroup

Inherits:
Phlex::HTML
  • Object
show all
Includes:
ResizablePanelGroupBehavior
Defined in:
app/components/ui/resizable_panel_group.rb

Overview

ResizablePanelGroup container component (Phlex) Wraps resizable panels with Stimulus controller

Examples:

Basic horizontal layout

render UI::PanelGroup.new(direction: "horizontal") do
  render UI::Panel.new(default_size: 50) do
    "Left panel content"
  end
  render UI::Handle.new
  render UI::Panel.new(default_size: 50) do
    "Right panel content"
  end
end

Vertical layout

render UI::PanelGroup.new(direction: "vertical") do
  render UI::Panel.new(default_size: 30) { "Top" }
  render UI::Handle.new
  render UI::Panel.new(default_size: 70) { "Bottom" }
end

Instance Method Summary collapse

Methods included from ResizablePanelGroupBehavior

#merged_panel_group_data_attributes, #panel_group_base_classes, #panel_group_data_attributes, #panel_group_html_attributes

Constructor Details

#initialize(direction: "horizontal", keyboard_resize_by: 10, classes: "", attributes: {}) ⇒ ResizablePanelGroup

Returns a new instance of ResizablePanelGroup.

Parameters:

  • direction (String) (defaults to: "horizontal")

    “horizontal” or “vertical” layout

  • keyboard_resize_by (Integer) (defaults to: 10)

    percentage to resize by on keyboard input

  • classes (String) (defaults to: "")

    additional CSS classes

  • attributes (Hash) (defaults to: {})

    additional HTML attributes



30
31
32
33
34
35
36
# File 'app/components/ui/resizable_panel_group.rb', line 30

def initialize(direction: "horizontal", keyboard_resize_by: 10, classes: "", attributes: {}, **)
  @direction = direction
  @keyboard_resize_by = keyboard_resize_by
  @classes = classes
  @attributes = attributes
  super()
end

Instance Method Details

#view_template(&block) ⇒ Object



38
39
40
# File 'app/components/ui/resizable_panel_group.rb', line 38

def view_template(&block)
  div(**panel_group_html_attributes, &block)
end