Class: PhlexKit::ResizablePanelGroup

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/resizable/resizable_panel_group.rb

Overview

Resizable split panels, ported from shadcn/ui's Resizable. The react-resizable-panels dependency is replaced by the phlex-kit--resizable controller: dragging a ResizableHandle rebalances the flex-grow of its neighbouring ResizablePanels. Compose ResizablePanelGroup(direction:) > ResizablePanel + ResizableHandle + ResizablePanel… .pk-resizable* (resizable.css).

Constant Summary collapse

DIRECTIONS =
{ horizontal: "horizontal", vertical: "vertical" }.freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(direction: :horizontal, **attrs) ⇒ ResizablePanelGroup

Returns a new instance of ResizablePanelGroup.



11
12
13
14
# File 'app/components/phlex_kit/resizable/resizable_panel_group.rb', line 11

def initialize(direction: :horizontal, **attrs)
  @direction = DIRECTIONS.fetch(direction.to_sym)
  @attrs = attrs
end

Instance Method Details

#view_templateObject



16
17
18
19
20
21
22
23
24
# File 'app/components/phlex_kit/resizable/resizable_panel_group.rb', line 16

def view_template(&)
  div(**mix({
    class: "pk-resizable-group #{@direction}",
    data: {
      controller: "phlex-kit--resizable",
      phlex_kit__resizable_direction_value: @direction
    }
  }, @attrs), &)
end