Class: PhlexKit::ResizablePanel
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::ResizablePanel
- 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
-
#initialize(default_size: nil, **attrs) ⇒ ResizablePanel
constructor
A new instance of ResizablePanel.
- #view_template ⇒ Object
Methods inherited from BaseComponent
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_template ⇒ Object
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 |