Class: PhlexKit::ResizablePanel

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

Overview

One pane of a ResizablePanelGroup. default_size: is a percentage. See resizable_panel_group.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(default_size: nil, **attrs) ⇒ ResizablePanel

Returns a new instance of ResizablePanel.



5
6
7
8
9
10
# File 'app/components/phlex_kit/resizable/resizable_panel.rb', line 5

def initialize(default_size: nil, **attrs)
  # Numeric coercion: the value is interpolated into a style attribute, and
  # hosts plausibly round-trip saved panel sizes from client state.
  @default_size = default_size.nil? ? nil : Float(default_size)
  @attrs = attrs
end

Instance Method Details

#view_templateObject



12
13
14
15
16
17
18
19
# File 'app/components/phlex_kit/resizable/resizable_panel.rb', line 12

def view_template(&)
  style = @default_size ? "flex-grow: #{Kernel.format("%g", @default_size)}" : nil
  div(**mix({
    class: "pk-resizable-panel",
    style: style,
    data: { phlex_kit__resizable_target: "panel" }
  }.compact, @attrs), &)
end