Class: Shadcn::ResizablePanelGroupComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/resizable_panel_group_component.rb

Overview

ResizablePanelGroup component for creating resizable panel layouts Matches shadcn/ui Resizable component Uses Stimulus for interactivity

Examples:

Horizontal layout

<%= render Shadcn::ResizablePanelGroupComponent.new(direction: :horizontal) do |group| %>
  <% group.with_panel(default_size: 50) do %>
    
One
<% end %> <% group.with_handle %> <% group.with_panel(default_size: 50) do %>
Two
<% end %> <% end %>

Vertical layout

<%= render Shadcn::ResizablePanelGroupComponent.new(direction: :vertical) do |group| %>
  <% group.with_panel(default_size: 25) do %>
    Header
  <% end %>
  <% group.with_handle %>
  <% group.with_panel(default_size: 75) do %>
    Content
  <% end %>
<% end %>

Constant Summary collapse

DIRECTIONS =
{
  horizontal: "flex h-full",
  vertical: "flex flex-col"
}.freeze

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Instance Method Summary collapse

Methods inherited from BaseComponent

#content

Methods included from Shadcn::Rails::Helpers::ClassNameHelper

#cn

Constructor Details

#initialize(direction: :horizontal, auto_save_id: nil, **options) ⇒ ResizablePanelGroupComponent

Returns a new instance of ResizablePanelGroupComponent.

Parameters:

  • direction (Symbol) (defaults to: :horizontal)

    Direction of the panels (:horizontal, :vertical)

  • auto_save_id (String) (defaults to: nil)

    ID for persisting panel sizes to localStorage



68
69
70
71
72
# File 'app/components/shadcn/resizable_panel_group_component.rb', line 68

def initialize(direction: :horizontal, auto_save_id: nil, **options)
  super(**options)
  @direction = direction.to_sym
  @auto_save_id = auto_save_id
end

Instance Method Details

#callObject



74
75
76
# File 'app/components/shadcn/resizable_panel_group_component.rb', line 74

def call
  (:div, group_content, group_attributes)
end